Proposal: throw error if no config file is found
See original GitHub issueFrom my travels around the internet, it seems that first-time ESLint users are very confused about the “nothing by default” mode. It seems many do not read the getting started docs, and so don’t know to use --init
to get started. That leaves them thinking that ESLint is broken because JSHint shows output out of the box.
To remedy this, I’d like to propose that in 3.0, we change the default behavior to use eslint:recommended
when we don’t find a config file. This should only affect CLI users and not affect CLIEngine
by default (so as not to affect API consumers).
Another option is to automatically run --init
when a config file isn’t found, but that won’t work well in editors, where an interactive prompt won’t be available.
Edit: new proposal is throwing an error asking the user to run --init (we can use a pretty error message via messagsTemplate rather than showing the stack trace).
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:26 (25 by maintainers)
Top GitHub Comments
Agree. @ilyavolodin makes a strong case for why using a default config is a bad idea. Thanks for taking the time to explain (and for everyone watching, I’d hold this up as an example of how to argue your case, taking the time to write more than a couple sentences makes a huge difference).
I can get behind throwing an error asking the user to run
--init
(we can use a pretty error message viamessagsTemplate
rather than showing the stack trace).Are people good with that?
Here’s a situation where I think this is going to create more problems then it will solve:
I’m a new user and I just installed ESLint and ran it on my repository without configuring it first. I got a bunch of errors and fixed them all. Now I continue to run ESLint with no config for a while on my repository and after a while I go to twitter and post “Love ESLint, but I wish it could check for indentations!”. Somebody responds with “All you need to do is add
indent: 2
to your .eslintrc file and it will”. So I go do that and get a bunch of indentation errors that I fix. Now for the next few weeks I keep running ESLint, but at this point what I don’t realize is that the only rule that is checked by ESLint isindent
. Since I fixed all of the previous errors, until I create a new error and remember that it should’ve been flagged, I have no way of knowing that default rules no longer apply.This silent change is what I’m afraid of. I can see how this one change might result in a bunch of issues for us, create confusion for new users and in general make users very unhappy.
In my mind, exiting ESLint process with an error “No config file found, please run 'eslint --init` to configure. Exiting.” is much more to the point and explain to users how to get started. If we do this with exit code 1, most of the editors should be able to pick up this error (since they have to be able to pick up parsing errors, which are display in the same format). This will stop CI builds, but that’s probably a good thing as well.
P.S. I apologize for not making my thoughts clearer in the first response. I’m still a bit jet-lagged.