[英]I need remove the semicolon error ESLint + Prettier
How can I remove the semicolon rule?如何删除分号规则?
I've tried to remove the semi rules, but I'm not succeeding.我试图删除半规则,但我没有成功。 When I save the file once it removes the semicolons and lint complains that it's missing, and when I insert it it complains again saying to remove.
当我删除分号后保存文件时,lint 抱怨它丢失了,当我插入它时,它再次抱怨说要删除。
I would like to keep the semicolon我想保留分号
Thats my .prettierrc file:那是我的 .prettierrc 文件:
{
"printWidth": 100,
"singleQuote": true,
"tabWidth": 4,
"trailingComma": "es5",
"endOfLine":"auto",
"semi": true
}
and thats my .eslintrc file这就是我的 .eslintrc 文件
{
"parser": "babel-eslint",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
}
},
"env": {
"browser": true,
"node": true,
"es6": true
},
"extends": [
"airbnb",
"plugin:prettier/recommended",
"plugin:react/recommended",
"plugin:jsx-a11y/recommended"
],
"plugins": ["prettier", "react", "react-hooks"],
"rules": {
"prettier/prettier": [
"error",
{
"endOfLine": "auto"
}
],
"react-hooks/exhaustive-deps": "warn",
"react-hooks/rules-of-hooks": "error",
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
"react/jsx-indent-props": [2, 4],
"react/jsx-indent": [2, 4],
"react/jsx-one-expression-per-line": [0],
"react/prefer-stateless-function": [1],
"react/static-property-placement": [1, "property assignment"],
"react/prop-types": "off"
}
}
I got rid of the same error by setting the prettier rules configuration in .eslintrc to:我通过将 .eslintrc 中更漂亮的规则配置设置为:
"rules": {
"prettier/prettier": [
"error",
{
"endOfLine": "off"
}
],
while keeping in .prettierrc:同时保留.prettierrc:
"endOfLine": "auto"
NOTE: This is just an intent to workaround the error you (and I) got, but the effect I see is that the "endOfLine" rule will work when using the pretty formatted but not when running eslint.注意:这只是为了解决您(和我)遇到的错误,但我看到的效果是“endOfLine”规则在使用漂亮格式时有效,但在运行 eslint 时无效。
You should change semi with false
你应该用
false
改变 semi
{
"printWidth": 100,
"singleQuote": true,
"tabWidth": 4,
"trailingComma": "es5",
"endOfLine":"auto",
"semi": false
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.