安装
1 | npm install eslint |
之后根据提示操作,如使用 commjs、Airbnb等
其他语言插件
摘自某项目
1 | "eslint-config-airbnb-base": "^14.2.1", |
配置.eslintrc.js
或者直接在 package.json
文件里的 eslintConfig
字段指定配置
1 | module.exports = { |
保存时自动lint
VS Code
- File -> Prefrences -> Settings
- Search ESLint
- ESLint Code Action -> ‘Edit in settings.json’
1 | "eslint.validate": ["javascript", "vue", "html"], |
WebStorm
- File -> Settings
- Language & Frameworks -> JavaScript -> Code Quailty Tools -> ESLint
- OR search ‘ESLint’
Choose:
- Automatic ESLint configuration (You can manully do the settings if you want)
- Run eslint –fix on save