From 6c85a47dee7078f80b95d5fe9e5ab4821754be4a Mon Sep 17 00:00:00 2001 From: Goxiaoy Date: Fri, 3 Feb 2023 14:57:44 +0800 Subject: [PATCH] fix lint --- admin/.eslintrc.js | 44 ++-- admin/package.json | 4 +- admin/src/components.d.ts | 4 - admin/src/components/Screenfull/index.vue | 2 +- admin/src/layout/aside.vue | 10 +- admin/src/layout/components/content.vue | 10 +- admin/src/layout/components/header.vue | 22 +- admin/src/layout/components/sidebar.vue | 4 +- admin/src/layout/index.vue | 10 +- admin/src/main.ts | 18 +- admin/src/permission.ts | 1 + admin/src/store/modules/layout.ts | 16 +- admin/src/type/shim.vue.d.ts | 2 +- admin/src/utils/util.ts | 10 +- .../GlobalTransactions/AllTransactions.vue | 238 +++++++++--------- .../_Components/DialogTransactionDetail.vue | 15 +- admin/src/views/Dashboard/KVPairs/Topics.vue | 185 +++++++------- .../KVPairs/_Components/DialogTopicDetail.vue | 106 ++++---- .../_Components/DialogTopicSubscribe.vue | 96 +++---- admin/tailwind.config.js | 10 +- admin/vite.config.ts | 130 +++++----- 21 files changed, 474 insertions(+), 463 deletions(-) diff --git a/admin/.eslintrc.js b/admin/.eslintrc.js index f4078c6..58f2b95 100644 --- a/admin/.eslintrc.js +++ b/admin/.eslintrc.js @@ -1,32 +1,32 @@ module.exports = { - parser: "vue-eslint-parser", - "env": { - "browser": true, - "es2021": true + parser: 'vue-eslint-parser', + env: { + browser: true, + es2021: true }, - "extends": [ - "plugin:@typescript-eslint/recommended", - "plugin:vue/vue3-recommended" + extends: [ + 'plugin:@typescript-eslint/recommended', + 'plugin:vue/vue3-recommended' ], - "parserOptions": { - "parser": "@typescript-eslint/parser", - "sourceType": "module", + parserOptions: { + parser: '@typescript-eslint/parser', + sourceType: 'module', ecmaFeature: { jsx: true, tsx: true } }, - "plugins": [ - "@typescript-eslint" + plugins: [ + '@typescript-eslint' ], - "rules": { + rules: { 'vue/max-attributes-per-line': ['error', { singleline: 10, multiline: { - max: 1, - allowFirstLine: false + max: 1 } }], + 'vue/multi-word-component-names': 0, 'vue/singleline-html-element-content-newline': 'off', 'vue/multiline-html-element-content-newline': 'off', 'vue/html-indent': ['error', 4], @@ -35,7 +35,9 @@ module.exports = { quotes: ['error', 'single'], // 单引号 // 'vue/html-quotes': ['error', 'single'], semi: ['error', 'never'], // 禁止使用分号 - 'space-infix-ops': ['error', { int32Hint: false }], // 要求操作符周围有空格 + 'space-infix-ops': ['error', { + int32Hint: false + }], // 要求操作符周围有空格 'no-multi-spaces': 'error', // 禁止多个空格 'no-whitespace-before-property': 'error', // 禁止在属性前使用空格 'space-before-blocks': 'error', // 在块之前强制保持一致的间距 @@ -48,8 +50,8 @@ module.exports = { array: true, object: true }, { - enforceForRenamedProperties: false - }], + enforceForRenamedProperties: false + }], 'comma-dangle': ['error', 'never'], // 最后一个属性不允许有逗号 'arrow-spacing': 'error', // 箭头函数空格 'prefer-template': 'error', @@ -59,10 +61,12 @@ module.exports = { 'no-unneeded-ternary': 'error', // 禁止可以表达为更简单结构的三元操作符 'no-restricted-syntax': ['error', 'WithStatement', 'BinaryExpression[operator="in"]'], // 禁止with/in语句 'no-lonely-if': 'error', // 禁止 if 语句作为唯一语句出现在 else 语句块中 - 'newline-per-chained-call': ['error', { ignoreChainWithDepth: 2 }], // 要求方法链中每个调用都有一个换行符 + 'newline-per-chained-call': ['error', { + ignoreChainWithDepth: 2 + }], // 要求方法链中每个调用都有一个换行符 // 路径别名设置 'no-submodule-imports': ['off', '/@'], 'no-implicit-dependencies': ['off', ['/@']], '@typescript-eslint/no-explicit-any': 'off' // 类型可以使用any } -} +} \ No newline at end of file diff --git a/admin/package.json b/admin/package.json index ec0eeb2..4250499 100644 --- a/admin/package.json +++ b/admin/package.json @@ -5,7 +5,9 @@ "scripts": { "dev": "vite", "build": "vite build && echo > dist/placeholder", - "preview": "vite preview" + "preview": "vite preview", + "lint": "eslint --ext .tsx,.ts,vue src/", + "lint:fix": "eslint --ext .tsx,.ts,vue src/ --fix" }, "dependencies": { "ant-design-vue": "^3.1.1", diff --git a/admin/src/components.d.ts b/admin/src/components.d.ts index 9344e27..92aed78 100644 --- a/admin/src/components.d.ts +++ b/admin/src/components.d.ts @@ -5,7 +5,6 @@ import '@vue/runtime-core' declare module '@vue/runtime-core' { export interface GlobalComponents { - AAlert: typeof import('ant-design-vue/es')['Alert'] ABreadcrumb: typeof import('ant-design-vue/es')['Breadcrumb'] ABreadcrumbItem: typeof import('ant-design-vue/es')['BreadcrumbItem'] AButton: typeof import('ant-design-vue/es')['Button'] @@ -19,11 +18,8 @@ declare module '@vue/runtime-core' { ALayoutSider: typeof import('ant-design-vue/es')['LayoutSider'] AMenu: typeof import('ant-design-vue/es')['Menu'] AMenuItem: typeof import('ant-design-vue/es')['MenuItem'] - AModal: typeof import('ant-design-vue/es')['Modal'] - ASubMenu: typeof import('ant-design-vue/es')['SubMenu'] ATable: typeof import('ant-design-vue/es')['Table'] ATag: typeof import('ant-design-vue/es')['Tag'] - ATextarea: typeof import('ant-design-vue/es')['Textarea'] RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] Screenfull: typeof import('./components/Screenfull/index.vue')['default'] diff --git a/admin/src/components/Screenfull/index.vue b/admin/src/components/Screenfull/index.vue index 6f12919..2a418d2 100644 --- a/admin/src/components/Screenfull/index.vue +++ b/admin/src/components/Screenfull/index.vue @@ -5,7 +5,7 @@ diff --git a/admin/src/layout/components/header.vue b/admin/src/layout/components/header.vue index bf24541..da949a1 100644 --- a/admin/src/layout/components/header.vue +++ b/admin/src/layout/components/header.vue @@ -1,16 +1,16 @@ diff --git a/admin/src/main.ts b/admin/src/main.ts index 9a68c50..916cb4c 100644 --- a/admin/src/main.ts +++ b/admin/src/main.ts @@ -15,18 +15,18 @@ app.use(pinia) app.mount('#app') window.onunhandledrejection = (ev: PromiseRejectionEvent) => { - showAlert(ev.reason.stack || ev.reason.message) + showAlert(ev.reason.stack || ev.reason.message) } window.onerror = err => { - if (typeof err === "string") { - return showAlert(err) - } - showAlert(JSON.stringify(err)) + if (typeof err === 'string') { + return showAlert(err) + } + showAlert(JSON.stringify(err)) } function showAlert(msg: string) { - let layout = useLayoutStore() - if (!layout.globalError) { - layout.setGlobalError(msg) - } + const layout = useLayoutStore() + if (!layout.globalError) { + layout.setGlobalError(msg) + } } diff --git a/admin/src/permission.ts b/admin/src/permission.ts index 10ad91f..e7b1a51 100644 --- a/admin/src/permission.ts +++ b/admin/src/permission.ts @@ -4,6 +4,7 @@ import { useLayoutStore } from './store/modules/layout' configure({ showSpinner: false }) +// eslint-disable-next-line @typescript-eslint/no-unused-vars const defaultRoutePath = '/' router.beforeEach((to) => { diff --git a/admin/src/store/modules/layout.ts b/admin/src/store/modules/layout.ts index 0e2d8a5..37b1acb 100644 --- a/admin/src/store/modules/layout.ts +++ b/admin/src/store/modules/layout.ts @@ -1,7 +1,7 @@ -import { defineStore } from 'pinia'; -import { allowRouter } from '/@/router'; -import { ILayout, IMenubar, IMenubarList, IStatus } from '/@/type/store/layout'; -import { getDtmVersion } from '/@/api/api_dtm'; +import { defineStore } from 'pinia' +import { allowRouter } from '/@/router' +import { ILayout, IMenubar, IMenubarList, IStatus } from '/@/type/store/layout' +import { getDtmVersion } from '/@/api/api_dtm' export const useLayoutStore = defineStore({ id: 'layout', @@ -12,8 +12,8 @@ export const useLayoutStore = defineStore({ status: { isLoading: false }, - dtmVersion: "", - globalError: "", + dtmVersion: '', + globalError: '' }), getters: { getMenubar(): IMenubar { @@ -21,7 +21,7 @@ export const useLayoutStore = defineStore({ }, getStatus(): IStatus { return this.status - }, + } }, actions: { setRoutes(data: Array): void { @@ -36,7 +36,7 @@ export const useLayoutStore = defineStore({ async loadDtmVersion(): Promise { const { data: { version } } = await getDtmVersion() this.dtmVersion = version - console.log("dtm version: ", this.dtmVersion) + console.log('dtm version: ', this.dtmVersion) } } }) diff --git a/admin/src/type/shim.vue.d.ts b/admin/src/type/shim.vue.d.ts index 54d56ab..14edcf0 100644 --- a/admin/src/type/shim.vue.d.ts +++ b/admin/src/type/shim.vue.d.ts @@ -1,5 +1,5 @@ declare module '*.vue' { - import { defineComponent } from 'vue'; + import { defineComponent } from 'vue' const Component: ReturnType export default Component } diff --git a/admin/src/utils/util.ts b/admin/src/utils/util.ts index 1f2b118..64f5c43 100644 --- a/admin/src/utils/util.ts +++ b/admin/src/utils/util.ts @@ -1,12 +1,12 @@ -import { useRoute } from 'vue-router'; -import { IMenubarList } from '../type/store/layout'; +import { useRoute } from 'vue-router' +import { IMenubarList } from '../type/store/layout' export const findCurrentMenubar = (menuList: IMenubarList[], root?: boolean) => { const route = useRoute() let arr: IMenubarList[] | IMenubarList = [] for (let i = 0; i < menuList.length; i++) { - const v = menuList[i]; - const usePath = v.meta.activeMenu || v.redirect || v.path; + const v = menuList[i] + const usePath = v.meta.activeMenu || v.redirect || v.path const pos = usePath.lastIndexOf('/') const rootPath = pos == 0 ? usePath : usePath.substring(0, pos) if (route.path.indexOf(rootPath) !== -1) { @@ -22,6 +22,6 @@ export const findCurrentMenubar = (menuList: IMenubarList[], root?: boolean) => return arr } -export const sleep = async (ms: number) => { +export const sleep = async(ms: number) => { return new Promise(resolve => setTimeout(resolve, ms)) } \ No newline at end of file diff --git a/admin/src/views/Dashboard/GlobalTransactions/AllTransactions.vue b/admin/src/views/Dashboard/GlobalTransactions/AllTransactions.vue index b0a48bb..6bad0a9 100644 --- a/admin/src/views/Dashboard/GlobalTransactions/AllTransactions.vue +++ b/admin/src/views/Dashboard/GlobalTransactions/AllTransactions.vue @@ -1,164 +1,170 @@ diff --git a/admin/src/views/Dashboard/GlobalTransactions/_Components/DialogTransactionDetail.vue b/admin/src/views/Dashboard/GlobalTransactions/_Components/DialogTransactionDetail.vue index bfec29d..fc54a31 100644 --- a/admin/src/views/Dashboard/GlobalTransactions/_Components/DialogTransactionDetail.vue +++ b/admin/src/views/Dashboard/GlobalTransactions/_Components/DialogTransactionDetail.vue @@ -2,21 +2,20 @@
- + + diff --git a/admin/src/views/Dashboard/KVPairs/_Components/DialogTopicDetail.vue b/admin/src/views/Dashboard/KVPairs/_Components/DialogTopicDetail.vue index a0c77fa..93b7ff7 100644 --- a/admin/src/views/Dashboard/KVPairs/_Components/DialogTopicDetail.vue +++ b/admin/src/views/Dashboard/KVPairs/_Components/DialogTopicDetail.vue @@ -1,80 +1,80 @@ diff --git a/admin/src/views/Dashboard/KVPairs/_Components/DialogTopicSubscribe.vue b/admin/src/views/Dashboard/KVPairs/_Components/DialogTopicSubscribe.vue index c41c574..1827abd 100644 --- a/admin/src/views/Dashboard/KVPairs/_Components/DialogTopicSubscribe.vue +++ b/admin/src/views/Dashboard/KVPairs/_Components/DialogTopicSubscribe.vue @@ -1,71 +1,77 @@ diff --git a/admin/tailwind.config.js b/admin/tailwind.config.js index 9dad44b..7fdc6ef 100644 --- a/admin/tailwind.config.js +++ b/admin/tailwind.config.js @@ -1,7 +1,7 @@ module.exports = { - content: ['./index.html', './src/**/*.{vue,js,ts,jsx,tsx}'], - theme: { - extend: {}, - }, - plugins: [], + content: ['./index.html', './src/**/*.{vue,js,ts,jsx,tsx}'], + theme: { + extend: {} + }, + plugins: [] } diff --git a/admin/vite.config.ts b/admin/vite.config.ts index 8ae2bd8..2964fb8 100644 --- a/admin/vite.config.ts +++ b/admin/vite.config.ts @@ -1,73 +1,73 @@ -import { ConfigEnv, UserConfigExport } from "vite"; -import path from "path"; -import vue from "@vitejs/plugin-vue"; -import { createSvgIconsPlugin } from "vite-plugin-svg-icons"; -import Components from "unplugin-vue-components/vite"; -import { AntDesignVueResolver } from "unplugin-vue-components/resolvers"; -import { ViteEjsPlugin } from "vite-plugin-ejs"; +import { ConfigEnv, UserConfigExport } from 'vite' +import path from 'path' +import vue from '@vitejs/plugin-vue' +import { createSvgIconsPlugin } from 'vite-plugin-svg-icons' +import Components from 'unplugin-vue-components/vite' +import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers' +import { ViteEjsPlugin } from 'vite-plugin-ejs' const setAlias = (alias: [string, string][]) => - alias.map((v) => { - return { find: v[0], replacement: path.resolve(__dirname, v[1]) }; - }); + alias.map((v) => { + return { find: v[0], replacement: path.resolve(__dirname, v[1]) } + }) export default ({ mode }: ConfigEnv): UserConfigExport => { - return { - resolve: { - alias: setAlias([["/@", "src"]]), - }, - plugins: [ - vue(), - createSvgIconsPlugin({ - iconDirs: [path.resolve(process.cwd(), "src/icons")], - symbolId: "icon-[dir]-[name]", - }), - Components({ - dts: "src/components.d.ts", - resolvers: [AntDesignVueResolver()], - }), - ViteEjsPlugin({ - PUBLIC_PATH: mode !== "development" ? "PUBLIC-PATH-VARIABLE" : "", - }), - ], - experimental: { - renderBuiltUrl( - filename: string, - { - hostType, - }: { + return { + resolve: { + alias: setAlias([['/@', 'src']]) + }, + plugins: [ + vue(), + createSvgIconsPlugin({ + iconDirs: [path.resolve(process.cwd(), 'src/icons')], + symbolId: 'icon-[dir]-[name]' + }), + Components({ + dts: 'src/components.d.ts', + resolvers: [AntDesignVueResolver()] + }), + ViteEjsPlugin({ + PUBLIC_PATH: mode !== 'development' ? 'PUBLIC-PATH-VARIABLE' : '' + }) + ], + experimental: { + renderBuiltUrl( + filename: string, + { + hostType + }: { hostId: string; - hostType: "js" | "css" | "html"; - type: "asset" | "public"; - } - ) { - if (hostType === "js") { - return { - runtime: `window.__assetsPathBuilder(${JSON.stringify(filename)})`, - }; + hostType: 'js' | 'css' | 'html'; + type: 'asset' | 'public'; } + ) { + if (hostType === 'js') { + return { + runtime: `window.__assetsPathBuilder(${JSON.stringify(filename)})` + } + } - return filename; - }, - }, - server: { - port: 6789, - base: "admin", - proxy: { - "/api": { - target: "http://localhost:36789", + return filename + } }, - }, - }, - css: { - postcss: { - plugins: [ - require("autoprefixer"), - require("tailwindcss"), - require("postcss-simple-vars"), - require("postcss-import"), - ], - }, - }, - }; -}; + server: { + port: 6789, + base: 'admin', + proxy: { + '/api': { + target: 'http://localhost:36789' + } + } + }, + css: { + postcss: { + plugins: [ + require('autoprefixer'), + require('tailwindcss'), + require('postcss-simple-vars'), + require('postcss-import') + ] + } + } + } +}