Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

When tslint.json uses extends, some rules can't be disabled #1759

Closed
ChrisMBarr opened this issue Nov 20, 2016 · 7 comments · Fixed by #1764
Closed

When tslint.json uses extends, some rules can't be disabled #1759

ChrisMBarr opened this issue Nov 20, 2016 · 7 comments · Fixed by #1764

Comments

@ChrisMBarr
Copy link
Contributor

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.

@adidahiya
Copy link
Contributor

likely a bug introduced by #1622

@nchen63
Copy link
Contributor

nchen63 commented Nov 21, 2016

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

@nchen63
Copy link
Contributor

nchen63 commented Nov 21, 2016

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. (Slightly better error for failed tslint.json parses #1686)

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

@tommedema
Copy link

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.

@brokenthorn
Copy link

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

@adidahiya
Copy link
Contributor

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.

@brokenthorn
Copy link

brokenthorn commented Apr 18, 2019

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants