繁体   English   中英

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

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

我想在我的 typescript 文件中使用分号,但 eslint 给我一个错误

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

问题是我的 eslint 文件是 a.js 文件而不是 a.json 文件所以我不能放 "@typescript-eslint/semi": "warn" 因为它给我一个错误

编辑:这是 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'
  }
};

只需将其添加到规则中,完全相同
不要忘记引号

  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