Tslint: When tslint.json uses extends, some rules can't be disabled

Created on 20 Nov 2016  路  7Comments  路  Source: palantir/tslint

Bug Report

  • __TSLint version__: 4.0.1
  • __TypeScript version__: 1.8.10
  • __Running TSLint via__: gulp-tslint v7.0.0

When I use this configuration

{
  "rulesDirectory": [
    "node_modules/tslint-eslint-rules/dist/rules"
  ],
  "extends": [
    "./tslint-eslint-rules.json"
  ],
  "rules": {
    "comment-format": [ false ],
    "quotemark": [ false ]
  }
}

I get violations for those 2 rules, even though they are set to be disabled. (I probably get more violations than this, but I have it limited to only show 50 at a time). However, if I comment out the contents of the rulesDirectory and extends arrays like this:

{
  "rulesDirectory": [
    //"node_modules/tslint-eslint-rules/dist/rules"
  ],
  "extends": [
    //"./tslint-eslint-rules.json"
  ],
  "rules": {
    "comment-format": [ false ],
    "quotemark": [ false ]
  }
}

those rules stay disabled and do not report violations as expected.

API P1 Accepting PRs Bug

Most helpful comment

This still seems to happen:

{
    "defaultSeverity": "error",
    "extends": [
        "tslint:all",
        "tslint-config-prettier"
    ],
    "jsRules": {},
    "rules": {
        "object-literal-sort-keys": false
    },
    "rulesDirectory": []
}

I get ERROR: /Users/tommedema/projects/vg/playground/tshape/src/index.ts[5, 3]: 'width' should come alphabetically before 'x' therefore the rule is not disabled.

All 7 comments

I can't reproduce. I can override quotemark with false if the extend .json file contains "quotemark": [ true, "double", "avoid-escape"] or if it extends tslint:recommended

There are 2 problems here:

  1. This is reproducible in gulp-tslint when the config file in extends does not exist. In the CLI, you see the error, but gulp-tslint swallows the error.
  2. The change of behavior occurred because the API used to throw an exception, but now attaches an error property to the result object. (#1686)

I think the fix would be to catch the error in the non-API part of the code

This still seems to happen:

{
    "defaultSeverity": "error",
    "extends": [
        "tslint:all",
        "tslint-config-prettier"
    ],
    "jsRules": {},
    "rules": {
        "object-literal-sort-keys": false
    },
    "rulesDirectory": []
}

I get ERROR: /Users/tommedema/projects/vg/playground/tshape/src/index.ts[5, 3]: 'width' should come alphabetically before 'x' therefore the rule is not disabled.

I have the same problem and it's been a year since the last comment.

{
  "extends": ["gts/tslint.json"],
  "rules": {
    "quotemark": [true, "double", "avoid-escape", "avoid-template"]
  },
  "jsRules": {
    "quotemark": [true, "double", "avoid-escape", "avoid-template"]
  }
}
$ gts check
...
    export async function get_employees_as_json() {
      const response = await pool.query(build_sql_to_get_all_employees_as_json());
   -  return response.rows[0]["json"];
   +  return response.rows[0]['json'];
    }

gts 0.9.0
tslint 5.14.0
clang-format (used by gts) 1.2.3

I'm not really familiar with gts. It would be best if you created a minimal repro to demonstrate the issue with the tslint CLI.

You are right! I could not reproduce it with the tslint CLI. The Google Typescript Style says it uses tslint under the hood to do checks but it seems it is overriding the config file.

Was this page helpful?
0 / 5 - 0 ratings