【发布时间】:2020-11-13 15:11:29
【问题描述】:
我正在使用 eslint 建立一个新的打字稿项目。我正在尝试正确设置 eslint 规则,以便 tsc 命令运行时不会出错。我在 tsconfig.json 中使用的“noImplicitAny”规则有问题,但我无法在 eslint 中检查。
.eslintrc.js:
module.exports = {
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
],
parser: "@typescript-eslint/parser",
parserOptions: {
project: ["tsconfig.json"],
sourceType: "module",
},
rules: {
"no-undef": "warn",
},
plugins: ["@typescript-eslint"],
settings: {
"import/resolver": {
node: {
extensions: [".js", ".ts"],
},
},
},
};
tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"module": "ES6",
"declaration": true,
"outDir": "./lib",
"strict": true,
"noImplicitAny": true
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules", "**/__tests__/*"]
}
简而言之,我希望 eslint 检查隐含的 any 并警告其使用情况。如何配置.eslintrc.js 中的规则来实现这一点?
【问题讨论】:
-
我已经检查了那个线程,它建议在 .eslintrc 中设置
noImplicitAny,但是在 ESLint 中不存在这样的规则。我知道有'@typescript-eslint/no-explicit-any',但这不是我要找的。span>
标签: typescript eslint