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也无效,之后查看是不是设置有问题

{
    "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文件,好使了,但是切回这个项目又不好使了...

思路中断ing

错误

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

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

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

Code: -32603

附上.editorconfig文件

root = true

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

搜索之后 发现是stylus写错了 所以格式化失败

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

更改css之后

.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"  

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值