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

Allow Line comment in tslint.json #4484

Closed
sokcuri opened this issue Jan 28, 2019 · 3 comments
Closed

Allow Line comment in tslint.json #4484

sokcuri opened this issue Jan 28, 2019 · 3 comments
Labels

Comments

@sokcuri
Copy link

sokcuri commented Jan 28, 2019

If Line comment is present in tslint.json, the following error occurs.

SyntaxError: D:\repo\noname\tslint.json: Unexpected token / in JSON at position 2895
    at JSON.parse (<anonymous>)
    at Object.Module._extensions..json (internal/modules/cjs/loader.js:707:27)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
    at startup (internal/bootstrap/node.js:285:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)

https://github.com/Microsoft/TypeScript/blob/master/tslint.json

I have noticed that copying tslint.json from the Microsoft Typescript repository will cause an error. I think there will be enough cases to write line comment during development.

The JSON specification does not officially support Line comment, so I get the above error, but I would like to be able to comment on line.

@sokcuri sokcuri changed the title Allow Comment in tslint.json Allow Line comment in tslint.json Jan 28, 2019
@JoshuaKGoldberg
Copy link
Contributor

@sokcuri very much agreed! I typically do write inline comments in tslint.json, so you getting an error there is a bit confusing. How are you running TSLint, and what version are you using? For example, on the command line, or via an IDE extension?
https://github.com/palantir/tslint/blob/master/tslint.json itself has comments.

@adidahiya
Copy link
Contributor

As @JoshuaKGoldberg mentioned, TSLint itself already supports comments in tslint.json, so this issue is external to TSLint. For other config file format requests, see #1721 and #1071

@sokcuri
Copy link
Author

sokcuri commented Jan 29, 2019

I have figured out why this is happening. The package.json below is the npm script where the error occurred.

"scripts": {
  "lint": "node tslint 'src/**/*.{ts,tsx}'"
}

The node is excluded, so it works normally. tslint is not installed globally.
Depending on whether you're attaching a node or not, it's operating inconsistent.

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