@coze-arch/cli 0.0.1-alpha.fd3d56 → 0.0.1-alpha.ff3d06
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/dev_run.sh +13 -12
- package/lib/__templates__/expo/.cozeproj/scripts/server_dev_run.sh +9 -8
- package/lib/__templates__/expo/_npmrc +1 -0
- package/lib/__templates__/expo/client/components/Screen.tsx +2 -2
- package/lib/__templates__/expo/client/eslint.config.mjs +11 -1
- package/lib/__templates__/expo/client/metro.config.js +3 -0
- package/lib/__templates__/expo/client/package.json +35 -35
- package/lib/__templates__/expo/client/screens/demo/index.tsx +3 -3
- 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/react-native/index.js +9 -0
- package/lib/__templates__/expo/eslint-plugins/react-native/rule.js +64 -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/package.json +1 -1
- package/lib/__templates__/expo/patches/{expo@54.0.32.patch → expo@54.0.33.patch} +3 -2
- package/lib/__templates__/expo/pnpm-lock.yaml +340 -1736
- package/lib/__templates__/expo/server/package.json +9 -7
- package/lib/__templates__/expo/server/src/index.ts +1 -0
- package/lib/__templates__/expo/template.config.js +56 -0
- 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/AGENTS.md +54 -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 +15 -6
- package/lib/__templates__/nextjs/pnpm-lock.yaml +1859 -736
- 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 +17 -60
- package/lib/__templates__/nextjs/src/server.ts +35 -0
- package/lib/__templates__/nextjs/template.config.js +49 -14
- package/lib/__templates__/nextjs/tsconfig.json +1 -1
- package/lib/__templates__/nuxt-vue/.coze +12 -0
- package/lib/__templates__/nuxt-vue/AGENTS.md +42 -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/.coze +14 -0
- package/lib/__templates__/taro/.cozeproj/scripts/deploy_build.sh +19 -0
- package/lib/__templates__/taro/.cozeproj/scripts/deploy_run.sh +14 -0
- package/lib/__templates__/taro/.cozeproj/scripts/dev_build.sh +2 -0
- package/lib/__templates__/taro/.cozeproj/scripts/dev_run.sh +151 -0
- package/lib/__templates__/taro/.cozeproj/scripts/init_env.sh +5 -0
- package/lib/__templates__/taro/.cozeproj/scripts/pack.sh +24 -0
- package/lib/__templates__/taro/README.md +763 -0
- package/lib/__templates__/taro/_gitignore +40 -0
- package/lib/__templates__/taro/_npmrc +18 -0
- package/lib/__templates__/taro/babel.config.js +12 -0
- package/lib/__templates__/taro/config/dev.ts +9 -0
- package/lib/__templates__/taro/config/index.ts +238 -0
- package/lib/__templates__/taro/config/prod.ts +34 -0
- package/lib/__templates__/taro/eslint.config.mjs +135 -0
- package/lib/__templates__/taro/key/private.appid.key +0 -0
- package/lib/__templates__/taro/package.json +112 -0
- package/lib/__templates__/taro/patches/@tarojs__plugin-mini-ci@4.1.9.patch +30 -0
- package/lib/__templates__/taro/pnpm-lock.yaml +23412 -0
- package/lib/__templates__/taro/pnpm-workspace.yaml +2 -0
- package/lib/__templates__/taro/project.config.json +15 -0
- package/lib/__templates__/taro/server/nest-cli.json +10 -0
- package/lib/__templates__/taro/server/package.json +40 -0
- package/lib/__templates__/taro/server/src/app.controller.ts +23 -0
- package/lib/__templates__/taro/server/src/app.module.ts +10 -0
- package/lib/__templates__/taro/server/src/app.service.ts +8 -0
- package/lib/__templates__/taro/server/src/interceptors/http-status.interceptor.ts +23 -0
- package/lib/__templates__/taro/server/src/main.ts +49 -0
- package/lib/__templates__/taro/server/tsconfig.json +24 -0
- package/lib/__templates__/taro/src/app.config.ts +11 -0
- package/lib/__templates__/taro/src/app.css +156 -0
- 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/index.html +39 -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/network.ts +39 -0
- package/lib/__templates__/taro/src/pages/index/index.config.ts +3 -0
- package/lib/__templates__/taro/src/pages/index/index.css +1 -0
- package/lib/__templates__/taro/src/pages/index/index.tsx +33 -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__/taro/stylelint.config.mjs +4 -0
- package/lib/__templates__/taro/template.config.js +68 -0
- package/lib/__templates__/taro/tsconfig.json +29 -0
- package/lib/__templates__/taro/types/global.d.ts +32 -0
- package/lib/__templates__/templates.json +75 -0
- package/lib/__templates__/vite/AGENTS.md +41 -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 -3
- package/lib/__templates__/vite/pnpm-lock.yaml +820 -1593
- 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/src/main.ts +17 -47
- package/lib/__templates__/vite/template.config.js +49 -14
- package/lib/__templates__/vite/tsconfig.json +4 -3
- package/lib/__templates__/vite/vite.config.ts +5 -0
- package/lib/cli.js +2983 -209
- package/package.json +10 -3
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
meta: {
|
|
3
|
+
type: 'problem',
|
|
4
|
+
docs: {
|
|
5
|
+
description: '禁止带有 horizontal: true 属性的 ScrollView 单独使用',
|
|
6
|
+
recommended: false,
|
|
7
|
+
},
|
|
8
|
+
schema: [],
|
|
9
|
+
messages: {
|
|
10
|
+
noSiblings: '禁止带有 props.horizontal: true 的 ScrollView 单独使用,需要在 ScrollView 外层使用一个单独的 View 组件进行包裹',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
create(context) {
|
|
14
|
+
return {
|
|
15
|
+
JSXElement(node) {
|
|
16
|
+
const isScrollView = node.openingElement.name.name === 'ScrollView';
|
|
17
|
+
|
|
18
|
+
if (!isScrollView) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const hasHorizontalProp = node.openingElement.attributes.some(attr => {
|
|
23
|
+
if (attr.type === 'JSXAttribute' && attr.name.name === 'horizontal') {
|
|
24
|
+
if (!attr.value) {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
if (
|
|
28
|
+
attr.value.type === 'JSXExpressionContainer' &&
|
|
29
|
+
attr.value.expression.value === true
|
|
30
|
+
) {
|
|
31
|
+
return true; // horizontal={true}
|
|
32
|
+
}
|
|
33
|
+
if (attr.value.type === 'Literal' && attr.value.value === true) {
|
|
34
|
+
return true; // horizontal={true} 的另一种形式
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return false;
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
if (!hasHorizontalProp) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const parent = node.parent;
|
|
45
|
+
|
|
46
|
+
if (
|
|
47
|
+
parent.type === 'JSXFragment' ||
|
|
48
|
+
parent.type === 'JSXElement'
|
|
49
|
+
) {
|
|
50
|
+
const siblings = parent.children.filter(
|
|
51
|
+
child => child.type === 'JSXElement' && child !== node
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
if (siblings.length > 0) {
|
|
55
|
+
context.report({
|
|
56
|
+
node,
|
|
57
|
+
messageId: 'noSiblings',
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
},
|
|
64
|
+
}
|
|
@@ -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
|
+
- 早返回空节点与非字符串值
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
diff --git a/src/async-require/hmr.ts b/src/async-require/hmr.ts
|
|
2
|
-
index 33ce50ee2950c40d2b0553b148710f1e24e44f3d..
|
|
2
|
+
index 33ce50ee2950c40d2b0553b148710f1e24e44f3d..3d78cb02dd7e96ac9727a2935d8178f2c7e95982 100644
|
|
3
3
|
--- a/src/async-require/hmr.ts
|
|
4
4
|
+++ b/src/async-require/hmr.ts
|
|
5
|
-
@@ -216,6 +216,
|
|
5
|
+
@@ -216,6 +216,40 @@ const HMRClient: HMRClientNativeInterface = {
|
|
6
6
|
|
|
7
7
|
client.on('update-done', () => {
|
|
8
8
|
hideLoading();
|
|
@@ -39,6 +39,7 @@ index 33ce50ee2950c40d2b0553b148710f1e24e44f3d..a13d6f2da10dea858019cc991c21753f
|
|
|
39
39
|
+ checkServerAndReload(6);
|
|
40
40
|
+ }, 35_000);
|
|
41
41
|
+ }
|
|
42
|
+
+ console.log('[HMR] Update done.');
|
|
42
43
|
});
|
|
43
44
|
|
|
44
45
|
client.on('error', (data: { type: string; message: string }) => {
|