Vscode踩坑之(因为stylus)不能格式化.vue文件

                           Vscode踩坑之不能格式化.vue文件

 

前言

在码云clone一个公司的项目,可是在家里Alt shift F 不能格式化文件, 相关插件有 ESLint,language-stylus,Manya's Stylus,Vetur,vue,vue 2 Snippets,Vue VSCode Snippets,觉得是插件太多冲突了,禁用以后只留ES跟Vetur也无效,以后查看是否是设置有问题javascript

{
    "workbench.colorTheme": "Visual Studio Dark",
    "git.ignoreMissingGitWarning": true,
    "window.zoomLevel": 1,
    "files.autoSave": "onFocusChange", // 自动保存
    "workbench.iconTheme": "vscode-icons",
    "editor.quickSuggestions": {
        "other": true,
        "comments": true,
        "strings": true,
    },
    "editor.detectIndentation": false,
    "less.compile": {
        "compress": true,
        "sourceMap": true,
        "out": "${workspaceRoot}/css/",
    },
    // 强制单引号
    "prettier.singleQuote": true,
    // 开启 eslint 支持
    "prettier.eslintIntegration": true,
    // 保存时自动fix
    "eslint.autoFixOnSave": true,
    // 添加 vue 支持
    "eslint.validate": [
        "javascript",
        "javascriptreact",
        {
            "language": "vue",
            "autoFix": true
        }
    ],
    // 使用插件格式化 html
    "vetur.format.defaultFormatter.html": "js-beautify-html",
    // 格式化插件的配置
    "vetur.format.defaultFormatterOptions": {
        "js-beautify-html": {
            // 属性强制折行对齐
            "wrap_attributes": "force-aligned",
        }
    },
    // 如下为stylus配置
    "stylusSupremacy.insertColons": true, // 是否插入冒号
    "stylusSupremacy.insertSemicolons": false, // 是否插入分好
    "stylusSupremacy.insertBraces": false, // 是否插入大括号
    "stylusSupremacy.insertNewLineAroundImports": false, // import以后是否换行
    "stylusSupremacy.insertNewLineAroundBlocks": false // 两个选择器中是否换行
}

应该也没什么问题, 后来从新打开一个新的项目新建了一个vue文件,好使了,可是切回这个项目又很差使了...css

思路中断inghtml

错误

vscode在个别项目中没法格式化vue文件  项目出现,其余(无问题)项目并未出现vue

[Error - 6:23:27 PM] Request textDocument/formatting failed.java

Message: Request textDocument/formatting failed with message: expected "indent", got ";"react

Code: -32603git

附上.editorconfig文件less

root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

搜索以后 发现是stylus写错了 因此格式化失败ui

.aa
    .list
    width: 100%
    height: 200px
    .ppp
    width: 100%
    width: 100px
    height: 200px

更改css以后spa

.aa
    .list
        width: 100%
        height: 200px
    .ppp
        width: 100%
    width: 100px
    height: 200px

解决

stylus写错了 因此格式化 失败 检查下css就行了

vscode报错并未有提示 stylus 字样 Message: Request textDocument/formatting failed with message: expected "indent", got ";"

          浪费了好多时间 Stylus ParseError: expected "indent", got "outdent"