Update readme and vim error messages for eslint global support

This commit is contained in:
dc3671 2017-10-05 16:57:12 +08:00
parent 5ea2893299
commit ab7ead0c3f
2 changed files with 7 additions and 7 deletions

View File

@ -162,11 +162,11 @@ Here is a list of formatprograms that are supported by default, and thus will be
It can be installed by running `npm install -g standard` (`nodejs` is required). No more configuration needed. It can be installed by running `npm install -g standard` (`nodejs` is required). No more configuration needed.
More information about the style guide can be found here: http://standardjs.com/. More information about the style guide can be found here: http://standardjs.com/.
* `ESlint (local)` for __Javascript__. http://eslint.org/ * `ESlint (support local&global)` for __Javascript__. http://eslint.org/
It can be installed by running `npm install eslint`. The linter is then installed locally at ```node_modules/.bin/eslint``` It can be installed by running `npm install eslint` for local project or by running `npm install -g eslint` for global use. The linter is then installed locally at `$YOUR_PROJECT/node_modules/.bin/eslint` for local or `~/.npm-global/bin/eslint` for global.
When running formatter vim will walk up from the current file to search for such local installation and a When running formatter vim will walk up from the current file to search for such local installation and a ESLint configuration file (either .eslintrc.js or eslintrc.json). When local version is missing it will fallback to global version. When both requirements are found eslint is executed with the --fix argument.
ESLint configuration file (either .eslintrc or eslintrc.json). When both are found eslint is executed with the --fix argument. Note that the formatter's name is still `eslint_local` for legacy reason while it has already support global `eslint`.
Currently only working on *nix like OS (Linux, MacOS etc.) requires OS to provide sh like shell syntax Currently only working on \*nix like OS (Linux, MacOS etc.) requires OS to provide sh like shell syntax
* `xo` for __Javascript__. * `xo` for __Javascript__.
It can be installed by running `npm install -g xo` (`nodejs` is required). It can be installed by running `npm install -g xo` (`nodejs` is required).

View File

@ -181,7 +181,7 @@ if !exists('g:formatdef_eslint_local')
let l:path = fnamemodify(expand('%'), ':p') let l:path = fnamemodify(expand('%'), ':p')
let verbose = &verbose || g:autoformat_verbosemode == 1 let verbose = &verbose || g:autoformat_verbosemode == 1
if has('win32') if has('win32')
return "(>&2 echo 'ESLint Local not supported on win32')" return "(>&2 echo 'ESLint not supported on win32')"
endif endif
" find formatter & config file " find formatter & config file
let l:prog = findfile('node_modules/.bin/eslint', l:path.";") let l:prog = findfile('node_modules/.bin/eslint', l:path.";")
@ -218,7 +218,7 @@ if !exists('g:formatdef_eslint_local')
endif endif
if (empty(l:cfg) || empty(l:prog)) if (empty(l:cfg) || empty(l:prog))
if verbose if verbose
return "(>&2 echo 'No local ESLint program and/or config found')" return "(>&2 echo 'No local&global ESLint program and/or config found')"
endif endif
return return
endif endif