简体   繁体   中英

how to add rules to ESLint in Create React App

I can't add rules or edit ESLint in a Create React App.

before version 4.0. all was ok- i had .eslintrc.js file with rules. i moved to 4.0.2 and - the app stopped compiling. so i removed.eslintrc.js, and got completion back. ok.

but now, i can't add or edit anything regarding ESLlint.

i can't add a new .eslintrc.js , use the old one, or config the lint in the package.json file like the documentation solution - all returning to completion problem.

tried to add.env file with ESLINT_NO_DEV_ERRORS=true but still the same problem.

how can you extend or Edit ESLint?

one solution is to use to edit the rules in the package.json:

for example:

  "eslintConfig": {
    "extends": ["react-app"],
    "rules": {
      "no-unused-vars": "warn"
    },
    "overrides": [
      {
        "files": ["**/*.ts?(x)"],
        "rules": {
          "max-len": "warn"
        }
      }
    ]
  },

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