Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Alert about tslint.json bad format. #45

Closed
nathanredblur opened this issue Jan 23, 2019 · 3 comments
Closed

Alert about tslint.json bad format. #45

nathanredblur opened this issue Jan 23, 2019 · 3 comments
Labels

Comments

@nathanredblur
Copy link

I lost like 3 hours trying to find why my tslint plugin didn't work.
Then I fount that my tslint.json file had an extra comma that disable it.

VScode set the lenguage to JSON with comments by default, and I did't see the error.

here an example:

{
  "extends": "tslint-config-airbnb",
  "rules": {
    "import-name": [ true, {
      "classnames": "cx",
    }]
  }
}

I wouldn't lost all this 3 hours if someone point this extra comma after "cx".

@adenflorian
Copy link

This cost me a bit of time too, and now I'm trying to find a github issue on the right project to make sure this doesn't happen to someone else. I'm not sure if this is a vscode, tslint, or this project, or some other project's issue. What would we want to change?

From reading issues on multiple projects, these seem to be the options:

  1. Make jsonc (vscode's JSON parser?) not allow trailing commas
    a. Related: jsonc: Should not allow invalid JSON syntax (trailing commas) vscode#43825
  2. Make tslint allow trailing commas
    a. Related: Consider JSON5 for config (e.g. trailing commas) palantir/tslint#1721
  3. Make sure that tsconfig.json is not used with jsonc, and instead parse it as vanilla JSON
    a. I'm not sure what is telling vscode to use jsonc for this file. Is it vscode itself, or this tslint extension?

Thoughts?

@adenflorian
Copy link

Workaround:

Add to settings.json:

"files.associations": {
    "tsconfig.json": "json"
},

Downside is you'll get errors for having comments in there.

Saying that, I think the best way forward might be to push for trailing commas to be allowed by tslint, because all the other options are breaking changes.

@mjbvz
Copy link
Contributor

mjbvz commented Mar 2, 2019

Caused by fix for #8. TSlint support comments in config files but not trailing commas and there is no equivalent language mode for this in VS Code. Proper support for trailing commas requires palantir/tslint#1721 upstream.

Until then, you can make such errors more obvious with the suggestion in #45 (comment)

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

No branches or pull requests

3 participants