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

Proposal: eslint --locate-config #7719

Closed
jethrokuan opened this issue Dec 8, 2016 · 7 comments

Comments

Projects
None yet
6 participants
@jethrokuan
Copy link

commented Dec 8, 2016

This proposal will benefit all editor plugins that use eslint under the hood. Some plugins (like flycheck) currently use eslint --print-config to determine if an eslint config exists. However, the check also fails in other scenarios, such as a npm package not being installed, or the config is errorneous.

The plugins, however, have no easy way of determining whether the config file is actually missing or not, and may print misleading messages. See flycheck/flycheck#1175.

I propose an additional CLI option, --locate-config, that simply prints the location of the eslint config file.

@eslintbot eslintbot added the triage label Dec 8, 2016

@cpitclaudel

This comment has been minimized.

Copy link

commented Dec 8, 2016

Flycheck maintainer here; this would also help us with cases in which --print-config is slow, I believe (flycheck/flycheck#1129). Inviting @Simplify to the discussion, as our flycheck/eslint expert :)

@platinumazure

This comment has been minimized.

Copy link
Member

commented Dec 8, 2016

Given that multiple configuration files are allowed and some can inherit from each other, which config file in particular are you looking for? The first one found when traversing up the directory tree? The one with root: true, if it exists? The last one found? Etc.

@not-an-aardvark

This comment has been minimized.

Copy link
Member

commented Dec 8, 2016

I'm not sure whether this would satisfy your use case, but a simple/fast way to do this would be

test -e .eslintrc || test -e .eslintrc.yml || test -e .eslintrc.yaml || test -e .eslintrc.json || test -e .eslintrc.js
@jethrokuan

This comment has been minimized.

Copy link
Author

commented Dec 8, 2016

@platinumazure the current practice is to pass a string to indicate the directory, and I think that should still be fine. e.g. eslint --locate-config . in the project directory would locate "project-specific" one.

@not-an-aardvark preferably the functionality would be provided by eslint, in case these conventions change again and the plugins that depend on it are unaware.

@cpitclaudel

This comment has been minimized.

Copy link

commented Dec 8, 2016

@Simplify will confirm, but IIUC we're just trying to determine whether eslint will complain about a missing configuration when we run it; given this, we don't really care which file exactly is being returned; we just want a quick way to make sure that there is one, so that we can disable eslint if there isn't.

@Simplify

This comment has been minimized.

Copy link

commented Dec 8, 2016

Basically, we only need to know if ESLint can find any configuration at all.

Best option for us will be --valid-config . with different exit codes:
0 - There is config and config is valid, no modules are missing, etc..
1 - There is no configuration at all, user need to run eslint --init
2 - There is configuration file, but ESLint can't use it, some modules are missing, oa ESLint couldn't find the plugin "eslint-plugin-react"..

@not-an-aardvark

This comment has been minimized.

Copy link
Member

commented Jul 11, 2017

Thanks for your interest in improving ESLint. Unfortunately, it looks like this issue didn't get enough support from the team and so I'm closing it. While we wish we'd be able to accommodate everyone's requests, we do need to prioritize. We've found that issues failing to reach consensus after a long time tend to never do it, and as such, we close those issues. This doesn't mean the idea isn't interesting, just that it's not something the team can commit to.

@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.