为什么 ESLint 只检查 src 目录?
Why dos TSLint only checks src directory?
为什么dos TSLint只检查src目录?
tsconfig.json
{
"compilerOptions": {
"outDir": "./built",
"allowJs": true,
"target": "es5",
"typeRoots": ["node_modules/@types", "typings"]
},
"include": ["./src/**/*", "./typings/**/*"],
"exclude": ["node_modules"]
}
tslint.json
{
"defaultSeverity": "error",
"extends": [
"tslint:recommended"
],
"jsRules": {},
"rules": {},
"rulesDirectory": []
}
检查整个项目
只显示src目录的错误
tslint --project .
ERROR: /Users/kiwenlau/Desktop/tslint-test/src/index.ts:1:1 - Forbidden 'var' keyword, use 'let' or 'const' instead
检查 src 目录
tslint "src/**/*"
ERROR: src/index.ts:1:1 - Forbidden 'var' keyword, use 'let' or 'const' instead
检查打字目录
tslint "typings/**/*"
ERROR: typings/index.d.ts:1:11 - interface name must start with a capitalized I
请检查 kiwenlau/tslint-test 以获得源代码。
如 this github issue 中所述,TSLint 在处理来自 tsconfig.json
.
的 include
路径时忽略 .d.ts
文件
不幸的是,TSLint 不再处于开发阶段,所以这永远不会改变。官方建议是将 ESLint 与 typescript-eslint 一起使用。您可以在 this blog post.
中阅读更多相关信息
如果您想暂时继续使用 TSLint,可以在调用时指定两个路径:
tslint "src/**/*" "typings/**/*"
或者像这样短一点:
tslint "{src,typings}/**/*"
即使这个问题
TSLint ignores .d.ts files when processing the include paths from tsconfig.json.
上面的答案中提到的已修复或使用了另一个 linter,文件 ./typings/index.d.ts
仍然可以被任何 linter 忽略,就像 Typescript 编译器一样,它认为它是一个 possible output 文件src/index.ts
.
的存在感
执行 tslint "typings/**/*"
将 src/index.ts
排除在外,因此无法再忽略文件 ./typings/index.d.ts
。
使用Visual Studio代码的TSLint扩展时,只要将tslint.ignoreDefinitionFiles
设置为false
即可解决问题。
为什么dos TSLint只检查src目录?
tsconfig.json
{
"compilerOptions": {
"outDir": "./built",
"allowJs": true,
"target": "es5",
"typeRoots": ["node_modules/@types", "typings"]
},
"include": ["./src/**/*", "./typings/**/*"],
"exclude": ["node_modules"]
}
tslint.json
{
"defaultSeverity": "error",
"extends": [
"tslint:recommended"
],
"jsRules": {},
"rules": {},
"rulesDirectory": []
}
检查整个项目
只显示src目录的错误
tslint --project .
ERROR: /Users/kiwenlau/Desktop/tslint-test/src/index.ts:1:1 - Forbidden 'var' keyword, use 'let' or 'const' instead
检查 src 目录
tslint "src/**/*"
ERROR: src/index.ts:1:1 - Forbidden 'var' keyword, use 'let' or 'const' instead
检查打字目录
tslint "typings/**/*"
ERROR: typings/index.d.ts:1:11 - interface name must start with a capitalized I
请检查 kiwenlau/tslint-test 以获得源代码。
如 this github issue 中所述,TSLint 在处理来自 tsconfig.json
.
include
路径时忽略 .d.ts
文件
不幸的是,TSLint 不再处于开发阶段,所以这永远不会改变。官方建议是将 ESLint 与 typescript-eslint 一起使用。您可以在 this blog post.
中阅读更多相关信息如果您想暂时继续使用 TSLint,可以在调用时指定两个路径:
tslint "src/**/*" "typings/**/*"
或者像这样短一点:
tslint "{src,typings}/**/*"
即使这个问题
TSLint ignores .d.ts files when processing the include paths from tsconfig.json.
上面的答案中提到的已修复或使用了另一个 linter,文件 ./typings/index.d.ts
仍然可以被任何 linter 忽略,就像 Typescript 编译器一样,它认为它是一个 possible output 文件src/index.ts
.
执行 tslint "typings/**/*"
将 src/index.ts
排除在外,因此无法再忽略文件 ./typings/index.d.ts
。
使用Visual Studio代码的TSLint扩展时,只要将tslint.ignoreDefinitionFiles
设置为false
即可解决问题。