(function () {
console.log('Hello World!');
})();
如果没有tslint.json
配置,它会显示错误消息:
> tslint test.ts
Could not find implementations for the following rules specified in the configuration:
label-undefined
no-duplicate-key
no-trailing-comma
no-unreachable
use-strict
Try upgrading TSLint and/or ensuring that you have all necessary custom rules installed.
If TSLint was recently upgraded, you may have old rules configured which need to be cleaned up.
Warning: The 'no-unused-variable' rule requires type information.
Warning: The 'no-use-before-declare' rule requires type information.
ERROR: test.ts[1, 11]: expected call-signature to have a typedef
ERROR: test.ts[2, 17]: ' should be "
为什么它抱怨无法找到配置中指定的规则label-undefined 、 no-duplicate-key 、 no-trailing-comma 、 no-unreachable 、 use-strict的实现? 由于没有定义自定义规则,也没有扩展规则,它应该来自 TSLint,但我搜索了从 npm 下载的 TSLint 包,除了它们在CHANGELOG.md 中提到过
但是使用低于tslint.json
配置,它显示 OK:
{
"defaultSeverity": "error",
"extends": [
"tslint:recommended"
],
"jsRules": {},
"rules": {},
"rulesDirectory": []
}
如果没有tslint.json
配置,它不应该抱怨无法找到这些规则的实现。
您在父目录或主目录中有一个过时的 tslint.json。
@ajafff谢谢,你说得对。 不知何故,在我这次安装TSLint
之前,我的用户文件夹中已经有一个\Users\<MyUserName>\tslint.json
。 所以关闭它。
不知何故,我也在我的主文件夹中创建了一个tslint.json
并导致了这个问题。 如果 tslint 可以选择不在用户主目录中钓鱼,那就太好了。 或者,如果错误消息指示列出的规则来自何处。 感谢@ajafff 的提示! 我对这个错误感到很头疼。
最有用的评论
您在父目录或主目录中有一个过时的 tslint.json。