一. 跨编辑器格式化文件
- 给项目添加
.editorconfig配置文件 
# https://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
insert_final_newline = false
trim_trailing_whitespace = false
[*.xlsx]
insert_final_newline = false
trim_trailing_whitespace = false
- 看项目中
package.json文件中是否安装过包eslint,babel-eslint,没有就运行一下npm install --save-dev eslint babel-eslint。 
二. 使用插件
- VSCode 下安装
ESLint插件,后重启
微信截图_20210701164302.png
setting.json配置文件中的设置 
{
    "eslint.validate": [
        "javascript",
        "javascriptreact",
        "html",
        "vue"
    ],
    "editor.codeActionsOnSave": {
        "source.fixAll.eslint": true
    }
}
- WebStorm 安装插件
Save Actions并重启,idea 安装插件Save Actions、vue.js并重启
webstrom插件
 
idea插件
- 
配置设置file=>setting中
微信截图_20210702092100.png
微信截图_20210702092323.png
 













网友评论