diff --git a/lib/client/src/components/methods/forms/form-items/monaco.vue b/lib/client/src/components/methods/forms/form-items/monaco.vue index 154de584b..243e94c43 100644 --- a/lib/client/src/components/methods/forms/form-items/monaco.vue +++ b/lib/client/src/components/methods/forms/form-items/monaco.vue @@ -223,6 +223,7 @@ 'form.id' () { this.outputs = [] this.params = this.form.funcParams.map((key) => ({ key, value: '', format: 'value' })) + this.fixMethod() } }, diff --git a/lib/client/src/element-materials/materials/vue2/bk/pagination/index.js b/lib/client/src/element-materials/materials/vue2/bk/pagination/index.js index fecbb1aa3..1cbeee9ea 100644 --- a/lib/client/src/element-materials/materials/vue2/bk/pagination/index.js +++ b/lib/client/src/element-materials/materials/vue2/bk/pagination/index.js @@ -26,13 +26,13 @@ export default { funcName: 'handlePageChange', funcParams: ['current'], funcBody: '// 先记录当前页码。下面的 lesscode[\'${prop:current}\'] 可以替换为绑定在分页组件 current 属性上的变量\n' - + 'lesscode[\'${prop:current}\'] = current\n' + + 'lesscode[\'${prop:current}\'] = current;\n' + '// 请求接口获取最新的分页数据。下面的 url 替换为接口地址,参数根据接口进行修改\n' + 'this.$http.get(\'url\', { params: { page: lesscode[\'${prop:current}\'], pageSize: lesscode[\'${prop:limit}\'] } }).then((data) => {\n' - + ' // 将接口返回的数据,赋值给绑定在 table 组件 data 属性的变量,table 就会自动展示新一页的数据。lesscode[\'${prop:tableData}\'] 为绑定在 data 属性上的变量\n' - + ' lesscode[\'${prop:tableData}\'] = data.list\n' - + ' // 记录总数,分页组件内部计算页码和总页数使用。lesscode[\'${prop:count}\'] 为绑定在 count 属性上的变量\n' - + ' lesscode[\'${prop:count}\'] = data.count\n' + + ' // 将接口返回的数据,赋值给绑定在 table 组件 data 属性的变量,table 就会自动展示新一页的数据。lesscode[\'${prop:tableData}\'] 为绑定在 data 属性上的变量\n' + + ' lesscode[\'${prop:tableData}\'] = data.list;\n' + + ' // 记录总数,分页组件内部计算页码和总页数使用。lesscode[\'${prop:count}\'] 为绑定在 count 属性上的变量\n' + + ' lesscode[\'${prop:count}\'] = data.count;\n' + '})\n' } ] @@ -45,13 +45,13 @@ export default { funcName: 'handleLimitChange', funcParams: ['limit'], funcBody: '// 先记录当前页码。下面的 lesscode[\'${prop:limit}\'] 可以替换为绑定在分页组件 limit 属性上的变量\n' - + 'lesscode[\'${prop:limit}\'] = limit\n' + + 'lesscode[\'${prop:limit}\'] = limit;\n' + '// 请求接口获取最新的分页数据。下面的 url 替换为接口地址,参数根据接口进行修改\n' + 'this.$http.get(\'url\', { params: { page: lesscode[\'${prop:current}\'], pageSize: lesscode[\'${prop:limit}\'] } }).then((data) => {\n' - + ' // 将接口返回的数据,赋值给绑定在 table 组件 data 属性的变量,table 就会自动展示新一页的数据。lesscode[\'${prop:tableData}\'] 为绑定在 data 属性上的变量\n' - + ' lesscode[\'${prop:tableData}\'] = data.list\n' - + ' // 记录总数,分页组件内部计算页码和总页数使用。lesscode[\'${prop:count}\'] 为绑定在 count 属性上的变量\n' - + ' lesscode[\'${prop:count}\'] = data.count\n' + + ' // 将接口返回的数据,赋值给绑定在 table 组件 data 属性的变量,table 就会自动展示新一页的数据。lesscode[\'${prop:tableData}\'] 为绑定在 data 属性上的变量\n' + + ' lesscode[\'${prop:tableData}\'] = data.list;\n' + + ' // 记录总数,分页组件内部计算页码和总页数使用。lesscode[\'${prop:count}\'] 为绑定在 count 属性上的变量\n' + + ' lesscode[\'${prop:count}\'] = data.count;\n' + '})\n' } ] diff --git a/lib/client/src/element-materials/materials/vue2/bk/tab-old/index.js b/lib/client/src/element-materials/materials/vue2/bk/tab-old/index.js index 4de76660d..29755701d 100644 --- a/lib/client/src/element-materials/materials/vue2/bk/tab-old/index.js +++ b/lib/client/src/element-materials/materials/vue2/bk/tab-old/index.js @@ -24,7 +24,7 @@ export default { functionTemplates: [{ funcName: 'handleTabChange', funcParams: ['tabName'], - funcBody: '// 将选中 tab 的 name,赋值给 tab 组件的 active 属性的变量来记录当前选中的tab。lesscode[\'${prop:activeTab}\'] 可以替换成实际绑定的变量\nlesscode[\'${prop:activeTab}\'] = tabName\n' + funcBody: '// 将选中 tab 的 name,赋值给 tab 组件的 active 属性的变量来记录当前选中的tab。lesscode[\'${prop:activeTab}\'] 可以替换成实际绑定的变量\nlesscode[\'${prop:activeTab}\'] = tabName;\n' }] }, { diff --git a/lib/client/src/element-materials/materials/vue2/bk/table/index.js b/lib/client/src/element-materials/materials/vue2/bk/table/index.js index 3a4759258..1706acca8 100644 --- a/lib/client/src/element-materials/materials/vue2/bk/table/index.js +++ b/lib/client/src/element-materials/materials/vue2/bk/table/index.js @@ -25,7 +25,7 @@ export default { { funcName: 'handleSelect', funcParams: ['selection', 'row'], - funcBody: '// 可以使用 selection 和 row 进行业务操作\nconsole.log(selection, row)\n' + funcBody: '// 可以使用 selection 和 row 进行业务操作\nconsole.log(selection, row);\n' } ] }, @@ -109,13 +109,13 @@ export default { funcName: 'handlePageChange', funcParams: ['newPage'], funcBody: '// 先记录当前页码。下面的 lesscode[\'${prop:tablePagination}\'] 可以替换为绑定在分页属性上的变量\n' - + 'lesscode[\'${prop:tablePagination}\'].current = newPage\n' + + 'lesscode[\'${prop:tablePagination}\'].current = newPage;\n' + '// 请求接口获取最新的分页数据。下面的 url 替换为接口地址,参数根据接口进行修改\n' + 'this.$http.get(\'url\', { params: { page: lesscode[\'${prop:tablePagination}\'].current, pageSize: lesscode[\'${prop:tablePagination}\'].limit } }).then((data) => {\n' - + ' // 将接口返回的数据,赋值给绑定在 table 组件 data 属性的变量上,table 就会自动展示新一页的数据\n' - + ' lesscode[\'${prop:tableData}\'] = data.list\n' - + ' // 记录总数,分页组件内部计算页码和总页数使用\n' - + ' lesscode[\'${prop:tablePagination}\'].count = data.count\n' + + ' // 将接口返回的数据,赋值给绑定在 table 组件 data 属性的变量上,table 就会自动展示新一页的数据\n' + + ' lesscode[\'${prop:tableData}\'] = data.list;\n' + + ' // 记录总数,分页组件内部计算页码和总页数使用\n' + + ' lesscode[\'${prop:tablePagination}\'].count = data.count;\n' + '})\n' } ] @@ -128,13 +128,13 @@ export default { funcName: 'handlePageLimitChange', funcParams: ['limit'], funcBody: '// 先记录当前展示的数量。下面的 lesscode[\'${prop:tablePagination}\'] 可以替换为绑定在分页属性上的变量\n' - + 'lesscode[\'${prop:tablePagination}\'].limit = limit\n' + + 'lesscode[\'${prop:tablePagination}\'].limit = limit;\n' + '// 请求接口获取最新的分页数据。下面的 url 替换为接口地址,参数根据接口进行修改\n' + 'this.$http.get(\'url\', { params: { page: lesscode[\'${prop:tablePagination}\'].current, pageSize: lesscode[\'${prop:tablePagination}\'].limit } }).then((data) => {\n' - + ' // 将接口返回的数据,赋值给绑定在 table 组件 data 属性的变量上,table 就会自动展示新一页的数据\n' - + ' lesscode[\'${prop:tableData}\'] = data\n' - + ' // 记录总数,分页组件内部计算页码和总页数使用\n' - + ' lesscode[\'${prop:tablePagination}\'].count = data.count\n' + + ' // 将接口返回的数据,赋值给绑定在 table 组件 data 属性的变量上,table 就会自动展示新一页的数据\n' + + ' lesscode[\'${prop:tableData}\'] = data;\n' + + ' // 记录总数,分页组件内部计算页码和总页数使用\n' + + ' lesscode[\'${prop:tablePagination}\'].count = data.count;\n' + '})\n' } ] diff --git a/lib/client/src/element-materials/materials/vue3/bk/pagination/index.js b/lib/client/src/element-materials/materials/vue3/bk/pagination/index.js index b59579e55..43d11e363 100644 --- a/lib/client/src/element-materials/materials/vue3/bk/pagination/index.js +++ b/lib/client/src/element-materials/materials/vue3/bk/pagination/index.js @@ -26,13 +26,13 @@ export default { funcName: 'handlePageChange', funcParams: ['current'], funcBody: '// 先记录当前页码。下面的 lesscode[\'${prop:current}\'] 可以替换为绑定在分页组件 current 属性上的变量\n' - + 'lesscode[\'${prop:current}\'] = current\n' + + 'lesscode[\'${prop:current}\'] = current;\n' + '// 请求接口获取最新的分页数据。下面的 url 替换为接口地址,参数根据接口进行修改\n' + 'this.$http.get(\'url\', { params: { page: lesscode[\'${prop:current}\'], pageSize: lesscode[\'${prop:limit}\'] } }).then((data) => {\n' - + ' // 将接口返回的数据,赋值给绑定在 table 组件 data 属性的变量,table 就会自动展示新一页的数据。lesscode[\'${prop:tableData}\'] 为绑定在 data 属性上的变量\n' - + ' lesscode[\'${prop:tableData}\'] = data.list\n' - + ' // 记录总数,分页组件内部计算页码和总页数使用。lesscode[\'${prop:count}\'] 为绑定在 count 属性上的变量\n' - + ' lesscode[\'${prop:count}\'] = data.count\n' + + ' // 将接口返回的数据,赋值给绑定在 table 组件 data 属性的变量,table 就会自动展示新一页的数据。lesscode[\'${prop:tableData}\'] 为绑定在 data 属性上的变量\n' + + ' lesscode[\'${prop:tableData}\'] = data.list;\n' + + ' // 记录总数,分页组件内部计算页码和总页数使用。lesscode[\'${prop:count}\'] 为绑定在 count 属性上的变量\n' + + ' lesscode[\'${prop:count}\'] = data.count;\n' + '})\n' } ] @@ -45,13 +45,13 @@ export default { funcName: 'handleLimitChange', funcParams: ['limit'], funcBody: '// 先记录当前页码。下面的 lesscode[\'${prop:limit}\'] 可以替换为绑定在分页组件 limit 属性上的变量\n' - + 'lesscode[\'${prop:limit}\'] = limit\n' + + 'lesscode[\'${prop:limit}\'] = limit;\n' + '// 请求接口获取最新的分页数据。下面的 url 替换为接口地址,参数根据接口进行修改\n' + 'this.$http.get(\'url\', { params: { page: lesscode[\'${prop:current}\'], pageSize: lesscode[\'${prop:limit}\'] } }).then((data) => {\n' - + ' // 将接口返回的数据,赋值给绑定在 table 组件 data 属性的变量,table 就会自动展示新一页的数据。lesscode[\'${prop:tableData}\'] 为绑定在 data 属性上的变量\n' - + ' lesscode[\'${prop:tableData}\'] = data.list\n' - + ' // 记录总数,分页组件内部计算页码和总页数使用。lesscode[\'${prop:count}\'] 为绑定在 count 属性上的变量\n' - + ' lesscode[\'${prop:count}\'] = data.count\n' + + ' // 将接口返回的数据,赋值给绑定在 table 组件 data 属性的变量,table 就会自动展示新一页的数据。lesscode[\'${prop:tableData}\'] 为绑定在 data 属性上的变量\n' + + ' lesscode[\'${prop:tableData}\'] = data.list;\n' + + ' // 记录总数,分页组件内部计算页码和总页数使用。lesscode[\'${prop:count}\'] 为绑定在 count 属性上的变量\n' + + ' lesscode[\'${prop:count}\'] = data.count;\n' + '})\n' } ] diff --git a/lib/client/src/element-materials/materials/vue3/bk/table/index.js b/lib/client/src/element-materials/materials/vue3/bk/table/index.js index b43ca7cd2..381174e28 100644 --- a/lib/client/src/element-materials/materials/vue3/bk/table/index.js +++ b/lib/client/src/element-materials/materials/vue3/bk/table/index.js @@ -25,7 +25,7 @@ export default { { funcName: 'handleSelect', funcParams: ['selection', 'row'], - funcBody: '// 可以使用 selection 和 row 进行业务操作\nconsole.log(selection, row)\n' + funcBody: '// 可以使用 selection 和 row 进行业务操作\nconsole.log(selection, row);\n' } ] }, diff --git a/lib/client/src/views/help/docs/method.md b/lib/client/src/views/help/docs/method.md index cb967b0d9..e3599e6ed 100644 --- a/lib/client/src/views/help/docs/method.md +++ b/lib/client/src/views/help/docs/method.md @@ -39,10 +39,10 @@ * 函数用于组件属性时,函数体代码示例如下: ```bash return Promise.all([ - this.$http.get('接口地址'), - this.$http.post('接口地址', { value: 2 }) + this.$http.get('接口地址'), + this.$http.post('接口地址', { value: 2 }) ]).then(([getDataRes, postDataRes]) => { - return [...getDataRes.data, ...postDataRes.data] + return [...getDataRes.data, ...postDataRes.data]; }) ``` diff --git a/lib/server/model/vue-code.js b/lib/server/model/vue-code.js index d8b8b6a6c..b6a946176 100644 --- a/lib/server/model/vue-code.js +++ b/lib/server/model/vue-code.js @@ -19,6 +19,7 @@ const eslintConfig = require('../system-conf/eslint-config') const cli = new CLIEngine({ fix: true, useEslintrc: true, + configFile: path.resolve(__dirname, '../system-conf/eslint-config.js'), allowInlineConfig: false, reportUnusedDisableDirectives: true, cwd: path.join(__dirname) @@ -68,9 +69,9 @@ module.exports = { try { let formatCode = prettier.format(code, { vueIndentScriptAndStyle: true, - semi: false, + semi: true, parser: 'vue', - tabWidth: 4, + tabWidth: 2, singleQuote: true, printWidth: 120, endOfLine: 'crlf' @@ -100,9 +101,9 @@ module.exports = { try { let formatCode = prettier.format(code, { vueIndentScriptAndStyle: true, - semi: false, + semi: true, parser: 'vue', - tabWidth: 4, + tabWidth: 2, singleQuote: true, printWidth: 120, endOfLine: 'crlf' @@ -132,9 +133,9 @@ module.exports = { try { const formatCode = prettier.format(code, { vueIndentScriptAndStyle: true, - semi: false, + semi: true, parser: 'babel', - tabWidth: 4, + tabWidth: 2, singleQuote: true, printWidth: 120, endOfLine: 'crlf' diff --git a/lib/server/project-template/vue2/project-init-code/.eslintrc.js b/lib/server/project-template/vue2/project-init-code/.eslintrc.js index 608c675b7..6ee8d25b5 100644 --- a/lib/server/project-template/vue2/project-init-code/.eslintrc.js +++ b/lib/server/project-template/vue2/project-init-code/.eslintrc.js @@ -1,683 +1,24 @@ module.exports = { - root: true, - parserOptions: { - parser: '@typescript-eslint/parser', - sourceType: 'module', - ecmaFeatures: { - legacyDecorators: true - } + root: true, + parser: 'vue-eslint-parser', + parserOptions: { + parser: '@typescript-eslint/parser', + sourceType: 'module', + ecmaVersion: 2019, + ecmaFeatures: { + globalReturn: false, + impliedStrict: false, + jsx: true, }, - env: { - browser: true - }, - extends: [ - 'plugin:vue/recommended', - 'standard', - '@vue/typescript' - ], - // required to lint *.vue files - plugins: [ - 'vue', - '@typescript-eslint' - ], - // 代码中的全局变量,key 为全局变量名称,value 为 true 允许被重写,为 false 不允许被重写 - globals: { - NODE_ENV: false, - LOGIN_SERVICE_URL: false, - AJAX_URL_PREFIX: false, - APP_CODE: false, - ENV: false, - monaco: false, - ResizeSensor: false, - define: false, - USER_INFO_URL: false, - BK_USER_MANAGE_HOST: false, - BKPAAS_ENVIRONMENT: false, - BK_ITSM_URL: false, - BK_APP_APIGW_PREFIX: false - }, - // add your custom rules hered - rules: { - '@typescript-eslint/adjacent-overload-signatures': 'error', - /** - * 类的只读属性若是一个字面量,则必须使用只读属性而不是 getter - */ - '@typescript-eslint/class-literal-property-style': [ - 'error', - 'fields' - ], - /** - * 类型断言必须使用 as Type,禁止使用 ,禁止对对象字面量进行类型断言(断言成 any 是允许的) - * @reason 容易被理解为 jsx - */ - '@typescript-eslint/consistent-type-assertions': [ - 'error', - { - assertionStyle: 'as', - objectLiteralTypeAssertions: 'never' - } - ], - /** - * 优先使用 interface 而不是 type - */ - '@typescript-eslint/consistent-type-definitions': 'off', - /** - * 必须设置类的成员的可访问性 - * @reason 将不需要公开的成员设为私有的,可以增强代码的可理解性,对文档输出也很友好 - */ - '@typescript-eslint/explicit-member-accessibility': 'off', - /** - * 要求或禁止在函数标识符和其调用之间有空格 - */ - '@typescript-eslint/func-call-spacing': [ - 'error', - 'never' - ], - /** - * 指定类成员的排序规则 - * @reason 优先级: - * 1. static > instance - * 2. field > constructor > method - * 3. public > protected > private - */ - '@typescript-eslint/member-ordering': [ - 'error', - { - default: [ - 'public-static-field', - 'protected-static-field', - 'private-static-field', - 'static-field', - 'public-static-method', - 'protected-static-method', - 'private-static-method', - 'static-method', - 'public-instance-field', - 'protected-instance-field', - 'private-instance-field', - 'public-field', - 'protected-field', - 'private-field', - 'instance-field', - 'field', - 'constructor', - 'public-instance-method', - 'protected-instance-method', - 'private-instance-method', - 'public-method', - 'protected-method', - 'private-method', - 'instance-method', - 'method' - ] - } - ], - /** - * 接口中的方法必须用属性的方式定义 - */ - '@typescript-eslint/method-signature-style': 'off', - /** 同 JS 规则的 TS 版本 */ - '@typescript-eslint/no-array-constructor': 'error', - /** 同 JS 规则的 TS 版本 */ - '@typescript-eslint/no-dupe-class-members': 'error', - /** - * 禁止定义空的接口 - */ - '@typescript-eslint/no-empty-interface': 'error', - /** - * 禁止给一个初始化时直接赋值为 number, string 的变量显式的声明类型 - * @reason 可以简化代码 - */ - '@typescript-eslint/no-inferrable-types': 'warn', - /** - * 禁止使用 namespace 来定义命名空间 - * @reason 使用 es6 引入模块,才是更标准的方式。 - * 但是允许使用 declare namespace ... {} 来定义外部命名空间 - */ - '@typescript-eslint/no-namespace': [ - 'error', - { - allowDeclarations: true, - allowDefinitionFiles: true - } - ], - /** - * 禁止在 optional chaining 之后使用 non-null 断言(感叹号) - * @reason optional chaining 后面的属性一定是非空的 - */ - '@typescript-eslint/no-non-null-asserted-optional-chain': 'error', - /** - * 禁止给类的构造函数的参数添加修饰符 - */ - '@typescript-eslint/no-parameter-properties': 'off', - /** - * 禁止无用的表达式 - */ - '@typescript-eslint/no-unused-expressions': [ - 'error', - { - allowShortCircuit: true, - allowTernary: true, - allowTaggedTemplates: true - } - ], - /** - * 禁止出现没必要的 constructor - */ - '@typescript-eslint/no-useless-constructor': 'warn', - /** - * 使用函数类型别名替代包含函数调用声明的接口 - */ - '@typescript-eslint/prefer-function-type': 'warn', - /** - * 禁止使用 module 来定义命名空间 - * @reason module 已成为 js 的关键字 - */ - '@typescript-eslint/prefer-namespace-keyword': 'error', - /** - * 使用 optional chaining 替代 && - */ - /** 同 JS 规则的 TS 版本 */ - '@typescript-eslint/quotes': [ - 'warn', - 'single', - { - allowTemplateLiterals: false - } - ], - /** - * 禁止使用三斜杠导入文件 - * @reason 三斜杠是已废弃的语法,但在类型声明文件中还是可以使用的 - */ - '@typescript-eslint/triple-slash-reference': [ - 'error', - { - path: 'never', - types: 'always', - lib: 'always' - } - ], - /** - * 在类型注释周围需要一致的间距 - */ - '@typescript-eslint/type-annotation-spacing': 'error', - /** - * interface 和 type 定义时必须声明成员的类型 - */ - '@typescript-eslint/typedef': [ - 'error', - { - arrayDestructuring: false, - arrowParameter: false, - memberVariableDeclaration: false, - objectDestructuring: false, - parameter: false, - propertyDeclaration: true, - variableDeclaration: false - } - ], - /** - * 函数重载时,若能通过联合类型将两个函数的类型声明合为一个,则使用联合类型而不是两个函数声明 - */ - '@typescript-eslint/unified-signatures': 'error', - // https://eslint.org/docs/rules/brace-style - 'brace-style': ['error', '1tbs', { 'allowSingleLine': false }], - - // https://eslint.org/docs/rules/camelcase - 'camelcase': ['error', { 'properties': 'never', 'ignoreDestructuring': true }], - - // 缩进使用 4 个空格,并且 switch 语句中的 Case 需要缩进 - // https://eslint.org/docs/rules/indent - 'indent': ['error', 4, { - 'SwitchCase': 1, - 'flatTernaryExpressions': true - }], - - // 数组的括号内的前后禁止有空格 - // https://eslint.org/docs/rules/array-bracket-spacing - 'array-bracket-spacing': ['error', 'never'], - - // https://eslint.org/docs/rules/operator-linebreak - 'operator-linebreak': ['error', 'before'], - - // 在开发阶段打开调试 - // https://eslint.org/docs/rules/no-debugger - 'no-debugger': 'off', - - // 只有一个参数时,箭头函数体可以省略圆括号 - // https://eslint.org/docs/rules/arrow-parens - 'arrow-parens': 'off', - - // 禁止空语句(可在空语句写注释避免),允许空的 catch 语句 - // https://eslint.org/docs/rules/no-empty - 'no-empty': ['error', { 'allowEmptyCatch': true }], - - // 禁止在语句末尾使用分号 - // https://eslint.org/docs/rules/semi - 'semi': ['error', 'never'], - - // 禁用不必要的分号 - // https://eslint.org/docs/rules/no-extra-semi - 'no-extra-semi': 'error', - - // generator 的 * 前面禁止有空格,后面必须有空格 - // https://eslint.org/docs/rules/generator-star-spacing - 'generator-star-spacing': [ - 'error', - { - before: false, - after: true - } - ], - - // 函数圆括号之前有一个空格 - // https://eslint.org/docs/rules/space-before-function-paren - 'space-before-function-paren': ['error', { - 'anonymous': 'always', // 匿名函数表达式 - 'named': 'always', // 命名的函数表达式 - 'asyncArrow': 'always' // 异步的箭头函数表达式 - }], - - // 禁止行尾有空格 - // https://eslint.org/docs/rules/no-trailing-spaces - 'no-trailing-spaces': ['error', { - 'skipBlankLines': true // 允许在空行使用空白符 - }], - - // 注释的斜线或 * 后必须有空格 - // https://eslint.org/docs/rules/spaced-comment - 'spaced-comment': ['error', 'always', { - 'line': { - 'markers': ['*package', '!', '/', ',', '='] - }, - 'block': { - // 前后空格是否平衡 - 'balanced': false, - 'markers': ['*package', '!', ',', ':', '::', 'flow-include'], - 'exceptions': ['*'] - } - }], - - // https://eslint.org/docs/rules/no-template-curly-in-string - // 禁止在字符串中使用字符串模板。不限制 - 'no-template-curly-in-string': 'off', - - // https://eslint.org/docs/rules/no-useless-escape - // 禁止出现没必要的转义。不限制 - 'no-useless-escape': 'off', - - // https://eslint.org/docs/rules/no-var - // 禁止使用 var - 'no-var': 'error', - - // https://eslint.org/docs/rules/prefer-const - // 如果一个变量不会被重新赋值,必须使用 `const` 进行声明。 - 'prefer-const': 'error', - - // eslint-plugin-vue@7 新增的规则,暂时先全部关闭 - 'vue/no-dupe-v-else-if': 'off', - 'vue/component-definition-name-casing': 'off', - 'vue/one-component-per-file': 'off', - 'vue/v-slot-style': 'off', - 'vue/no-arrow-functions-in-watch': 'off', - 'vue/no-custom-modifiers-on-v-model': 'off', - 'vue/no-multiple-template-root': 'off', - 'vue/no-mutating-props': 'off', - 'vue/no-v-for-template-key': 'off', - 'vue/no-v-model-argument': 'off', - 'vue/valid-v-bind-sync': 'off', - 'vue/valid-v-slot': 'off', - 'vue/experimental-script-setup-vars': 'off', - 'vue/no-lone-template': 'off', - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/array-bracket-spacing.md - 'vue/array-bracket-spacing': ['error', 'never'], - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/arrow-spacing.md - 'vue/arrow-spacing': ['error', { 'before': true, 'after': true }], - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/attribute-hyphenation.md - 'vue/attribute-hyphenation': ['error', 'always'], - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/attributes-order.md - // 属性顺序,不限制 - 'vue/attributes-order': 'off', - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/block-spacing.md - 'vue/block-spacing': ['error', 'always'], - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/brace-style.md - 'vue/brace-style': ['error', '1tbs', { 'allowSingleLine': false }], - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/camelcase.md - // 后端数据字段经常不是驼峰,所以不限制 properties,也不限制解构 - 'vue/camelcase': ['error', { 'properties': 'never', 'ignoreDestructuring': true }], - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/comma-dangle.md - // 禁止使用拖尾逗号,如 {demo: 'test',} - 'vue/comma-dangle': ['error', 'never'], - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/comment-directive.md - // vue 文件 template 中允许 eslint-disable eslint-enable eslint-disable-line eslint-disable-next-line - // 行内注释启用/禁用某些规则,配置为 1 即允许 - 'vue/comment-directive': 1, - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/component-name-in-template-casing.md - // 组件 html 标签的形式,连字符形式,所有 html 标签均会检测,如引入第三方不可避免,可通过 ignores 配置,支持正则,不限制 - 'vue/component-name-in-template-casing': 'off', - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/dot-location.md - // 等待 https://github.com/vuejs/eslint-plugin-vue/pull/794 合入 - // 'vue/dot-location': ['error', 'property'], - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/eqeqeq.md - 'vue/eqeqeq': ['error', 'always', { 'null': 'ignore' }], - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/html-closing-bracket-newline.md - // 单行写法不需要换行,多行需要,不限制 - 'vue/html-closing-bracket-newline': 'off', - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/html-closing-bracket-spacing.md - 'vue/html-closing-bracket-spacing': ['error', { - 'startTag': 'never', - 'endTag': 'never', - 'selfClosingTag': 'always' - }], - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/html-end-tags.md - 'vue/html-end-tags': 'error', - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/html-indent.md - 'vue/html-indent': ['error', 4, { - 'attribute': 1, - 'baseIndent': 1, - 'closeBracket': 0, - 'alignAttributesVertically': false, - 'ignores': [] - }], - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/html-quotes.md - 'vue/html-quotes': ['error', 'double'], - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/html-self-closing.md - // html tag 是否自闭和,不限制 - 'vue/html-self-closing': 'off', - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/jsx-uses-vars.md - // 当变量在 `JSX` 中被使用了,那么 eslint 就不会报出 `no-unused-vars` 的错误。需要开启 eslint no-unused-vars 规则才适用 - 'vue/jsx-uses-vars': 1, - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/key-spacing.md - 'vue/key-spacing': ['error', { 'beforeColon': false, 'afterColon': true }], - - // 关键字周围空格一致性,在关键字前后保留空格,如 if () else {} - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/keyword-spacing.md - // 等待 https://github.com/vuejs/eslint-plugin-vue/pull/795 合入 - // 'vue/keyword-spacing': ['error', {'before': true, 'after': true}], - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/match-component-file-name.md - // 组件名称属性与其文件名匹配,不限制 - 'vue/match-component-file-name': 'off', - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/max-attributes-per-line.md - // 每行属性的最大个数,不限制 - 'vue/max-attributes-per-line': 'off', - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/multiline-html-element-content-newline.md - // 在多行元素的内容前后需要换行符,不限制 - 'vue/multiline-html-element-content-newline': 'off', - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/mustache-interpolation-spacing.md - // template 中 {{var}},不限制 - 'vue/mustache-interpolation-spacing': 'off', - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/name-property-casing.md - 'vue/name-property-casing': 'off', - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/no-async-in-computed-properties.md - 'vue/no-async-in-computed-properties': 'error', - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/no-boolean-default.md - 'vue/no-boolean-default': 'off', - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/no-confusing-v-for-v-if.md - 'vue/no-confusing-v-for-v-if': 'error', - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/no-dupe-keys.md - // 二级属性名禁止重复 - 'vue/no-dupe-keys': 'error', - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/no-duplicate-attributes.md - // 禁止 html 元素中出现重复的属性 - 'vue/no-duplicate-attributes': 'error', - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/no-empty-pattern.md - // 等待 https://github.com/vuejs/eslint-plugin-vue/pull/798 合入 - // 禁止解构中出现空 {} 或 [] - // 'vue/no-empty-pattern': 'error', - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/no-multi-spaces.md - // 删除 html 标签中连续多个不用于缩进的空格 - 'vue/no-multi-spaces': 'error', - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/no-parsing-error.md - // 禁止语法错误 - 'vue/no-parsing-error': 'error', - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/no-reserved-keys.md - // 禁止使用保留字 - 'vue/no-reserved-keys': 'error', - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/no-restricted-syntax.md - // 禁止使用特定的语法 - 'vue/no-restricted-syntax': 'off', - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/no-shared-component-data.md - // data 属性必须是函数 - 'vue/no-shared-component-data': 'error', - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/no-side-effects-in-computed-properties.md - // 禁止在计算属性对属性进行修改,不限制 - 'vue/no-side-effects-in-computed-properties': 'off', - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/no-spaces-around-equal-signs-in-attribute.md - 'vue/no-spaces-around-equal-signs-in-attribute': 'error', - - // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/no-template-key.md - // 禁止在