我\xe2\x80\x99m 使用 TypeScript 和 ESLint 开发 React 项目。我有以下版本的eslint和typescript-eslint我的 package.json 文件中
"@typescript-eslint/eslint-plugin": "^6.3.0",\n"@typescript-eslint/parser": "^6.0.0",\n"eslint": "^8.45.0",\nRun Code Online (Sandbox Code Playgroud)\n我也有以下.eslintrc.cjs文件:
/* eslint-env node */\n\nmodule.exports = {\n root: true,\n env: { browser: true, es2020: true },\n extends: [\n \'eslint:recommended\',\n \'plugin:@typescript-eslint/recommended\',\n \'plugin:@typescript-eslint/recommended-requiring-type-checking\',\n \'plugin:react-hooks/recommended\',\n ],\n parser: \'@typescript-eslint/parser\',\n parserOptions: {\n ecmaVersion: \'latest\',\n sourceType: \'module\',\n project: true,\n tsconfigRootDir: __dirname,\n },\n plugins: [\'react-refresh\'],\n rules: {\n \'react-refresh/only-export-components\': [\n \'warn\',\n { allowConstantExport: true },\n ],\n \'@typescript-eslint/no-non-null-assertion\': \'off\',\n "@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],\n },\n}\n …Run Code Online (Sandbox Code Playgroud)