在我看来,有一个已回答的问题实际上并没有回答这个问题,关于ESLint 中extends: []vs之间plugins: []的区别。
就我而言,我只使用了扩展部分:
extends: [
'plugin:@typescript-eslint/recommended',
],
plugins: [],
rules: {
'@typescript-eslint/explicit-function-return-type': [
'error',
{
allowExpressions: true,
},
],
}
Run Code Online (Sandbox Code Playgroud)
如您所见,我只是使用了预定义的配置,plugin:@typescript-eslint/recommended并@typescript-eslint/explicit-function-return-type在rules: {}部分中覆盖了规则。但是为什么我们需要这个插件部分呢?如果没有它一切正常?我想念什么?
我正在尝试为我的打字稿反应项目设置,当我工作时,如果我正在做一些无法访问的事情,它会给我警告/错误。我的编辑器已经给我列出错误,但我尝试设置 eslint-plugin-jsx-a11y,但我无法让它工作。
这是我的 package.json 中的 eslint 部分
"eslintConfig": {
parser: '@typescript-eslint/parser',
"extends": [
"react-app",
"react-app/jest",
"shared-config",
"plugin:jsx-a11y/recommended"
],
"rules": {
"additional-rule": "warn"
},
"overrides": [
{
"files": [
"**/*.ts?(x)"
],
"rules": {
"additional-typescript-only-rule": "warn"
}
}
]
},
Run Code Online (Sandbox Code Playgroud)
不知道我错过了什么。谢谢