Skip to content

Latest commit

 

History

History
 
 

tslint

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Steps to adding a custom TSLint rule

  1. Make a new file, the name is important, it must be camel-case and not a .ts file (the @ts-check declaration at the top of each file uses JSDoc to check types while developing rules – read here for more info). The suffix must be ...Rule.js.

  2. You will need to convert your camelCase name to kebab-case and add it to the tslint.json

    E.g. noDoingAnythingRule.js -> no-doing-anything and:

    {
      "extends": ["tslint:recommended", "tslint-react", "tslint-config-prettier"],
      "rules": {
        "no-import-un-mocked": true,
    +    "no-doing-anything": true,
        "curly": false,
        ...
  3. You want to export a class called Rule that lints your file, this is what it used on the file.

  4. Ideally you can do simple string matching like in noImportUnMockedRule.js - but if not, study how to make an AST walker here