perf: add eslint import rules, improve the coupling of some components
This commit is contained in:
@@ -1,12 +1,125 @@
|
||||
import type { Linter } from 'eslint';
|
||||
|
||||
const restrictedImportIgnores = [
|
||||
'**/vite.config.mts',
|
||||
'**/tailwind.config.mjs',
|
||||
'**/postcss.config.mjs',
|
||||
];
|
||||
|
||||
const customConfig: Linter.FlatConfig[] = [
|
||||
// shadcn-ui 内部组件是自动生成的,这里忽略
|
||||
{
|
||||
files: ['packages/@core/ui-kit/shadcn-ui/**/**'],
|
||||
rules: {
|
||||
'vue/require-default-prop': 'off',
|
||||
},
|
||||
},
|
||||
{
|
||||
// apps内部的一些基础规则
|
||||
files: ['apps/**/**'],
|
||||
ignores: restrictedImportIgnores,
|
||||
rules: {
|
||||
'no-restricted-imports': [
|
||||
'error',
|
||||
{
|
||||
patterns: [
|
||||
{
|
||||
group: ['#/api/*'],
|
||||
message:
|
||||
'The #/api package cannot be imported, please use the @core package itself',
|
||||
},
|
||||
{
|
||||
group: ['#/layouts/*'],
|
||||
message:
|
||||
'The #/layouts package cannot be imported, please use the @core package itself',
|
||||
},
|
||||
{
|
||||
group: ['#/locales/*'],
|
||||
message:
|
||||
'The #/locales package cannot be imported, please use the @core package itself',
|
||||
},
|
||||
{
|
||||
group: ['#/stores/*'],
|
||||
message:
|
||||
'The #/stores package cannot be imported, please use the @core package itself',
|
||||
},
|
||||
{
|
||||
group: ['#/forward/*'],
|
||||
message:
|
||||
'The #/forward package cannot be imported, please use the @core package itself',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
// @core内部组件,不能引入@vben/* 里面的包
|
||||
files: ['packages/@core/**/**'],
|
||||
ignores: restrictedImportIgnores,
|
||||
rules: {
|
||||
'no-restricted-imports': [
|
||||
'error',
|
||||
{
|
||||
// 如果需要,可以指定禁止特定的子路径
|
||||
patterns: [
|
||||
{
|
||||
group: ['@vben/*'],
|
||||
message:
|
||||
'The @core package cannot import the @vben package, please use the @core package itself',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
// @core/shared内部组件,不能引入@vben/* 或者 @vben-core/* 里面的包
|
||||
files: ['packages/@core/shared/**/**'],
|
||||
ignores: restrictedImportIgnores,
|
||||
rules: {
|
||||
'no-restricted-imports': [
|
||||
'error',
|
||||
{
|
||||
// 如果需要,可以指定禁止特定的子路径
|
||||
patterns: [
|
||||
{
|
||||
group: ['@vben/*', '@vben-core/*'],
|
||||
message:
|
||||
'The @vben-core/shared package cannot import the @vben package, please use the @core/shared package itself',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
// 不能引入@vben/*里面的包
|
||||
files: [
|
||||
'packages/types/**/**',
|
||||
'packages/utils/**/**',
|
||||
'packages/icons/**/**',
|
||||
'packages/constants/**/**',
|
||||
'packages/styles/**/**',
|
||||
],
|
||||
ignores: restrictedImportIgnores,
|
||||
rules: {
|
||||
'no-restricted-imports': [
|
||||
'error',
|
||||
{
|
||||
// 如果需要,可以指定禁止特定的子路径
|
||||
patterns: [
|
||||
{
|
||||
group: ['@vben/*'],
|
||||
message:
|
||||
'The @vben package cannot be imported, please use the @core package itself',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
// 后端模拟代码,不需要太多规则
|
||||
{
|
||||
files: ['apps/backend-mock/**/**'],
|
||||
rules: {
|
||||
|
Reference in New Issue
Block a user