1
votes

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.

1

1 Answers

2
votes

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.