Skip to content

Commit cbcafb8

Browse files
committed
feat(ESLint): 迁移并优化有关代码
1 parent ae2b680 commit cbcafb8

69 files changed

Lines changed: 274 additions & 180 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

eslint.config.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ import typescript from 'typescript-eslint';
1010

1111
export default antfu(
1212
{
13-
formatters: true,
1413
typescript: true,
1514
vue: true,
15+
jsonc: false,
16+
yaml: false,
17+
markdown: false,
18+
formatters: false,
1619
},
1720
[
1821
...typescript.configs.recommended,
@@ -51,11 +54,16 @@ export default antfu(
5154
},
5255

5356
rules: {
57+
/* Closed due to template running
58+
* (Recommended to open!)
59+
*/
60+
'no-console': 'off',
5461
'ts/no-explicit-any': 'off',
5562

5663
/* Disallow person rules */
5764
'antfu/top-level-function': 'off',
5865
'antfu/if-newline': 'off',
66+
'n/prefer-global/process': 'off',
5967

6068
/* If you need control the imports sequence, must be off
6169
* https://github.com/vuejs/vue-eslint-parser/issues/58
@@ -100,16 +108,27 @@ export default antfu(
100108

101109
rules: {
102110
'vue/component-name-in-template-casing': ['error', 'kebab-case'],
111+
'vue/custom-event-name-casing': ['error', 'kebab-case'],
103112
'vue/block-order': [
104113
'error',
105114
{
106115
order: ['template', 'script', 'style'],
107116
},
108117
],
118+
'vue/block-lang': [
119+
'error',
120+
{
121+
script: {
122+
lang: ['ts', 'tsx'],
123+
},
124+
},
125+
],
109126
'vue/multi-word-component-names': 'off',
110127
'vue/no-reserved-props': 'off',
111128
'vue/no-v-html': 'off',
112129

130+
'vue-scoped-css/no-parsing-error': 'off',
131+
'vue-scoped-css/no-unused-selector': 'off',
113132
'vue-scoped-css/enforce-style-type': [
114133
'error',
115134
{

mock/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Mock from 'mockjs';
2-
import { MockMethod } from 'vite-plugin-mock';
2+
import type { MockMethod } from 'vite-plugin-mock';
33

44
export default [
55
{
@@ -11,7 +11,7 @@ export default [
1111
...Mock.mock({
1212
'list|1-100': [
1313
{
14-
index: /S20201228115950[0-9][0-9][0-9]/,
14+
index: /S20201228115950\d\d\d/,
1515
pdName: 'Macbook',
1616
pdNum: 'p_tmp_60a637cd0d',
1717
'purchaseNum|1-100': 100,
@@ -20,7 +20,7 @@ export default [
2020
pdType: '电子产品',
2121
},
2222
{
23-
index: /S20201228115950[0-9][0-9][0-9]/,
23+
index: /S20201228115950\d\d\d/,
2424
pdName: 'Macbook',
2525
pdNum: 'p_tmp_60a637cd0d',
2626
'purchaseNum|1-100': 100,

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"preview": "vite preview",
1414
"lint": "eslint --ext .vue,.js,.jsx,.ts,.tsx ./ --max-warnings 0",
1515
"lint:fix": "eslint --ext .vue,.js,jsx,.ts,.tsx ./ --max-warnings 0 --fix",
16-
"stylelint": "stylelint src/**/*.{html,vue,sass,less}",
16+
"stylelint": "stylelint src/**/*.{html,vue,css,sass,less}",
1717
"stylelint:fix": "stylelint --fix src/**/*.{html,vue,css,sass,less}",
1818
"prepare": "husky install",
1919
"site:preview": "npm run build && cp -r dist _site",
@@ -55,7 +55,6 @@
5555
"cz-conventional-changelog": "^3.3.0",
5656
"eslint": "^9.22.0",
5757
"eslint-config-prettier": "^10.1.1",
58-
"eslint-plugin-format": "^1.0.1",
5958
"eslint-plugin-prettier": "^5.2.3",
6059
"eslint-plugin-simple-import-sort": "^12.1.1",
6160
"eslint-plugin-vue": "^10.0.0",
@@ -94,5 +93,5 @@
9493
},
9594
"engines": {
9695
"node": ">=18.18.0"
97-
},
96+
}
9897
}

src/App.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<router-view :key="locale" :class="[mode]" />
44
</t-config-provider>
55
</template>
6+
67
<script setup lang="ts">
78
import { computed } from 'vue';
89
@@ -17,6 +18,7 @@ const mode = computed(() => {
1718
1819
const { getComponentsLocale, locale } = useLocale();
1920
</script>
21+
2022
<style lang="less" scoped>
2123
#nprogress .bar {
2224
background: var(--td-brand-color) !important;

src/api/model/permissionModel.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { defineComponent } from 'vue';
1+
import type { defineComponent } from 'vue';
22

3-
import { RouteMeta } from '@/types/interface';
3+
import type { RouteMeta } from '@/types/interface';
44

55
export interface MenuListResult {
66
list: Array<RouteItem>;

src/components/color/index.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
<template>
22
<div :style="style" class="color-container" />
33
</template>
4+
45
<script setup lang="ts">
56
import { computed } from 'vue';
67
78
import { DEFAULT_COLOR_OPTIONS } from '@/config/color';
89
9-
const panelColor =
10-
'conic-gradient(from 90deg at 50% 50%, #FF0000 -19.41deg, #FF0000 18.76deg, #FF8A00 59.32deg, #FFE600 99.87deg, #14FF00 141.65deg, #00A3FF 177.72deg, #0500FF 220.23deg, #AD00FF 260.13deg, #FF00C7 300.69deg, #FF0000 340.59deg, #FF0000 378.76deg)';
11-
1210
const { value } = defineProps({
1311
value: {
1412
type: String,
13+
default: '',
1514
},
1615
});
1716
17+
const panelColor =
18+
'conic-gradient(from 90deg at 50% 50%, #FF0000 -19.41deg, #FF0000 18.76deg, #FF8A00 59.32deg, #FFE600 99.87deg, #14FF00 141.65deg, #00A3FF 177.72deg, #0500FF 220.23deg, #AD00FF 260.13deg, #FF00C7 300.69deg, #FF0000 340.59deg, #FF0000 378.76deg)';
19+
1820
const style = computed(() => {
1921
return {
20-
background: DEFAULT_COLOR_OPTIONS.indexOf(value) > -1 ? value : panelColor,
22+
background: DEFAULT_COLOR_OPTIONS.includes(value) ? value : panelColor,
2123
};
2224
});
2325
</script>

src/components/common-table/index.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="list-common-table">
3-
<t-form ref="form" :data="formData" :label-width="80" colon @reset="onReset" @submit="onSubmit">
3+
<t-form :data="formData" :label-width="80" colon @reset="onReset" @submit="onSubmit">
44
<t-row>
55
<t-col :span="10">
66
<t-row :gutter="[24, 24]">
@@ -122,8 +122,10 @@
122122
</div>
123123
</div>
124124
</template>
125+
125126
<script setup lang="ts">
126-
import { MessagePlugin, PageInfo, PrimaryTableCol, TableRowData } from 'tdesign-vue-next';
127+
import type { PageInfo, PrimaryTableCol, TableRowData } from 'tdesign-vue-next';
128+
import { MessagePlugin } from 'tdesign-vue-next';
127129
import { computed, onMounted, ref } from 'vue';
128130
import { useRouter } from 'vue-router';
129131

src/components/product-card/index.vue

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
<template #avatar>
44
<t-avatar size="56px">
55
<template #icon>
6-
<shop-icon v-if="product.type === 1" />
7-
<calendar-icon v-if="product.type === 2" />
8-
<service-icon v-if="product.type === 3" />
9-
<user-avatar-icon v-if="product.type === 4" />
10-
<laptop-icon v-if="product.type === 5" />
6+
<shop-icon v-if="props.product.type === 1" />
7+
<calendar-icon v-if="props.product.type === 2" />
8+
<service-icon v-if="props.product.type === 3" />
9+
<user-avatar-icon v-if="props.product.type === 4" />
10+
<laptop-icon v-if="props.product.type === 5" />
1111
</template>
1212
</t-avatar>
1313
</template>
1414
<template #status>
15-
<t-tag :theme="product.isSetup ? 'success' : 'default'" :disabled="!product.isSetup">{{
16-
product.isSetup ? t('components.isSetup.on') : t('components.isSetup.off')
17-
}}</t-tag>
15+
<t-tag :theme="props.product.isSetup ? 'success' : 'default'" :disabled="!props.product.isSetup">
16+
{{ props.product.isSetup ? t('components.isSetup.on') : t('components.isSetup.off') }}
17+
</t-tag>
1818
</template>
1919
<template #content>
20-
<p class="list-card-item_detail--name">{{ product.name }}</p>
21-
<p class="list-card-item_detail--desc">{{ product.description }}</p>
20+
<p class="list-card-item_detail--name">{{ props.product.name }}</p>
21+
<p class="list-card-item_detail--desc">{{ props.product.description }}</p>
2222
</template>
2323
<template #footer>
2424
<t-avatar-group cascading="left-up" :max="2">
@@ -32,28 +32,29 @@
3232
</template>
3333
<template #actions>
3434
<t-dropdown
35-
:disabled="!product.isSetup"
35+
:disabled="!props.product.isSetup"
3636
trigger="click"
3737
:options="[
3838
{
3939
content: t('components.manage'),
4040
value: 'manage',
41-
onClick: () => handleClickManage(product),
41+
onClick: () => handleClickManage(props.product),
4242
},
4343
{
4444
content: t('components.delete'),
4545
value: 'delete',
46-
onClick: () => handleClickDelete(product),
46+
onClick: () => handleClickDelete(props.product),
4747
},
4848
]"
4949
>
50-
<t-button theme="default" :disabled="!product.isSetup" shape="square" variant="text">
50+
<t-button theme="default" :disabled="!props.product.isSetup" shape="square" variant="text">
5151
<more-icon />
5252
</t-button>
5353
</t-dropdown>
5454
</template>
5555
</t-card>
5656
</template>
57+
5758
<script setup lang="ts">
5859
import {
5960
AddIcon,
@@ -75,10 +76,10 @@ export interface CardProductType {
7576
name: string;
7677
}
7778
78-
// eslint-disable-next-line
7979
const props = defineProps({
8080
product: {
8181
type: Object as PropType<CardProductType>,
82+
default: undefined,
8283
},
8384
});
8485

src/components/result/index.vue

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<slot />
99
</div>
1010
</template>
11+
1112
<script setup lang="ts">
1213
import { computed } from 'vue';
1314
@@ -19,10 +20,22 @@ import ResultMaintenanceIcon from '@/assets/assets-result-maintenance.svg?compon
1920
import ResultWifiIcon from '@/assets/assets-result-wifi.svg?component';
2021
2122
const { type } = defineProps({
22-
bgUrl: String,
23-
title: String,
24-
tip: String,
25-
type: String,
23+
bgUrl: {
24+
type: String,
25+
default: '',
26+
},
27+
title: {
28+
type: String,
29+
default: '',
30+
},
31+
tip: {
32+
type: String,
33+
default: '',
34+
},
35+
type: {
36+
type: String,
37+
default: '',
38+
},
2639
});
2740
2841
const dynamicComponent = computed(() => {
@@ -44,6 +57,7 @@ const dynamicComponent = computed(() => {
4457
}
4558
});
4659
</script>
60+
4761
<style lang="less" scoped>
4862
.result {
4963
&-link {

src/components/thumbnail/index.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
<template>
22
<img :class="className" :src="url" />
33
</template>
4+
45
<script setup lang="ts">
56
import { computed } from 'vue';
67
78
const { type } = defineProps({
8-
url: String,
9+
url: {
10+
type: String,
11+
default: '',
12+
},
913
type: {
1014
type: String,
1115
default: 'layout',
@@ -22,6 +26,7 @@ const className = computed(() => {
2226
];
2327
});
2428
</script>
29+
2530
<style lang="less" scoped>
2631
@import '@/style/index.less';
2732

0 commit comments

Comments
 (0)