目录下新建.eslintrc.js
module.exports = {
root: true,
env: {
node: true,
},
extends: [
"plugin:vue/vue3-essential",
"eslint:recommended",
"plugin:prettier/recommended",
],
parserOptions: {
parser: "@babel/eslint-parser",
},
rules: {
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
},
};
{
"eslint.enable": true,
"eslint.run": "onType",
"eslint.options": {
"extensions": [".js", ".vue", ".jsx", ".tsx"]
},
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
// 保存自动格式化代码
// "editor.formatOnSave": true,
// 粘贴自动格式化
"editor.formatOnPaste": true,
}
保存自动格式化 并 按照eslint的要求来。
保证保存的格式为eslint规范的。
关于.eslintrc.js的配置大全。
http://eslint.cn/docs/rules/
官网配置大全,比如想全体统一强制使用一致的反勾号、双引号或单引号
双引号比较规范。
rules: {
quotes: [1, "double"], //引号类型 `` "" ''
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
},