If you are working on a codebase within which you lint non-TypeScript code (i.e. .js/.jsx), you should ensure that you should use ESLint overrides to only enable the rule on .ts/.tsx files. If you don't, then you will get unfixable lint errors reported within .js/.jsx files.
{
"rules": {
// disable the rule for all files
"@typescript-eslint/explicit-module-boundary-types": "off"
},
"overrides": [
{
// enable the rule specifically for TypeScript files
"files": ["*.ts", "*.tsx"],
"rules": {
"@typescript-eslint/explicit-module-boundary-types": ["error"]
}
}
]
}
首先不太明白楼主为什么使用了typescript的规则校验,却没有在这个文件中使用typescript,这似乎失去了eslint对编码规范校验的意义,以下解决方法,楼主可以一试。
Configuring in a mixed JS/TS codebase
If you are working on a codebase within which you lint non-TypeScript code (i.e.
.js
/.jsx
), you should ensure that you should use ESLintoverrides
to only enable the rule on.ts
/.tsx
files. If you don't, then you will get unfixable lint errors reported within.js
/.jsx
files.