ESlint --config option not working and still uses the same root file config

46 views Asked by At

I have this in my package.json

 "scripts": {
   "lint": "eslint --quiet .",
   "lint:prcleancode": "eslint -c ./ci/.eslint-cleancode.json    

The first lint command is configured with the .eslintrc.json file (in the project's root). I expected that the lint:prcleancode command will get it's configuration from the file in ./ci/.eslint-cleancode.json. But it still uses the .eslintrc.json in the root folder. Any idea why?

1

There are 1 answers

0
Chen Peleg On

Turns out that if you have a eslintre.json in your root folder, you need to add: --no-eslintrc flag.

 "lint:prcleancode": "eslint --no-eslintrc -c ./ci/.eslint- 
  cleancode.json .",`

source:

If you are using one configuration file and want ESLint to ignore any .eslintrc.* files, make sure to use --no-eslintrc along with the --config flag.

https://eslint.org/docs/latest/use/configure/configuration-files