使用自定义 tslint 规则导致找不到实现
Using custom tslint rule results in no implementation found
我很难理解为什么我的自定义打字稿规则不起作用。
下面的一些代码显示了我的设置。
package.json:
{
"name": "lintingrules",
"version": "0.0.1",
"description": "Custom linting rules",
"main": "lintrules.json"
}
lintrules.json:
{
"rulesDirectory": "./rules",
"rules": {
"enounderscore": true
}
}
tslint.json项目的我要使用的linting规则:
{
"extends": ["lintingrules"]
}
在我的文件夹 src/rules
中,我有一个使用 tsquery
的规则。在我的 angular 项目中使用它时,我总是在 运行 ng lint
时收到以下消息:
Could not find implementations for the following rules specified in
the configuration:
enounderscore 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.
所以我的错误是我没有使用 TSLint 需要的约定,只是创建了一个随机名称的文件:
Important conventions:
Rule identifiers are always kebab-cased. Rule files are always
camel-cased (camelCasedRule.ts). Rule files must contain the suffix
Rule. The exported class must always be named Rule and extend from
Lint.Rules.AbstractRule.
我很难理解为什么我的自定义打字稿规则不起作用。 下面的一些代码显示了我的设置。
package.json:
{
"name": "lintingrules",
"version": "0.0.1",
"description": "Custom linting rules",
"main": "lintrules.json"
}
lintrules.json:
{
"rulesDirectory": "./rules",
"rules": {
"enounderscore": true
}
}
tslint.json项目的我要使用的linting规则:
{
"extends": ["lintingrules"]
}
在我的文件夹 src/rules
中,我有一个使用 tsquery
的规则。在我的 angular 项目中使用它时,我总是在 运行 ng lint
时收到以下消息:
Could not find implementations for the following rules specified in the configuration: enounderscore 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.
所以我的错误是我没有使用 TSLint 需要的约定,只是创建了一个随机名称的文件:
Important conventions:
Rule identifiers are always kebab-cased. Rule files are always camel-cased (camelCasedRule.ts). Rule files must contain the suffix Rule. The exported class must always be named Rule and extend from Lint.Rules.AbstractRule.