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

[Feature Request]: --print-config flag like eslint #3720

Closed
bensaufley opened this issue Feb 15, 2018 · 2 comments · Fixed by #4744
Closed

[Feature Request]: --print-config flag like eslint #3720

bensaufley opened this issue Feb 15, 2018 · 2 comments · Fixed by #4744

Comments

@bensaufley
Copy link

I'm not using the issue template because I'm not reporting a bug and all the fields appear to relate to bug reporting. Please let me know if I can provide any other information.

Description

It would be great to have a way to audit the rules being applied to a given file or project, as eslint does with --print-config [FILENAME]. I've currently got a number of extends in my tslint.json and I'm getting unexpected results; being able to print the config would help. Ideally something like:

$ tslint --print-config path/to/file.ts

With the result being a simple JSON configuration of the evaluated set of rules.

Implementation

It looks like it might be pretty easy to accomplish, if I understand the library usage example properly—it seems like you'd just have to pretty-format the object returned by this command (assuming commandLineConfigArg?: string and commandLineFileArg: string were supplied through the command line):

tslint.Configuration.findConfiguration(commandLineConfigArg, commandLineFileArg).results

Is that a reasonable approach? In experimenting, I'm getting a pretty short set of rules compared to my eslint output on another project, so I might be missing something—ah it looks like the eslint output includes a lot of "off" rules, so I don't know how this flag might account for that. But if I understand the above line correctly, then in the short term I think I can just npx node and run these commands myself in a node console, but I think this would be a useful flag and help to align this tool with its ES analog.

@JoshuaKGoldberg
Copy link
Contributor

Related: summary request at #2267. Perhaps these two could be accomplished together? Perhaps they shouldn't be?

@JoshuaKGoldberg
Copy link
Contributor

JoshuaKGoldberg commented May 25, 2019

Given the upcoming migration to ESLint (#4534), this seems like it would be a very useful configuration flag to help with migrating to typescript-eslint.

Marking as accepting PRs! 🎉

Since nobody piped up with an alternate proposal (☹️), let's keep this as similar to ESLint's --print-config as possible. It should directly print out the JSON equivalent of whatever configuration is found for a single file.

$ eslint --print-config src/index.js
{
  "globals": {},
  "env": {},
  "rules": {
    "some-rule": 1
  },
  "parserOptions": {
    "ecmaFeatures": {
      "jsx": true
    },
    "ecmaVersion": 2018,
    "sourceType": "module"
  }
}

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

Successfully merging a pull request may close this issue.

3 participants