@coze-arch/cli 0.0.1-alpha.de5a13 → 0.0.1-alpha.deaedf
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 +1 -0
- package/lib/__templates__/expo/.cozeproj/scripts/server_dev_run.sh +1 -1
- package/lib/__templates__/expo/client/components/Screen.tsx +2 -2
- package/lib/__templates__/expo/client/eslint.config.mjs +7 -0
- package/lib/__templates__/expo/client/metro.config.js +3 -0
- package/lib/__templates__/expo/client/scripts/install-missing-deps.js +10 -10
- package/lib/__templates__/expo/eslint-plugins/forbid-emoji/index.js +9 -0
- package/lib/__templates__/expo/eslint-plugins/forbid-emoji/rule.js +112 -0
- package/lib/__templates__/expo/eslint-plugins/forbid-emoji/tech.md +94 -0
- package/lib/__templates__/expo/eslint-plugins/restrict-linear-gradient/index.js +9 -0
- package/lib/__templates__/expo/eslint-plugins/restrict-linear-gradient/rule.js +120 -0
- package/lib/__templates__/expo/eslint-plugins/restrict-linear-gradient/tech.md +58 -0
- package/lib/__templates__/expo/pnpm-lock.yaml +8 -5
- package/lib/__templates__/expo/server/package.json +1 -1
- package/lib/__templates__/native-static/.coze +11 -0
- package/lib/__templates__/native-static/index.html +33 -0
- package/lib/__templates__/native-static/styles/main.css +136 -0
- package/lib/__templates__/native-static/template.config.js +22 -0
- package/lib/__templates__/nextjs/.babelrc +3 -0
- package/lib/__templates__/nextjs/README.md +5 -0
- package/lib/__templates__/nextjs/eslint.config.mjs +5 -0
- package/lib/__templates__/nextjs/next.config.ts +1 -2
- package/lib/__templates__/nextjs/package.json +3 -6
- package/lib/__templates__/nextjs/pnpm-lock.yaml +1036 -10
- package/lib/__templates__/nextjs/scripts/build.sh +4 -1
- package/lib/__templates__/nextjs/scripts/dev.sh +8 -2
- package/lib/__templates__/nextjs/scripts/start.sh +7 -1
- package/lib/__templates__/nextjs/src/app/layout.tsx +1 -1
- package/lib/__templates__/nextjs/src/app/page.tsx +1 -2
- package/lib/__templates__/nextjs/src/server.ts +35 -0
- package/lib/__templates__/nextjs/tsconfig.json +1 -1
- package/lib/__templates__/nuxt-vue/.coze +12 -0
- package/lib/__templates__/nuxt-vue/README.md +73 -0
- package/lib/__templates__/nuxt-vue/_gitignore +24 -0
- package/lib/__templates__/nuxt-vue/_npmrc +23 -0
- package/lib/__templates__/nuxt-vue/app/app.vue +6 -0
- package/lib/__templates__/nuxt-vue/app/pages/index.vue +23 -0
- package/lib/__templates__/nuxt-vue/assets/css/main.css +24 -0
- package/lib/__templates__/nuxt-vue/nuxt.config.ts +116 -0
- package/lib/__templates__/nuxt-vue/package.json +35 -0
- package/lib/__templates__/nuxt-vue/pnpm-lock.yaml +8759 -0
- package/lib/__templates__/nuxt-vue/postcss.config.mjs +8 -0
- package/lib/__templates__/nuxt-vue/public/favicon.ico +0 -0
- package/lib/__templates__/nuxt-vue/public/robots.txt +2 -0
- package/lib/__templates__/nuxt-vue/scripts/build.sh +14 -0
- package/lib/__templates__/nuxt-vue/scripts/dev.sh +39 -0
- package/lib/__templates__/nuxt-vue/scripts/prepare.sh +14 -0
- package/lib/__templates__/nuxt-vue/scripts/start.sh +21 -0
- package/lib/__templates__/nuxt-vue/server/api/hello.ts +10 -0
- package/lib/__templates__/nuxt-vue/server/middleware/logger.ts +10 -0
- package/lib/__templates__/nuxt-vue/server/routes/health.ts +10 -0
- package/lib/__templates__/nuxt-vue/tailwind.config.js +13 -0
- package/lib/__templates__/nuxt-vue/template.config.js +87 -0
- package/lib/__templates__/nuxt-vue/tsconfig.json +18 -0
- package/lib/__templates__/taro/.cozeproj/scripts/dev_run.sh +107 -37
- package/lib/__templates__/taro/.cozeproj/scripts/pack.sh +24 -1
- package/lib/__templates__/taro/README.md +138 -62
- package/lib/__templates__/taro/config/index.ts +105 -41
- package/lib/__templates__/taro/config/prod.ts +4 -5
- package/lib/__templates__/taro/eslint.config.mjs +82 -4
- package/lib/__templates__/taro/package.json +23 -7
- package/lib/__templates__/taro/patches/@tarojs__plugin-mini-ci@4.1.9.patch +30 -0
- package/lib/__templates__/taro/pnpm-lock.yaml +1198 -214
- package/lib/__templates__/taro/server/package.json +3 -1
- package/lib/__templates__/taro/src/app.css +140 -47
- package/lib/__templates__/taro/src/app.tsx +9 -0
- package/lib/__templates__/taro/src/components/ui/accordion.tsx +159 -0
- package/lib/__templates__/taro/src/components/ui/alert-dialog.tsx +260 -0
- package/lib/__templates__/taro/src/components/ui/alert.tsx +60 -0
- package/lib/__templates__/taro/src/components/ui/aspect-ratio.tsx +36 -0
- package/lib/__templates__/taro/src/components/ui/avatar.tsx +84 -0
- package/lib/__templates__/taro/src/components/ui/badge.tsx +37 -0
- package/lib/__templates__/taro/src/components/ui/breadcrumb.tsx +117 -0
- package/lib/__templates__/taro/src/components/ui/button-group.tsx +83 -0
- package/lib/__templates__/taro/src/components/ui/button.tsx +67 -0
- package/lib/__templates__/taro/src/components/ui/calendar.tsx +394 -0
- package/lib/__templates__/taro/src/components/ui/card.tsx +108 -0
- package/lib/__templates__/taro/src/components/ui/carousel.tsx +228 -0
- package/lib/__templates__/taro/src/components/ui/checkbox.tsx +58 -0
- package/lib/__templates__/taro/src/components/ui/code-block.tsx +169 -0
- package/lib/__templates__/taro/src/components/ui/collapsible.tsx +71 -0
- package/lib/__templates__/taro/src/components/ui/command.tsx +385 -0
- package/lib/__templates__/taro/src/components/ui/context-menu.tsx +614 -0
- package/lib/__templates__/taro/src/components/ui/dialog.tsx +256 -0
- package/lib/__templates__/taro/src/components/ui/drawer.tsx +192 -0
- package/lib/__templates__/taro/src/components/ui/dropdown-menu.tsx +561 -0
- package/lib/__templates__/taro/src/components/ui/field.tsx +228 -0
- package/lib/__templates__/taro/src/components/ui/hover-card.tsx +282 -0
- package/lib/__templates__/taro/src/components/ui/input-group.tsx +197 -0
- package/lib/__templates__/taro/src/components/ui/input-otp.tsx +136 -0
- package/lib/__templates__/taro/src/components/ui/input.tsx +56 -0
- package/lib/__templates__/taro/src/components/ui/label.tsx +24 -0
- package/lib/__templates__/taro/src/components/ui/menubar.tsx +595 -0
- package/lib/__templates__/taro/src/components/ui/navigation-menu.tsx +264 -0
- package/lib/__templates__/taro/src/components/ui/pagination.tsx +118 -0
- package/lib/__templates__/taro/src/components/ui/popover.tsx +291 -0
- package/lib/__templates__/taro/src/components/ui/portal.tsx +19 -0
- package/lib/__templates__/taro/src/components/ui/progress.tsx +28 -0
- package/lib/__templates__/taro/src/components/ui/radio-group.tsx +64 -0
- package/lib/__templates__/taro/src/components/ui/resizable.tsx +346 -0
- package/lib/__templates__/taro/src/components/ui/scroll-area.tsx +34 -0
- package/lib/__templates__/taro/src/components/ui/select.tsx +438 -0
- package/lib/__templates__/taro/src/components/ui/separator.tsx +30 -0
- package/lib/__templates__/taro/src/components/ui/sheet.tsx +262 -0
- package/lib/__templates__/taro/src/components/ui/skeleton.tsx +17 -0
- package/lib/__templates__/taro/src/components/ui/slider.tsx +203 -0
- package/lib/__templates__/taro/src/components/ui/sonner.tsx +1 -0
- package/lib/__templates__/taro/src/components/ui/switch.tsx +55 -0
- package/lib/__templates__/taro/src/components/ui/table.tsx +142 -0
- package/lib/__templates__/taro/src/components/ui/tabs.tsx +114 -0
- package/lib/__templates__/taro/src/components/ui/textarea.tsx +54 -0
- package/lib/__templates__/taro/src/components/ui/toast.tsx +517 -0
- package/lib/__templates__/taro/src/components/ui/toggle-group.tsx +120 -0
- package/lib/__templates__/taro/src/components/ui/toggle.tsx +77 -0
- package/lib/__templates__/taro/src/components/ui/tooltip.tsx +455 -0
- package/lib/__templates__/taro/src/lib/hooks/use-keyboard-offset.ts +37 -0
- package/lib/__templates__/taro/src/lib/measure.ts +115 -0
- package/lib/__templates__/taro/src/lib/platform.ts +12 -0
- package/lib/__templates__/taro/src/lib/utils.ts +6 -0
- package/lib/__templates__/taro/src/presets/dev-debug.ts +23 -0
- package/lib/__templates__/taro/src/presets/h5-container.tsx +15 -0
- package/lib/__templates__/taro/src/presets/h5-navbar.tsx +238 -0
- package/lib/__templates__/taro/src/presets/h5-styles.ts +220 -0
- package/lib/__templates__/taro/src/presets/index.tsx +18 -0
- package/lib/__templates__/templates.json +43 -0
- package/lib/__templates__/vite/README.md +190 -11
- package/lib/__templates__/vite/_gitignore +1 -0
- package/lib/__templates__/vite/eslint.config.mjs +6 -1
- package/lib/__templates__/vite/package.json +14 -5
- package/lib/__templates__/vite/pnpm-lock.yaml +768 -24
- package/lib/__templates__/vite/scripts/build.sh +4 -1
- package/lib/__templates__/vite/scripts/dev.sh +9 -2
- package/lib/__templates__/vite/scripts/start.sh +9 -3
- package/lib/__templates__/vite/server/routes/index.ts +31 -0
- package/lib/__templates__/vite/server/server.ts +65 -0
- package/lib/__templates__/vite/server/vite.ts +67 -0
- package/lib/__templates__/vite/tsconfig.json +4 -3
- package/lib/__templates__/vite/vite.config.ts +5 -0
- package/lib/cli.js +124 -103
- package/package.json +7 -3
- package/lib/__templates__/taro/src/app.ts +0 -14
- package/lib/__templates__/taro/src/utils/h5-styles.ts +0 -22
- package/lib/__templates__/taro/src/utils/wx-debug.ts +0 -23
package/README.md
CHANGED
|
@@ -43,4 +43,4 @@ kill_old_server
|
|
|
43
43
|
|
|
44
44
|
echo "启动 server 服务..."
|
|
45
45
|
cd "$SERVER_DIR"
|
|
46
|
-
NODE_ENV=development PORT="$SERVER_PORT" npx tsx ./src/index.ts 2>&1 | pipe_to_log "SERVER" "$LOG_SERVER_FILE"
|
|
46
|
+
NODE_ENV=development PORT="$SERVER_PORT" npx tsx watch ./src/index.ts 2>&1 | pipe_to_log "SERVER" "$LOG_SERVER_FILE"
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
*
|
|
33
33
|
* ## 2. 沉浸式 Header (推荐)
|
|
34
34
|
* - 场景:Header 背景色/图片需要延伸到状态栏 (如首页、个人中心)。
|
|
35
|
-
* - 用法:`<Screen safeAreaEdges={['left', 'right', 'bottom']}>` (
|
|
35
|
+
* - 用法:`<Screen safeAreaEdges={['left', 'right', 'bottom']}>` (去掉 'top')
|
|
36
36
|
* - 配合:页面内部 Header 组件必须手动添加 paddingTop:
|
|
37
37
|
* ```tsx
|
|
38
38
|
* const insets = useSafeAreaInsets();
|
|
@@ -41,7 +41,7 @@ import {
|
|
|
41
41
|
*
|
|
42
42
|
* ## 3. 底部有 TabBar 或 悬浮按钮
|
|
43
43
|
* - 场景:页面底部有固定导航栏,或者需要精细控制底部留白。
|
|
44
|
-
* - 用法:`<Screen safeAreaEdges={['top', 'left', 'right']}>` (
|
|
44
|
+
* - 用法:`<Screen safeAreaEdges={['top', 'left', 'right']}>` (去掉 'bottom')
|
|
45
45
|
* - 配合:
|
|
46
46
|
* - 若是滚动页:`<ScrollView contentContainerStyle={{ paddingBottom: insets.bottom + 80 }}>`
|
|
47
47
|
* - 若是固定页:`<View style={{ paddingBottom: insets.bottom + 60 }}>`
|
|
@@ -8,6 +8,8 @@ import pluginImport from 'eslint-plugin-import';
|
|
|
8
8
|
import fontawesome6 from '../eslint-plugins/fontawesome6/index.js';
|
|
9
9
|
import reanimated from '../eslint-plugins/reanimated/index.js';
|
|
10
10
|
import reactnative from '../eslint-plugins/react-native/index.js';
|
|
11
|
+
import forbidEmoji from '../eslint-plugins/forbid-emoji/index.js';
|
|
12
|
+
import restrictLinearGradient from '../eslint-plugins/restrict-linear-gradient/index.js';
|
|
11
13
|
|
|
12
14
|
export default [
|
|
13
15
|
{
|
|
@@ -20,6 +22,7 @@ export default [
|
|
|
20
22
|
'tailwind.config.js', // 排除 Tailwind 配置文件
|
|
21
23
|
'**/*.d.ts',
|
|
22
24
|
'eslint.config.*',
|
|
25
|
+
'metro.config.*',
|
|
23
26
|
],
|
|
24
27
|
},
|
|
25
28
|
regexp.configs["flat/recommended"],
|
|
@@ -60,6 +63,8 @@ export default [
|
|
|
60
63
|
fontawesome6,
|
|
61
64
|
reanimated,
|
|
62
65
|
reactnative,
|
|
66
|
+
forbidEmoji,
|
|
67
|
+
restrictLinearGradient,
|
|
63
68
|
},
|
|
64
69
|
rules: {
|
|
65
70
|
// 关闭代码风格规则
|
|
@@ -80,6 +85,8 @@ export default [
|
|
|
80
85
|
'react/jsx-uses-react': 'off',
|
|
81
86
|
'fontawesome6/valid-name': 'error',
|
|
82
87
|
'reanimated/ban-mix-use': 'error',
|
|
88
|
+
'forbidEmoji/no-emoji': 'error',
|
|
89
|
+
'restrictLinearGradient/no-linear-gradient-backgroundcolor': 'error',
|
|
83
90
|
// 禁止使用 via.placeholder.com 服务
|
|
84
91
|
'no-restricted-syntax': [
|
|
85
92
|
'error',
|
|
@@ -9,7 +9,7 @@ const { execSync } = require('child_process');
|
|
|
9
9
|
const fs = require('fs');
|
|
10
10
|
const path = require('path');
|
|
11
11
|
|
|
12
|
-
console.log('
|
|
12
|
+
console.log('检测缺失的依赖...\n');
|
|
13
13
|
|
|
14
14
|
try {
|
|
15
15
|
// 运行 depcheck 并获取 JSON 输出
|
|
@@ -61,11 +61,11 @@ try {
|
|
|
61
61
|
});
|
|
62
62
|
|
|
63
63
|
if (missingPackages.length === 0) {
|
|
64
|
-
console.log('
|
|
64
|
+
console.log('没有发现缺失的依赖');
|
|
65
65
|
process.exit(0);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
console.log('
|
|
68
|
+
console.log('发现以下缺失的依赖:');
|
|
69
69
|
missingPackages.forEach((pkg, index) => {
|
|
70
70
|
const files = missing[pkg];
|
|
71
71
|
console.log(` ${index + 1}. ${pkg}`);
|
|
@@ -74,7 +74,7 @@ try {
|
|
|
74
74
|
);
|
|
75
75
|
});
|
|
76
76
|
|
|
77
|
-
console.log('\n
|
|
77
|
+
console.log('\n开始安装...\n');
|
|
78
78
|
|
|
79
79
|
// 使用 expo install 安装所有缺失的包
|
|
80
80
|
const packagesToInstall = missingPackages.join(' ');
|
|
@@ -84,22 +84,22 @@ try {
|
|
|
84
84
|
stdio: 'inherit',
|
|
85
85
|
});
|
|
86
86
|
|
|
87
|
-
console.log('\n
|
|
87
|
+
console.log('\n所有缺失的依赖已安装完成');
|
|
88
88
|
} catch (installError) {
|
|
89
|
-
console.log('\
|
|
89
|
+
console.log('\nexpo install 失败,尝试使用 npm install...\n');
|
|
90
90
|
|
|
91
91
|
execSync(`npm install ${packagesToInstall}`, {
|
|
92
92
|
stdio: 'inherit',
|
|
93
93
|
});
|
|
94
94
|
|
|
95
|
-
console.log('\n
|
|
95
|
+
console.log('\n所有缺失的依赖已通过 npm 安装完成');
|
|
96
96
|
}
|
|
97
97
|
} catch (error) {
|
|
98
98
|
if (error.message.includes('depcheck')) {
|
|
99
|
-
console.error('
|
|
100
|
-
console.log('
|
|
99
|
+
console.error('depcheck 未安装或运行失败');
|
|
100
|
+
console.log('尝试运行: npm install -g depcheck');
|
|
101
101
|
} else {
|
|
102
|
-
console.error('
|
|
102
|
+
console.error('发生错误:', error.message);
|
|
103
103
|
}
|
|
104
104
|
process.exit(1);
|
|
105
105
|
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
const DEFAULTS = {
|
|
2
|
+
ignorePatterns: [],
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
const RE_EMOJI =
|
|
6
|
+
// 匹配完整 emoji 序列:基础图形 + 可选变体选择符/肤色 + 可选 ZWJ 连接序列;以及国旗与 keycap
|
|
7
|
+
/(?:\p{Extended_Pictographic}(?:\uFE0F|[\u{1F3FB}-\u{1F3FF}])?(?:\u200D\p{Extended_Pictographic}(?:\uFE0F|[\u{1F3FB}-\u{1F3FF}])?)*)|(?:[\u{1F1E6}-\u{1F1FF}]{2})|(?:[#*0-9]\uFE0F?\u20E3)/gu
|
|
8
|
+
|
|
9
|
+
function buildIgnoreRegexes(patterns) {
|
|
10
|
+
if (!Array.isArray(patterns)) return []
|
|
11
|
+
const result = []
|
|
12
|
+
for (const pattern of patterns) {
|
|
13
|
+
if (typeof pattern !== 'string') continue
|
|
14
|
+
try {
|
|
15
|
+
result.push(new RegExp(pattern))
|
|
16
|
+
} catch (_) {
|
|
17
|
+
continue
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return result
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function shouldIgnore(text, ignoreRegexes) {
|
|
24
|
+
if (!ignoreRegexes.length) return false
|
|
25
|
+
for (const re of ignoreRegexes) {
|
|
26
|
+
if (re.test(text)) return true
|
|
27
|
+
}
|
|
28
|
+
return false
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function hasEmoji(text) {
|
|
32
|
+
if (!text) return false
|
|
33
|
+
RE_EMOJI.lastIndex = 0
|
|
34
|
+
return RE_EMOJI.test(text)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function collectEmojis(text) {
|
|
38
|
+
if (!text) return []
|
|
39
|
+
RE_EMOJI.lastIndex = 0
|
|
40
|
+
const result = []
|
|
41
|
+
const seen = new Set()
|
|
42
|
+
for (const match of text.matchAll(RE_EMOJI)) {
|
|
43
|
+
if (match[0] && !seen.has(match[0])) {
|
|
44
|
+
seen.add(match[0])
|
|
45
|
+
result.push(match[0])
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return result
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
module.exports = {
|
|
52
|
+
meta: {
|
|
53
|
+
type: 'problem',
|
|
54
|
+
docs: {
|
|
55
|
+
description: 'Disallow emoji in code',
|
|
56
|
+
recommended: 'error',
|
|
57
|
+
},
|
|
58
|
+
schema: [
|
|
59
|
+
{
|
|
60
|
+
type: 'object',
|
|
61
|
+
additionalProperties: false,
|
|
62
|
+
properties: {
|
|
63
|
+
ignorePatterns: {
|
|
64
|
+
type: 'array',
|
|
65
|
+
items: { type: 'string' },
|
|
66
|
+
default: DEFAULTS.ignorePatterns,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
messages: {
|
|
72
|
+
noEmoji: '禁止在代码中使用 emoji:{{emojis}},请移除或者使用 @expo/vector-icons 图标',
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
create(context) {
|
|
77
|
+
const options = context.options && context.options[0] ? context.options[0] : {}
|
|
78
|
+
const ignoreRegexes = buildIgnoreRegexes(
|
|
79
|
+
Array.isArray(options.ignorePatterns) ? options.ignorePatterns : DEFAULTS.ignorePatterns
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
function checkText(node, text) {
|
|
83
|
+
if (!text) return
|
|
84
|
+
if (shouldIgnore(text, ignoreRegexes)) return
|
|
85
|
+
if (hasEmoji(text)) {
|
|
86
|
+
const emojis = collectEmojis(text)
|
|
87
|
+
const emojiText = emojis.length ? emojis.join(' ') : ''
|
|
88
|
+
context.report({ node, messageId: 'noEmoji', data: { emojis: emojiText } })
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
Literal(node) {
|
|
94
|
+
if (typeof node.value !== 'string') return
|
|
95
|
+
checkText(node, node.value)
|
|
96
|
+
},
|
|
97
|
+
TemplateLiteral(node) {
|
|
98
|
+
for (const quasi of node.quasis) {
|
|
99
|
+
const cooked = quasi.value && typeof quasi.value.cooked === 'string'
|
|
100
|
+
? quasi.value.cooked
|
|
101
|
+
: quasi.value && typeof quasi.value.raw === 'string'
|
|
102
|
+
? quasi.value.raw
|
|
103
|
+
: ''
|
|
104
|
+
checkText(quasi, cooked)
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
JSXText(node) {
|
|
108
|
+
checkText(node, node.value)
|
|
109
|
+
},
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# forbid-emoji 技术设计
|
|
2
|
+
|
|
3
|
+
## 目标
|
|
4
|
+
- 在代码中检测并禁止使用 emoji
|
|
5
|
+
- 覆盖常见的字符串与 JSX 场景,避免明显漏报
|
|
6
|
+
- 保持实现简单、可维护,避免引入新依赖
|
|
7
|
+
|
|
8
|
+
## 规则命名与对外形态
|
|
9
|
+
- 插件目录:demo/eslint-plugins/forbid-emoji
|
|
10
|
+
- 规则名:forbid-emoji/no-emoji
|
|
11
|
+
- 规则类型:problem
|
|
12
|
+
- 默认等级:error
|
|
13
|
+
|
|
14
|
+
## 规则行为定义
|
|
15
|
+
### 报错
|
|
16
|
+
当以下任一位置包含 emoji 时,报错:
|
|
17
|
+
- 字符串字面量
|
|
18
|
+
- 模板字符串的静态片段
|
|
19
|
+
- JSXText 文本
|
|
20
|
+
- JSXAttribute 中可静态解析为字符串的值
|
|
21
|
+
|
|
22
|
+
### 不报错
|
|
23
|
+
以下场景不触发:
|
|
24
|
+
- 标识符、对象键名、属性名中的字符
|
|
25
|
+
- 数值、正则字面量、BigInt
|
|
26
|
+
- 模板字符串的表达式部分(仅检测静态片段)
|
|
27
|
+
- 被用户显式忽略的路径或内容
|
|
28
|
+
|
|
29
|
+
## 配置项
|
|
30
|
+
```json
|
|
31
|
+
{
|
|
32
|
+
"ignorePatterns": []
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
- ignorePatterns:字符串数组,命中任一正则则跳过该文本片段
|
|
36
|
+
|
|
37
|
+
## 检测策略
|
|
38
|
+
### AST 访问节点
|
|
39
|
+
- Literal:仅处理 typeof value === 'string'
|
|
40
|
+
- TemplateLiteral:遍历 quasis,使用 cooked 值
|
|
41
|
+
- JSXText:使用 node.value
|
|
42
|
+
- JSXAttribute:可静态解析为字符串时处理
|
|
43
|
+
|
|
44
|
+
### 忽略策略
|
|
45
|
+
当文本命中 ignorePatterns 的任一正则时,不再做 emoji 检测,减少误报与白名单配置成本。
|
|
46
|
+
|
|
47
|
+
## Emoji 识别方案
|
|
48
|
+
### 组合序列处理
|
|
49
|
+
考虑到真实文本中的 emoji 组合形式,需要识别以下组合序列并保证命中:
|
|
50
|
+
- 变体选择符:U+FE0F
|
|
51
|
+
- 皮肤色修饰符:U+1F3FB–U+1F3FF
|
|
52
|
+
- ZWJ 组合:U+200D
|
|
53
|
+
- 区域指示符组成的国旗:U+1F1E6–U+1F1FF 的成对序列
|
|
54
|
+
- Keycap 组合:[#*0-9] + U+FE0F? + U+20E3
|
|
55
|
+
|
|
56
|
+
实现上直接使用完整序列正则匹配,覆盖 ZWJ 连接序列、国旗与 keycap。
|
|
57
|
+
|
|
58
|
+
### 正则示意
|
|
59
|
+
```
|
|
60
|
+
const RE_EMOJI =
|
|
61
|
+
/(?:\p{Extended_Pictographic}(?:\uFE0F|[\u{1F3FB}-\u{1F3FF}])?(?:\u200D\p{Extended_Pictographic}(?:\uFE0F|[\u{1F3FB}-\u{1F3FF}])?)*)|(?:[\u{1F1E6}-\u{1F1FF}]{2})|(?:[#*0-9]\uFE0F?\u20E3)/gu
|
|
62
|
+
```
|
|
63
|
+
命中即判定为 emoji。
|
|
64
|
+
|
|
65
|
+
## 报错信息
|
|
66
|
+
- messageId: noEmoji
|
|
67
|
+
- 文案:禁止在代码中使用 emoji
|
|
68
|
+
|
|
69
|
+
## 典型示例
|
|
70
|
+
### 触发
|
|
71
|
+
- "hello🙂"
|
|
72
|
+
- `title: "Nice 👍"`
|
|
73
|
+
- <Text>欢迎🎉</Text>
|
|
74
|
+
|
|
75
|
+
### 不触发
|
|
76
|
+
- const icon = "face-smile"
|
|
77
|
+
- <Text>{user.name}</Text>
|
|
78
|
+
- "hello" + emojiName
|
|
79
|
+
|
|
80
|
+
## 边界与决策
|
|
81
|
+
- 模板字符串表达式部分:不深入解析,避免执行风险与复杂度
|
|
82
|
+
- 正则字面量:不扫描,避免干扰正则语义
|
|
83
|
+
- 注释:默认不扫描
|
|
84
|
+
- 误报控制:提供 ignorePatterns,由使用者按文件或内容片段进行排除
|
|
85
|
+
|
|
86
|
+
## 性能考虑
|
|
87
|
+
- 仅在字符串节点上进行扫描
|
|
88
|
+
- 正则预编译并复用
|
|
89
|
+
- 对空字符串与短文本快速返回
|
|
90
|
+
|
|
91
|
+
## 测试计划
|
|
92
|
+
- 覆盖 Literal、TemplateLiteral、JSXText、JSXAttribute 四类节点
|
|
93
|
+
- 覆盖 ZWJ 组合、变体选择符、国旗、keycap、皮肤色修饰符
|
|
94
|
+
- 覆盖 ignorePatterns 行为
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
const LINEAR_GRADIENT_RE = /linear-gradient/i
|
|
2
|
+
|
|
3
|
+
function getPropertyKeyName(property) {
|
|
4
|
+
if (!property || property.type !== 'Property') return null
|
|
5
|
+
if (property.key.type === 'Identifier') return property.key.name
|
|
6
|
+
if (property.key.type === 'Literal' && typeof property.key.value === 'string') {
|
|
7
|
+
return property.key.value
|
|
8
|
+
}
|
|
9
|
+
return null
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function getStaticStringValue(node) {
|
|
13
|
+
if (!node) return null
|
|
14
|
+
if (node.type === 'Literal' && typeof node.value === 'string') return node.value
|
|
15
|
+
if (node.type === 'TemplateLiteral') {
|
|
16
|
+
return node.quasis.map(quasi => quasi.value?.cooked || '').join('')
|
|
17
|
+
}
|
|
18
|
+
return null
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function isLinearGradientString(text) {
|
|
22
|
+
if (!text) return false
|
|
23
|
+
return LINEAR_GRADIENT_RE.test(text)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function checkStyleObjectExpression(objectExpression, report) {
|
|
27
|
+
if (!objectExpression || objectExpression.type !== 'ObjectExpression') return
|
|
28
|
+
for (const property of objectExpression.properties) {
|
|
29
|
+
if (!property || property.type !== 'Property') continue
|
|
30
|
+
const keyName = getPropertyKeyName(property)
|
|
31
|
+
if (keyName !== 'backgroundColor') continue
|
|
32
|
+
const valueText = getStaticStringValue(property.value)
|
|
33
|
+
if (isLinearGradientString(valueText)) {
|
|
34
|
+
report(property.key || property)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function isStyleSheetMethodCall(node, methodName) {
|
|
40
|
+
if (!node || node.type !== 'CallExpression') return false
|
|
41
|
+
const callee = node.callee
|
|
42
|
+
if (!callee || callee.type !== 'MemberExpression') return false
|
|
43
|
+
if (callee.object.type !== 'Identifier' || callee.object.name !== 'StyleSheet') return false
|
|
44
|
+
if (callee.property.type === 'Identifier') return callee.property.name === methodName
|
|
45
|
+
return false
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function checkStyleExpression(expression, report) {
|
|
49
|
+
if (!expression) return
|
|
50
|
+
if (expression.type === 'ObjectExpression') {
|
|
51
|
+
checkStyleObjectExpression(expression, report)
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
if (expression.type === 'ArrayExpression') {
|
|
55
|
+
for (const element of expression.elements) {
|
|
56
|
+
if (!element) continue
|
|
57
|
+
if (element.type === 'SpreadElement') {
|
|
58
|
+
checkStyleExpression(element.argument, report)
|
|
59
|
+
} else {
|
|
60
|
+
checkStyleExpression(element, report)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return
|
|
64
|
+
}
|
|
65
|
+
// 例:StyleSheet.flatten([styles.a, { backgroundColor: 'linear-gradient(...)' }])
|
|
66
|
+
if (isStyleSheetMethodCall(expression, 'flatten')) {
|
|
67
|
+
const arg = expression.arguments[0]
|
|
68
|
+
checkStyleExpression(arg, report)
|
|
69
|
+
return
|
|
70
|
+
}
|
|
71
|
+
// 例:StyleSheet.compose(styles.a, { backgroundColor: `linear-gradient(${angle},#fff,#000)` })
|
|
72
|
+
if (isStyleSheetMethodCall(expression, 'compose')) {
|
|
73
|
+
const [first, second] = expression.arguments
|
|
74
|
+
checkStyleExpression(first, report)
|
|
75
|
+
checkStyleExpression(second, report)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
module.exports = {
|
|
80
|
+
meta: {
|
|
81
|
+
type: 'problem',
|
|
82
|
+
docs: {
|
|
83
|
+
description: 'Disallow linear-gradient string in backgroundColor',
|
|
84
|
+
recommended: 'error',
|
|
85
|
+
},
|
|
86
|
+
schema: [],
|
|
87
|
+
messages: {
|
|
88
|
+
noLinearGradientBackgroundColor:
|
|
89
|
+
'backgroundColor 和 linear-gradient 无法一起使用,请将 backgroundColor 改为 experimental_backgroundImage',
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
create(context) {
|
|
94
|
+
function report(node) {
|
|
95
|
+
context.report({ node, messageId: 'noLinearGradientBackgroundColor' })
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
CallExpression(node) {
|
|
100
|
+
if (!isStyleSheetMethodCall(node, 'create')) return
|
|
101
|
+
const firstArg = node.arguments[0]
|
|
102
|
+
if (!firstArg || firstArg.type !== 'ObjectExpression') return
|
|
103
|
+
|
|
104
|
+
checkStyleObjectExpression(firstArg, report)
|
|
105
|
+
|
|
106
|
+
for (const property of firstArg.properties) {
|
|
107
|
+
if (!property || property.type !== 'Property') continue
|
|
108
|
+
if (!property.value || property.value.type !== 'ObjectExpression') continue
|
|
109
|
+
checkStyleObjectExpression(property.value, report)
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
JSXAttribute(node) {
|
|
114
|
+
if (!node.name || node.name.name !== 'style') return
|
|
115
|
+
if (!node.value || node.value.type !== 'JSXExpressionContainer') return
|
|
116
|
+
checkStyleExpression(node.value.expression, report)
|
|
117
|
+
},
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# restrict-linear-gradient 技术设计
|
|
2
|
+
|
|
3
|
+
## 目标
|
|
4
|
+
- 禁止在 backgroundColor 中使用 linear-gradient 字符串
|
|
5
|
+
- 覆盖 StyleSheet.create 与 JSX style 的常见写法
|
|
6
|
+
- 实现轻量、易维护,不引入新依赖
|
|
7
|
+
|
|
8
|
+
## 规则命名与对外形态
|
|
9
|
+
- 插件目录:expo/eslint-plugins/restrict-linear-gradient
|
|
10
|
+
- 规则名:restrict-linear-gradient/no-linear-gradient-backgroundcolor
|
|
11
|
+
- 规则类型:problem
|
|
12
|
+
- 默认等级:error
|
|
13
|
+
|
|
14
|
+
## 规则行为定义
|
|
15
|
+
### 报错
|
|
16
|
+
当以下任一位置出现 backgroundColor 且值包含 linear-gradient( 时,报错:
|
|
17
|
+
- StyleSheet.create 的样式对象中
|
|
18
|
+
- JSX 元素 style 属性内的对象或数组成员
|
|
19
|
+
|
|
20
|
+
### 不报错
|
|
21
|
+
以下场景不触发:
|
|
22
|
+
- 非 backgroundColor 的属性
|
|
23
|
+
- backgroundColor 的非字符串值
|
|
24
|
+
- 模板字符串包含表达式的动态值
|
|
25
|
+
- 与 style 无关的对象字面量
|
|
26
|
+
|
|
27
|
+
## 检测策略
|
|
28
|
+
### StyleSheet.create
|
|
29
|
+
遍历 StyleSheet.create 的首个参数对象,检查:
|
|
30
|
+
- 顶层 backgroundColor
|
|
31
|
+
- 每个样式项对应的对象内的 backgroundColor
|
|
32
|
+
|
|
33
|
+
### JSX style
|
|
34
|
+
定位 JSXAttribute(name=style) 后,检查表达式:
|
|
35
|
+
- ObjectExpression
|
|
36
|
+
- ArrayExpression 的各元素
|
|
37
|
+
- StyleSheet.flatten / StyleSheet.compose 的参数
|
|
38
|
+
|
|
39
|
+
## 线性渐变识别
|
|
40
|
+
使用正则 /linear-gradient/i 检测字符串字面量与模板字符串静态片段。
|
|
41
|
+
|
|
42
|
+
## 报错信息
|
|
43
|
+
- messageId: noLinearGradientBackgroundColor
|
|
44
|
+
- 文案:backgroundColor 和 linear-gradient 无法一起使用,请将 backgroundColor 改为 experimental_backgroundImage
|
|
45
|
+
|
|
46
|
+
## 典型示例
|
|
47
|
+
### 触发
|
|
48
|
+
- StyleSheet.create({ a: { backgroundColor: 'linear-gradient(135deg,#F97316 0%,#FB923C 100%)' } })
|
|
49
|
+
- <View style={{ backgroundColor: "linear-gradient(135deg,#F97316 0%,#FB923C 100%)" }} />
|
|
50
|
+
- <View style={[{ backgroundColor: `linear-gradient(135deg,#F97316 0%,#FB923C 100%)` }]} />
|
|
51
|
+
|
|
52
|
+
### 不触发
|
|
53
|
+
- { background: 'linear-gradient(...)' }
|
|
54
|
+
- { backgroundColor: someVar }
|
|
55
|
+
|
|
56
|
+
## 性能考虑
|
|
57
|
+
- 仅扫描目标节点与静态字符串
|
|
58
|
+
- 早返回空节点与非字符串值
|
|
@@ -251,8 +251,8 @@ importers:
|
|
|
251
251
|
specifier: ^2.8.5
|
|
252
252
|
version: 2.8.6
|
|
253
253
|
coze-coding-dev-sdk:
|
|
254
|
-
specifier: ^0.7.
|
|
255
|
-
version: 0.7.
|
|
254
|
+
specifier: ^0.7.16
|
|
255
|
+
version: 0.7.16(openai@6.16.0(ws@8.19.0)(zod@4.3.6))(ws@8.19.0)
|
|
256
256
|
dayjs:
|
|
257
257
|
specifier: ^1.11.19
|
|
258
258
|
version: 1.11.19
|
|
@@ -2515,8 +2515,8 @@ packages:
|
|
|
2515
2515
|
resolution: {integrity: sha512-AdmX6xUzdNASswsFtmwSt7Vj8po9IuqXm0UXz7QKPuEUmPB4XyjGfaAr2PSuELMwkRMVH1EpIkX5bTZGRB3eCA==}
|
|
2516
2516
|
engines: {node: '>=10'}
|
|
2517
2517
|
|
|
2518
|
-
coze-coding-dev-sdk@0.7.
|
|
2519
|
-
resolution: {integrity: sha512-
|
|
2518
|
+
coze-coding-dev-sdk@0.7.16:
|
|
2519
|
+
resolution: {integrity: sha512-B7gRPBa+sfrZL8ur0+F/92SOgZgFaWD/fOnCN2DjthnHSdmCYhAJWCfqzG2oO2vwTiYCXkKUuTBZ3MJLMj886g==}
|
|
2520
2520
|
engines: {node: '>=18.0.0'}
|
|
2521
2521
|
hasBin: true
|
|
2522
2522
|
|
|
@@ -8695,19 +8695,22 @@ snapshots:
|
|
|
8695
8695
|
path-type: 4.0.0
|
|
8696
8696
|
yaml: 1.10.2
|
|
8697
8697
|
|
|
8698
|
-
coze-coding-dev-sdk@0.7.
|
|
8698
|
+
coze-coding-dev-sdk@0.7.16(openai@6.16.0(ws@8.19.0)(zod@4.3.6))(ws@8.19.0):
|
|
8699
8699
|
dependencies:
|
|
8700
8700
|
'@langchain/core': 1.1.17(openai@6.16.0(ws@8.19.0)(zod@4.3.6))
|
|
8701
8701
|
'@langchain/openai': 1.2.3(@langchain/core@1.1.17(openai@6.16.0(ws@8.19.0)(zod@4.3.6)))(ws@8.19.0)
|
|
8702
|
+
'@supabase/supabase-js': 2.95.3
|
|
8702
8703
|
axios: 1.13.3
|
|
8703
8704
|
pg: 8.17.2
|
|
8704
8705
|
transitivePeerDependencies:
|
|
8705
8706
|
- '@opentelemetry/api'
|
|
8706
8707
|
- '@opentelemetry/exporter-trace-otlp-proto'
|
|
8707
8708
|
- '@opentelemetry/sdk-trace-base'
|
|
8709
|
+
- bufferutil
|
|
8708
8710
|
- debug
|
|
8709
8711
|
- openai
|
|
8710
8712
|
- pg-native
|
|
8713
|
+
- utf-8-validate
|
|
8711
8714
|
- ws
|
|
8712
8715
|
|
|
8713
8716
|
create-jest@29.7.0(@types/node@25.0.10):
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<meta name="description" content="扣子编程,你的 AI 开发伙伴已就位" />
|
|
7
|
+
<title>扣子编程 - AI 开发伙伴</title>
|
|
8
|
+
<link rel="stylesheet" href="/styles/main.css" />
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
<div id="app">
|
|
12
|
+
<main class="main-wrapper">
|
|
13
|
+
<div class="content-container">
|
|
14
|
+
<img
|
|
15
|
+
src="https://lf-coze-web-cdn.coze.cn/obj/eden-cn/lm-lgvj/ljhwZthlaukjlkulzlp/coze-coding/icon/coze-coding.gif"
|
|
16
|
+
alt="扣子编程 Logo"
|
|
17
|
+
class="logo-image"
|
|
18
|
+
/>
|
|
19
|
+
<div>
|
|
20
|
+
<div class="text-container">
|
|
21
|
+
<h1 class="heading">
|
|
22
|
+
应用开发中
|
|
23
|
+
</h1>
|
|
24
|
+
<p class="description">
|
|
25
|
+
请稍后,页面即将呈现
|
|
26
|
+
</p>
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
</main>
|
|
31
|
+
</div>
|
|
32
|
+
</body>
|
|
33
|
+
</html>
|