1. npm install -g eslint-config-airbnb-base eslint-plugin-import eslint
2. eslint --init
在 vim 安裝 vim-syntastic
cd ~/.vim/bundle && git clone --depth=1 https://github.com/vim-syntastic/syntastic.git
設置 vim 的設置檔 .vimrc
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 0
let g:syntastic_check_on_wq = 1
let g:syntastic_javascript_checkers = ['standard']
let g:syntastic_javascript_standard_generic = 1
let g:syntastic_javascript_checkers = ['eslint']
" let g:syntastic_javascript_eslint_exec = 'eslint'
let g:syntastic_mode_map = { 'mode': 'passive', 'active_filetypes': [],'passive_filetypes': [] }
在 vim 啟動 linter
:SyntasticCheck
:SyntasticCheck
在 vim 檢查 linter 是否成功設置
:SyntasticInfo
關閉顯示 lint Error 的 Location List
:lclose
讓本地端資料夾的 eslint 被 syntastic 優先採用
cd ~/.vim/bundle && git clone https://github.com/mtscout6/syntastic-local-eslint.vim.git
在已經有安裝 local eslint 的資料夾下,啟動 eslint 來做 autofix
node_modules/.bin/eslint --fix FILENAME