Ale: JavaScript: conflict between standard and eslint

Created on 17 Sep 2017  路  6Comments  路  Source: dense-analysis/ale

Ale gets confused between standard (https://standardjs.com/) and eslint (https://eslint.org/).

Details

Standard is built on top of Eslint, so any Standard project also has Eslint in it. Consider a simple project:

mkdir my-project
cd my-project
npm init --yes
npm install --save-dev standard

Doing so will install both commands:

  • node_modules/.bin/eslint
  • node_modules/.bin/standard

Which enables them both linters in Ale (see :ALEInfo below):

 Current Filetype: javascript
Available Linters: ['eslint', 'flow', 'jscs', 'jshint', 'standard', 'xo']
  Enabled Linters: ['eslint', 'flow', 'jscs', 'jshint', 'standard', 'xo']

As a result, Ale will use eslint (which will produce an error), instead of standard.

Suggested solution

Having standard should disable the Eslint linter.

Most helpful comment

FYI I solve this like so:

autocmd FileType javascript let g:ale_linters = {
\  'javascript': glob('.eslintrc*', '.;') != '' ? [ 'eslint', 'flow' ] : [ 'standard', 'flow' ],
\}

Note:

  • glob('.eslintrc*', '.;') rather than findfile('.eslintrc', '.;') since some projects will have an .eslintrc, while others an .eslintrc.js or .eslintrc.json. The glob covers all bases.
  • You can remove the 'flow' if you don't need 'flow' checks.

All 6 comments

Users could prefer either. The correct thing to do is to disable the linter you don't want.

Thanks for the quick feedback! I'd appeal for you to reconsider.

  • This makes Ale's support for standard not work properly by default. It would only work if you have to configure it yourself by disabling the eslint linter.

  • "Disabling the linter you don't want" is something that I feel is contrary to Ale's batteries-included nature, where it can adapt to reasonable setups of any project you may be using it with.

  • There is only one case when someone would want both of standard and eslint in a project, and that can be detected heuristically by checking if .eslintrc is available.

    If there's no .eslintrc, you can assume that eslint is only present simply because it's a dependency of standard. Using eslint in that case would likely fail.

Btw, great fan of ale, I recommend it to everyone I know who uses Vim!

If you can come up with a sensible implementation with documentation, feel free to create a pull request.

some project use eslint, and others use standard.
Can't switch linter between eslint and standard automatically.

FYI I solve this like so:

autocmd FileType javascript let g:ale_linters = {
\  'javascript': glob('.eslintrc*', '.;') != '' ? [ 'eslint', 'flow' ] : [ 'standard', 'flow' ],
\}

Note:

  • glob('.eslintrc*', '.;') rather than findfile('.eslintrc', '.;') since some projects will have an .eslintrc, while others an .eslintrc.js or .eslintrc.json. The glob covers all bases.
  • You can remove the 'flow' if you don't need 'flow' checks.

I've tried adding a .eslintignore file with **/*.js in it, but then I still get a warning

File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

Anybody know how to disable that? The above solution sounded promising, but prove to be buggy for me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

plexigras picture plexigras  路  3Comments

arthuryangcs picture arthuryangcs  路  4Comments

ianchanning picture ianchanning  路  3Comments

chauncey-garrett picture chauncey-garrett  路  3Comments

sodiumjoe picture sodiumjoe  路  4Comments