Neomake: Neomake running eslint in unknown manner, reporting fixed errors

Created on 27 Mar 2018  路  4Comments  路  Source: neomake/neomake

Expected behavior

Neomake shouldn't show errors that eslint isn't reporting when being run manually related to incorrect imports

Steps to reproduce

  • I'm using neomake with local-npm-bin. Neomake info correctly shows that it's using a local eslint bin from ./node-modules.
  • Neomake was run with :Neomake eslint, or run through writing a file.
  • When run, Neomake complains of imports that are unresolved. These imports are using babel-plugin-root-import to import for a root section in the project. Our eslint config is using bingqichen/eslint-import-resolver-babel-plugin-root-import to correctly resolve these imports. This npm package is installed in local node_modules and globally. The problematic imports look something like this: import app from ~/ui/app.js
  • Running eslint globally and from the local ./node_modules/.bin doesn't report these errors.

Neomake has to be running eslint differently, but I can't find where in the output or config that it's doing this.

Output from (verbose) NeomakeInfo

Neomake debug information

Async support: 1
Current filetype: javascript
Windows: 0

Enabled makers

For the current filetype ("javascript", used with :Neomake):

  • eslint

    • args: ['-f', 'compact']

    • auto_enabled: 0

    • cwd: '%:p:h'

    • errorformat: '%E%f: line %l\, col %c\, Error - %m,%W%f: line %l\, col %c\, Warning - %m,%-G,%-G%*\d problems%#'

    • exe: '/Users/msecret/project/node_modules/.bin/eslint'

      NOTE: you can define g:neomake_javascript_enabled_makers to configure it (or b:neomake_javascript_enabled_makers).

Default maker settings:

  • output_stream: 'both'
  • remove_invalid_entries: 0
  • buffer_output: 1

For the project (used with :Neomake!):
None.
NOTE: you can define g:neomake_enabled_makers to configure it.

Settings
New-style (dict, overrides old-style)
g:neomake: {
  'automake': {
    'ignore_filetypes': ['startify'],
    'events': {
      'InsertLeave': {},
      'BufWritePost': {
        'delay': 0,
      },
      'TextChanged': {},
    },
  },
  'automake_delay': 750,
}
b:neomake: unset
Old-style
g:neomake_error_sign = {'texthl': 'ErrorMsg', 'text': 'X'}
g:neomake_javascript_enabled_makers = ['eslint']
g:neomake_open_list = 0
g:neomake_place_signs = 1
g:neomake_warning_sign = {'texthl': 'WarningMsg', 'text': '?'}

makeprg=make

:version

NVIM v0.2.2
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/local/Homebrew/Library/Homebrew/shims/super/clang -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -I/tmp/neovim-20180209-66903-ukwirj/neovim-0.2.2/build/config -I/tmp/neovim-20180209-66903-ukwirj/neovim-0.2.2/src -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/opt/gettext/include -I/usr/include -I/tmp/neovim-20180209-66903-ukwirj/neovim-0.2.2/build/src/nvim/auto -I/tmp/neovim-20180209-66903-ukwirj/neovim-0.2.2/build/include
Compiled by [email protected]

Features: +acl +iconv +jemalloc +tui 
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/0.2.2_1/share/nvim"

Run :checkhealth for more info

:messages

"app/javascript/ui/organizations/OrganizationMenu.js" 211L, 5707C
"app/javascript/ui/organizations/OrganizationMenu.js" 211L, 5707C written

Neomake log information

11:24:10 [D      ] [-.-:3:1] automake: handling event BufWritePost.
11:24:10 [D      ] [-.-:3:1] Using setting automake.ignore_filetypes=['startify'] from 'global'.
11:24:10 [D      ] [-.-:3:1] automake: automake for event BufWritePost.
11:24:10 [D      ] [-.-:3:1] Using setting automake.events={'InsertLeave': {}, 'BufWritePost': {'delay': 0}, 'TextChanged': {}} from 'global'.
11:24:10 [D      ] [-.-:3:1] automake: neomake_do_automake: BufWritePost.
11:24:10 [D      ] [-.-:3:1] automake: tick is unchanged with BufWritePost adjustment.
11:24:10 [D      ] [-.-:3:1] automake: Updating tick: 4.
11:24:10 [D      ] [-.-:3:1] automake: buffer was not changed.
11:24:10 [D +0.01] [3.-:3:1] Running makers: eslint.
11:24:10 [D      ] [3.3:3:1] Setting neomake_automake_tick.
11:24:12 [D +1.97] [3.3:3:1] stdout: eslint: ['/Users/msecret/project/app/javascript/ui/organizations/OrganizationMenu.js: line 1, col 1, Error - Resolve error: Cannot find module ''/Users/msecret/project/app/javascript/ui/organizations/package.json'' (import/no-named-as-default)', '/Users/msecret/project/app/javascript/ui/organizations/OrganizationMenu.js: line 1, col 1, Error - Resolve error: Cannot find module ''/Users/msecret/project/app/javascript/ui/organizations/package.json'' (import/no-unresolved)', '/Users/msecret/project/app/javascript/ui/organizations/OrganizationMenu.js: line 1, col 1, Error - Resolve error: Cannot find module ''/Users/msecret/project/app/javascript/ui/organizations/package.json'' (import/no-extraneous-dependencies)', '/Users/msecret/project/app/javascript/ui/organizations/OrganizationMenu.js: line 1, col 1, Error - Resolve error: Cannot find module ''/Users/msecret/project/app/javascript/ui/organizations/package.json'' (import/no-duplicates)', '/Users/msecret/project/app/javascript/ui/organizations/OrganizationMenu.js: line 1, col 1, Error - Resolve error: Cannot find module ''/Users/msecret/project/app/javascript/ui/organizations/package.json'' (import/no-named-as-default-member)', '/Users/msecret/project/app/javascript/ui/organizations/OrganizationMenu.js: line 3, col 40, Error - Unable to resolve path to module ''~/ui/global/styled/forms''. (import/no-unresolved)', '/Users/msecret/project/app/javascript/ui/organizations/OrganizationMenu.js: line 4, col 35, Error - Unable to resolve path to module ''~/ui/global/styled/layout''. (import/no-unresolved)', '/Users/msecret/project/app/javascript/ui/organizations/OrganizationMenu.js: line 5, col 39, Error - Unable to resolve path to module ''~/ui/global/styled/typography''. (import/no-unresolved)', '/Users/msecret/project/app/javascript/ui/organizations/OrganizationMenu.js: line 6, col 19, Error - Unable to resolve path to module ''~/ui/global/Modal''. (import/no-unresolved)', '/Users/msecret/project/app/javascript/ui/organizations/OrganizationMenu.js: line 7, col 25, Error - Unable to resolve path to module ''~/ui/groups/GroupModify''. (import/no-unresolved)', '/Users/msecret/project/app/javascript/ui/organizations/OrganizationMenu.js: line 8, col 23, Error - Unable to resolve path to module ''~/ui/roles/RolesMenu''. (import/no-unresolved)', '/Users/msecret/project/app/javascript/ui/organizations/OrganizationMenu.js: line 28, col 23, Warning - Unexpected console statement. (no-console)', '/Users/msecret/project/app/javascript/ui/organizations/OrganizationMenu.js: line 179, col 7, Warning - Unexpected console statement. (no-console)', '/Users/msecret/project/app/javascript/ui/organizations/OrganizationMenu.js: line 180, col 7, Warning - Unexpected console statement. (no-console)', '', '14 problems', ''].
11:24:12 [D +0.07] [3.3:3:1] exit: eslint: 1.
11:24:12 [D      ] [3.3:3:1] eslint: processing 16 lines of output.
11:24:12 [D      ] [3.3:3:1] Processing 14 entries.
11:24:12 [D      ] [3.-:3:1] File-level errors cleaned.
11:24:12 [D      ] [-.-:3:1] Reusing sign: id=5000, type=neomake_file_err, lnum=1.
11:24:12 [D      ] [-.-:3:1] Reusing sign: id=5001, type=neomake_file_warn, lnum=28.
11:24:12 [D      ] [-.-:3:1] Reusing sign: id=5002, type=neomake_file_err, lnum=3.
11:24:12 [D      ] [-.-:3:1] Reusing sign: id=5003, type=neomake_file_err, lnum=4.
11:24:12 [D      ] [-.-:3:1] Reusing sign: id=5004, type=neomake_file_err, lnum=5.
11:24:12 [D      ] [-.-:3:1] Reusing sign: id=5005, type=neomake_file_err, lnum=6.
11:24:12 [D      ] [-.-:3:1] Reusing sign: id=5006, type=neomake_file_err, lnum=7.
11:24:12 [D      ] [-.-:3:1] Reusing sign: id=5007, type=neomake_file_err, lnum=8.
11:24:12 [D      ] [-.-:3:1] Reusing sign: id=5008, type=neomake_file_warn, lnum=180.
11:24:12 [D      ] [-.-:3:1] Reusing sign: id=5009, type=neomake_file_warn, lnum=179.
11:24:12 [D      ] [3.3:3:1] eslint: completed with exit code 1.
11:24:12 [D      ] [3.3:3:1] Cleaning jobinfo.
11:24:12 [D      ] Cleaning old signs in buffer 3: {}.
11:24:12 [D      ] [3.-:3:1] Cleaning make info.
11:24:14 [D +1.81] Calling VimLeave.
bug

Most helpful comment

Looks like you left out output from the log (the actual run, and the cwd).
My guess is that it's related to the current working directory, which might have an impact on which config file is used.
You can try to reproduce/debug this outside of Neomake by changing e.g. to the same directory as Vim is using (see :pwd), and/or going to the linted file's directory.

All 4 comments

GitMate.io thinks possibly related issues are https://github.com/neomake/neomake/issues/101 (:Neomake giving error), https://github.com/neomake/neomake/issues/1484 (Neomake is reporting errors as warnings), https://github.com/neomake/neomake/issues/754 (Neomake function error), https://github.com/neomake/neomake/issues/81 (Neomake error on rust file.), and https://github.com/neomake/neomake/issues/519 (Error every time :Neomake is run).

Looks like you left out output from the log (the actual run, and the cwd).
My guess is that it's related to the current working directory, which might have an impact on which config file is used.
You can try to reproduce/debug this outside of Neomake by changing e.g. to the same directory as Vim is using (see :pwd), and/or going to the linted file's directory.

A better way than local-npm-bin is to use the official npx binary that node comes with
I have a setup that does this here: https://github.com/davidosomething/dotfiles/blob/dev/vim/autoload/dko/neomake/javascript.vim
It overrides the eslint maker to use npx and eslint as the first arg

the NpxMaker function is here:
https://github.com/davidosomething/dotfiles/blob/dev/vim/autoload/dko/neomake.vim#L29
which can set up npx as the exe for any maker

Additionally you need to customize cwd for eslint in some scenarios. eslint needs to be executed from the root path where node_modules is located because it has a flaw in that it cannot find eslint-plugins unless run from the directory above node_modules

See @blueyed's final comment in #1892 for a solution to cwd

Neomake has to be running eslint differently, but I can't find where in the output or config that it's doing this.

cwd might be something - since you've said it would use the correct bin already.

See https://github.com/neomake/neomake/pull/2407 for a method that would pick up node_modules/.bin automatically (but that does not appear to have been your problem).

Closing for now due to lack of feedback, but feel free to re-open (or create a new issue) with more details.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stjepang picture stjepang  路  4Comments

sirex picture sirex  路  6Comments

pengowen123 picture pengowen123  路  6Comments

mcnelson picture mcnelson  路  4Comments

RenatoUtsch picture RenatoUtsch  路  4Comments