Search code examples
linthuskylint-staged

How to have multiple patterns for lint-staged?


I had it match on .rb and .js files for instance.

e.g. **/*.{js,rb}

And wanted to also match on Gemfile and Rakefile for instance.


Solution

  • the solution was to recursively use {}, e.g.

      "lint-staged": {
        "{Gemfile,Rakefile,**/*.{js,rb,rake,ru}}": [
          "./node_modules/prettier/bin-prettier.js --write"
        ],
        "**/*.js": [
          "node_modules/eslint/bin/eslint.js"
        ],
        "{Gemfile,Rakefile,**/*.{rb,rake,ru}}": [
          "bundle exec rubocop -a"
        ]
      }