@coze-arch/cli 0.0.1-beta.6 → 0.0.3

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.
Files changed (239) hide show
  1. package/README.md +1 -0
  2. package/lib/__templates__/expo/.coze +7 -2
  3. package/lib/__templates__/expo/.cozeproj/scripts/dev_build.sh +46 -0
  4. package/lib/__templates__/expo/.cozeproj/scripts/dev_run.sh +229 -0
  5. package/lib/__templates__/expo/.cozeproj/scripts/prod_build.sh +47 -0
  6. package/lib/__templates__/expo/.cozeproj/scripts/prod_run.sh +34 -0
  7. package/lib/__templates__/expo/.cozeproj/scripts/server_dev_run.sh +46 -0
  8. package/lib/__templates__/expo/README.md +68 -7
  9. package/lib/__templates__/expo/_gitignore +2 -1
  10. package/lib/__templates__/expo/_npmrc +4 -5
  11. package/lib/__templates__/expo/client/app/+not-found.tsx +15 -64
  12. package/lib/__templates__/expo/client/app/_layout.tsx +15 -12
  13. package/lib/__templates__/expo/client/app/index.tsx +1 -0
  14. package/lib/__templates__/expo/client/app.config.ts +76 -0
  15. package/lib/__templates__/expo/client/components/Screen.tsx +3 -19
  16. package/lib/__templates__/expo/client/components/ThemedText.tsx +33 -0
  17. package/lib/__templates__/expo/client/components/ThemedView.tsx +37 -0
  18. package/lib/__templates__/expo/client/constants/theme.ts +117 -58
  19. package/lib/__templates__/expo/client/contexts/AuthContext.tsx +14 -107
  20. package/lib/__templates__/expo/client/declarations.d.ts +5 -0
  21. package/lib/__templates__/expo/{eslint.config.mjs → client/eslint.config.mjs} +40 -10
  22. package/lib/__templates__/expo/client/hooks/useColorScheme.tsx +48 -0
  23. package/lib/__templates__/expo/client/hooks/useSafeRouter.ts +152 -0
  24. package/lib/__templates__/expo/client/hooks/useTheme.ts +26 -6
  25. package/lib/__templates__/expo/client/metro.config.js +124 -0
  26. package/lib/__templates__/expo/client/package.json +95 -0
  27. package/lib/__templates__/expo/client/screens/demo/index.tsx +25 -0
  28. package/lib/__templates__/expo/client/screens/demo/styles.ts +28 -0
  29. package/lib/__templates__/expo/client/scripts/install-missing-deps.js +11 -10
  30. package/lib/__templates__/expo/client/tsconfig.json +24 -0
  31. package/lib/__templates__/expo/client/utils/index.ts +23 -2
  32. package/lib/__templates__/expo/eslint-plugins/fontawesome6/index.js +9 -0
  33. package/lib/__templates__/expo/eslint-plugins/fontawesome6/names.js +1889 -0
  34. package/lib/__templates__/expo/eslint-plugins/fontawesome6/rule.js +174 -0
  35. package/lib/__templates__/expo/eslint-plugins/fontawesome6/v5-only-names.js +388 -0
  36. package/lib/__templates__/expo/eslint-plugins/forbid-emoji/index.js +9 -0
  37. package/lib/__templates__/expo/eslint-plugins/forbid-emoji/rule.js +112 -0
  38. package/lib/__templates__/expo/eslint-plugins/forbid-emoji/tech.md +94 -0
  39. package/lib/__templates__/expo/eslint-plugins/react-native/index.js +9 -0
  40. package/lib/__templates__/expo/eslint-plugins/react-native/rule.js +64 -0
  41. package/lib/__templates__/expo/eslint-plugins/reanimated/index.js +9 -0
  42. package/lib/__templates__/expo/eslint-plugins/reanimated/rule.js +88 -0
  43. package/lib/__templates__/expo/eslint-plugins/restrict-linear-gradient/index.js +9 -0
  44. package/lib/__templates__/expo/eslint-plugins/restrict-linear-gradient/rule.js +120 -0
  45. package/lib/__templates__/expo/eslint-plugins/restrict-linear-gradient/tech.md +58 -0
  46. package/lib/__templates__/expo/package.json +16 -101
  47. package/lib/__templates__/expo/patches/expo@54.0.33.patch +45 -0
  48. package/lib/__templates__/expo/pnpm-lock.yaml +1622 -3274
  49. package/lib/__templates__/expo/pnpm-workspace.yaml +3 -0
  50. package/lib/__templates__/expo/server/build.js +21 -0
  51. package/lib/__templates__/expo/server/package.json +34 -0
  52. package/lib/__templates__/expo/server/src/index.ts +20 -0
  53. package/lib/__templates__/expo/server/tsconfig.json +24 -0
  54. package/lib/__templates__/expo/template.config.js +58 -1
  55. package/lib/__templates__/expo/tsconfig.json +1 -24
  56. package/lib/__templates__/native-static/.coze +11 -0
  57. package/lib/__templates__/native-static/index.html +33 -0
  58. package/lib/__templates__/native-static/styles/main.css +136 -0
  59. package/lib/__templates__/native-static/template.config.js +22 -0
  60. package/lib/__templates__/nextjs/.coze +4 -3
  61. package/lib/__templates__/nextjs/README.md +5 -0
  62. package/lib/__templates__/nextjs/_gitignore +1 -0
  63. package/lib/__templates__/nextjs/_npmrc +2 -1
  64. package/lib/__templates__/nextjs/eslint.config.mjs +5 -0
  65. package/lib/__templates__/nextjs/next.config.ts +11 -0
  66. package/lib/__templates__/nextjs/package.json +15 -1
  67. package/lib/__templates__/nextjs/pnpm-lock.yaml +7694 -4394
  68. package/lib/__templates__/nextjs/scripts/build.sh +4 -1
  69. package/lib/__templates__/nextjs/scripts/dev.sh +15 -28
  70. package/lib/__templates__/nextjs/scripts/prepare.sh +9 -0
  71. package/lib/__templates__/nextjs/scripts/start.sh +7 -1
  72. package/lib/__templates__/nextjs/src/app/globals.css +109 -89
  73. package/lib/__templates__/nextjs/src/app/layout.tsx +20 -33
  74. package/lib/__templates__/nextjs/src/app/page.tsx +18 -49
  75. package/lib/__templates__/nextjs/src/components/ui/resizable.tsx +29 -22
  76. package/lib/__templates__/nextjs/src/components/ui/sidebar.tsx +228 -230
  77. package/lib/__templates__/nextjs/src/server.ts +35 -0
  78. package/lib/__templates__/nextjs/template.config.js +68 -3
  79. package/lib/__templates__/nextjs/tsconfig.json +1 -1
  80. package/lib/__templates__/nuxt-vue/.coze +12 -0
  81. package/lib/__templates__/nuxt-vue/README.md +73 -0
  82. package/lib/__templates__/nuxt-vue/_gitignore +25 -0
  83. package/lib/__templates__/nuxt-vue/_npmrc +23 -0
  84. package/lib/__templates__/nuxt-vue/app/app.vue +6 -0
  85. package/lib/__templates__/nuxt-vue/app/pages/index.vue +23 -0
  86. package/lib/__templates__/nuxt-vue/assets/css/main.css +24 -0
  87. package/lib/__templates__/nuxt-vue/nuxt.config.ts +126 -0
  88. package/lib/__templates__/nuxt-vue/package.json +35 -0
  89. package/lib/__templates__/nuxt-vue/pnpm-lock.yaml +8759 -0
  90. package/lib/__templates__/nuxt-vue/postcss.config.mjs +8 -0
  91. package/lib/__templates__/nuxt-vue/public/favicon.ico +0 -0
  92. package/lib/__templates__/nuxt-vue/public/robots.txt +2 -0
  93. package/lib/__templates__/nuxt-vue/scripts/build.sh +14 -0
  94. package/lib/__templates__/nuxt-vue/scripts/dev.sh +39 -0
  95. package/lib/__templates__/nuxt-vue/scripts/prepare.sh +14 -0
  96. package/lib/__templates__/nuxt-vue/scripts/start.sh +21 -0
  97. package/lib/__templates__/nuxt-vue/server/api/hello.ts +10 -0
  98. package/lib/__templates__/nuxt-vue/server/middleware/logger.ts +10 -0
  99. package/lib/__templates__/nuxt-vue/server/routes/health.ts +10 -0
  100. package/lib/__templates__/nuxt-vue/tailwind.config.js +13 -0
  101. package/lib/__templates__/nuxt-vue/template.config.js +87 -0
  102. package/lib/__templates__/nuxt-vue/tsconfig.json +18 -0
  103. package/lib/__templates__/taro/.coze +14 -0
  104. package/lib/__templates__/taro/.cozeproj/scripts/deploy_build.sh +19 -0
  105. package/lib/__templates__/taro/.cozeproj/scripts/deploy_run.sh +14 -0
  106. package/lib/__templates__/taro/.cozeproj/scripts/dev_build.sh +2 -0
  107. package/lib/__templates__/taro/.cozeproj/scripts/dev_run.sh +151 -0
  108. package/lib/__templates__/taro/.cozeproj/scripts/init_env.sh +5 -0
  109. package/lib/__templates__/taro/.cozeproj/scripts/pack.sh +24 -0
  110. package/lib/__templates__/taro/README.md +763 -0
  111. package/lib/__templates__/taro/_gitignore +41 -0
  112. package/lib/__templates__/taro/_npmrc +18 -0
  113. package/lib/__templates__/taro/babel.config.js +12 -0
  114. package/lib/__templates__/taro/config/dev.ts +9 -0
  115. package/lib/__templates__/taro/config/index.ts +238 -0
  116. package/lib/__templates__/taro/config/prod.ts +34 -0
  117. package/lib/__templates__/taro/eslint.config.mjs +135 -0
  118. package/lib/__templates__/taro/key/private.appid.key +0 -0
  119. package/lib/__templates__/taro/package.json +112 -0
  120. package/lib/__templates__/taro/patches/@tarojs__plugin-mini-ci@4.1.9.patch +30 -0
  121. package/lib/__templates__/taro/pnpm-lock.yaml +23412 -0
  122. package/lib/__templates__/taro/pnpm-workspace.yaml +2 -0
  123. package/lib/__templates__/taro/project.config.json +15 -0
  124. package/lib/__templates__/taro/server/nest-cli.json +10 -0
  125. package/lib/__templates__/taro/server/package.json +40 -0
  126. package/lib/__templates__/taro/server/src/app.controller.ts +23 -0
  127. package/lib/__templates__/taro/server/src/app.module.ts +10 -0
  128. package/lib/__templates__/taro/server/src/app.service.ts +8 -0
  129. package/lib/__templates__/taro/server/src/interceptors/http-status.interceptor.ts +23 -0
  130. package/lib/__templates__/taro/server/src/main.ts +49 -0
  131. package/lib/__templates__/taro/server/tsconfig.json +24 -0
  132. package/lib/__templates__/taro/src/app.config.ts +11 -0
  133. package/lib/__templates__/taro/src/app.css +156 -0
  134. package/lib/__templates__/taro/src/app.tsx +9 -0
  135. package/lib/__templates__/taro/src/components/ui/accordion.tsx +159 -0
  136. package/lib/__templates__/taro/src/components/ui/alert-dialog.tsx +260 -0
  137. package/lib/__templates__/taro/src/components/ui/alert.tsx +60 -0
  138. package/lib/__templates__/taro/src/components/ui/aspect-ratio.tsx +36 -0
  139. package/lib/__templates__/taro/src/components/ui/avatar.tsx +84 -0
  140. package/lib/__templates__/taro/src/components/ui/badge.tsx +37 -0
  141. package/lib/__templates__/taro/src/components/ui/breadcrumb.tsx +117 -0
  142. package/lib/__templates__/taro/src/components/ui/button-group.tsx +83 -0
  143. package/lib/__templates__/taro/src/components/ui/button.tsx +67 -0
  144. package/lib/__templates__/taro/src/components/ui/calendar.tsx +394 -0
  145. package/lib/__templates__/taro/src/components/ui/card.tsx +108 -0
  146. package/lib/__templates__/taro/src/components/ui/carousel.tsx +228 -0
  147. package/lib/__templates__/taro/src/components/ui/checkbox.tsx +58 -0
  148. package/lib/__templates__/taro/src/components/ui/code-block.tsx +169 -0
  149. package/lib/__templates__/taro/src/components/ui/collapsible.tsx +71 -0
  150. package/lib/__templates__/taro/src/components/ui/command.tsx +385 -0
  151. package/lib/__templates__/taro/src/components/ui/context-menu.tsx +614 -0
  152. package/lib/__templates__/taro/src/components/ui/dialog.tsx +256 -0
  153. package/lib/__templates__/taro/src/components/ui/drawer.tsx +192 -0
  154. package/lib/__templates__/taro/src/components/ui/dropdown-menu.tsx +561 -0
  155. package/lib/__templates__/taro/src/components/ui/field.tsx +228 -0
  156. package/lib/__templates__/taro/src/components/ui/hover-card.tsx +282 -0
  157. package/lib/__templates__/taro/src/components/ui/input-group.tsx +197 -0
  158. package/lib/__templates__/taro/src/components/ui/input-otp.tsx +136 -0
  159. package/lib/__templates__/taro/src/components/ui/input.tsx +56 -0
  160. package/lib/__templates__/taro/src/components/ui/label.tsx +24 -0
  161. package/lib/__templates__/taro/src/components/ui/menubar.tsx +595 -0
  162. package/lib/__templates__/taro/src/components/ui/navigation-menu.tsx +264 -0
  163. package/lib/__templates__/taro/src/components/ui/pagination.tsx +118 -0
  164. package/lib/__templates__/taro/src/components/ui/popover.tsx +291 -0
  165. package/lib/__templates__/taro/src/components/ui/portal.tsx +19 -0
  166. package/lib/__templates__/taro/src/components/ui/progress.tsx +28 -0
  167. package/lib/__templates__/taro/src/components/ui/radio-group.tsx +64 -0
  168. package/lib/__templates__/taro/src/components/ui/resizable.tsx +346 -0
  169. package/lib/__templates__/taro/src/components/ui/scroll-area.tsx +34 -0
  170. package/lib/__templates__/taro/src/components/ui/select.tsx +438 -0
  171. package/lib/__templates__/taro/src/components/ui/separator.tsx +30 -0
  172. package/lib/__templates__/taro/src/components/ui/sheet.tsx +262 -0
  173. package/lib/__templates__/taro/src/components/ui/skeleton.tsx +17 -0
  174. package/lib/__templates__/taro/src/components/ui/slider.tsx +203 -0
  175. package/lib/__templates__/taro/src/components/ui/sonner.tsx +1 -0
  176. package/lib/__templates__/taro/src/components/ui/switch.tsx +55 -0
  177. package/lib/__templates__/taro/src/components/ui/table.tsx +142 -0
  178. package/lib/__templates__/taro/src/components/ui/tabs.tsx +114 -0
  179. package/lib/__templates__/taro/src/components/ui/textarea.tsx +54 -0
  180. package/lib/__templates__/taro/src/components/ui/toast.tsx +517 -0
  181. package/lib/__templates__/taro/src/components/ui/toggle-group.tsx +120 -0
  182. package/lib/__templates__/taro/src/components/ui/toggle.tsx +77 -0
  183. package/lib/__templates__/taro/src/components/ui/tooltip.tsx +455 -0
  184. package/lib/__templates__/taro/src/index.html +39 -0
  185. package/lib/__templates__/taro/src/lib/hooks/use-keyboard-offset.ts +37 -0
  186. package/lib/__templates__/taro/src/lib/measure.ts +115 -0
  187. package/lib/__templates__/taro/src/lib/platform.ts +12 -0
  188. package/lib/__templates__/taro/src/lib/utils.ts +6 -0
  189. package/lib/__templates__/taro/src/network.ts +39 -0
  190. package/lib/__templates__/taro/src/pages/index/index.config.ts +3 -0
  191. package/lib/__templates__/taro/src/pages/index/index.css +1 -0
  192. package/lib/__templates__/taro/src/pages/index/index.tsx +33 -0
  193. package/lib/__templates__/taro/src/presets/dev-debug.ts +23 -0
  194. package/lib/__templates__/taro/src/presets/h5-container.tsx +15 -0
  195. package/lib/__templates__/taro/src/presets/h5-navbar.tsx +238 -0
  196. package/lib/__templates__/taro/src/presets/h5-styles.ts +220 -0
  197. package/lib/__templates__/taro/src/presets/index.tsx +18 -0
  198. package/lib/__templates__/taro/stylelint.config.mjs +4 -0
  199. package/lib/__templates__/taro/template.config.js +68 -0
  200. package/lib/__templates__/taro/tsconfig.json +29 -0
  201. package/lib/__templates__/taro/types/global.d.ts +32 -0
  202. package/lib/__templates__/templates.json +173 -36
  203. package/lib/__templates__/vite/.coze +4 -3
  204. package/lib/__templates__/vite/README.md +383 -26
  205. package/lib/__templates__/vite/_gitignore +2 -0
  206. package/lib/__templates__/vite/_npmrc +2 -1
  207. package/lib/__templates__/vite/eslint.config.mjs +14 -0
  208. package/lib/__templates__/vite/package.json +23 -3
  209. package/lib/__templates__/vite/pnpm-lock.yaml +2509 -293
  210. package/lib/__templates__/vite/scripts/build.sh +4 -1
  211. package/lib/__templates__/vite/scripts/dev.sh +16 -28
  212. package/lib/__templates__/vite/scripts/prepare.sh +9 -0
  213. package/lib/__templates__/vite/scripts/start.sh +9 -3
  214. package/lib/__templates__/vite/server/routes/index.ts +31 -0
  215. package/lib/__templates__/vite/server/server.ts +65 -0
  216. package/lib/__templates__/vite/server/vite.ts +67 -0
  217. package/lib/__templates__/vite/src/main.ts +17 -48
  218. package/lib/__templates__/vite/template.config.js +77 -7
  219. package/lib/__templates__/vite/tsconfig.json +4 -3
  220. package/lib/__templates__/vite/vite.config.ts +8 -3
  221. package/lib/cli.js +1545 -526
  222. package/package.json +20 -7
  223. package/lib/__templates__/expo/.cozeproj/scripts/deploy_build.sh +0 -109
  224. package/lib/__templates__/expo/.cozeproj/scripts/deploy_run.sh +0 -257
  225. package/lib/__templates__/expo/app.json +0 -63
  226. package/lib/__templates__/expo/babel.config.js +0 -9
  227. package/lib/__templates__/expo/client/app/(tabs)/_layout.tsx +0 -43
  228. package/lib/__templates__/expo/client/app/(tabs)/home.tsx +0 -1
  229. package/lib/__templates__/expo/client/app/(tabs)/index.tsx +0 -7
  230. package/lib/__templates__/expo/client/hooks/useColorScheme.ts +0 -1
  231. package/lib/__templates__/expo/client/index.js +0 -12
  232. package/lib/__templates__/expo/client/screens/home/index.tsx +0 -54
  233. package/lib/__templates__/expo/client/screens/home/styles.ts +0 -332
  234. package/lib/__templates__/expo/metro.config.js +0 -53
  235. package/lib/__templates__/expo/src/index.ts +0 -12
  236. package/lib/__templates__/nextjs/.vscode/settings.json +0 -121
  237. package/lib/__templates__/nextjs/server.mjs +0 -50
  238. package/lib/__templates__/vite/.vscode/settings.json +0 -7
  239. /package/lib/__templates__/expo/{eslint-formatter-simple.mjs → client/eslint-formatter-simple.mjs} +0 -0
@@ -0,0 +1,174 @@
1
+ const names = require('./names')
2
+ const v5OnlyNames = require('./v5-only-names')
3
+ const v5OnlyNamesSet = new Set(v5OnlyNames)
4
+
5
+ const DEFAULTS = {
6
+ whitelist: names,
7
+ componentName: 'FontAwesome6',
8
+ attributeName: 'name',
9
+ };
10
+
11
+ function getJSXAttribute(openingElement, attrName) {
12
+ return openingElement.attributes.find(
13
+ (attr) =>
14
+ attr &&
15
+ attr.type === 'JSXAttribute' &&
16
+ attr.name &&
17
+ attr.name.name === attrName
18
+ );
19
+ }
20
+
21
+ function getStringLiteralValue(attribute) {
22
+ if (!attribute || !attribute.value) return null;
23
+
24
+ const val = attribute.value;
25
+
26
+ // <Comp name="hello" />
27
+ if (val.type === 'Literal' && typeof val.value === 'string') {
28
+ return val.value;
29
+ }
30
+
31
+ // <Comp name={'hello'} />
32
+ if (
33
+ val.type === 'JSXExpressionContainer' &&
34
+ val.expression &&
35
+ val.expression.type === 'Literal' &&
36
+ typeof val.expression.value === 'string'
37
+ ) {
38
+ return val.expression.value;
39
+ }
40
+
41
+ // <Comp name={`hello`} /> template literal without expressions
42
+ if (
43
+ val.type === 'JSXExpressionContainer' &&
44
+ val.expression &&
45
+ val.expression.type === 'TemplateLiteral' &&
46
+ val.expression.expressions.length === 0
47
+ ) {
48
+ return val.expression.quasis[0]?.value?.cooked ?? null;
49
+ }
50
+
51
+ return null;
52
+ }
53
+
54
+ const replacements = {
55
+ 'plus-circle': 'circle-plus',
56
+ }
57
+
58
+ module.exports = {
59
+ meta: {
60
+ type: 'problem',
61
+ docs: {
62
+ description:
63
+ 'Ensure FontAwesome6 name prop is a string literal in whitelist',
64
+ recommended: false,
65
+ },
66
+ schema: [
67
+ {
68
+ type: 'object',
69
+ additionalProperties: false,
70
+ properties: {
71
+ whitelist: {
72
+ type: 'array',
73
+ items: { type: 'string' },
74
+ default: DEFAULTS.whitelist,
75
+ },
76
+ componentName: {
77
+ type: 'string',
78
+ default: DEFAULTS.componentName,
79
+ },
80
+ attributeName: {
81
+ type: 'string',
82
+ default: DEFAULTS.attributeName,
83
+ },
84
+ caseSensitive: {
85
+ type: 'boolean',
86
+ default: true
87
+ }
88
+ },
89
+ },
90
+ ],
91
+ messages: {
92
+ invalidName:
93
+ '{{componentName}} 中不存在图标 {{name}},{{suggestion}}',
94
+ },
95
+ },
96
+
97
+ create(context) {
98
+ const options = context.options && context.options[0] ? context.options[0] : {};
99
+ const componentName = options.componentName || DEFAULTS.componentName;
100
+ const attributeName = options.attributeName || DEFAULTS.attributeName;
101
+ const caseSensitive = options.caseSensitive ?? true;
102
+
103
+ const whitelistRaw = Array.isArray(options.whitelist)
104
+ ? options.whitelist
105
+ : DEFAULTS.whitelist;
106
+
107
+ const normalize = (s) =>
108
+ caseSensitive ? String(s) : String(s).toLowerCase();
109
+
110
+ const whitelist = new Set(whitelistRaw.map(normalize));
111
+
112
+ function isTargetComponent(node) {
113
+ // Supports: <FontAwesome6 />, <NS.FontAwesome6 />
114
+ const nameNode = node.name;
115
+ if (!nameNode) return false;
116
+
117
+ if (nameNode.type === 'JSXIdentifier') {
118
+ return nameNode.name === componentName;
119
+ }
120
+
121
+ if (nameNode.type === 'JSXMemberExpression') {
122
+ // e.g., UI.FontAwesome6
123
+ let base = nameNode;
124
+ while (base.type === 'JSXMemberExpression') {
125
+ if (base.property && base.property.name === componentName) {
126
+ return true;
127
+ }
128
+ base = base.object;
129
+ }
130
+ }
131
+
132
+ return false;
133
+ }
134
+
135
+ return {
136
+ JSXOpeningElement(opening) {
137
+ if (!isTargetComponent(opening)) return;
138
+
139
+ const attrNode = getJSXAttribute(opening, attributeName);
140
+ if (!attrNode) return;
141
+
142
+ const literal = getStringLiteralValue(attrNode);
143
+
144
+ // Only lint when it's a string literal
145
+ if (literal == null) return;
146
+
147
+ const normalized = normalize(literal);
148
+ if (!whitelist.has(normalized)) {
149
+ context.report({
150
+ node: attrNode.value || attrNode,
151
+ messageId: 'invalidName',
152
+ data: {
153
+ componentName,
154
+ name: literal,
155
+ suggestion: getSuggestion(normalized, literal),
156
+ },
157
+ });
158
+ }
159
+ },
160
+ };
161
+ },
162
+ };
163
+
164
+ function getSuggestion(name, originalName) {
165
+ if (replacements[name]) {
166
+ return `请更换为 ${replacements[name]}`
167
+ }
168
+
169
+ if (v5OnlyNamesSet.has(name)) {
170
+ return `${originalName} 只能和 FontAwesome5 组件一起使用`
171
+ }
172
+
173
+ return '请更换为其他图标'
174
+ }
@@ -0,0 +1,388 @@
1
+ const v5names = [
2
+ "acquisitions-incorporated",
3
+ "behance-square",
4
+ "dribbble-square",
5
+ "facebook-square",
6
+ "font-awesome-alt",
7
+ "font-awesome-flag",
8
+ "font-awesome-logo-full",
9
+ "git-square",
10
+ "github-square",
11
+ "google-plus-square",
12
+ "hacker-news-square",
13
+ "innosoft",
14
+ "instagram-square",
15
+ "js-square",
16
+ "lastfm-square",
17
+ "medium-m",
18
+ "odnoklassniki-square",
19
+ "penny-arcade",
20
+ "pied-piper-square",
21
+ "pinterest-square",
22
+ "reddit-square",
23
+ "slack-hash",
24
+ "snapchat-ghost",
25
+ "snapchat-square",
26
+ "steam-square",
27
+ "telegram-plane",
28
+ "tripadvisor",
29
+ "tumblr-square",
30
+ "twitter-square",
31
+ "viadeo-square",
32
+ "vimeo-square",
33
+ "whatsapp-square",
34
+ "xing-square",
35
+ "youtube-square",
36
+ "angry",
37
+ "arrow-alt-circle-down",
38
+ "arrow-alt-circle-left",
39
+ "arrow-alt-circle-right",
40
+ "arrow-alt-circle-up",
41
+ "calendar-alt",
42
+ "calendar-times",
43
+ "caret-square-down",
44
+ "caret-square-left",
45
+ "caret-square-right",
46
+ "caret-square-up",
47
+ "check-circle",
48
+ "check-square",
49
+ "comment-alt",
50
+ "dizzy",
51
+ "dot-circle",
52
+ "edit",
53
+ "file-alt",
54
+ "file-archive",
55
+ "flushed",
56
+ "frown-open",
57
+ "frown",
58
+ "grimace",
59
+ "grin-alt",
60
+ "grin-beam-sweat",
61
+ "grin-beam",
62
+ "grin-hearts",
63
+ "grin-squint-tears",
64
+ "grin-squint",
65
+ "grin-stars",
66
+ "grin-tears",
67
+ "grin-tongue-squint",
68
+ "grin-tongue-wink",
69
+ "grin-tongue",
70
+ "grin-wink",
71
+ "grin",
72
+ "hand-paper",
73
+ "hand-rock",
74
+ "hdd",
75
+ "kiss-beam",
76
+ "kiss-wink-heart",
77
+ "kiss",
78
+ "laugh-beam",
79
+ "laugh-squint",
80
+ "laugh-wink",
81
+ "laugh",
82
+ "list-alt",
83
+ "meh-blank",
84
+ "meh-rolling-eyes",
85
+ "meh",
86
+ "minus-square",
87
+ "money-bill-alt",
88
+ "pause-circle",
89
+ "play-circle",
90
+ "plus-square",
91
+ "question-circle",
92
+ "sad-cry",
93
+ "sad-tear",
94
+ "save",
95
+ "share-square",
96
+ "smile-beam",
97
+ "smile-wink",
98
+ "smile",
99
+ "sticky-note",
100
+ "stop-circle",
101
+ "surprise",
102
+ "times-circle",
103
+ "tired",
104
+ "trash-alt",
105
+ "user-circle",
106
+ "window-close",
107
+ "ad",
108
+ "adjust",
109
+ "air-freshener",
110
+ "allergies",
111
+ "ambulance",
112
+ "american-sign-language-interpreting",
113
+ "angle-double-down",
114
+ "angle-double-left",
115
+ "angle-double-right",
116
+ "angle-double-up",
117
+ "apple-alt",
118
+ "archive",
119
+ "arrow-circle-down",
120
+ "arrow-circle-left",
121
+ "arrow-circle-right",
122
+ "arrow-circle-up",
123
+ "arrows-alt-h",
124
+ "arrows-alt-v",
125
+ "arrows-alt",
126
+ "assistive-listening-systems",
127
+ "atlas",
128
+ "backspace",
129
+ "balance-scale-left",
130
+ "balance-scale-right",
131
+ "balance-scale",
132
+ "band-aid",
133
+ "baseball-ball",
134
+ "basketball-ball",
135
+ "beer",
136
+ "bible",
137
+ "biking",
138
+ "birthday-cake",
139
+ "blind",
140
+ "book-dead",
141
+ "book-reader",
142
+ "border-style",
143
+ "boxes",
144
+ "broadcast-tower",
145
+ "burn",
146
+ "bus-alt",
147
+ "car-alt",
148
+ "car-crash",
149
+ "chalkboard-teacher",
150
+ "chevron-circle-down",
151
+ "chevron-circle-left",
152
+ "chevron-circle-right",
153
+ "chevron-circle-up",
154
+ "clinic-medical",
155
+ "cloud-download-alt",
156
+ "cloud-upload-alt",
157
+ "cocktail",
158
+ "coffee",
159
+ "cog",
160
+ "cogs",
161
+ "columns",
162
+ "compress-alt",
163
+ "compress-arrows-alt",
164
+ "concierge-bell",
165
+ "crop-alt",
166
+ "cut",
167
+ "deaf",
168
+ "diagnoses",
169
+ "digital-tachograph",
170
+ "directions",
171
+ "dolly-flatbed",
172
+ "donate",
173
+ "drafting-compass",
174
+ "ellipsis-h",
175
+ "ellipsis-v",
176
+ "envelope-square",
177
+ "exchange-alt",
178
+ "exclamation-circle",
179
+ "exclamation-triangle",
180
+ "expand-alt",
181
+ "expand-arrows-alt",
182
+ "external-link-alt",
183
+ "external-link-square-alt",
184
+ "fast-backward",
185
+ "fast-forward",
186
+ "feather-alt",
187
+ "female",
188
+ "fighter-jet",
189
+ "file-download",
190
+ "file-medical-alt",
191
+ "file-upload",
192
+ "fire-alt",
193
+ "first-aid",
194
+ "fist-raised",
195
+ "football-ball",
196
+ "funnel-dollar",
197
+ "glass-cheers",
198
+ "glass-martini-alt",
199
+ "glass-martini",
200
+ "glass-whiskey",
201
+ "globe-africa",
202
+ "globe-americas",
203
+ "globe-asia",
204
+ "globe-europe",
205
+ "golf-ball",
206
+ "grip-horizontal",
207
+ "h-square",
208
+ "hamburger",
209
+ "hand-holding-usd",
210
+ "hand-holding-water",
211
+ "hands-helping",
212
+ "hands-wash",
213
+ "handshake-alt-slash",
214
+ "hard-hat",
215
+ "headphones-alt",
216
+ "heart-broken",
217
+ "heartbeat",
218
+ "hiking",
219
+ "history",
220
+ "home",
221
+ "hospital-alt",
222
+ "hospital-symbol",
223
+ "hot-tub",
224
+ "house-damage",
225
+ "hryvnia",
226
+ "id-card-alt",
227
+ "info-circle",
228
+ "journal-whills",
229
+ "laptop-house",
230
+ "level-down-alt",
231
+ "level-up-alt",
232
+ "long-arrow-alt-down",
233
+ "long-arrow-alt-left",
234
+ "long-arrow-alt-right",
235
+ "long-arrow-alt-up",
236
+ "low-vision",
237
+ "luggage-cart",
238
+ "magic",
239
+ "mail-bulk",
240
+ "male",
241
+ "map-marked-alt",
242
+ "map-marked",
243
+ "map-marker-alt",
244
+ "map-marker",
245
+ "map-signs",
246
+ "mars-stroke-h",
247
+ "mars-stroke-v",
248
+ "medkit",
249
+ "microphone-alt-slash",
250
+ "microphone-alt",
251
+ "minus-circle",
252
+ "mobile-alt",
253
+ "money-bill-wave-alt",
254
+ "money-check-alt",
255
+ "mouse-pointer",
256
+ "mouse",
257
+ "paint-brush",
258
+ "parking",
259
+ "pastafarianism",
260
+ "pen-alt",
261
+ "pen-square",
262
+ "pencil-alt",
263
+ "pencil-ruler",
264
+ "people-carry",
265
+ "percentage",
266
+ "phone-alt",
267
+ "phone-square-alt",
268
+ "phone-square",
269
+ "photo-video",
270
+ "plus-circle",
271
+ "poll-h",
272
+ "poll",
273
+ "portrait",
274
+ "pound-sign",
275
+ "pray",
276
+ "praying-hands",
277
+ "prescription-bottle-alt",
278
+ "procedures",
279
+ "project-diagram",
280
+ "quidditch",
281
+ "quran",
282
+ "radiation-alt",
283
+ "random",
284
+ "redo-alt",
285
+ "redo",
286
+ "remove-format",
287
+ "rss-square",
288
+ "running",
289
+ "search-dollar",
290
+ "search-location",
291
+ "search-minus",
292
+ "search-plus",
293
+ "search",
294
+ "share-alt-square",
295
+ "share-alt",
296
+ "shield-alt",
297
+ "shipping-fast",
298
+ "shopping-bag",
299
+ "shopping-basket",
300
+ "shopping-cart",
301
+ "shuttle-van",
302
+ "sign-in-alt",
303
+ "sign-language",
304
+ "sign-out-alt",
305
+ "sign",
306
+ "skating",
307
+ "skiing-nordic",
308
+ "skiing",
309
+ "sliders-h",
310
+ "smoking-ban",
311
+ "sms",
312
+ "snowboarding",
313
+ "sort-alpha-down-alt",
314
+ "sort-alpha-down",
315
+ "sort-alpha-up-alt",
316
+ "sort-alpha-up",
317
+ "sort-amount-down-alt",
318
+ "sort-amount-down",
319
+ "sort-amount-up-alt",
320
+ "sort-amount-up",
321
+ "sort-numeric-down-alt",
322
+ "sort-numeric-down",
323
+ "sort-numeric-up-alt",
324
+ "sort-numeric-up",
325
+ "space-shuttle",
326
+ "square-root-alt",
327
+ "star-half-alt",
328
+ "step-backward",
329
+ "step-forward",
330
+ "store-alt-slash",
331
+ "store-alt",
332
+ "stream",
333
+ "subway",
334
+ "swimmer",
335
+ "swimming-pool",
336
+ "sync-alt",
337
+ "sync",
338
+ "table-tennis",
339
+ "tablet-alt",
340
+ "tachometer-alt",
341
+ "tasks",
342
+ "tenge",
343
+ "th-large",
344
+ "th-list",
345
+ "th",
346
+ "theater-masks",
347
+ "thermometer-empty",
348
+ "thermometer-full",
349
+ "thermometer-half",
350
+ "thermometer-quarter",
351
+ "thermometer-three-quarters",
352
+ "ticket-alt",
353
+ "times",
354
+ "tint-slash",
355
+ "tint",
356
+ "tools",
357
+ "torah",
358
+ "tram",
359
+ "transgender-alt",
360
+ "trash-restore-alt",
361
+ "trash-restore",
362
+ "truck-loading",
363
+ "tshirt",
364
+ "undo-alt",
365
+ "undo",
366
+ "university",
367
+ "unlink",
368
+ "unlock-alt",
369
+ "user-alt-slash",
370
+ "user-alt",
371
+ "user-cog",
372
+ "user-edit",
373
+ "user-friends",
374
+ "user-md",
375
+ "user-times",
376
+ "users-cog",
377
+ "utensil-spoon",
378
+ "volleyball-ball",
379
+ "volume-down",
380
+ "volume-mute",
381
+ "volume-up",
382
+ "vote-yea",
383
+ "walking",
384
+ "weight",
385
+ "wine-glass-alt"
386
+ ]
387
+
388
+ module.exports = v5names
@@ -0,0 +1,9 @@
1
+ const noEmoji = require('./rule')
2
+
3
+ const plugin = {
4
+ rules: {
5
+ 'no-emoji': noEmoji,
6
+ },
7
+ }
8
+
9
+ module.exports = plugin
@@ -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
+ }