Last active
March 18, 2024 16:10
-
-
Save phanhaiquang/17a733bd7a9a2e9e7a6fa59768dca3fe to your computer and use it in GitHub Desktop.
Setup ESLint for VIM ALE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
"parser": "@babel/eslint-parser", | |
"env": { | |
"browser": true, | |
"es2021": true | |
}, | |
"extends": "plugin:react/recommended", | |
"parserOptions": { | |
"requireConfigFile": false, | |
"ecmaFeatures": { | |
"jsx": true | |
}, | |
"ecmaVersion": 12, | |
"sourceType": "module" | |
}, | |
"plugins": [ | |
"react" | |
], | |
"rules": { | |
"react/prop-types": 0 | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let g:ale_enabled = 1 | |
let g:ale_linters = { | |
'javascript': ['prettier', 'eslint'] | |
} | |
let g:ale_fixers = {} | |
let g:ale_fix_on_save = 1 | |
let g:ale_lint_on_enter = 1 | |
let g:ale_lint_on_text_changed = 'always' | |
let g:ale_lint_delay = 300 | |
let g:ale_sign_error = '✗' | |
let g:ale_sign_warning = '⚠' | |
" common for all languages | |
let g:ale_fixers['*'] = ['remove_trailing_lines', 'trim_whitespace'] | |
" javascript | |
let g:ale_fixers['javascript'] = ['prettier', 'eslint'] | |
let g:ale_javascript_prettier_options = '--trailing-comma es5 --write' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Open a .js or .jsx file | |
- Type | |
:ALEInfo | |
- Make sure below information | |
Enabled Linters: ['stylelint', 'eslint'] | |
.... | |
(executable check - success) .....eslint.js | |
.... | |
<<<OUTPUT STARTS>>> | |
[{"filePath":"your_js_file.js","messages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]}] | |
<<<OUTPUT ENDS>>> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yarn add @babel/core --dev | |
yarn add @babel/eslint-parser --dev | |
yarn add @babel/plugin-proposal-class-properties --dev | |
yarn add @babel/plugin-proposal-object-rest-spread --dev | |
yarn add @babel/plugin-syntax-dynamic-import --dev | |
yarn add @babel/plugin-transform-destructuring --dev | |
yarn add @babel/plugin-transform-regenerator --dev | |
yarn add @babel/plugin-transform-runtime --dev | |
yarn add @babel/preset-env --dev | |
yarn add babel-plugin-macros --dev | |
yarn add eslint --dev | |
yarn add eslint-plugin-prettier --dev | |
yarn add eslint-plugin-react --dev | |
yarn add prettier --dev | |
yarn add jsonlint --dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" In ~/.vim/ftplugin/jsx.vim, or somewhere similar | |
let b:ale_linter_aliases = ['css', 'javascript'] | |
let b:ale_linters = ['stylelint', 'eslint', 'prettier'] | |
let b:ale_fixers = ['prettier', 'eslint'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment