美文网首页
VSCode、idea、WebStorm 保存自动按照eslin

VSCode、idea、WebStorm 保存自动按照eslin

作者: 前端小飞象 | 来源:发表于2021-07-01 16:59 被阅读0次

一. 跨编辑器格式化文件

  1. 给项目添加.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
  1. 看项目中package.json文件中是否安装过包eslint,babel-eslint,没有就运行一下npm install --save-dev eslint babel-eslint

二. 使用插件

  1. VSCode 下安装ESLint插件,后重启
    微信截图_20210701164302.png
    setting.json配置文件中的设置
{
    "eslint.validate": [
        "javascript",
        "javascriptreact",
        "html",
        "vue"
    ],
    "editor.codeActionsOnSave": {
        "source.fixAll.eslint": true
    }
}
  • WebStorm 安装插件Save Actions并重启,idea 安装插件Save Actionsvue.js并重启
    webstrom插件
idea插件
  • 配置设置file=>setting中


    微信截图_20210702092100.png
    微信截图_20210702092323.png

相关文章

网友评论

      本文标题:VSCode、idea、WebStorm 保存自动按照eslin

      本文链接:https://www.haomeiwen.com/subject/wiojultx.html