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

Consider JSON5 for config (e.g. trailing commas) #1721

Closed
aseemk opened this issue Nov 14, 2016 · 11 comments
Closed

Consider JSON5 for config (e.g. trailing commas) #1721

aseemk opened this issue Nov 14, 2016 · 11 comments

Comments

@aseemk
Copy link

aseemk commented Nov 14, 2016

(TSLint 3.15.1 and TypeScript 2.0.9, run via CLI & Atom, but prob not relevant.)

Hi there,

Great work on TSLint! I've been using it for a couple of months now, and it's really valuable.

A particularly nice feature is that you all allow comments in tslint.json. This is really useful.

I just wanted to toss out: instead of stripping out those comments manually, would you all be open to considering JSON5 for achieving both that as well as other niceties?

Trailing commas would be the big one to me; that keeps tripping me up whenever I'm modifying the config. More flexible quoting would also be nice, but less of a big deal.

Big disclaimer: I'm the original author of JSON5, though others maintain it these days, and it's reasonably popular on its own. (E.g. used by Babel and React Native for their config files.)

Thanks for the consideration. Cheers.

(Edit: FYI I just made a similar request for tsconfig.json: microsoft/TypeScript#12242)

@nchen63
Copy link
Contributor

nchen63 commented Nov 15, 2016

some also suggested yaml #1598

@IllusionMH
Copy link
Contributor

I'm not a part of TSLint team, but as for me - only positive side of such feature - simplify files merge.
Linter config files are not rewritten every week, there are no need (no cases) to escape " like in package.json so "easier to write" may be to small benefit in comparison with possible interoperability/sharing problems.

I think YAML is better alternative to json5.

@roman-petrov
Copy link

+1 for JSON5. Great benefit for us, for example, we can split tslint.json into 'Sections' like VSCode settings file
// Standard TSLint rules
...
// vrsource-tslint-rules
...
// Our custom tslint rules
...
And even more, we will be able provide comments on rule in tslint.json to describe team members why do we use this rule.

IMHO, YAML is not a goot alternative: it is not a widely used in web.

@IllusionMH
Copy link
Contributor

IllusionMH commented Dec 7, 2016

@roman-petrov TSLint already supports comments in tslint.json.
See configuration.ts

YAML is used in any project that uses Travis CI, Circle CI etc.

@ikokostya
Copy link

ikokostya commented Jan 17, 2017

TSLint already supports comments in tslint.json.

I think this is bad practice: use json extension for format which actually isn't json. Any editor will show error for json with comments. Why just not use nodejs module for that (like eslint):

module.export = {
   // configuraiton here
};

Pros:

  • Allow comments.
  • Don't need additional libraries for parsing.
  • Good errors for invalid js.

@mohsen1
Copy link
Contributor

mohsen1 commented Jan 17, 2017

I would say TypeScript or JSDoc annotated JavaScript so we keep the autocomplete feature alive.

@IllusionMH
Copy link
Contributor

@ikokostya JS config files are supported too.

I agree that comments may be bad in JSON config only files (totally bad in other cases) but until it is optional it is OK and users want them.

I think README may be updated here with more info about available configuration formats.

@mohsen1 is I understand correctly - TSLint config autocomplete relies on JSON Schema. Does JSDoc provides such level of "validation"?

@mohsen1
Copy link
Contributor

mohsen1 commented Jan 17, 2017

TypeScript interface can be generated from JSON Schema. Something like this:

import * as tslint from 'tslint';

const config: tslint.Config = {
};
export default config;

@JoshuaKGoldberg
Copy link
Contributor

We already stripComments (src/utils.ts) from configuration files. Agreed that this would be great.

How would this interact with cosmiconfig (#1071)?

@JoshuaKGoldberg
Copy link
Contributor

💀 It's time! 💀

TSLint is being deprecated and no longer accepting pull requests for major new changes or features. See #4534. 😱

If you'd like to see this change implemented, you have two choices:

  • Recommended: Check if this is available in ESLint + typescript-eslint
  • Not Recommended: Fork TSLint locally 🤷‍♂️

👋 It was a pleasure open sourcing with you!

If you believe this message was posted here in error, please comment so we can re-open the issue!

@JoshuaKGoldberg
Copy link
Contributor

🤖 Beep boop! 👉 TSLint is deprecated 👈 (#4534) and you should switch to typescript-eslint! 🤖

🔒 This issue is being locked to prevent further unnecessary discussions. Thank you! 👋

@palantir palantir locked and limited conversation to collaborators Sep 15, 2020
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

8 participants