@chatbi-v/config 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +108 -0
- package/base.json +23 -0
- package/eslint.mjs +71 -0
- package/index.js +4 -0
- package/package.json +38 -0
- package/prettier.js +15 -0
- package/tailwind.js +59 -0
package/README.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# @chatbi-v/config
|
|
2
|
+
|
|
3
|
+
ChatBI-V 项目的统一配置包,包含 ESLint, Prettier, Tailwind CSS 和 TypeScript 的共享配置。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add -D @chatbi-v/config
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 使用指南
|
|
12
|
+
|
|
13
|
+
### 1. ESLint 配置
|
|
14
|
+
|
|
15
|
+
在项目根目录创建 `eslint.config.mjs`:
|
|
16
|
+
|
|
17
|
+
```javascript
|
|
18
|
+
import chatbiConfig from '@chatbi-v/config/eslint';
|
|
19
|
+
|
|
20
|
+
export default [
|
|
21
|
+
...chatbiConfig,
|
|
22
|
+
{
|
|
23
|
+
// 你的自定义配置
|
|
24
|
+
rules: {
|
|
25
|
+
// ...
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
];
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### 2. Prettier 配置
|
|
32
|
+
|
|
33
|
+
在项目根目录创建 `.prettierrc.js` 或 `prettier.config.js`:
|
|
34
|
+
|
|
35
|
+
```javascript
|
|
36
|
+
module.exports = require('@chatbi-v/config/prettier');
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
或者在 `package.json` 中:
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"prettier": "@chatbi-v/config/prettier"
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### 3. Tailwind CSS 配置
|
|
48
|
+
|
|
49
|
+
在项目根目录创建 `tailwind.config.js`:
|
|
50
|
+
|
|
51
|
+
```javascript
|
|
52
|
+
const baseConfig = require('@chatbi-v/config/tailwind');
|
|
53
|
+
|
|
54
|
+
/** @type {import('tailwindcss').Config} */
|
|
55
|
+
module.exports = {
|
|
56
|
+
...baseConfig,
|
|
57
|
+
content: [
|
|
58
|
+
"./index.html",
|
|
59
|
+
"./src/**/*.{js,ts,jsx,tsx}",
|
|
60
|
+
// 如果是 Monorepo,可能需要包含其他包
|
|
61
|
+
"../../packages/ui/src/**/*.{js,ts,jsx,tsx}"
|
|
62
|
+
],
|
|
63
|
+
theme: {
|
|
64
|
+
extend: {
|
|
65
|
+
...baseConfig.theme.extend,
|
|
66
|
+
// 你的自定义主题
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 4. TypeScript 配置
|
|
73
|
+
|
|
74
|
+
在项目根目录创建 `tsconfig.json`:
|
|
75
|
+
|
|
76
|
+
```json
|
|
77
|
+
{
|
|
78
|
+
"extends": "@chatbi-v/config/base.json",
|
|
79
|
+
"compilerOptions": {
|
|
80
|
+
"baseUrl": ".",
|
|
81
|
+
"outDir": "dist"
|
|
82
|
+
},
|
|
83
|
+
"include": ["src"]
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## 配置详情
|
|
88
|
+
|
|
89
|
+
### ESLint
|
|
90
|
+
- 基于 `eslint-config-standard`
|
|
91
|
+
- 集成 `@typescript-eslint`
|
|
92
|
+
- 集成 `eslint-plugin-react` 和 `eslint-plugin-react-hooks`
|
|
93
|
+
- 强制 import 排序 (`simple-import-sort`)
|
|
94
|
+
|
|
95
|
+
### Tailwind
|
|
96
|
+
- 预定义颜色系统(Primary, Secondary, Accent 等)
|
|
97
|
+
- 预定义阴影效果(Neon, Glass)
|
|
98
|
+
- 自动关闭 Preflight(避免与 Ant Design 冲突)
|
|
99
|
+
|
|
100
|
+
### TypeScript
|
|
101
|
+
- 严格模式 (`strict: true`)
|
|
102
|
+
- 目标版本 `ESNext`
|
|
103
|
+
- 模块解析 `bundler`
|
|
104
|
+
|
|
105
|
+
## 维护
|
|
106
|
+
|
|
107
|
+
- **Author**: ChatBI Team
|
|
108
|
+
- **License**: MIT
|
package/base.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"//": "共享的 TypeScript 基础配置,定义了 ChatBI-V 项目的编译标准",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"target": "ESNext",
|
|
5
|
+
"useDefineForClassFields": true,
|
|
6
|
+
"lib": ["DOM", "DOM.Iterable", "ESNext"],
|
|
7
|
+
"allowJs": false,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"esModuleInterop": false,
|
|
10
|
+
"allowSyntheticDefaultImports": true,
|
|
11
|
+
"strict": true,
|
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
|
13
|
+
"module": "ESNext",
|
|
14
|
+
"moduleResolution": "bundler",
|
|
15
|
+
"resolveJsonModule": true,
|
|
16
|
+
"isolatedModules": true,
|
|
17
|
+
"jsx": "react-jsx",
|
|
18
|
+
"composite": true,
|
|
19
|
+
"declaration": true,
|
|
20
|
+
"declarationMap": false,
|
|
21
|
+
"sourceMap": false
|
|
22
|
+
}
|
|
23
|
+
}
|
package/eslint.mjs
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file eslint.mjs
|
|
3
|
+
* @description 共享的 ESLint 配置,支持 TypeScript、React、React Hooks 和导入排序
|
|
4
|
+
* @author ChatBI Team
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import js from '@eslint/js';
|
|
8
|
+
import tsPlugin from '@typescript-eslint/eslint-plugin';
|
|
9
|
+
import tsParser from '@typescript-eslint/parser';
|
|
10
|
+
import reactPlugin from 'eslint-plugin-react';
|
|
11
|
+
import reactHooksPlugin from 'eslint-plugin-react-hooks';
|
|
12
|
+
import simpleImportSortPlugin from 'eslint-plugin-simple-import-sort';
|
|
13
|
+
import globals from 'globals';
|
|
14
|
+
|
|
15
|
+
export default [
|
|
16
|
+
{
|
|
17
|
+
ignores: ['**/dist/**', '**/build/**', '**/node_modules/**', '**/.trae/**'],
|
|
18
|
+
},
|
|
19
|
+
js.configs.recommended,
|
|
20
|
+
{
|
|
21
|
+
files: ['**/*.js', '**/*.cjs'],
|
|
22
|
+
languageOptions: {
|
|
23
|
+
sourceType: 'commonjs',
|
|
24
|
+
globals: {
|
|
25
|
+
...globals.node,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
files: ['**/*.ts', '**/*.tsx'],
|
|
31
|
+
languageOptions: {
|
|
32
|
+
parser: tsParser,
|
|
33
|
+
parserOptions: {
|
|
34
|
+
ecmaVersion: 'latest',
|
|
35
|
+
sourceType: 'module',
|
|
36
|
+
ecmaFeatures: {
|
|
37
|
+
jsx: true,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
globals: {
|
|
41
|
+
...globals.browser,
|
|
42
|
+
...globals.node,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
plugins: {
|
|
46
|
+
'@typescript-eslint': tsPlugin,
|
|
47
|
+
'react': reactPlugin,
|
|
48
|
+
'react-hooks': reactHooksPlugin,
|
|
49
|
+
'simple-import-sort': simpleImportSortPlugin,
|
|
50
|
+
},
|
|
51
|
+
rules: {
|
|
52
|
+
...tsPlugin.configs.recommended.rules,
|
|
53
|
+
...reactPlugin.configs.recommended.rules,
|
|
54
|
+
...reactHooksPlugin.configs.recommended.rules,
|
|
55
|
+
'simple-import-sort/imports': 'error',
|
|
56
|
+
'simple-import-sort/exports': 'error',
|
|
57
|
+
'react/react-in-jsx-scope': 'off', // Not needed in React 17+
|
|
58
|
+
'react/prop-types': 'off', // TS covers this
|
|
59
|
+
'react/display-name': 'off', // TS inference is usually enough
|
|
60
|
+
'no-undef': 'off', // TS covers this
|
|
61
|
+
'@typescript-eslint/no-explicit-any': 'warn',
|
|
62
|
+
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
|
|
63
|
+
'no-console': ['warn', { allow: ['warn', 'error', 'info'] }],
|
|
64
|
+
},
|
|
65
|
+
settings: {
|
|
66
|
+
react: {
|
|
67
|
+
version: 'detect',
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
];
|
package/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@chatbi-v/config",
|
|
3
|
+
"version": "2.1.0",
|
|
4
|
+
"main": "./index.js",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./index.js",
|
|
11
|
+
"./eslint": "./eslint.mjs",
|
|
12
|
+
"./prettier": "./prettier.js",
|
|
13
|
+
"./tailwind": "./tailwind.js",
|
|
14
|
+
"./base.json": "./base.json",
|
|
15
|
+
"./package.json": "./package.json"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"index.js",
|
|
19
|
+
"eslint.mjs",
|
|
20
|
+
"prettier.js",
|
|
21
|
+
"tailwind.js",
|
|
22
|
+
"base.json"
|
|
23
|
+
],
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@eslint/js": "^9.0.0",
|
|
26
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
27
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
28
|
+
"eslint-plugin-react": "^7.33.0",
|
|
29
|
+
"eslint-plugin-react-hooks": "^7.0.0",
|
|
30
|
+
"eslint-plugin-simple-import-sort": "^12.0.0",
|
|
31
|
+
"globals": "^15.0.0"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"eslint": "^9.0.0",
|
|
35
|
+
"typescript": "^5.0.0",
|
|
36
|
+
"tailwindcss": "^3.0.0"
|
|
37
|
+
}
|
|
38
|
+
}
|
package/prettier.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file prettier.js
|
|
3
|
+
* @description 共享的 Prettier 配置
|
|
4
|
+
* @author ChatBI Team
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
module.exports = {
|
|
8
|
+
semi: true,
|
|
9
|
+
tabWidth: 2,
|
|
10
|
+
printWidth: 100,
|
|
11
|
+
singleQuote: true,
|
|
12
|
+
trailingComma: 'all',
|
|
13
|
+
jsxSingleQuote: false,
|
|
14
|
+
bracketSpacing: true,
|
|
15
|
+
};
|
package/tailwind.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file tailwind.js
|
|
3
|
+
* @description 共享的 Tailwind CSS 配置,定义了项目的主题色、圆角、阴影及自定义变体
|
|
4
|
+
* @author ChatBI Team
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const { green, red } = require('tailwindcss/colors');
|
|
8
|
+
const plugin = require('tailwindcss/plugin');
|
|
9
|
+
|
|
10
|
+
/** @type {import('tailwindcss').Config} */
|
|
11
|
+
module.exports = {
|
|
12
|
+
// ① 关闭 Preflight,避免与 antd 的 normalize 冲突
|
|
13
|
+
corePlugins: { preflight: false },
|
|
14
|
+
// ② 只在 #root 容器内让 utilities 权重+1,解决优先级问题
|
|
15
|
+
// important: '#root',
|
|
16
|
+
theme: {
|
|
17
|
+
extend: {
|
|
18
|
+
colors: {
|
|
19
|
+
background: 'rgb(var(--color-background) / <alpha-value>)',
|
|
20
|
+
surface: 'rgb(var(--color-surface) / <alpha-value>)',
|
|
21
|
+
primary: 'rgb(var(--color-primary) / <alpha-value>)',
|
|
22
|
+
secondary: 'rgb(var(--color-secondary) / <alpha-value>)',
|
|
23
|
+
accent: 'rgb(var(--color-accent) / <alpha-value>)',
|
|
24
|
+
'text-main': 'rgb(var(--color-text-main) / <alpha-value>)',
|
|
25
|
+
'text-muted': 'rgb(var(--color-text-muted) / <alpha-value>)',
|
|
26
|
+
border: 'rgb(var(--color-border) / <alpha-value>)',
|
|
27
|
+
// ③ 与 antd 的 Less 变量保持同步,AI 可直接用 text-success / text-danger
|
|
28
|
+
success: green[500], // @success-color
|
|
29
|
+
danger: red[500], // @error-color
|
|
30
|
+
},
|
|
31
|
+
backgroundImage: {
|
|
32
|
+
'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))',
|
|
33
|
+
glass:
|
|
34
|
+
'linear-gradient(145deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.01) 100%)',
|
|
35
|
+
},
|
|
36
|
+
borderRadius: {
|
|
37
|
+
DEFAULT: '6px', // @border-radius-base
|
|
38
|
+
lg: '8px',
|
|
39
|
+
xl: '12px',
|
|
40
|
+
},
|
|
41
|
+
boxShadow: {
|
|
42
|
+
neon: '0 0 10px rgb(var(--color-primary) / 0.5), 0 0 20px rgb(var(--color-primary) / 0.3)',
|
|
43
|
+
glass: '0 8px 32px 0 rgba(0, 0, 0, 0.37)',
|
|
44
|
+
},
|
|
45
|
+
fontSize: {
|
|
46
|
+
sm: ['12px', '20px'], // @font-size-sm
|
|
47
|
+
base: ['14px', '22px'], // @font-size-base
|
|
48
|
+
lg: ['16px', '24px'], // @font-size-lg
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
plugins: [
|
|
53
|
+
// 注册自定义 variant: perf
|
|
54
|
+
// 使用方法: perf:shadow-none perf:backdrop-none
|
|
55
|
+
plugin(function({ addVariant }) {
|
|
56
|
+
addVariant('perf', 'body.perf-mode &');
|
|
57
|
+
}),
|
|
58
|
+
],
|
|
59
|
+
};
|