vscode eslint 自動保存


vscode安裝插件Prettier - JavaScript formatter和vetur

File -> Preference -> Settings(如果裝了中文插件包應該是 文件 -> 選項 -> 用戶),搜索 eslint,點擊 Edit in setting.json

最新版本只需添加

{
"editor.codeActionsOnSave": {
        "source.fixAll.eslint": true,
    },

}

 

添加后 ,Ctrl+s保存會自動按照你的項目建的eslintrc.js文件的規則修復

我的eslintrc.js內容:

module.exports = {
    settings: {
        "import/resolver": {
            webpack: {
                config: './build/webpack.base.conf.js'
            }
        }
    },
    "env": {
        "browser": true,
        "es6": true
    },
    "extends": [
        "plugin:vue/base",
        "airbnb-base",
    ],
    "globals": {
    },
    "parserOptions": {
        "parser": "babel-eslint",
        // "ecmaVersion": 2018,
        // "sourceType": "module",
    },
    plugins: [
        "vue",
    ],
    "rules": {
        "no-unused-vars": "warn",
        "import/extensions": "warn",
        "import/no-extraneous-dependencies": [2, { "devDependencies": true }],
        "import/no-unresolved": [2, { "ignore": ["antd-mobile"] }],
        "no-param-reassign": "warn",
        "max-len": ["error", { "code": 120 }],
        "vue/no-parsing-error": "warn",
        "arrow-parens": "off",
        "consistent-return": "off",
        "no-else-return": "off",
        "prefer-destructuring": "off",
        "strict": "off",
        "linebreak-style": "off",
        "prefer-template": "off",
        "no-unreachable": "off",
    }
};

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM