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

flycheck-eslint errors out with a bare setup #1085

Closed
cowboyd opened this Issue Sep 12, 2016 · 16 comments

Comments

Projects
None yet
7 participants
@cowboyd

cowboyd commented Sep 12, 2016

Opened up a file with a .js extension using the javascript-eslint checker enabled. It plopped a big nasty error into my minibuffer saying that the checker might be mal-defined instead of verifying the javascript syntax as expected.

emacs_prelude_-_scratch_js_and_check_buffers_ _flycheck_30-cvs_documentation_

It looks as though the problem is that eslint throws an error if you don't have at least some configuration file present, even if it's an empty one in your home directory. This seems suboptimal to me, but I don't know if this is something that I should raise upstream, or that can be worked around in flycheck.

Elsint does support a --no-eslintrc flag that will make the error go away:

$ echo "var x = 'y';" | eslint --stdin                                                                                                                                        
No ESLint configuration found.
Error: No ESLint configuration found.
    at getLocalConfig (/Users/cowboyd/.nvm/versions/node/v4.2.3/lib/node_modules/eslint/lib/config.js:162:35)
    at Config.getConfig (/Users/cowboyd/.nvm/versions/node/v4.2.3/lib/node_modules/eslint/lib/config.js:256:22)
    at processText (/Users/cowboyd/.nvm/versions/node/v4.2.3/lib/node_modules/eslint/lib/cli-engine.js:222:33)
    at CLIEngine.executeOnText (/Users/cowboyd/.nvm/versions/node/v4.2.3/lib/node_modules/eslint/lib/cli-engine.js:749:26)
    at Object.execute (/Users/cowboyd/.nvm/versions/node/v4.2.3/lib/node_modules/eslint/lib/cli.js:174:42)
    at /Users/cowboyd/.nvm/versions/node/v4.2.3/lib/node_modules/eslint/bin/eslint.js:57:36
    at ConcatStream.<anonymous> (/Users/cowboyd/.nvm/versions/node/v4.2.3/lib/node_modules/eslint/node_modules/concat-stream/index.js:36:43)
    at emitNone (events.js:72:20)
    at ConcatStream.emit (events.js:166:7)
    at finishMaybe (/Users/cowboyd/.nvm/versions/node/v4.2.3/lib/node_modules/eslint/node_modules/concat-stream/node_modules/readable-stream/lib/_stream_writable.js:475:14)

vs

$ echo "var x = 'y';" | eslint --stdin --no-eslintrc

Perhaps there is a way to detect this and retry with the --no-eslintrc set?

Environment

Syntax checkers for buffer scratch.js in js2-mode:

  javascript-eslint
    - predicate:          t
    - executable:         Found at /Users/cowboyd/.nvm/versions/node/v4.2.3/bin/eslint
    - configuration file: Not found

  javascript-jshint
    - predicate:          nil
    - executable:         Not found
    - configuration file: Not found

  javascript-gjslint
    - predicate:          nil
    - executable:         Not found
    - configuration file: Not found

  javascript-jscs
    - predicate:          nil
    - executable:         Not found
    - configuration file: Not found

  javascript-standard
    - predicate:  nil
    - executable: Not found

Flycheck Mode is enabled.  Use C-u C-c ! x to enable disabled
checkers.

--------------------

Flycheck version: 30snapshot (package: 20160912.814)
Emacs version:    24.4.1
System:           x86_64-apple-darwin14.0.0
Window system:    ns
GNU Emacs 24.4.1 (x86_64-apple-darwin14.0.0, NS apple-appkit-1343.14) of 2014-10-27 on galadriel.att.net
Flycheck version: 30snapshot (package: 20160912.814)

@cowboyd cowboyd changed the title from flycheck-eslint errors out with to flycheck-eslint errors out with a bare setup Sep 12, 2016

@lunaryorn

This comment has been minimized.

Contributor

lunaryorn commented Sep 13, 2016

Oh I wasn't aware that eslint now errors if it doesn't find a configuration. Unfortunately there's little that we can do: We have no infrastructure to re-run a syntax checker with different flags if a particular error occurs, and I don't want to add a special case for just a single syntax checker.

Defaulting to --no-eslintrc is not an option either as it'd completely disable configuration files even if they exist as far as I understand. We could only add a user option for it.

The best way though would be to take this issue to eslint and ask them to gracefully deal with the absence of a configuration file. I'd expect eslint to do at least a syntax check of some kind if there's no configuration file. Would you take it upstream?

In any case we should probably turn our default back to jshint.

@flycheck/javascript Your opinion?

@aaronjensen

This comment has been minimized.

Member

aaronjensen commented Sep 13, 2016

Can we add a search for an eslintrc to the predicate?

@lunaryorn

This comment has been minimized.

Contributor

lunaryorn commented Sep 13, 2016

@aaronjensen I'm not sure. eslint is looking at a lot of places for its configuration—including package.json—and I'm not sure in how far we'd have to deal with its intricate cascading of config files.

@Simplify

This comment has been minimized.

Member

Simplify commented Sep 13, 2016

Ok, this is change in one of the recent versions of ESLint. This problem does not occur with 2.8 that I had installed, but after installing 3.5 I got same error. As @lunaryorn said, we can not use predicate, there are different ways to put ESLint configuration. So there is also no way to "auto magically" add --no-eslintrc. We can add option for this flag, but that is really project dependent and users will need to use that option in .dir-locals.el on project basis.

Strange thing is that according to ESLint rules page: "No rules are enabled by default.". If there is "default" that are no rules enabled, why --no-eslintrc option exists? Just to return '0' back to shell? Does not compute. That page is or outdated or this is a bug in ESLint. Also, if somebody specify CheckStyle XML output as option to ESLint, that error has to be returned in XML, simply because who ever called ESLint with that option expect XML back and will not be able to parse response. This is bug IMHO.

We can:

  • Change default checker to JSHint. I have no problem with that, personally, JSHint is default Ember.js checker, Ember's test suite assert that all files are validated with JSHint with .jshintrc files generated with Ember project. However, ESLint is currently the best JS checker available and used by most React projects (and more). This is really last valid option.
  • Build predicate and require users to use .eslintrc and ignore 5 other ways to configure ESLint. I don't like this one. This will break many existing configurations.
  • Add in documentation that user must generate config file with eslint --init in project or in his home directory before using ESLint. That will not stop crash issue...
  • Add option for --no-eslintrc but I think that this is just waste of time and brings more complexity.
  • The best option is as @lunaryorn said, to take this issue upstream, to ESLint developers.
@lunaryorn

This comment has been minimized.

Contributor

lunaryorn commented Sep 13, 2016

@Simplify Yup, I'd love to have eslint people weight in on this issue.

@Simplify

This comment has been minimized.

Member

Simplify commented Sep 13, 2016

Ok, I'll open issue there today. Can't do it right now doe some other obligations.

@cowboyd

This comment has been minimized.

cowboyd commented Sep 13, 2016

Change default checker to JSHint. I have no problem with that, personally, JSHint is default Ember.js checker, Ember's test suite assert that all files are validated with JSHint with .jshintrc files generated with Ember project. However, ESLint is currently the best JS checker available and used by most React projects (and more). This is really last valid option.

While it's still the default, eslint support for Ember is really good, and I believe there are plans to make eslint the default for new projects soon. In fact, I actually enountered this because of using eslint within Ember projects.

@cowboyd

This comment has been minimized.

cowboyd commented Sep 13, 2016

@Simplify Hope you don't mind, I went ahead and opened the issue since this is a papercut currently affecting me and my team.

@Simplify

This comment has been minimized.

Member

Simplify commented Sep 13, 2016

@cowboyd No problem at all, even I already started creating issue there :) I'll add my 5 cents there.

@Simplify

This comment has been minimized.

Member

Simplify commented Sep 13, 2016

@Simplify

This comment has been minimized.

Member

Simplify commented Sep 13, 2016

@cowboyd The best option for now is to create config in your project and place it in version control. That way everybody on your team will have same config and not have this issue.

@lunaryorn

This comment has been minimized.

Contributor

lunaryorn commented Sep 14, 2016

To summarize, we'll

  1. add #1089 (hence blocked),
  2. add an :enabled function for eslint that uses eslint --print-config to check whether the current buffer has a suitable configuration,
  3. and thus implicitly fall back to jshint or standard if there's none.

/cc @Simplify @flycheck/maintainers

Simplify added a commit that referenced this issue Sep 24, 2016

ESLint support for :enabled
Fixes and closes GH-1085

Simplify added a commit that referenced this issue Sep 24, 2016

ESLint support for :enabled
Fixes and closes GH-1085

Simplify added a commit that referenced this issue Sep 24, 2016

ESLint support for :enabled
Fixes and closes GH-1085

Simplify added a commit that referenced this issue Sep 24, 2016

ESLint support for :enabled
Fixes and closes GH-1085

Simplify added a commit that referenced this issue Sep 25, 2016

ESLint support for :enabled
Fixes and closes GH-1085

Simplify added a commit that referenced this issue Sep 26, 2016

Simplify added a commit that referenced this issue Sep 26, 2016

lunaryorn added a commit that referenced this issue Sep 27, 2016

@eastwood

This comment has been minimized.

eastwood commented Dec 14, 2016

I believe this issue has caused eslint to be extremely slow with --print-config. Opening any buffer now has significant latency, almost unusable :(

@fmdkdd

This comment has been minimized.

Member

fmdkdd commented Dec 14, 2016

@eastwood See #1129 and its discussion.

@tko

This comment has been minimized.

tko commented Jan 10, 2017

It seems this broke compatibility with older eslint versions that do not support --print-config option. With .eslintrc in place in the project everything used to work fine but no more.

$ eslint --print-config .
Invalid option '--print-config' - perhaps you meant '--inline-config'?
$ eslint --version
v1.10.3

I realize 1.10.3 is relatively old (Dec 1, 2015) so not sure if there's enough interest to keep compatibility.

@Simplify

This comment has been minimized.

Member

Simplify commented Jan 10, 2017

@tko we don't support versions that old. You need at eslint version that supports --print-config (3.0 I think, maybe even 3.5).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment