//vue eslint url https://eslint.vuejs.org/rules module.exports = { root: true, env: { node: true, 'vue/setup-compiler-macros': true }, globals: { defineProps: 'readonly', defineEmits: 'readonly' }, 'extends': [ 'plugin:vue/vue3-essential', 'eslint:recommended', '@vue/typescript/recommended' ], parserOptions: { ecmaVersion: 2020 }, rules: { '@typescript-eslint/no-explicit-any': ['off'], 'vue/comment-directive': 'off', 'no-console': 'off', 'generator-star-spacing': 'off', 'no-mixed-operators': 0, // 'reportUnusedDisableDirectives':true, 'arrow-spacing': [2, { 'before': true, 'after': true }], // 要求箭头函数的箭头之前或之后有空格 'block-spacing': [2, 'always'], // 禁止或强制在代码块中开括号前和闭括号后有空格 'brace-style': [2, '1tbs', { 'allowSingleLine': true // 允许块的开括号和闭括号在 同一行 }], // 大括号的风格统一使用one true brace style 'vue/max-attributes-per-line': [ 2, { singleline: 5, // 配置单行能够防止的属性个数, 和多行的配置是二选一的 multiline:2 // 配置单行能够防止的属性个数,和单行的配置是二选一的 } ], quotes: [2, 'single', { // js代码中,必须使用单引号 'avoidEscape': true, // 允许字符串使用单引号或双引号,只要字符串中包含了一个其它引号,否则需要转义 'allowTemplateLiterals': true // 允许字符串使用反勾号 }], // 强制使用一致的反勾号、双引号或单引号 'semi': [ // 末尾不用出现分号 2, 'never', { beforeStatementContinuationChars: 'never' //"never" 如果该语句不会因为ASI而带来风险,那么即使它的下一行语句以 [,(,/,+,或 - 开头,也不允许在语句末尾添加分号。 } ], 'no-delete-var': 2, // 禁止对变量使用 delete 操作符。 'vue/v-on-event-hyphenation': ['error', 'always', { //组件参数规范,always使用-分隔,never使用驼峰分隔 'autofix': false, //自动修复,Vue2不建议使用,可能会有问题 'ignore': [] //忽略的名称数组 }], 'vue/no-multi-spaces': 2, //不允许多个空格 'vue/no-spaces-around-equal-signs-in-attribute':2, //属性中的等号周围不允许有空格 'vue/require-explicit-emits': ['error', { //要求emits必须命名 'allowProps': false }], 'vue/attributes-order': ['error', { // 属性顺序强制执行属性顺序 'order': [ 'DEFINITION', 'LIST_RENDERING', 'CONDITIONALS', 'RENDER_MODIFIERS', 'GLOBAL', ['UNIQUE', 'SLOT'], 'TWO_WAY_BINDING', 'OTHER_DIRECTIVES', 'OTHER_ATTR', 'EVENTS', 'CONTENT' ], 'alphabetical': false }], 'vue/html-closing-bracket-spacing': ['error', { //vue标签闭合间距 'startTag': 'never', 'endTag': 'never', 'selfClosingTag': 'always' //单标签需要空格 }], 'prefer-const': [ // 要求使用 const 声明那些声明后不再被修改的变量 2, { ignoreReadBeforeAssign: false //忽略声明和第一次赋值之间的变量 } ], 'vue/script-indent': [ //vue script缩进 'error', 2, //缩进的类型。默认为2。如果这是一个数字,它是一个缩进的空格数。如果是"tab",它使用一个制表符进行一个缩进。 { 'baseIndent': 1 //基础缩进 } ], 'vue/html-quotes': 2, //html属性引号,默认双引号 'vue/html-indent': [ //vue template缩进 'error', 2, { 'baseIndent': 1 } ], 'operator-linebreak': [2, 'after', { // 要求把换行符放在操作符后面 'overrides': { '?': 'before', // 问号置于操作数之前 ':': 'before' // 冒号置于操作数之前 } }], 'space-before-blocks': [2, 'always'], // 强制代码块之前出现空格 'template-curly-spacing': 'off', // 'space-before-function-paren': [2, 'never'], //关闭函数圆括号之前有一个空格,这个会和prettier冲突,暂未找到解决方法 'require-await': 'off', '@typescript-eslint/ban-ts-ignore': 'off', '@typescript-eslint/explicit-function-return-type': 'off', '@typescript-eslint/no-var-requires': 'off', '@typescript-eslint/no-empty-function': 'off', 'vue/custom-event-name-casing': 'off', 'no-use-before-define': 'off', '@typescript-eslint/no-use-before-define': 'off', '@typescript-eslint/ban-ts-comment': 'off', '@typescript-eslint/ban-types': 'off', '@typescript-eslint/no-non-null-assertion': 'off', '@typescript-eslint/explicit-module-boundary-types': 'off', '@typescript-eslint/no-unused-vars': [ 'error', { argsIgnorePattern: '^h$', varsIgnorePattern: '^h$' } ], 'no-unused-vars': [ 'error', { argsIgnorePattern: '^h$', varsIgnorePattern: '^h$' } ], 'comma-dangle': ['error', 'never'], // 对象字面量项尾不能有逗号 'no-proto': 2,//禁止使用__proto__属性 'no-redeclare': 2,//禁止重复声明变量 'no-trailing-spaces': 2, // 禁止使用行尾空白(空格、tab 和其它 Unicode 空白字符)。 'no-undef': 2,//不能有未定义的变量 'eol-last': 2 // 文件末尾需存在至少一行空行 } }