From 1611d8584e279e41951956d288d1eb072e0c54ad Mon Sep 17 00:00:00 2001 From: ulleo Date: Thu, 12 Jun 2025 14:54:30 +0800 Subject: [PATCH] feat: eslint --- frontend/.eslintignore | 10 -- frontend/.eslintrc-auto-import.json | 6 + frontend/.eslintrc.js | 33 ----- frontend/eslint.config.cjs | 7 +- frontend/package.json | 1 + .../src/components/icon-custom/src/Icon.vue | 2 +- frontend/src/main.ts | 3 + frontend/src/views/chat/ChatAnswer.vue | 4 +- frontend/src/views/chat/ChatBlock.vue | 2 +- frontend/src/views/chat/index.vue | 11 -- .../views/dashboard/common/ResourceTree.vue | 118 ++++++++---------- .../dashboard/components/sq-tab/index.vue | 12 +- frontend/vite.config.ts | 3 + 13 files changed, 79 insertions(+), 133 deletions(-) delete mode 100644 frontend/.eslintignore create mode 100644 frontend/.eslintrc-auto-import.json delete mode 100644 frontend/.eslintrc.js diff --git a/frontend/.eslintignore b/frontend/.eslintignore deleted file mode 100644 index 87337b4c..00000000 --- a/frontend/.eslintignore +++ /dev/null @@ -1,10 +0,0 @@ -/node_modules/ -/dist/ -/public/ -*.md -*.woff -*.ttf -.vscode/ -.DS_Store -eslint.config.cjs -.eslintrc.js diff --git a/frontend/.eslintrc-auto-import.json b/frontend/.eslintrc-auto-import.json new file mode 100644 index 00000000..05a87d9e --- /dev/null +++ b/frontend/.eslintrc-auto-import.json @@ -0,0 +1,6 @@ +{ + "globals": { + "ElMessage": true, + "ElMessageBox": true + } +} diff --git a/frontend/.eslintrc.js b/frontend/.eslintrc.js deleted file mode 100644 index c7c7db27..00000000 --- a/frontend/.eslintrc.js +++ /dev/null @@ -1,33 +0,0 @@ -module.exports = { - root: true, - env: { - node: true, - }, - extends: [ - 'plugin:vue/vue3-recommended', - 'eslint:recommended', - '@vue/typescript/recommended', - 'plugin:@typescript-eslint/recommended', - 'plugin:prettier/recommended', - ], - parserOptions: { - ecmaVersion: 2020, - }, - rules: { - 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', - 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', - 'vue/multi-word-component-names': 'off', - '@typescript-eslint/no-explicit-any': 'off', - 'prettier/prettier': [ - 'warn', - { - singleQuote: true, - semi: false, - trailingComma: 'es5', - printWidth: 100, - tabWidth: 2, - endOfLine: 'auto', - }, - ], - }, -} diff --git a/frontend/eslint.config.cjs b/frontend/eslint.config.cjs index b98d8374..109373cb 100644 --- a/frontend/eslint.config.cjs +++ b/frontend/eslint.config.cjs @@ -5,11 +5,13 @@ const eslintPluginPrettierRecommended = require('eslint-plugin-prettier/recommen const eslintPluginVue = require('eslint-plugin-vue') const globals = require('globals') const typescriptEslint = require('typescript-eslint') +const eslintrcImport = require('./.eslintrc-auto-import.json') + module.exports = typescriptEslint.config( { languageOptions: { - globals: globals.browser, + globals: { ...globals.browser, ...globals.node, ...eslintrcImport.globals }, ecmaVersion: 'latest', parserOptions: { parser: typescriptEslint.parser, @@ -47,7 +49,6 @@ module.exports = typescriptEslint.config( 'dist/', 'public/', 'eslint.config.cjs', - '.eslintrc.js', '**/*.md', '**/*.woff', '**/*.ttf', @@ -55,5 +56,5 @@ module.exports = typescriptEslint.config( '**/.DS_Store', ]), eslintConfigPrettier, - eslintPluginPrettierRecommended + eslintPluginPrettierRecommended, ) diff --git a/frontend/package.json b/frontend/package.json index fbe51e57..7a59f24c 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -29,6 +29,7 @@ "snowflake-id": "^1.1.0", "tinymce": "^5.8.2", "vue": "^3.5.13", + "vue-dompurify-html": "^5.3.0", "vue-i18n": "^9.14.4", "vue-router": "^4.5.0", "web-storage-cache": "^1.1.1" diff --git a/frontend/src/components/icon-custom/src/Icon.vue b/frontend/src/components/icon-custom/src/Icon.vue index 43b33352..2f50c2b6 100644 --- a/frontend/src/components/icon-custom/src/Icon.vue +++ b/frontend/src/components/icon-custom/src/Icon.vue @@ -29,10 +29,10 @@ const svgClass = computed(() => { diff --git a/frontend/src/main.ts b/frontend/src/main.ts index 530607b4..f81e9fcb 100644 --- a/frontend/src/main.ts +++ b/frontend/src/main.ts @@ -4,6 +4,8 @@ import './style.less' import App from './App.vue' import router from './router' import { i18n } from './i18n' +import VueDOMPurifyHTML from 'vue-dompurify-html' + // import 'element-plus/dist/index.css' const app = createApp(App) const pinia = createPinia() @@ -11,4 +13,5 @@ const pinia = createPinia() app.use(pinia) app.use(router) app.use(i18n) +app.use(VueDOMPurifyHTML) app.mount('#app') diff --git a/frontend/src/views/chat/ChatAnswer.vue b/frontend/src/views/chat/ChatAnswer.vue index 54e4aa7b..eeaa9990 100644 --- a/frontend/src/views/chat/ChatAnswer.vue +++ b/frontend/src/views/chat/ChatAnswer.vue @@ -215,12 +215,12 @@ function onTypeChange() {
diff --git a/frontend/src/views/chat/ChatBlock.vue b/frontend/src/views/chat/ChatBlock.vue index 376de9c7..e339fb9d 100644 --- a/frontend/src/views/chat/ChatBlock.vue +++ b/frontend/src/views/chat/ChatBlock.vue @@ -11,7 +11,7 @@ defineProps<{
-
+
diff --git a/frontend/src/views/chat/index.vue b/frontend/src/views/chat/index.vue index 62b95a02..e443e88e 100644 --- a/frontend/src/views/chat/index.vue +++ b/frontend/src/views/chat/index.vue @@ -341,17 +341,6 @@ const sendMessage = async () => { } } -//@ts-ignore -const formatMessage = (content: string) => { - if (!content) return '' - return content - .replace(/&/g, '&') - .replace(//g, '>') - .replace(/\n/g, '
') - .replace(/ {2}/g, '  ') -} - const handleCtrlEnter = (e: KeyboardEvent) => { const textarea = e.target as HTMLTextAreaElement const start = textarea.selectionStart diff --git a/frontend/src/views/dashboard/common/ResourceTree.vue b/frontend/src/views/dashboard/common/ResourceTree.vue index 6b4a1aaa..d36825e8 100644 --- a/frontend/src/views/dashboard/common/ResourceTree.vue +++ b/frontend/src/views/dashboard/common/ResourceTree.vue @@ -1,6 +1,6 @@ @@ -270,16 +263,16 @@ defineExpose({
- {{ t('dashboard.dashboard') }} + {{ t('dashboard.dashboard') }}
- + @@ -287,36 +280,29 @@ defineExpose({ - +
- +
- +