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

Incorrect JSON schema for import-blacklist and variable-name #4677

Closed
ChrisMBarr opened this issue Apr 23, 2019 · 3 comments
Closed

Incorrect JSON schema for import-blacklist and variable-name #4677

ChrisMBarr opened this issue Apr 23, 2019 · 3 comments

Comments

@ChrisMBarr
Copy link
Contributor

ChrisMBarr commented Apr 23, 2019

Bug Report

  • TSLint version: 5.16.0
  • TypeScript version: 3.2.4
  • Running TSLint via: (pick one) CLI

with tslint.json configuration:

"import-blacklist": {
    "options": ["rxjs/Rx", {"protractor": ["By"]}]
},
"variable-name": {
    "options": ["ban-keywords", "check-format", "require-const-for-all-caps"]
},

Actual behavior

The VSCode IDE reports that the object syntax for the import-blacklist rule is invalid, and that the "require-const-for-all-caps" option for the variable-name rule is invalid.

Screenshots

2019-04-23 09_04_59-● tslint json - borrower-v2-mockup - Visual Studio Code

2019-04-23 09_05_24-tslint json - borrower-v2-mockup - Visual Studio Code

Expected behavior

Both of these options are valid, they work just fine. They are taken straight from the documentation page. The JSON schema just needs to be updated to know about these so they don't throw people off when they are trying to configure these rules.

@mirceapop89
Copy link

I took a look at this and noticed that for "variable-name" the "require-const-for-all-caps" rule is indeed missing from the JSON schema enum. I will try to make time one of these days for a PR.

That being said, the situation for import-blacklist is different as the JSON schema is supposed to handle the mentioned situation. The problem there seems to be that VSCode is configured to use the JSON Schema Store server (http://schemastore.org/) and the tslint JSON schema is indeed not updated on their server.

Even if someone did update the schema from there I think that the default behavior of VSCode using the JSON Schema Store server is flawed because it doesn't seem to have a versioning concept, which might result in mismatches if breaking changes are introduced in tslint.

There is an alternative to updating the schema on the server, more exactly to define another schema in the VS Code workspace or the VS Code settings files.

More information about VSCode and JSON schemas can be found here.

@adidahiya
Copy link
Contributor

adidahiya commented May 16, 2019

I've fixed up the variable name rule metadata in #4731. We don't maintain the JSON schema in Schema Store here in this repo. As @mirceapop89 mentioned, getting the schema there to match up with the installed version of TSLint is a little out of scope, but if you find a good solution please share here.

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

No branches or pull requests

4 participants