VscodeフォーマットESlint-メソッド

1810 ワード

ESlint-はJavaScriptコードスタイルを統一するためのツールで、css、htmlなどは含まれていません.
vscodeのファイル-プリファレンス-設定で、右側の構成に次のコードを追加すればいいです(コードにコメントがあります!)、これから直接Ctrl+Sでワンタッチフォーマットできます
{
     // 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_attributes": "force-aligned"
            // #vue   html       
        }
    },
    //    stylus,    Manta's Stylus Supremacy  
    "stylusSupremacy.insertColons": false, //       
    "stylusSupremacy.insertSemicolons": false, //       
    "stylusSupremacy.insertBraces": false, //        
    "stylusSupremacy.insertNewLineAroundImports": false, // import      
    "stylusSupremacy.insertNewLineAroundBlocks": false //           
}