{ "root": true, "env": { "browser": true, "es2021": true }, "settings": { //自动发现React的版本,从而进行规范react代码 "react": { "pragma": "React", "version": "detect" } }, "extends": [ // "eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier", "plugin:prettier/recommended" ], "parser": "@typescript-eslint/parser", // 定义ESLint的解析器 "parserOptions": { "parser": "@typescript-eslint/parser", "ecmaVersion": "latest", "sourceType": "module", "ecmaFeatures": { "jsx": true } }, "plugins": ["@typescript-eslint", "eslint-plugin-react"], // typescript-eslint https://typescript-eslint.io/getting-started // eslint https://zh-hans.eslint.org/docs/latest/ // prettier https://prettier.io/docs/en/ // off或0 关闭规则; warn或1 启用并警告(不影响现有代码); error或2 启用并报错(错误代码1) "rules": { "@typescript-eslint/ban-ts-ignore": "off", "@typescript-eslint/explicit-function-return-type": "off", "@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-var-requires": "off", "@typescript-eslint/no-empty-function": "off", "@typescript-eslint/no-use-before-define": "off", "@typescript-eslint/ban-ts-comment": "off", "@typescript-eslint/ban-types": "off", "@typescript-eslint/no-non-null-assertion": "off", "@typescript-eslint/explicit-module-boundary-types": "off", "@typescript-eslint/no-this-alias": "off", "@typescript-eslint/no-empty-object-type": "off", "@typescript-eslint/no-unused-vars": [ "off", { "argsIgnorePattern": "^_", "varsIgnorePattern": "^_" } ], "prettier/prettier": [ "off", { "endOfLine": "auto" } ], // 定义了未使用的变量 "no-unused-vars": [ "off", { "argsIgnorePattern": "^_", "varsIgnorePattern": "^_" } ], "no-var": "off", // 单引号 "quotes": ["error", "single"], // 尾随逗号 "comma-dangle": ["error", "never"], // 在非空文件的末尾至少有一个换行(或没有换行)的末尾至少有一个换行 "eol-last": ["error", "always"], // 禁止出现多行空行 "no-multiple-empty-lines": ["error", { "max": 1 }] } }