美文网首页
想要 .vue文件在vs code中根据eslint配置规则保存

想要 .vue文件在vs code中根据eslint配置规则保存

作者: 一半苍白 | 来源:发表于2017-11-02 17:58 被阅读0次

    此文假设相关环境已经搭好,仅用于解决题目中问题

    1.command+shift+X 或点击左侧相应按钮打开拓展,搜索ESlint并安装;

    2.  npm 安装 eslint,eslint-plugin-vue;

    3. .eslintrc | .eslintrc.js文件中配置"plugins": ["vue"];

    4.command+英文逗号,打开用户设置文件

    // 将设置放入此文件中以覆盖默认设置

    {

         "editor.tabSize":2,

        // Turns auto fix on save on or off.

        "eslint.autoFixOnSave":true,

        // 启用后,按 TAB 键时,将展开 Emmet 缩写。

        "emmet.triggerExpansionOnTab":true,

        // 启用使用默认不支持的语言的 Emmet 缩写。

        //在此添加该语言与支持 Emmet 的语言之间的映射。

        "emmet.includeLanguages": {

            "vue-html":"html",

            "vue":"html",

            "javascript":"javascriptreact"

        },

        "emmet.syntaxProfiles": {

            "javascript":"jsx",

            "vue":"html",

            "vue-html":"html"

        },

        "eslint.validate": [

            "javascript",{

                // 支持.vue文件保存时自动格式化

                "language":"vue",

                "autoFix":true

             },

            "javascriptreact",

            "vue",

            "vue-html"

        ]

    }


    闲言

    想要支持react吗?

    在第2步安装eslint-plugin-react,第3步中的配置改为'plugins':['react']

    相关文章

      网友评论

          本文标题:想要 .vue文件在vs code中根据eslint配置规则保存

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