简体   繁体   English

如何在 Eslint.js 文件和打字稿中关闭分号错误

[英]How to turn of semicolon error in a Eslint.js file and typescrip

I want to use semicolons in my typescript files, but eslint is giving me an error Extra semicolon.eslint@typescript-eslint/semi now I went to the docs and it tells me to put this in my eslint file我想在我的 typescript 文件中使用分号,但 eslint 给我一个错误

"rules": {
    // Note: you must disable the base rule as it can report incorrect errors
    "semi": "off",
    "@typescript-eslint/semi": "warn"
  }

The problem is that my eslint file is a.js file not a.json file so I can't put "@typescript-eslint/semi": "warn" because it gives me an error问题是我的 eslint 文件是 a.js 文件而不是 a.json 文件所以我不能放 "@typescript-eslint/semi": "warn" 因为它给我一个错误

Edit: this is the eslit.js file编辑:这是 eslit.js 文件

module.exports = {
  env: {
    browser: true,
    es2021: true
  },
  extends: [
    'plugin:react/recommended',
    'plugin:react/jsx-runtime',
    'standard-with-typescript'
  ],
  overrides: [],
  parserOptions: {
    ecmaVersion: 'latest',
    sourceType: 'module',
    project: ['./tsconfig.json']
  },
  plugins: ['react'],
  rules: {
    semi: 'off'
  }
};

Just add it into rules, the exaclty same way只需将其添加到规则中,完全相同
DO NOT FORGET THE QUOTES不要忘记引号

  plugins: ['react'],
  rules: {
    semi: 'off',
    "@typescript-eslint/semi": "warn" // < just add it
  }
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM