Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI option for printing effective configuration #5099

Closed
spencerhakim opened this issue Jan 29, 2016 · 17 comments

Comments

Projects
None yet
7 participants
@spencerhakim
Copy link

commented Jan 29, 2016

With the ability to inherit multiple other rule configurations, it'd be very helpful to be able to print out the unified configuration.

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@eslintbot

This comment has been minimized.

Copy link

commented Jan 29, 2016

@spencerhakim Thanks for the issue! If you're reporting a bug, please be sure to include:

  1. The version of ESLint you are using (run eslint -v)
  2. What you did (the source code and ESLint configuration)
  3. The actual ESLint output complete with numbers
  4. What you expected to happen instead

Requesting a new rule? Please see Proposing a New Rule for instructions.

@ilyavolodin

This comment has been minimized.

Copy link
Member

commented Jan 29, 2016

Due to the way configs cascade, you can have a different config for more or less every file that you lint. When you pass in a pattern to the linter, we have no way to identify which merged config to print. And having an option that would only work for a single file would go against our current strategy.

@platinumazure

This comment has been minimized.

Copy link
Member

commented Jan 29, 2016

@ilyavolodin What about having debug code before parsing a given file which spits out the effective config for that file? Yes, that's a lot of output potentially, but users can tailor that by passing only certain files on the CLI.

@ilyavolodin

This comment has been minimized.

Copy link
Member

commented Jan 29, 2016

Hmm.. Maybe, but it would be a lot of extra output. And we don't really have a way of filtering debug statements right now.

@spencerhakim

This comment has been minimized.

Copy link
Author

commented Jan 29, 2016

I'm not asking for per-file config output, I just want to be able to point to a directory or specific .eslintrc and have it resolve. Config comments in files are definitely outside of this scope.

@nzakas

This comment has been minimized.

Copy link
Member

commented Jan 29, 2016

The only real way we can do this is to have a different mode altogether, something like:

$ eslint --config-calc some-file.js

(The name --config-calc is horrible, let's not use that.)

In this case, ESLint would just output the calculated config for the given file without doing any linting.

@spencerhakim

This comment has been minimized.

Copy link
Author

commented Jan 29, 2016

Yep, that's more or less what I'd love to see, no need to do any actual linting in this mode. 👍

@nzakas

This comment has been minimized.

Copy link
Member

commented Jan 30, 2016

@spencerhakim do you want to submit a PR for it?

@spencerhakim

This comment has been minimized.

Copy link
Author

commented Jan 31, 2016

@nzakas I'm not at all familiar with the internals of eslint, but I'm willing to try. Any hints for where to start looking?

@kaicataldo

This comment has been minimized.

Copy link
Member

commented Feb 1, 2016

I'd love to work on this if @spencerhakim doesn't take this on. Been looking for a chance to get to know ESLint's internals a bit better!

@kaicataldo

This comment has been minimized.

Copy link
Member

commented Feb 3, 2016

Hey all, just wanted to follow up. I'd love to get started on this if no one else is currently working on it.

@ilyavolodin

This comment has been minimized.

Copy link
Member

commented Feb 3, 2016

@spencerhakim How is your progress on this? Do you want @kaicataldo to take over or are you fine finishing it yourself?

@christophercrouzet

This comment has been minimized.

Copy link
Contributor

commented Feb 3, 2016

Heya,

For information I've just been looking for such a feature and landed on this issue.

Thanks to @ilyavolodin links, the implementation seemed straighforward enough so I decided to give it a quick go. So far I got a basic version to work but the output log is quite long, especially since getConfigForFile() also includes the globals config. As an alternative I've started to look into defining the command line flag config-calc as a [String] to allow filtering the output, ie:

$ eslint --config-calc env,rules some-file.js

I'm not sure if I'm picking the right approach though? If I don't have any news, I'll get back onto it tomorrow (as it's getting late over here) and if I get something working I'll definitely post a PR to start a discussion regarding the implementation.

In any case, I didn't mean to steal it from either @spencerhakim or @kaicataldo—it just seemed like a good exercise for me to dive into some code that is not mine and contribute a bit—so please feel free to come with other PRs, no worries!

PS: how about --print-config for the flag name?

@nzakas

This comment has been minimized.

Copy link
Member

commented Feb 3, 2016

I wouldn't filter, it's fine to just dump the whole config. People can always save to a file and filter however they want.

I can live with --print-config.

@spencerhakim

This comment has been minimized.

Copy link
Author

commented Feb 3, 2016

I'm fine with someone else grabbing it if they're interested, it was hard to find time to work on it myself.

@kaicataldo

This comment has been minimized.

Copy link
Member

commented Feb 3, 2016

Bummer - was looking forward to maybe working on this, haha. But glad it's getting done! 👍

@nzakas nzakas closed this in 413247f Feb 7, 2016

nzakas added a commit that referenced this issue Feb 7, 2016

Merge pull request #5145 from christophercrouzet/issue5099
New: Add a --print-config flag (fixes #5099)

duoani added a commit to duoani/eslint that referenced this issue Feb 21, 2017

@eslint eslint bot locked and limited conversation to collaborators Feb 6, 2018

@eslint eslint bot added the archived due to age label Feb 6, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.