简体   繁体   English

如何禁用@typescript-eslint/semi?

[英]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.

相关问题 如何使用反应开发服务器禁用 @typescript-eslint/no-unused-vars 规则 - How can I disable @typescript-eslint/no-unused-vars rule with react dev server typescript-eslint:如何将 React 道具 lint 到换行符 - typescript-eslint: how to lint React props to newlines 如何强制编译并忽略@typescript-eslint 错误? - How to force a compilation and ignore @typescript-eslint errors? 找不到@typescript-eslint/no-unused-expressions' - @typescript-eslint/no-unused-expressions' was not found 关于“create-react-app --template typescript”如何与 typescript-eslint 连接的困惑 - Confusion about how `create-react-app --template typescript` hooked up with typescript-eslint 如何解决:“找不到规则'@typescript-eslint/consistent-type-assertions'的定义” - How to resolve: "Definition for rule '@typescript-eslint/consistent-type-assertions' was not found" 使用`useFormikContent()`时如何防止`@typescript-eslint/unbound-method`错误? - How do I prevent a `@typescript-eslint/unbound-method` error when using `useFormikContent()`? @typescript-eslint/no-unused-vars 类型声明中的误报 - @typescript-eslint/no-unused-vars false positive in type declarations 找不到与 @typescript-eslint/scope-manager@4.22.1 匹配的版本 - No matching version found for @typescript-eslint/scope-manager@4.22.1 npm WARN @typescript-eslint/eslint-plugin@1.6.0 需要 typescript@* 的同级 - npm WARN @typescript-eslint/eslint-plugin@1.6.0 requires a peer of typescript@*
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM