• 当前位置: 首 页 > 教育百科 > 其他 > 正文

    VScode代码格式自动修正,自动排版

    :2021年09月08日
    52learn

    下载插件ESLint文件->首选项->设置复制粘贴进去:{     // vscode默认启用了根据文件类型自动设置tabsize的选项     "editor.detectIndenta...

    下载插件ESLint

    03e1ec957fc40e192ba2d300076f0a5f.png

    文件->首选项->设置

    e50dea4b75a20ac159ab07326ac62e26.png

    复制粘贴进去:

    {
        // vscode默认启用了根据文件类型自动设置tabsize的选项
        "editor.detectIndentation": false,
        // 重新设定tabsize
        "editor.tabSize": 2,
        // #每次保存的时候自动格式化 
        "editor.formatOnSave": true,
        // #每次保存的时候将代码按eslint格式进行修复
        "eslint.autoFixOnSave": true,
        // 添加 vue 支持
        "eslint.validate": [
          "javascript",
          "javascriptreact",
          {
            "language": "vue",
            "autoFix": true
          }
        ],
        // #让prettier使用eslint的代码格式进行校验 
        "prettier.eslintIntegration": true,
        // #去掉代码结尾的分号 
        "prettier.semi": false,
        // #使用带引号替代双引号 
        "prettier.singleQuote": true,
        // #让函数(名)和后面的括号之间加个空格
        "javascript.format.insertSpaceBeforeFunctionParenthesis": true,
        // #这个按用户自身习惯选择 
        "vetur.format.defaultFormatter.html": "js-beautify-html",
        // #让vue中的js按编辑器自带的ts格式进行格式化 
        "vetur.format.defaultFormatter.js": "vscode-typescript",
        "vetur.format.defaultFormatterOptions": {
          "js-beautify-html": {
            "wrap_line_length": 120,
            "wrap_attributes": "auto"
            // #vue组件中html代码格式化样式
          }
        },
        // 格式化stylus, 需安装Manta's Stylus Supremacy插件
        "stylusSupremacy.insertColons": false, // 是否插入冒号
        "stylusSupremacy.insertSemicolons": false, // 是否插入分号
        "stylusSupremacy.insertBraces": false, // 是否插入大括号
        "stylusSupremacy.insertNewLineAroundImports": false, // import之后是否换行
        "stylusSupremacy.insertNewLineAroundBlocks": false,
        "explorer.confirmDelete": false // 两个选择器中是否换行
      }
    [编辑:宋聪乔 &发表于江苏]
    [我要纠错]

    来源:本文内容搜集或转自各大网络平台,并已注明来源、出处,如果转载侵犯您的版权或非授权发布,请联系小编,我们会及时审核处理。
    声明:江苏教育黄页对文中观点保持中立,对所包含内容的准确性、可靠性或者完整性不提供任何明示或暗示的保证,不对文章观点负责,仅作分享之用,文章版权及插图属于原作者。

    关键词: 下载 插件 ESLint 文件 首选项
    有价值
    0
    无价值
    1
    猜您喜欢
    最热文章

    暂不支持手机端,请登录电脑端访问

    正在加载验证码......

    请先完成验证