寻求帮助将 TypeScript 编译器报告的类型错误放入 ESLint 的输出中。库 typescript-eslint ( https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/TYPED_LINTING.md ) 让我觉得这应该是可能的。
文件结构
src/
... source files
tsconfig.json
test/
... testing files
.eslintrc.js
package.json
tsconfig.json (symlink to src/tsconfig.json)
Run Code Online (Sandbox Code Playgroud)
.eslintrc.js
module.exports = {
'env': {
'jest': true,
'node': true,
},
'extends': [
'airbnb-typescript/base',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:jest/recommended',
],
'parser': '@typescript-eslint/parser',
'parserOptions': {
'project': ['./tsconfig.json'],
'tsconfigRootDir': __dirname,
},
'plugins': [
'@typescript-eslint',
'jest',
],
'root': true,
};
Run Code Online (Sandbox Code Playgroud)
包.json
{
"name": "...",
"version": "...",
"description": "...",
"scripts": {},
"devDependencies": {
"@types/jest": "^25.1.3",
"@typescript-eslint/eslint-plugin": "^2.21.0",
"@typescript-eslint/parser": "^2.21.0", …Run Code Online (Sandbox Code Playgroud)