Skip to content

Commit e68e1b4

Browse files
committed
perf: add eslint import rules, improve the coupling of some components
1 parent fbe0fc1 commit e68e1b4

File tree

8 files changed

+130
-80
lines changed

8 files changed

+130
-80
lines changed

apps/web-antd/src/app.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ const tokenTheme = computed(() => {
3030
</script>
3131

3232
<template>
33-
<GlobalProvider>
33+
<GlobalProvider
34+
:enable-ai-assistant="preferences.app.aiAssistant"
35+
:is-mobile="preferences.app.isMobile"
36+
>
3437
<ConfigProvider :locale="antdLocale" :theme="tokenTheme">
3538
<App>
3639
<RouterView />

internal/lint-configs/eslint-config/src/custom-config.ts

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,125 @@
11
import type { Linter } from 'eslint';
22

3+
const restrictedImportIgnores = [
4+
'**/vite.config.mts',
5+
'**/tailwind.config.mjs',
6+
'**/postcss.config.mjs',
7+
];
8+
39
const customConfig: Linter.FlatConfig[] = [
10+
// shadcn-ui 内部组件是自动生成的,这里忽略
411
{
512
files: ['packages/@core/ui-kit/shadcn-ui/**/**'],
613
rules: {
714
'vue/require-default-prop': 'off',
815
},
916
},
17+
{
18+
// apps内部的一些基础规则
19+
files: ['apps/**/**'],
20+
ignores: restrictedImportIgnores,
21+
rules: {
22+
'no-restricted-imports': [
23+
'error',
24+
{
25+
patterns: [
26+
{
27+
group: ['#/api/*'],
28+
message:
29+
'The #/api package cannot be imported, please use the @core package itself',
30+
},
31+
{
32+
group: ['#/layouts/*'],
33+
message:
34+
'The #/layouts package cannot be imported, please use the @core package itself',
35+
},
36+
{
37+
group: ['#/locales/*'],
38+
message:
39+
'The #/locales package cannot be imported, please use the @core package itself',
40+
},
41+
{
42+
group: ['#/stores/*'],
43+
message:
44+
'The #/stores package cannot be imported, please use the @core package itself',
45+
},
46+
{
47+
group: ['#/forward/*'],
48+
message:
49+
'The #/forward package cannot be imported, please use the @core package itself',
50+
},
51+
],
52+
},
53+
],
54+
},
55+
},
56+
{
57+
// @core内部组件,不能引入@vben/* 里面的包
58+
files: ['packages/@core/**/**'],
59+
ignores: restrictedImportIgnores,
60+
rules: {
61+
'no-restricted-imports': [
62+
'error',
63+
{
64+
// 如果需要,可以指定禁止特定的子路径
65+
patterns: [
66+
{
67+
group: ['@vben/*'],
68+
message:
69+
'The @core package cannot import the @vben package, please use the @core package itself',
70+
},
71+
],
72+
},
73+
],
74+
},
75+
},
76+
{
77+
// @core/shared内部组件,不能引入@vben/* 或者 @vben-core/* 里面的包
78+
files: ['packages/@core/shared/**/**'],
79+
ignores: restrictedImportIgnores,
80+
rules: {
81+
'no-restricted-imports': [
82+
'error',
83+
{
84+
// 如果需要,可以指定禁止特定的子路径
85+
patterns: [
86+
{
87+
group: ['@vben/*', '@vben-core/*'],
88+
message:
89+
'The @vben-core/shared package cannot import the @vben package, please use the @core/shared package itself',
90+
},
91+
],
92+
},
93+
],
94+
},
95+
},
96+
{
97+
// 不能引入@vben/*里面的包
98+
files: [
99+
'packages/types/**/**',
100+
'packages/utils/**/**',
101+
'packages/icons/**/**',
102+
'packages/constants/**/**',
103+
'packages/styles/**/**',
104+
],
105+
ignores: restrictedImportIgnores,
106+
rules: {
107+
'no-restricted-imports': [
108+
'error',
109+
{
110+
// 如果需要,可以指定禁止特定的子路径
111+
patterns: [
112+
{
113+
group: ['@vben/*'],
114+
message:
115+
'The @vben package cannot be imported, please use the @core package itself',
116+
},
117+
],
118+
},
119+
],
120+
},
121+
},
122+
// 后端模拟代码,不需要太多规则
10123
{
11124
files: ['apps/backend-mock/**/**'],
12125
rules: {

packages/@core/locales/src/i18n.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { createI18n } from 'vue-i18n';
88

99
const loadedLanguages = new Set<string>();
1010

11-
// TODO:import.meta.env,会导致该包依赖外部项目必须是vite才可以
1211
const i18n = createI18n({
1312
globalInjection: true,
1413
legacy: false,

packages/@core/shared/toolkit/src/dom.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/**
22
* 获取元素可见高度
33
* @param element
4-
* @returns
54
*/
65
function getElementVisibleHeight(
76
element?: HTMLElement | null | undefined,

packages/@core/shared/typings/vue-router.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-restricted-imports */
12
import type { RouteMeta as IRouteMeta } from '@vben-core/typings';
23

34
import 'vue-router';
Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
<script setup lang="ts">
2-
import { preferences } from '@vben-core/preferences';
32
import { Toaster } from '@vben-core/shadcn-ui';
43
54
import { CozeAssistant } from '../coze-assistant';
65
6+
interface Props {
7+
enableAiAssistant?: boolean;
8+
isMobile?: boolean;
9+
}
10+
711
defineOptions({ name: 'GlobalProvider' });
12+
13+
withDefaults(defineProps<Props>(), {
14+
enableAiAssistant: false,
15+
isMobile: false,
16+
});
817
</script>
918
<template>
1019
<Toaster />
11-
<CozeAssistant
12-
v-if="preferences.app.aiAssistant"
13-
:is-mobile="preferences.app.isMobile"
14-
/>
20+
<CozeAssistant v-if="enableAiAssistant" :is-mobile="isMobile" />
1521
<slot></slot>
1622
</template>

packages/business/widgets/src/global-search/search-panel.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const emit = defineEmits<{ close: [] }>();
2626
2727
const router = useRouter();
2828
const searchHistory = useLocalStorage<MenuRecordRaw[]>(
29-
`__search-history-${import.meta.env.PROD ? 'prod' : 'dev'}__`,
29+
`__search-history-${location.hostname}__`,
3030
[],
3131
);
3232
const activeIndex = ref(-1);

scripts/vsh/src/aggregate-changelog/index.ts

Lines changed: 0 additions & 71 deletions
This file was deleted.

0 commit comments

Comments
 (0)