[英]how to add rules to ESLint in Create React App
I can't add rules or edit ESLint in a Create React App.我无法在 Create React App 中添加规则或编辑 ESLint。
before version 4.0. 4.0 版之前。 all was ok- i had .eslintrc.js file with rules.
一切都好——我有.eslintrc.js文件和规则。 i moved to 4.0.2 and - the app stopped compiling.
我搬到了 4.0.2 并且 - 该应用程序停止编译。 so i removed.eslintrc.js, and got completion back.
所以我删除了.eslintrc.js,然后完成了。 ok.
好的。
but now, i can't add or edit anything regarding ESLlint.但现在,我无法添加或编辑任何关于 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.我不能像文档解决方案一样添加新的.eslintrc.js ,使用旧的,或在package.json文件中配置 lint - 所有返回完成问题。
tried to add.env file with ESLINT_NO_DEV_ERRORS=true
but still the same problem.尝试使用
ESLINT_NO_DEV_ERRORS=true
添加.env 文件,但仍然是同样的问题。
how can you extend or Edit ESLint?如何扩展或编辑 ESLint?
one solution is to use to edit the rules in the package.json:一种解决方案是使用编辑 package.json 中的规则:
for example:例如:
"eslintConfig": {
"extends": ["react-app"],
"rules": {
"no-unused-vars": "warn"
},
"overrides": [
{
"files": ["**/*.ts?(x)"],
"rules": {
"max-len": "warn"
}
}
]
},
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.