[英]how disable @typescript-eslint/semi?
I have project typescript, react, eslint.我有项目 typescript,反应,eslint。 In file.eslintrc.json I have rules:在 file.eslintrc.json 我有规则:
"rules": {
"semi": [ "error", "never" ],
"@typescript-eslint/semi": ["error", "never"]
}
I have file with code tsx, where in end of file writed:我有带有代码 tsx 的文件,在文件末尾写入:
export default Main
When I use command in terminal:当我在终端中使用命令时:
npx eslint file.tsx
I get error:我得到错误:
number last string.20 error Missing semicolon
@typescript-eslint/semi
Full file.eslintrc.json完整文件.eslintrc.json
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"plugin:react/recommended",
"xo"
],
"overrides": [
{
"extends": [
"xo-typescript"
],
"files": [
"*.ts",
"*.tsx"
]
}
],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"react",
"@typescript-eslint"
],
"rules": {
"semi": [ "error", "never" ],
"@typescript-eslint/semi": ["error", "never"]
}
}
How right disabled semi rules?如何正确禁用半规则?
Use "off"
:使用"off"
:
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"plugin:react/recommended",
"xo"
],
"overrides": [
{
"extends": [
"xo-typescript"
],
"files": [
"*.ts",
"*.tsx"
]
}
],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"react",
"@typescript-eslint"
],
"rules": {
"semi": "off",
"@typescript-eslint/semi": "off"
}
}
I don't know why the rules didn't work when using我不知道为什么使用时规则不起作用
"extends": [
"xo"
],
so i reinstalled using the command所以我使用命令重新安装
npx eslint --init
only this time at the end chose只有这一次最后选择了
"extends": [
"plugin:react/recommended",
"standard-with-typescript"
],
so the whole file ".eslintrc.json" looks like所以整个文件“.eslintrc.json”看起来像
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"plugin:react/recommended",
"standard-with-typescript"
],
"overrides": [
],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module",
"project": "./tsconfig.json"
},
"plugins": [
"react"
],
"rules": {
"eol-last": 0,
"no-multiple-empty-lines": [
"error",
{
"max": 1,
"maxEOF": 0
}
],
"@typescript-eslint/space-before-function-paren": [
"error", {
"anonymous": "never",
"named": "never",
"asyncArrow": "never"
}
],
"@typescript-eslint/no-floating-promises": 0
}
}
in these rules by default is ignored semi.在这些规则中默认是忽略半的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.