1

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 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.