module.exports = { parser: 'vue-eslint-parser', parserOptions: { parser: '@typescript-eslint/parser', ecmaVersion: 2020, sourceType: 'module', ecmaFeatures: { jsx: true } }, extends: [ 'plugin:vue/vue3-recommended', ], rules: { // VUE相关规则配置: https://eslint.vuejs.org/rules/ // 避免单行标签的换行 'vue/singleline-html-element-content-newline': 'off', // 允许 自定义组件的 驼峰属性和中划线连接属性 'vue/attribute-hyphenation': 0, 'vue/v-on-event-hyphenation': 0, // // 允许 子组件更改props参数值 // 'vue/no-mutating-props': 0, // https://eslint.vuejs.org/rules/max-attributes-per-line.html#vue-max-attributes-per-line 'vue/max-attributes-per-line': ['error', { 'singleline': { 'max': 5 // vue 属性单行最多5个元素 }, 'multiline': { 'max': 1 // 多行最多1个 } }], 'no-multiple-empty-lines': [2, { 'max': 2 }], //空行最多不能超过2行 'no-empty': 2, //块语句中的内容不能为空 'no-tabs': 2, /** * 分号配置项: * 第一个参数: ' off'或0 - 关闭规则 ' warn'或1 - 将该规则作为警告打开(不影响退出代码) ' error'或2 - 将规则作为错误打开(退出代码将为1) * *第二个参数 always(默认):在语句末尾需要分号 never:不允许加分号 * * 第三个参数: 'beforeStatementContinuationChars': 'any'(默认)如果下一行语句以 [,(,/,+,或 - 开头,忽略语句末尾的分号(或缺失分号), 'beforeStatementContinuationChars': 'always' 如果下一行语句以 [,(,/,+,或 - 开头,在语句末尾需要添加分号。 'beforeStatementContinuationChars': 'never' 如果该语句不会因为ASI而带来风险,那么即使它的下一行语句以 [,(,/,+,或 - 开头,也不允许在语句末尾添加分号。 * **/ 'semi': [ 2, 'never', { 'beforeStatementContinuationChars': 'never' } ], // 单引号 'quotes': [ 2, 'single', { 'avoidEscape': true, 'allowTemplateLiterals': true } ], }, }