From fd6b77bdc3c9a181afd65a8ea6f756a5dc966a32 Mon Sep 17 00:00:00 2001 From: Kane Wang Date: Wed, 4 Feb 2026 12:17:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=9D=E5=AD=98=E8=BF=9B=E5=BA=A6=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../eslint.config copy.ts | 111 ++++++++++++++++++ .../eslint.config.ts | 29 +++-- .../package-lock.json | 17 +++ .../regulatory-management-util/package.json | 1 + .../regulatory-management-util/src/App.vue | 28 +++-- 5 files changed, 166 insertions(+), 20 deletions(-) create mode 100644 code/web/regulatory-management-util/eslint.config copy.ts diff --git a/code/web/regulatory-management-util/eslint.config copy.ts b/code/web/regulatory-management-util/eslint.config copy.ts new file mode 100644 index 0000000..292f900 --- /dev/null +++ b/code/web/regulatory-management-util/eslint.config copy.ts @@ -0,0 +1,111 @@ +import js from "@eslint/js"; +import globals from "globals"; +import tseslint from "typescript-eslint"; +import pluginVue from "eslint-plugin-vue"; +import { defineConfig } from "eslint/config"; +import stylistic from "@stylistic/eslint-plugin"; + +export default defineConfig([ + { + files: ["**/*.{js,mjs,cjs,ts,mts,cts,vue}",], + plugins: { js, }, + extends: ["js/recommended",], + languageOptions: { + globals: { + ...globals.browser, + ...globals.node,}, }, + }, + tseslint.configs.recommended, + { + files: ["src/**/*.ts", "eslint.config.ts",], + plugins: { + "@stylistic": stylistic, + }, + rules: { + "spaced-comment": "error", + "space-before-function-paren": "off", + "semi-spacing": ["error", {"before": false, + "after": true,},], + "@typescript-eslint/no-unused-vars": "warn", + "@stylistic/indent": ["error", 4, { SwitchCase: 1, },], + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-extra-semi": "off", + "@typescript-eslint/no-inferrable-types": "off", + "@typescript-eslint/ban-ts-comment": "warn", + "@typescript-eslint/member-delimiter-style": "off", + "@stylistic/semi": ["error", "always",], // 控制行尾部分号 + "@stylistic/brace-style": ["error", "allman", { allowSingleLine: true, },], + "@stylistic/comma-dangle": [ + "error", + { + arrays: "always", + objects: "always", + imports: "never", + exports: "never", + functions: "never", + }, + ], // 数组和对象键值对最后一个逗号 + "@stylistic/quotes": ["error", "double",], + "@typescript-eslint/space-before-function-paren": "off", + "@typescript-eslint/comma-spacing": ["off", { before: false, + after: true, },], // 使用eslint的,不用ts的 + // "@typescript-eslint/strict-boolean-expressions": ["error", { + // allowString: false, + // },], + "@stylistic/object-property-newline": "warn", + }, + }, + pluginVue.configs["flat/essential"], + pluginVue.configs["flat/strongly-recommended"], + { + files: ["**/*.vue",], + plugins: { + "@stylistic": stylistic, + }, + languageOptions: { + parserOptions: { parser: tseslint.parser, }, + }, + rules: { + "vue/html-indent": ["error", 4,], + // "vue/max-attributes-per-line": ["error", { + // "singleline": { + // "max": 1, + // }, + // "multiline": { + // "max": 1, + // }, + // },], + "spaced-comment": "error", + "space-before-function-paren": "off", + "semi-spacing": ["error", {"before": false, + "after": true,},], + "@typescript-eslint/no-unused-vars": "warn", + "@stylistic/indent": ["error", 4, { SwitchCase: 1, },], + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-extra-semi": "off", + "@typescript-eslint/no-inferrable-types": "off", + "@typescript-eslint/ban-ts-comment": "warn", + "@typescript-eslint/member-delimiter-style": "off", + "@stylistic/semi": ["error", "always",], // 控制行尾部分号 + "@stylistic/brace-style": ["error", "allman", { allowSingleLine: true, },], + "@stylistic/comma-dangle": [ + "error", + { + arrays: "always", + objects: "always", + imports: "never", + exports: "never", + functions: "never", + }, + ], // 数组和对象键值对最后一个逗号 + "@stylistic/quotes": ["error", "double",], + "@typescript-eslint/space-before-function-paren": "off", + "@typescript-eslint/comma-spacing": ["off", { before: false, + after: true, },], // 使用eslint的,不用ts的 + // "@typescript-eslint/strict-boolean-expressions": ["error", { + // allowString: false, + // },], + "@stylistic/object-property-newline": "warn", + }, + }, +]); diff --git a/code/web/regulatory-management-util/eslint.config.ts b/code/web/regulatory-management-util/eslint.config.ts index 5121bde..84472f0 100644 --- a/code/web/regulatory-management-util/eslint.config.ts +++ b/code/web/regulatory-management-util/eslint.config.ts @@ -4,6 +4,7 @@ import tseslint from "typescript-eslint"; import pluginVue from "eslint-plugin-vue"; import { defineConfig } from "eslint/config"; import stylistic from "@stylistic/eslint-plugin"; +// import eslintConfigPrettier from "eslint-config-prettier"; export default defineConfig([ { @@ -21,6 +22,9 @@ export default defineConfig([ plugins: { "@stylistic": stylistic, }, + languageOptions: { + parserOptions: { parser: tseslint.parser, }, + }, rules: { "spaced-comment": "error", "space-before-function-paren": "off", @@ -56,24 +60,28 @@ export default defineConfig([ }, }, pluginVue.configs["flat/essential"], + pluginVue.configs["flat/strongly-recommended"], { - files: ["**/*.vue",], + files: ["**/*.vue","**/.ts","eslint.config.ts",], plugins: { "@stylistic": stylistic, }, - languageOptions: { + languageOptions: { parserOptions: { parser: tseslint.parser, }, + ecmaVersion: "latest", + sourceType: "module", + globals: globals.browser, }, rules: { "vue/html-indent": ["error", 4,], - "vue/max-attributes-per-line": ["error", { - "singleline": { - "max": 1, - }, - "multiline": { - "max": 1, - }, - },], + // "vue/max-attributes-per-line": ["error", { + // "singleline": { + // "max": 1, + // }, + // "multiline": { + // "max": 1, + // }, + // },], "spaced-comment": "error", "space-before-function-paren": "off", "semi-spacing": ["error", {"before": false, @@ -107,4 +115,5 @@ export default defineConfig([ "@stylistic/object-property-newline": "warn", }, }, + // eslintConfigPrettier, ]); diff --git a/code/web/regulatory-management-util/package-lock.json b/code/web/regulatory-management-util/package-lock.json index 3cc9b86..807f4f5 100644 --- a/code/web/regulatory-management-util/package-lock.json +++ b/code/web/regulatory-management-util/package-lock.json @@ -33,6 +33,7 @@ "axios": "^1.13.4", "element-plus": "^2.13.2", "eslint": "^9.39.2", + "eslint-config-prettier": "^10.1.8", "eslint-plugin-vue": "^10.7.0", "globals": "^17.3.0", "jiti": "^2.6.1", @@ -3169,6 +3170,22 @@ } } }, + "node_modules/eslint-config-prettier": { + "version": "10.1.8", + "resolved": "https://registry.npmmirror.com/eslint-config-prettier/-/eslint-config-prettier-10.1.8.tgz", + "integrity": "sha512-82GZUjRS0p/jganf6q1rEO25VSoHH0hKPCTrgillPjdI/3bgBhAE1QzHrHTizjpRvy6pGAvKjDJtk2pF9NDq8w==", + "dev": true, + "license": "MIT", + "bin": { + "eslint-config-prettier": "bin/cli.js" + }, + "funding": { + "url": "https://opencollective.com/eslint-config-prettier" + }, + "peerDependencies": { + "eslint": ">=7.0.0" + } + }, "node_modules/eslint-plugin-vue": { "version": "10.7.0", "resolved": "https://registry.npmmirror.com/eslint-plugin-vue/-/eslint-plugin-vue-10.7.0.tgz", diff --git a/code/web/regulatory-management-util/package.json b/code/web/regulatory-management-util/package.json index 39b6092..88552f5 100644 --- a/code/web/regulatory-management-util/package.json +++ b/code/web/regulatory-management-util/package.json @@ -34,6 +34,7 @@ "axios": "^1.13.4", "element-plus": "^2.13.2", "eslint": "^9.39.2", + "eslint-config-prettier": "^10.1.8", "eslint-plugin-vue": "^10.7.0", "globals": "^17.3.0", "jiti": "^2.6.1", diff --git a/code/web/regulatory-management-util/src/App.vue b/code/web/regulatory-management-util/src/App.vue index fc0fc5e..905372c 100644 --- a/code/web/regulatory-management-util/src/App.vue +++ b/code/web/regulatory-management-util/src/App.vue @@ -1,16 +1,24 @@