简体   繁体   中英

ESLint not throwing any errors from npm command

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

在此处输入图片说明

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

在此处输入图片说明

Attaching the folder structure below where eslintrc is located 在此处输入图片说明 What is missing in my script?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM