Skip to content

Commit 6c85a47

Browse files
committed
fix lint
1 parent 94f9df0 commit 6c85a47

File tree

21 files changed

+474
-463
lines changed

21 files changed

+474
-463
lines changed

admin/.eslintrc.js

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
module.exports = {
2-
parser: "vue-eslint-parser",
3-
"env": {
4-
"browser": true,
5-
"es2021": true
2+
parser: 'vue-eslint-parser',
3+
env: {
4+
browser: true,
5+
es2021: true
66
},
7-
"extends": [
8-
"plugin:@typescript-eslint/recommended",
9-
"plugin:vue/vue3-recommended"
7+
extends: [
8+
'plugin:@typescript-eslint/recommended',
9+
'plugin:vue/vue3-recommended'
1010
],
11-
"parserOptions": {
12-
"parser": "@typescript-eslint/parser",
13-
"sourceType": "module",
11+
parserOptions: {
12+
parser: '@typescript-eslint/parser',
13+
sourceType: 'module',
1414
ecmaFeature: {
1515
jsx: true,
1616
tsx: true
1717
}
1818
},
19-
"plugins": [
20-
"@typescript-eslint"
19+
plugins: [
20+
'@typescript-eslint'
2121
],
22-
"rules": {
22+
rules: {
2323
'vue/max-attributes-per-line': ['error', {
2424
singleline: 10,
2525
multiline: {
26-
max: 1,
27-
allowFirstLine: false
26+
max: 1
2827
}
2928
}],
29+
'vue/multi-word-component-names': 0,
3030
'vue/singleline-html-element-content-newline': 'off',
3131
'vue/multiline-html-element-content-newline': 'off',
3232
'vue/html-indent': ['error', 4],
@@ -35,7 +35,9 @@ module.exports = {
3535
quotes: ['error', 'single'], // 单引号
3636
// 'vue/html-quotes': ['error', 'single'],
3737
semi: ['error', 'never'], // 禁止使用分号
38-
'space-infix-ops': ['error', { int32Hint: false }], // 要求操作符周围有空格
38+
'space-infix-ops': ['error', {
39+
int32Hint: false
40+
}], // 要求操作符周围有空格
3941
'no-multi-spaces': 'error', // 禁止多个空格
4042
'no-whitespace-before-property': 'error', // 禁止在属性前使用空格
4143
'space-before-blocks': 'error', // 在块之前强制保持一致的间距
@@ -48,8 +50,8 @@ module.exports = {
4850
array: true,
4951
object: true
5052
}, {
51-
enforceForRenamedProperties: false
52-
}],
53+
enforceForRenamedProperties: false
54+
}],
5355
'comma-dangle': ['error', 'never'], // 最后一个属性不允许有逗号
5456
'arrow-spacing': 'error', // 箭头函数空格
5557
'prefer-template': 'error',
@@ -59,10 +61,12 @@ module.exports = {
5961
'no-unneeded-ternary': 'error', // 禁止可以表达为更简单结构的三元操作符
6062
'no-restricted-syntax': ['error', 'WithStatement', 'BinaryExpression[operator="in"]'], // 禁止with/in语句
6163
'no-lonely-if': 'error', // 禁止 if 语句作为唯一语句出现在 else 语句块中
62-
'newline-per-chained-call': ['error', { ignoreChainWithDepth: 2 }], // 要求方法链中每个调用都有一个换行符
64+
'newline-per-chained-call': ['error', {
65+
ignoreChainWithDepth: 2
66+
}], // 要求方法链中每个调用都有一个换行符
6367
// 路径别名设置
6468
'no-submodule-imports': ['off', '/@'],
6569
'no-implicit-dependencies': ['off', ['/@']],
6670
'@typescript-eslint/no-explicit-any': 'off' // 类型可以使用any
6771
}
68-
}
72+
}

admin/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
"scripts": {
66
"dev": "vite",
77
"build": "vite build && echo > dist/placeholder",
8-
"preview": "vite preview"
8+
"preview": "vite preview",
9+
"lint": "eslint --ext .tsx,.ts,vue src/",
10+
"lint:fix": "eslint --ext .tsx,.ts,vue src/ --fix"
911
},
1012
"dependencies": {
1113
"ant-design-vue": "^3.1.1",

admin/src/components.d.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import '@vue/runtime-core'
55

66
declare module '@vue/runtime-core' {
77
export interface GlobalComponents {
8-
AAlert: typeof import('ant-design-vue/es')['Alert']
98
ABreadcrumb: typeof import('ant-design-vue/es')['Breadcrumb']
109
ABreadcrumbItem: typeof import('ant-design-vue/es')['BreadcrumbItem']
1110
AButton: typeof import('ant-design-vue/es')['Button']
@@ -19,11 +18,8 @@ declare module '@vue/runtime-core' {
1918
ALayoutSider: typeof import('ant-design-vue/es')['LayoutSider']
2019
AMenu: typeof import('ant-design-vue/es')['Menu']
2120
AMenuItem: typeof import('ant-design-vue/es')['MenuItem']
22-
AModal: typeof import('ant-design-vue/es')['Modal']
23-
ASubMenu: typeof import('ant-design-vue/es')['SubMenu']
2421
ATable: typeof import('ant-design-vue/es')['Table']
2522
ATag: typeof import('ant-design-vue/es')['Tag']
26-
ATextarea: typeof import('ant-design-vue/es')['Textarea']
2723
RouterLink: typeof import('vue-router')['RouterLink']
2824
RouterView: typeof import('vue-router')['RouterView']
2925
Screenfull: typeof import('./components/Screenfull/index.vue')['default']

admin/src/components/Screenfull/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</div>
66
</template>
77
<script setup lang='ts'>
8-
import { notification } from 'ant-design-vue';
8+
import { notification } from 'ant-design-vue'
99
import { onMounted, onUnmounted, ref } from 'vue'
1010
import screenfull from 'screenfull'
1111

admin/src/layout/aside.vue

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
<Sidebar />
55
</a-layout-sider>
66
<a-layout style="padding: 0 24px 24px">
7-
<div v-if="layout.dtmVersion && layout.dtmVersion != dashVer" style="color:#f00"> !!! admin version: {{dashVer}} != dtm version: {{layout.dtmVersion}}. </div>
7+
<div v-if="layout.dtmVersion && layout.dtmVersion != dashVer" style="color:#f00"> !!! admin version: {{ dashVer }} != dtm version: {{ layout.dtmVersion }}. </div>
88
<a-breadcrumb style="margin: 16px 0">
99
<a-breadcrumb-item>{{ mainNav }}</a-breadcrumb-item>
1010
<a-breadcrumb-item>{{ subNav }}</a-breadcrumb-item>
1111
<a-breadcrumb-item>{{ page }}</a-breadcrumb-item>
1212
</a-breadcrumb>
1313
<a-layout-content
14-
:style="{ background: '#fff', padding: '24px', margin: 0, minHeight: '280px' }"
14+
:style="{ background: '#fff', padding: '24px', margin: 0, minHeight: '280px' }"
1515
>
1616
<Content />
1717
</a-layout-content>
@@ -20,14 +20,10 @@
2020
</template>
2121

2222
<script setup lang='ts'>
23-
import Sidebar from './components/sidebar.vue'
24-
import Content from './components/content.vue'
2523
import { useRoute } from 'vue-router'
2624
import { useLayoutStore } from '../store/modules/layout'
27-
import { IMenubarList } from '../type/store/layout'
2825
import { findCurrentMenubar } from '../utils/util'
29-
import { computed, onMounted, ref } from 'vue'
30-
import { getDtmVersion } from '../api/api_dtm'
26+
import { computed, onMounted } from 'vue'
3127
3228
3329
const dashVer = import.meta.env.VITE_ADMIN_VERSION

admin/src/layout/components/content.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
closable
1010
@close="onClose"
1111
>
12-
<template v-slot:description>
13-
<span v-for="ln of errLines">{{ln}} <br/> </span>
12+
<template #description>
13+
<span v-for="(ln, index) of errLines" :key="index">{{ ln }} <br> </span>
1414
</template>
1515
</a-alert>
1616
<component :is="Component" :key="key" />
@@ -30,10 +30,10 @@ const route = useRoute()
3030
const key = computed(() => route.path)
3131
3232
const layoutStore = useLayoutStore()
33-
const errLines = computed(() => layoutStore.globalError.split("\n"))
34-
const onClose = async (e: MouseEvent) => {
33+
const errLines = computed(() => layoutStore.globalError.split('\n'))
34+
const onClose = async() => {
3535
await sleep(1000)
36-
layoutStore.setGlobalError("")
36+
layoutStore.setGlobalError('')
3737
}
3838
3939
</script>

admin/src/layout/components/header.vue

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
<template>
22
<div>
3-
<a-layout-header class="header flex">
4-
<div class="flex items-center logo h-16">
3+
<a-layout-header class="flex header">
4+
<div class="flex items-center h-16 logo">
55
<svg-icon style="width: 36px; height: 36px; margin-right: 84px;" icon-class="svg-logo" />
6-
<span class="text-gray-400 text-lg">DTM admin {{ version }}</span>
6+
<span class="text-lg text-gray-400">DTM admin {{ version }}</span>
77
</div>
88
<a-menu
9-
v-model:selectedKeys="activeMenu"
10-
theme="dark"
11-
mode="horizontal"
12-
:style="{ lineHeight: '64px' }"
13-
@select="onOpenChange"
9+
v-model:selectedKeys="activeMenu"
10+
theme="dark"
11+
mode="horizontal"
12+
:style="{ lineHeight: '64px' }"
13+
@select="onOpenChange"
1414
>
1515
<a-menu-item v-for="v in getMenubar.menuList" :key="v.path">{{ v.meta.title }}</a-menu-item>
1616
</a-menu>
1717
</a-layout-header>
1818
</div>
1919
</template>
2020
<script setup lang='ts'>
21-
import { computed, ref } from 'vue';
22-
import { useRoute, useRouter } from 'vue-router';
21+
import { ref } from 'vue'
22+
import { useRoute, useRouter } from 'vue-router'
2323
import { useLayoutStore } from '/@/store/modules/layout'
2424
2525
const route = useRoute()
2626
const router = useRouter()
27-
const { getMenubar, getCurrentVersion } = useLayoutStore()
27+
const { getMenubar } = useLayoutStore()
2828
const firstRedirectPath = '/admin'
2929
const version = import.meta.env.VITE_ADMIN_VERSION
3030

admin/src/layout/components/sidebar.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</template>
1919

2020
<script setup lang='ts'>
21-
import { ref, computed } from 'vue'
21+
import { computed } from 'vue'
2222
import { useRoute, useRouter } from 'vue-router'
2323
import { useLayoutStore } from '/@/store/modules/layout'
2424
import { IMenubarList } from '/@/type/store/layout'
@@ -36,6 +36,7 @@ const activeMenu = computed({
3636
get: () => {
3737
return [route.path]
3838
},
39+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
3940
set: (val) => {
4041
// do nothing, just for eliminate warn
4142
}
@@ -46,6 +47,7 @@ const openKeys = computed({
4647
const pos = route.path.lastIndexOf('/')
4748
return [route.path.substring(0, pos)]
4849
},
50+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
4951
set: (val) => {
5052
// do onthing, just for eliminate warn
5153
}

admin/src/layout/index.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<script setup lang="ts">
2-
import Header from './components/header.vue'
2+
import Header from './components/header.vue'
33
</script>
44

55
<template>
6-
<a-layout>
7-
<a-layout-header class="header">
8-
<Header />
9-
</a-layout-header>
6+
<a-layout>
7+
<a-layout-header class="header">
8+
<Header />
9+
</a-layout-header>
1010
<router-view />
1111
</a-layout>
1212
</template>

admin/src/main.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ app.use(pinia)
1515
app.mount('#app')
1616

1717
window.onunhandledrejection = (ev: PromiseRejectionEvent) => {
18-
showAlert(ev.reason.stack || ev.reason.message)
18+
showAlert(ev.reason.stack || ev.reason.message)
1919
}
2020
window.onerror = err => {
21-
if (typeof err === "string") {
22-
return showAlert(err)
23-
}
24-
showAlert(JSON.stringify(err))
21+
if (typeof err === 'string') {
22+
return showAlert(err)
23+
}
24+
showAlert(JSON.stringify(err))
2525
}
2626

2727
function showAlert(msg: string) {
28-
let layout = useLayoutStore()
29-
if (!layout.globalError) {
30-
layout.setGlobalError(msg)
31-
}
28+
const layout = useLayoutStore()
29+
if (!layout.globalError) {
30+
layout.setGlobalError(msg)
31+
}
3232
}

0 commit comments

Comments
 (0)