eslint自定义
module.exports = {
root: true,
env: {
node: true
},
extends: [
'plugin:vue/essential',
'@vue/standard'
],
parserOptions: {
parser: 'babel-eslint'
},
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'semi': ["error", "always"],
"prefer-const": "off",
"no-multiple-empty-lines": "off",
"no-unused-vars": "off",
"prefer-promise-reject-errors": "off",
"dot-notation": "off",
"space-before-function-paren": "off",
"space-infix-ops": "off",
"quotes": "off",
"no-useless-escap": "off",
"no-useless-escape": "off",
"import/first": "off",
"no-prototype-builtins": "off",
"vue/no-unused-components": "off",
"eqeqeq": "off"
}
}
Vetur插件设置
{
// tab 大小为2个空格
"editor.tabSize": 2,
//禁止保存的时候格式化
"editor.formatOnSave": false,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
//函数名称前 加一个空格
"javascript.format.insertSpaceBeforeFunctionParenthesis": false,
//格式化插件配置,设置为vetur
"[vue]": {
"editor.defaultFormatter": "octref.vetur"
},
"vetur.format.defaultFormatterOptions": {
"js-beautify-html": {
// #vue组件中html代码格式化样式
"wrap_attributes": "force-aligned", //也可以设置为“auto”,效果会不一样
"wrap_line_length": 200,
"end_with_newline": false,
"semi": true,
"singleQuote": true
},
"prettier": {
//设置分号
"semi": true,
//双引号变成单引号
"singleQuote": true,
//禁止随时添加逗号,这个很重要。找了好久
"trailingComma": "none"
}
},
"[javascript]": {
"editor.defaultFormatter": "vscode.typescript-language-features"
}
}