文件结构。
src/
... source files
tsconfig.json
test/
... testing files
.eslintrc.js
package.json
tsconfig.json (symlink to src/tsconfig.json)
.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,
};
package.json
->package.json
{
"name": "...",
"version": "...",
"description": "...",
"scripts": {},
"devDependencies": {
"@types/jest": "^25.1.3",
"@typescript-eslint/eslint-plugin": "^2.21.0",
"@typescript-eslint/parser": "^2.21.0",
"eslint": "^6.8.0",
"eslint-config-airbnb-typescript": "^7.0.0",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-jest": "^23.8.1",
"jest": "^25.1.0",
"nock": "^12.0.2",
"ts-jest": "^25.2.1"
},
"dependencies": {
"@types/node": "^13.7.7",
"aws-sdk": "^2.630.0",
"jsonschema": "^1.2.5",
"typescript": "^3.8.3"
}
}
ESLint的输出为空 - 没有错误 - 但在运行TypeScript编译器来构建项目时,会报告许多错误,例如:
src/file.ts:xx:xx - error TS2339: Property 'body' does not exist on type 'object'.
src/file.ts:xx:xx - error TS2314: Generic type 'Promise<T>' requires 1 type argument(s).
src/filets:xx:xx - error TS7006: Parameter 'err' implicitly has an 'any' type.
在配置中是否缺少某些内容或者存在问题?还是说这并不是一件可行的事情?
我希望通过ESLint来报告错误,因为我会在编辑器上看到这些lint错误。我使用的是Atom (https://atom.io/),但我也希望它能够在VSCode和可能的VIM上运行;团队成员有不同的编辑偏好。