1
votes

Below is the configuration setup for eslint. Trying to define a basic eslint rule to define const instead of let if its an array or object

"scripts": {
  "lint": "eslint src/**/*.js --fix"
}

.eslintrc

"rules": {
    "strict": [2, "never"],
    "prefer-const": 2
}

vscode referring to .eslintrc file for the rule defined on prefer-const and throwing error in ide as below which is perfectly fine

enter image description here

But npm run lint is not giving any error on the same nor fixing the code

enter image description here

Attaching the folder structure below where eslintrc is located enter image description here What is missing in my script?

1
Maybe, it's fixing it for you? Since you have --fix flag? - Manish Gharat
It’s not even fixing not giving any errors from command line - Mithun Shreevatsa
And the .eslintrc file is in the folder from where you're running the command? - Manish Gharat
Yes it is in root project folder - Mithun Shreevatsa
Can you please post a screenshot of your folder structure? - Manish Gharat

1 Answers

0
votes

Your config file name should be .eslintrc.json.

Here's the reference documentation you can check: https://eslint.org/docs/user-guide/configuring

Also attaching a link to deprecation notice for .eslintrc file without extension: https://dev.to/ohbarye/eslintrc-without-file-extension-is-deprecated-3ngg

Try changing your config file name and it should work.