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

Suggestion: Use typescript to parse JSON config file #3182

Closed
ajafff opened this issue Aug 29, 2017 · 5 comments
Closed

Suggestion: Use typescript to parse JSON config file #3182

ajafff opened this issue Aug 29, 2017 · 5 comments

Comments

@ajafff
Copy link
Contributor

ajafff commented Aug 29, 2017

TypeScript@2.5 uses its own parser to parse tsconfig.json files. We could use ts.readConfigFile or ts.parseConfigFileTextToJson for tslint.json files as well.
This API allows comments and trailing commas (and even tolerates single quotes, but returns an error for each single quoted string). It can also be used for better error reporting as it contains way more details than exceptions thrown by JSON.parse.

Before v2.5 the function only accepts comments, but that's probably OK as a fallback because that's also what the current implementation of tslint does.

Related: #1721

@ajafff
Copy link
Contributor Author

ajafff commented Oct 28, 2017

An update on this: ts.parseConfigFileTextToJson does not support negative numbers. Currently TSLint core rules don't expect negative numbers, but it could break configurations with custom rules.

I'll open an issue in the typescript repo to ask if this is intended.

@ajafff
Copy link
Contributor Author

ajafff commented Oct 31, 2017

microsoft/TypeScript#19552 landed in TypeScript. The fix will be released with version 2.7.0
That means we cannot use it until we drop support for all typescript versions older than 2.7.0

@JoshuaKGoldberg
Copy link
Contributor

#1071 is also open for moving to cosmiconfig. Do you have any thoughts or preferences here @ajafff?

@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 Mar 20, 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

2 participants