代码拉取完成,页面将自动刷新
module.exports = {
env: {
node: true,
browser: true,
es2021: true
},
extends: [
'plugin:vue/essential',
'eslint:recommended',
'./.eslintrc-auto-import.json'
],
parserOptions: {
sourceType: 'module',
ecmaVersion: 12,
parser: '@typescript-eslint/parser',
ecmaFeatures: {
// eslint 支持jsx语法
jsx: true
}
},
plugins: ['vue', '@typescript-eslint'],
rules: {
'vue/multi-word-component-names': 'off',
'spaced-comment': 'error', // 注释风格需要空格
'space-in-parens': ['error', 'never'], // 小括号里不要有空格
'space-before-function-paren': ['error', 'always'], // 函数定义时括号前面要不要有空格
'space-before-blocks': ['error', 'always'], // 不以新行开始的块{前面要不要有空格
'keyword-spacing': ['error', { before: true }], // 关键字后面是否要空一格
'quote-props': ['error', 'as-needed'], // 对象字面量中的属性名是否强制双引号
'prefer-const': 'error', // 首选const
'padded-blocks': ['error', 'never'], // 块语句内行首行尾不空行
'operator-linebreak': ['error', 'after'], // 换行时运算符在行尾
'operator-assignment': ['error', 'always'], // 赋值运算符设置成 += -=
'object-curly-spacing': ['error', 'always', { objectsInObjects: false }], // 大括号允许前后空格
'newline-after-var': ['error', 'never'], // 变量声明后不允许空行
'new-parens': ['error', 'never'], // new时必须加小括号
'max-nested-callbacks': ['error', 3], // 回调嵌套深度
'init-declarations': ['error', 'always'], // 声明时必须赋初值
'default-case': 'error', // switch语句最后必须有default
'eol-last': ['error', 'always'], // 文件以单一的换行符结束
'comma-style': ['error', 'last'], // 逗号风格,换行时在行尾
'comma-spacing': ['error', { before: false, after: true }], // 逗号后空格
'comma-dangle': ['error', 'never'], // 对象字面量项尾不能有逗号
'brace-style': ['error', '1tbs', { allowSingleLine: true }], // 大括号风格
'arrow-spacing': 'error', // =>的前/后空格
'arrow-parens': ['error', 'as-needed'], // /箭头函数不用小括号
'array-bracket-spacing': ['error', 'never'], // 数组前后不允许有空格
'no-var': 'error', // 禁用var,用let和const代替
'no-use-before-define': 'error', // 未定义前不能使用
'no-unused-expressions': 'error', // 禁止无用的表达式
'no-unreachable': 'error', // 不能有无法执行的代码
'no-unneeded-ternary': 'error', // 禁止不必要的嵌套 var isYes = answer === 1 ? true : false
'no-trailing-spaces': 'error', // 一行结束后面不要有空格
'no-shadow': 'error', // 外部作用域中的变量不能与它所包含的作用域中的变量或参数同名
'no-self-compare': 'error', // 不能比较自身
'no-regex-spaces': 'error', // 禁止在正则表达式字面量中使用多个空格 /foo bar/
'no-redeclare': 'error', // 禁止重复声明变量
'no-param-reassign': 'error', // 禁止给参数重新赋值
'no-obj-calls': 'error', // 不能调用内置的全局对象,比如Math() JSON()
'no-new-object': 'error', // 禁止使用new Object()
'no-new-require': 'error', // 禁止使用new require
'no-new-wrappers': 'error', // 禁止使用new创建包装实例,new String new Boolean new Number
'no-multiple-empty-lines': ['error', { max: 0 }], // 不允许有空行
'no-multi-str': 'error', // 字符串不能用\换行
'no-lone-blocks': 'error', // 禁止不必要的嵌套块
'no-invalid-regexp': 'error', // 禁止无效的正则表达式
'no-invalid-this': 'error', // 禁止无效的this,只能用在构造器,类,对象字面量
'no-func-assign': 'error', // 禁止重复的函数声明
'no-extra-parens': 'error', // 禁止非必要的括号
'no-ex-assign': 'error', // 禁止给catch语句中的异常参数赋值
'no-eq-null': 'error', // 禁止对null使用==或!=运算符
'no-empty-character-class': 'error', // 正则表达式中的[]内容不能为空
'no-empty': 'error', // 块语句中的内容不能为空
'no-else-return': 'error', // 如果if语句里面有return,后面不能跟else语句
'no-duplicate-case': 'error', // switch中的case标签不能重复
'no-dupe-keys': 'error', // 在创建对象字面量时不允许键重复 {a:1,a:1}
'no-dupe-args': 'error', // 函数参数不能重复
'no-constant-condition': 'error', // 禁止在条件中使用常量表达式 if(true) if(1)
'no-catch-shadow': 'error', // 禁止catch子句参数与外部作用域变量同名
'no-class-assign': 'error', // 禁止给类赋值
'space-infix-ops': 'error', // 运算符前后空格
camelcase: 'error', // 强制驼峰法命名
quotes: ['error', 'single'], // 引号类型 使用单引号
indent: ['error', 2], // 缩进风格
semi: ['error', 'never'], // 语句强制分号不结尾
'@typescript-eslint/no-unused-vars': 'error' // 关闭ts枚举enum报错
},
// eslint不能对html文件生效
overrides: [
{
files: ['*.html'],
processor: 'vue/.vue'
}
]
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。