【HAVENT原創】VSCode 配置 eslint+standard+prettier

在 VSCode 中希望項目在保存的時候自動格式化,並使用 standard 的規範標準進行 eslint 驗證。

安裝插件:

  • ESLint
  • Vetur
  • Prettier-Standard - JavaScript formatter
     

 

Setting.json 全局配置:

{
    "terminal.integrated.shell.osx": "/bin/sh",
    "workbench.colorTheme": "WarmNeon",
    "eslint.alwaysShowStatus": true,
    "[html]": {
        "editor.defaultFormatter": "vscode.html-language-features"
    },
    "terminal.integrated.fontSize": 12,
    "github.copilot.autocomplete.enable": true,
    "terminal.integrated.defaultProfile.windows": "Git Bash",
    "javascript.validate.enable": false,
    // "editor.codeActionsOnSave": {
    //     // "source.fixAll.eslint": true
    // },
    "[javascript]": {
        "editor.defaultFormatter": "numso.prettier-standard-vscode"
    },
    "[vue]": {
        // "editor.defaultFormatter": "numso.prettier-standard-vscode" // 效果不行
        "editor.defaultFormatter": "octref.vetur"
    },
    "editor.fontSize": 14,
    "workbench.startupEditor": "none",
    "window.zoomLevel": 1,
    "editor.formatOnSave": true,
    // "prettier.printWidth": 180,
    // "prettier.semi": false,
    // "prettier.singleQuote": true,
    // "prettier.proseWrap":"never",
    "html.format.wrapLineLength": 220,
    "html.format.wrapAttributes": "auto",
    "vetur.format.defaultFormatter.html": "js-beautify-html",
    "vetur.format.defaultFormatterOptions": {
        "js-beautify-html": {
            "wrap_line_length": 180,
            "wrap_attributes": "auto",
            // "end_with_newline": false
        },
        "prettier": {
            // Prettier option here
            // "trailingComma": "es5", // 多行時,儘可能打印尾隨的逗號
            "trailingComma": "none",
            // "tabWidth": 4, // 會忽略vetur的tabSize配置
            // "useTabs": false, // 是否利用tab替代空格
            "semi": false, // 句尾是否加;
            "singleQuote": true, // 使用單引號而不是雙引號
            // "arrowParens": "avoid", // allow paren-less arrow functions 箭頭函數的參數使用圓括號
        }
    },
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章