简体   繁体   中英

Using custom tslint rule results in no implementation found

I'm having difficulty to understand why my custom typescript rule is not working. Below some code to show my setup.

package.json:

 {
  "name": "lintingrules",
  "version": "0.0.1",
  "description": "Custom linting rules",
  "main": "lintrules.json"
 }

lintrules.json:

{
    "rulesDirectory": "./rules",
    "rules": {
        "enounderscore": true
    }
}

tslint.json of the project I want to use the linting rules:

{
  "extends": ["lintingrules"]
}

In my folder src/rules I have one rule that uses tsquery . When using this in my angular project I always get the following message when running 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.

So my mistake was that I didn't use the convention that TSLint needs but just created a file with a random name:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM