@cubocicloide/stack-react-fastapi 13.0.6

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 (295) hide show
  1. package/LICENSE +33 -0
  2. package/README.md +66 -0
  3. package/dist/commands/lint/checks/BE/001.d.ts +6 -0
  4. package/dist/commands/lint/checks/BE/001.js +95 -0
  5. package/dist/commands/lint/checks/BE/001.js.map +1 -0
  6. package/dist/commands/lint/checks/BE/002.d.ts +6 -0
  7. package/dist/commands/lint/checks/BE/002.js +30 -0
  8. package/dist/commands/lint/checks/BE/002.js.map +1 -0
  9. package/dist/commands/lint/checks/BE/003.d.ts +11 -0
  10. package/dist/commands/lint/checks/BE/003.js +46 -0
  11. package/dist/commands/lint/checks/BE/003.js.map +1 -0
  12. package/dist/commands/lint/checks/BE/004.d.ts +6 -0
  13. package/dist/commands/lint/checks/BE/004.js +27 -0
  14. package/dist/commands/lint/checks/BE/004.js.map +1 -0
  15. package/dist/commands/lint/checks/BE/005.d.ts +6 -0
  16. package/dist/commands/lint/checks/BE/005.js +107 -0
  17. package/dist/commands/lint/checks/BE/005.js.map +1 -0
  18. package/dist/commands/lint/checks/BE/006.d.ts +6 -0
  19. package/dist/commands/lint/checks/BE/006.js +27 -0
  20. package/dist/commands/lint/checks/BE/006.js.map +1 -0
  21. package/dist/commands/lint/checks/BE/007.d.ts +31 -0
  22. package/dist/commands/lint/checks/BE/007.js +109 -0
  23. package/dist/commands/lint/checks/BE/007.js.map +1 -0
  24. package/dist/commands/lint/checks/BE/008.d.ts +12 -0
  25. package/dist/commands/lint/checks/BE/008.js +57 -0
  26. package/dist/commands/lint/checks/BE/008.js.map +1 -0
  27. package/dist/commands/lint/checks/BE/009.d.ts +12 -0
  28. package/dist/commands/lint/checks/BE/009.js +104 -0
  29. package/dist/commands/lint/checks/BE/009.js.map +1 -0
  30. package/dist/commands/lint/checks/BE/010.d.ts +12 -0
  31. package/dist/commands/lint/checks/BE/010.js +54 -0
  32. package/dist/commands/lint/checks/BE/010.js.map +1 -0
  33. package/dist/commands/lint/checks/BE/011.d.ts +16 -0
  34. package/dist/commands/lint/checks/BE/011.js +46 -0
  35. package/dist/commands/lint/checks/BE/011.js.map +1 -0
  36. package/dist/commands/lint/checks/E2E/001.d.ts +6 -0
  37. package/dist/commands/lint/checks/E2E/001.js +35 -0
  38. package/dist/commands/lint/checks/E2E/001.js.map +1 -0
  39. package/dist/commands/lint/checks/E2E/002.d.ts +6 -0
  40. package/dist/commands/lint/checks/E2E/002.js +37 -0
  41. package/dist/commands/lint/checks/E2E/002.js.map +1 -0
  42. package/dist/commands/lint/checks/E2E/003.d.ts +6 -0
  43. package/dist/commands/lint/checks/E2E/003.js +42 -0
  44. package/dist/commands/lint/checks/E2E/003.js.map +1 -0
  45. package/dist/commands/lint/checks/E2E/004.d.ts +6 -0
  46. package/dist/commands/lint/checks/E2E/004.js +37 -0
  47. package/dist/commands/lint/checks/E2E/004.js.map +1 -0
  48. package/dist/commands/lint/checks/E2E/005.d.ts +6 -0
  49. package/dist/commands/lint/checks/E2E/005.js +47 -0
  50. package/dist/commands/lint/checks/E2E/005.js.map +1 -0
  51. package/dist/commands/lint/checks/E2E/006.d.ts +6 -0
  52. package/dist/commands/lint/checks/E2E/006.js +28 -0
  53. package/dist/commands/lint/checks/E2E/006.js.map +1 -0
  54. package/dist/commands/lint/checks/E2E/007.d.ts +6 -0
  55. package/dist/commands/lint/checks/E2E/007.js +47 -0
  56. package/dist/commands/lint/checks/E2E/007.js.map +1 -0
  57. package/dist/commands/lint/checks/FE/001.d.ts +6 -0
  58. package/dist/commands/lint/checks/FE/001.js +56 -0
  59. package/dist/commands/lint/checks/FE/001.js.map +1 -0
  60. package/dist/commands/lint/checks/FE/002.d.ts +6 -0
  61. package/dist/commands/lint/checks/FE/002.js +80 -0
  62. package/dist/commands/lint/checks/FE/002.js.map +1 -0
  63. package/dist/commands/lint/checks/FE/003.d.ts +6 -0
  64. package/dist/commands/lint/checks/FE/003.js +65 -0
  65. package/dist/commands/lint/checks/FE/003.js.map +1 -0
  66. package/dist/commands/lint/checks/FE/004.d.ts +6 -0
  67. package/dist/commands/lint/checks/FE/004.js +72 -0
  68. package/dist/commands/lint/checks/FE/004.js.map +1 -0
  69. package/dist/commands/lint/checks/FE/005.d.ts +6 -0
  70. package/dist/commands/lint/checks/FE/005.js +103 -0
  71. package/dist/commands/lint/checks/FE/005.js.map +1 -0
  72. package/dist/commands/lint/checks/FE/006.d.ts +6 -0
  73. package/dist/commands/lint/checks/FE/006.js +102 -0
  74. package/dist/commands/lint/checks/FE/006.js.map +1 -0
  75. package/dist/commands/lint/checks/FE/007.d.ts +6 -0
  76. package/dist/commands/lint/checks/FE/007.js +60 -0
  77. package/dist/commands/lint/checks/FE/007.js.map +1 -0
  78. package/dist/commands/lint/checks/FE/008.d.ts +6 -0
  79. package/dist/commands/lint/checks/FE/008.js +115 -0
  80. package/dist/commands/lint/checks/FE/008.js.map +1 -0
  81. package/dist/commands/lint/checks/FE/009.d.ts +6 -0
  82. package/dist/commands/lint/checks/FE/009.js +83 -0
  83. package/dist/commands/lint/checks/FE/009.js.map +1 -0
  84. package/dist/commands/lint/checks/FE/010.d.ts +6 -0
  85. package/dist/commands/lint/checks/FE/010.js +105 -0
  86. package/dist/commands/lint/checks/FE/010.js.map +1 -0
  87. package/dist/commands/lint/checks/FE/011.d.ts +6 -0
  88. package/dist/commands/lint/checks/FE/011.js +43 -0
  89. package/dist/commands/lint/checks/FE/011.js.map +1 -0
  90. package/dist/commands/lint/checks/FE/012.d.ts +6 -0
  91. package/dist/commands/lint/checks/FE/012.js +150 -0
  92. package/dist/commands/lint/checks/FE/012.js.map +1 -0
  93. package/dist/index.d.ts +5 -0
  94. package/dist/index.js +3491 -0
  95. package/dist/index.js.map +1 -0
  96. package/dude.stack.json +7 -0
  97. package/package.json +43 -0
  98. package/templates/aws-eks/backend/Dockerfile.prod.hbs +22 -0
  99. package/templates/aws-eks/docs/docs/deploy.md.hbs +159 -0
  100. package/templates/aws-eks/frontend/Dockerfile.prod +28 -0
  101. package/templates/aws-eks/frontend/nginx.conf +19 -0
  102. package/templates/aws-eks/iac/README.md.hbs +311 -0
  103. package/templates/aws-eks/iac/_gitignore +24 -0
  104. package/templates/aws-eks/iac/helm/app/.helmignore +7 -0
  105. package/templates/aws-eks/iac/helm/app/Chart.yaml.hbs +6 -0
  106. package/templates/aws-eks/iac/helm/app/templates/NOTES.txt +23 -0
  107. package/templates/aws-eks/iac/helm/app/templates/backend-deployment.yaml +44 -0
  108. package/templates/aws-eks/iac/helm/app/templates/backend-service.yaml +16 -0
  109. package/templates/aws-eks/iac/helm/app/templates/celery-beat-deployment.yaml +34 -0
  110. package/templates/aws-eks/iac/helm/app/templates/celery-worker-deployment.yaml +31 -0
  111. package/templates/aws-eks/iac/helm/app/templates/configmap.yaml +15 -0
  112. package/templates/aws-eks/iac/helm/app/templates/flower-deployment.yaml +28 -0
  113. package/templates/aws-eks/iac/helm/app/templates/flower-service.yaml +19 -0
  114. package/templates/aws-eks/iac/helm/app/templates/frontend-deployment.yaml +34 -0
  115. package/templates/aws-eks/iac/helm/app/templates/frontend-service.yaml +16 -0
  116. package/templates/aws-eks/iac/helm/app/templates/helpers.tpl +90 -0
  117. package/templates/aws-eks/iac/helm/app/templates/hpa.yaml +23 -0
  118. package/templates/aws-eks/iac/helm/app/templates/ingress.yaml +30 -0
  119. package/templates/aws-eks/iac/helm/app/templates/migration-job.yaml +38 -0
  120. package/templates/aws-eks/iac/helm/app/templates/redis-deployment.yaml +33 -0
  121. package/templates/aws-eks/iac/helm/app/templates/redis-service.yaml +18 -0
  122. package/templates/aws-eks/iac/helm/app/templates/secret.yaml +17 -0
  123. package/templates/aws-eks/iac/helm/app/templates/serviceaccount.yaml +12 -0
  124. package/templates/aws-eks/iac/helm/app/values-dev.yaml.hbs +35 -0
  125. package/templates/aws-eks/iac/helm/app/values.yaml.hbs +130 -0
  126. package/templates/aws-eks/iac/runner/Dockerfile +53 -0
  127. package/templates/aws-eks/iac/terraform/bootstrap/main.tf.hbs +101 -0
  128. package/templates/aws-eks/iac/terraform/bootstrap/outputs.tf +19 -0
  129. package/templates/aws-eks/iac/terraform/bootstrap/variables.tf.hbs +17 -0
  130. package/templates/aws-eks/iac/terraform/environments/dev/backend.hcl.hbs +12 -0
  131. package/templates/aws-eks/iac/terraform/environments/dev/terraform.tfvars.hbs +32 -0
  132. package/templates/aws-eks/iac/terraform/main.tf.hbs +305 -0
  133. package/templates/aws-eks/iac/terraform/outputs.tf.hbs +52 -0
  134. package/templates/aws-eks/iac/terraform/providers.tf +47 -0
  135. package/templates/aws-eks/iac/terraform/variables.tf.hbs +181 -0
  136. package/templates/aws-eks/iac/terraform/versions.tf +27 -0
  137. package/templates/base/.claude/agents/issue-fixer.md +190 -0
  138. package/templates/base/.claude/agents/security-fixer.md +250 -0
  139. package/templates/base/.claude/rules/BE/001.md +25 -0
  140. package/templates/base/.claude/rules/BE/002.md +15 -0
  141. package/templates/base/.claude/rules/BE/003.md +18 -0
  142. package/templates/base/.claude/rules/BE/004.md +14 -0
  143. package/templates/base/.claude/rules/BE/005.md +15 -0
  144. package/templates/base/.claude/rules/BE/006.md +17 -0
  145. package/templates/base/.claude/rules/BE/007.md +21 -0
  146. package/templates/base/.claude/rules/BE/008.md +19 -0
  147. package/templates/base/.claude/rules/BE/009.md +27 -0
  148. package/templates/base/.claude/rules/BE/010.md +16 -0
  149. package/templates/base/.claude/rules/BE/011.md +15 -0
  150. package/templates/base/.claude/rules/E2E/001.md +13 -0
  151. package/templates/base/.claude/rules/E2E/002.md +14 -0
  152. package/templates/base/.claude/rules/E2E/003.md +10 -0
  153. package/templates/base/.claude/rules/E2E/004.md +23 -0
  154. package/templates/base/.claude/rules/E2E/005.md +15 -0
  155. package/templates/base/.claude/rules/E2E/006.md +13 -0
  156. package/templates/base/.claude/rules/E2E/007.md +18 -0
  157. package/templates/base/.claude/rules/FE/001.md +22 -0
  158. package/templates/base/.claude/rules/FE/002.md +39 -0
  159. package/templates/base/.claude/rules/FE/003.md +19 -0
  160. package/templates/base/.claude/rules/FE/004.md +21 -0
  161. package/templates/base/.claude/rules/FE/005.md +33 -0
  162. package/templates/base/.claude/rules/FE/006.md +24 -0
  163. package/templates/base/.claude/rules/FE/007.md +19 -0
  164. package/templates/base/.claude/rules/FE/008.md +26 -0
  165. package/templates/base/.claude/rules/FE/009.md +30 -0
  166. package/templates/base/.claude/rules/FE/010.md +25 -0
  167. package/templates/base/.claude/rules/FE/011.md +22 -0
  168. package/templates/base/.claude/rules/FE/012.md +32 -0
  169. package/templates/base/.claude/settings.json +53 -0
  170. package/templates/base/.claude/skills/clean-branches/SKILL.md +100 -0
  171. package/templates/base/.claude/skills/create/SKILL.md +47 -0
  172. package/templates/base/.claude/skills/create-jira-issue/SKILL.md +174 -0
  173. package/templates/base/.claude/skills/create-page/SKILL.md +195 -0
  174. package/templates/base/.claude/skills/create-route/SKILL.md +199 -0
  175. package/templates/base/.claude/skills/draft-email/SKILL.md +104 -0
  176. package/templates/base/.claude/skills/fix-issues/SKILL.md +238 -0
  177. package/templates/base/.claude/skills/security-scan/SKILL.md +297 -0
  178. package/templates/base/.claude/skills/verify-security-fixes/SKILL.md +180 -0
  179. package/templates/base/.dude/commands/README.md +85 -0
  180. package/templates/base/.dude/commands/hello.ts +34 -0
  181. package/templates/base/.dude/lint/checks/PRJ/001.ts +26 -0
  182. package/templates/base/.dude/lint/checks/README.md +69 -0
  183. package/templates/base/.vscode/tasks.json +44 -0
  184. package/templates/base/.worktreeinclude +2 -0
  185. package/templates/base/CLAUDE.md.hbs +364 -0
  186. package/templates/base/README.md.hbs +187 -0
  187. package/templates/base/_env.example.hbs +29 -0
  188. package/templates/base/_env.hbs +25 -0
  189. package/templates/base/_gitignore +31 -0
  190. package/templates/base/_npmrc +2 -0
  191. package/templates/base/backend/Dockerfile.hbs +22 -0
  192. package/templates/base/backend/README.md.hbs +74 -0
  193. package/templates/base/backend/_dockerignore +11 -0
  194. package/templates/base/backend/app/__init__.py +1 -0
  195. package/templates/base/backend/app/core/__init__.py +0 -0
  196. package/templates/base/backend/app/core/config.py.hbs +23 -0
  197. package/templates/base/backend/app/fixtures/__init__.py +0 -0
  198. package/templates/base/backend/app/main.py.hbs +41 -0
  199. package/templates/base/backend/app/management/__init__.py +0 -0
  200. package/templates/base/backend/app/models/__init__.py +0 -0
  201. package/templates/base/backend/app/queries/__init__.py +0 -0
  202. package/templates/base/backend/app/routers/__init__.py +0 -0
  203. package/templates/base/backend/app/routers/health.py +13 -0
  204. package/templates/base/backend/app/schemas/__init__.py +0 -0
  205. package/templates/base/backend/app/schemas/health.py +7 -0
  206. package/templates/base/backend/app/tasks/__init__.py +1 -0
  207. package/templates/base/backend/app/tests/__init__.py +0 -0
  208. package/templates/base/backend/app/tests/conftest.py +13 -0
  209. package/templates/base/backend/app/tests/models/__init__.py +0 -0
  210. package/templates/base/backend/app/tests/queries/__init__.py +0 -0
  211. package/templates/base/backend/app/tests/routers/__init__.py +0 -0
  212. package/templates/base/backend/app/tests/routers/test_health.py +10 -0
  213. package/templates/base/backend/app/tests/tasks/__init__.py +1 -0
  214. package/templates/base/backend/app/tests/utils/__init__.py +0 -0
  215. package/templates/base/backend/app/utils/__init__.py +0 -0
  216. package/templates/base/backend/pyproject.toml.hbs +40 -0
  217. package/templates/base/docker-compose.yml.hbs +128 -0
  218. package/templates/base/docs/docs/api.md +21 -0
  219. package/templates/base/docs/docs/dude.md.hbs +316 -0
  220. package/templates/base/docs/docs/index.md.hbs +100 -0
  221. package/templates/base/docs/docs/mkdocs.md +238 -0
  222. package/templates/base/docs/mkdocs.yml.hbs +52 -0
  223. package/templates/base/e2e/.prettierrc.json +1 -0
  224. package/templates/base/e2e/_prettierignore +3 -0
  225. package/templates/base/e2e/cucumber.js +21 -0
  226. package/templates/base/e2e/eslint.config.mjs +14 -0
  227. package/templates/base/e2e/features/example.feature +13 -0
  228. package/templates/base/e2e/package.json.hbs +30 -0
  229. package/templates/base/e2e/pages/ExamplePage.ts +16 -0
  230. package/templates/base/e2e/playwright.config.ts +27 -0
  231. package/templates/base/e2e/steps/common.steps.ts +32 -0
  232. package/templates/base/e2e/steps/example.steps.ts +4 -0
  233. package/templates/base/e2e/support/hooks.ts +72 -0
  234. package/templates/base/e2e/support/world.ts +24 -0
  235. package/templates/base/e2e/tsconfig.json +22 -0
  236. package/templates/base/frontend/.prettierrc.json +6 -0
  237. package/templates/base/frontend/Dockerfile +10 -0
  238. package/templates/base/frontend/_dockerignore +4 -0
  239. package/templates/base/frontend/eslint.config.js +32 -0
  240. package/templates/base/frontend/index.html.hbs +13 -0
  241. package/templates/base/frontend/package.json.hbs +38 -0
  242. package/templates/base/frontend/public/favicon.svg +5 -0
  243. package/templates/base/frontend/src/$components/Layout/$assets/logo.svg +5 -0
  244. package/templates/base/frontend/src/$components/Layout/constants.tsx.hbs +10 -0
  245. package/templates/base/frontend/src/$components/Layout/index.tsx +80 -0
  246. package/templates/base/frontend/src/$components/Layout/types.tsx +9 -0
  247. package/templates/base/frontend/src/$components/index.tsx +1 -0
  248. package/templates/base/frontend/src/$hooks/index.tsx +2 -0
  249. package/templates/base/frontend/src/$hooks/useCounterStore/index.tsx +28 -0
  250. package/templates/base/frontend/src/$hooks/useCounterStore/types.tsx +7 -0
  251. package/templates/base/frontend/src/$hooks/usePageTitle/index.tsx +21 -0
  252. package/templates/base/frontend/src/$types/vite-env.d.ts +10 -0
  253. package/templates/base/frontend/src/App.tsx.hbs +40 -0
  254. package/templates/base/frontend/src/main.tsx +10 -0
  255. package/templates/base/frontend/src/openapi/utils/openapi.yaml.hbs +28 -0
  256. package/templates/base/frontend/src/pages/constants.tsx +31 -0
  257. package/templates/base/frontend/src/pages/index.tsx +192 -0
  258. package/templates/base/frontend/src/pages/types.tsx +6 -0
  259. package/templates/base/frontend/src/styles.module.css +7 -0
  260. package/templates/base/frontend/src/utils/constants.tsx +11 -0
  261. package/templates/base/frontend/src/utils/formatters/index.tsx +49 -0
  262. package/templates/base/frontend/src/utils/functions.tsx +70 -0
  263. package/templates/base/frontend/src/utils/index.tsx +3 -0
  264. package/templates/base/frontend/tsconfig.json +24 -0
  265. package/templates/base/frontend/vite.config.ts +20 -0
  266. package/templates/base/package.json.hbs +11 -0
  267. package/templates/base/security/baseline.json +4 -0
  268. package/templates/celery/backend/app/tasks/__init__.py +1 -0
  269. package/templates/celery/backend/app/tasks/example.py +21 -0
  270. package/templates/celery/backend/app/tests/tasks/test_example.py +7 -0
  271. package/templates/celery/backend/app/worker.py.hbs +33 -0
  272. package/templates/celerybeat/backend/app/tasks/scheduled.py +16 -0
  273. package/templates/celerybeat/backend/app/tests/tasks/test_scheduled.py +7 -0
  274. package/templates/postgres/.dude/commands/reset.ts +76 -0
  275. package/templates/postgres/backend/alembic/env.py +55 -0
  276. package/templates/postgres/backend/alembic/script.py.mako +27 -0
  277. package/templates/postgres/backend/alembic/versions/0001_create_user_table.py +38 -0
  278. package/templates/postgres/backend/alembic.ini +42 -0
  279. package/templates/postgres/backend/app/core/database.py +15 -0
  280. package/templates/postgres/backend/app/models/__init__.py +5 -0
  281. package/templates/postgres/backend/app/models/user.py +15 -0
  282. package/templates/postgres/backend/app/queries/__init__.py +5 -0
  283. package/templates/postgres/backend/app/queries/users.py +18 -0
  284. package/templates/postgres/backend/app/routers/users.py +19 -0
  285. package/templates/postgres/backend/app/routers/users__id.py +20 -0
  286. package/templates/postgres/backend/app/tests/conftest.py +33 -0
  287. package/templates/postgres/backend/app/tests/models/test_user.py +12 -0
  288. package/templates/postgres/backend/app/tests/queries/test_users.py +12 -0
  289. package/templates/postgres/backend/app/tests/routers/test_users.py +10 -0
  290. package/templates/postgres/backend/app/tests/routers/test_users__id.py +9 -0
  291. package/templates/postgres/backend/start.sh +32 -0
  292. package/templates/postgres/frontend/src/openapi/utils/openapi.yaml.hbs +138 -0
  293. package/templates/postgres/frontend/src/pages/users/[id]/index.tsx +51 -0
  294. package/templates/postgres/frontend/src/pages/users/index.tsx +54 -0
  295. package/templates/postgres/frontend/src/pages/users/types.tsx +4 -0
@@ -0,0 +1,105 @@
1
+ // src/commands/lint/checks/FE/010.ts
2
+ import { readdirSync as readdirSync2, existsSync as existsSync2 } from "fs";
3
+ import path2 from "pathe";
4
+
5
+ // src/commands/lint/frontend-structure.ts
6
+ import { readdirSync, existsSync } from "fs";
7
+ import path from "pathe";
8
+ function frontendSrc(root) {
9
+ return path.join(root, "frontend", "src");
10
+ }
11
+ function diag(root, absPath, severity, message) {
12
+ return { file: path.relative(root, absPath), line: 1, col: 1, severity, message };
13
+ }
14
+
15
+ // src/commands/lint/checks/FE/010.ts
16
+ var ALLOWED_ROOT_FILES = /* @__PURE__ */ new Set(["App.tsx", "main.tsx", "styles.module.css"]);
17
+ var ALLOWED_ROOT_DIRS = /* @__PURE__ */ new Set(["$types", "$components", "$hooks", "openapi", "pages", "utils"]);
18
+ var LEGACY_ENTRIES = /* @__PURE__ */ new Map([
19
+ ["components", "move it to $components/"],
20
+ ["hooks", "move it to $hooks/"],
21
+ ["assets", "move each asset into the $assets/ folder of its owning scope"],
22
+ ["index.css", "rename it to styles.module.css"],
23
+ ["vite-env.d.ts", "move it to $types/vite-env.d.ts"]
24
+ ]);
25
+ function check(root) {
26
+ const srcDir = frontendSrc(root);
27
+ if (!existsSync2(srcDir)) return [];
28
+ const results = [];
29
+ for (const entry of readdirSync2(srcDir, { withFileTypes: true })) {
30
+ const entryPath = path2.join(srcDir, entry.name);
31
+ const legacyHint = LEGACY_ENTRIES.get(entry.name);
32
+ if (legacyHint) {
33
+ results.push(
34
+ diag(
35
+ root,
36
+ entryPath,
37
+ "error",
38
+ `"${entry.name}" belongs to the legacy frontend layout \u2014 ${legacyHint}`
39
+ )
40
+ );
41
+ continue;
42
+ }
43
+ if (entry.isDirectory()) {
44
+ if (!ALLOWED_ROOT_DIRS.has(entry.name)) {
45
+ results.push(
46
+ diag(
47
+ root,
48
+ entryPath,
49
+ "error",
50
+ `Unexpected directory "${entry.name}" at src root. Allowed: $types/, $components/, $hooks/, openapi/, pages/, utils/`
51
+ )
52
+ );
53
+ }
54
+ } else if (!ALLOWED_ROOT_FILES.has(entry.name)) {
55
+ results.push(
56
+ diag(
57
+ root,
58
+ entryPath,
59
+ "error",
60
+ `Unexpected file "${entry.name}" at src root. Allowed: App.tsx, main.tsx, styles.module.css`
61
+ )
62
+ );
63
+ }
64
+ }
65
+ const typesDir = path2.join(srcDir, "$types");
66
+ if (existsSync2(typesDir)) {
67
+ for (const entry of readdirSync2(typesDir, { withFileTypes: true })) {
68
+ if (entry.isDirectory() || !entry.name.endsWith(".d.ts")) {
69
+ results.push(
70
+ diag(
71
+ root,
72
+ path2.join(typesDir, entry.name),
73
+ "error",
74
+ `"${entry.name}" is not allowed in $types/ \u2014 the folder may only contain *.d.ts declaration files`
75
+ )
76
+ );
77
+ }
78
+ }
79
+ }
80
+ function findStrayDts(dir) {
81
+ for (const entry of readdirSync2(dir, { withFileTypes: true })) {
82
+ const entryPath = path2.join(dir, entry.name);
83
+ if (entry.isDirectory()) {
84
+ if (entry.name === "$misc" || entry.name === "$types" || entry.name === "node_modules")
85
+ continue;
86
+ findStrayDts(entryPath);
87
+ } else if (entry.name.endsWith(".d.ts")) {
88
+ results.push(
89
+ diag(
90
+ root,
91
+ entryPath,
92
+ "error",
93
+ `Type declaration "${entry.name}" must live in frontend/src/$types/`
94
+ )
95
+ );
96
+ }
97
+ }
98
+ }
99
+ findStrayDts(srcDir);
100
+ return results;
101
+ }
102
+ export {
103
+ check as default
104
+ };
105
+ //# sourceMappingURL=010.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/commands/lint/checks/FE/010.ts","../../../../../src/commands/lint/frontend-structure.ts"],"sourcesContent":["import { readdirSync, existsSync } from 'node:fs'\nimport path from 'pathe'\nimport type { RawDiagnostic } from '@cubocicloide/dude'\nimport { diag, frontendSrc } from '../../frontend-structure'\n\nconst ALLOWED_ROOT_FILES = new Set(['App.tsx', 'main.tsx', 'styles.module.css'])\nconst ALLOWED_ROOT_DIRS = new Set(['$types', '$components', '$hooks', 'openapi', 'pages', 'utils'])\n\n/** Legacy layout entries and where their content belongs now. */\nconst LEGACY_ENTRIES = new Map([\n ['components', 'move it to $components/'],\n ['hooks', 'move it to $hooks/'],\n ['assets', 'move each asset into the $assets/ folder of its owning scope'],\n ['index.css', 'rename it to styles.module.css'],\n ['vite-env.d.ts', 'move it to $types/vite-env.d.ts'],\n])\n\n/** FE010 — src root contains only the app entry files + $types/$components/$hooks/openapi/pages/utils; *.d.ts live in $types/ */\nexport default function check(root: string): RawDiagnostic[] {\n const srcDir = frontendSrc(root)\n if (!existsSync(srcDir)) return []\n\n const results: RawDiagnostic[] = []\n\n for (const entry of readdirSync(srcDir, { withFileTypes: true })) {\n const entryPath = path.join(srcDir, entry.name)\n const legacyHint = LEGACY_ENTRIES.get(entry.name)\n if (legacyHint) {\n results.push(\n diag(\n root,\n entryPath,\n 'error',\n `\"${entry.name}\" belongs to the legacy frontend layout — ${legacyHint}`,\n ),\n )\n continue\n }\n if (entry.isDirectory()) {\n if (!ALLOWED_ROOT_DIRS.has(entry.name)) {\n results.push(\n diag(\n root,\n entryPath,\n 'error',\n `Unexpected directory \"${entry.name}\" at src root. Allowed: $types/, $components/, $hooks/, openapi/, pages/, utils/`,\n ),\n )\n }\n } else if (!ALLOWED_ROOT_FILES.has(entry.name)) {\n results.push(\n diag(\n root,\n entryPath,\n 'error',\n `Unexpected file \"${entry.name}\" at src root. Allowed: App.tsx, main.tsx, styles.module.css`,\n ),\n )\n }\n }\n\n // $types/ may only contain *.d.ts files…\n const typesDir = path.join(srcDir, '$types')\n if (existsSync(typesDir)) {\n for (const entry of readdirSync(typesDir, { withFileTypes: true })) {\n if (entry.isDirectory() || !entry.name.endsWith('.d.ts')) {\n results.push(\n diag(\n root,\n path.join(typesDir, entry.name),\n 'error',\n `\"${entry.name}\" is not allowed in $types/ — the folder may only contain *.d.ts declaration files`,\n ),\n )\n }\n }\n }\n\n // …and every *.d.ts must live there.\n function findStrayDts(dir: string): void {\n for (const entry of readdirSync(dir, { withFileTypes: true })) {\n const entryPath = path.join(dir, entry.name)\n if (entry.isDirectory()) {\n if (entry.name === '$misc' || entry.name === '$types' || entry.name === 'node_modules')\n continue\n findStrayDts(entryPath)\n } else if (entry.name.endsWith('.d.ts')) {\n results.push(\n diag(\n root,\n entryPath,\n 'error',\n `Type declaration \"${entry.name}\" must live in frontend/src/$types/`,\n ),\n )\n }\n }\n }\n findStrayDts(srcDir)\n\n return results\n}\n","/**\n * Shared vocabulary for the FE lint checks (frontend `$`-structure).\n *\n * The frontend tree is organised in \"scopes\" (components, hooks, pages, utils\n * domains). Every scope owns the same file set (SCOPE_FILES) plus privileged\n * `$`-prefixed subdirectories ($components, $hooks, $assets, $misc). The `$`\n * prefix sorts these folders on top and makes them impossible to confuse with\n * a route segment or a domain name.\n *\n * Not a check module: it lives outside `checks/` so the runner never tries to\n * load it; tsup inlines it into each check entry.\n */\nimport { readdirSync, existsSync } from 'node:fs'\nimport path from 'pathe'\nimport type { RawDiagnostic, Severity } from '@cubocicloide/dude'\n\n/** Files every scope (component, hook, page, utils domain) may contain. */\nexport const SCOPE_FILES = new Set([\n 'index.tsx',\n 'styles.module.css',\n 'types.tsx',\n 'constants.tsx',\n 'functions.tsx',\n])\n\n/** Human-readable version of SCOPE_FILES for messages. */\nexport const SCOPE_FILES_LABEL = 'index.tsx, styles.module.css, types.tsx, constants.tsx, functions.tsx'\n\n/** The full set of privileged directory names. */\nexport const PRIVILEGED_DIRS = new Set(['$components', '$hooks', '$assets', '$misc', '$types'])\n\nexport const PASCAL_CASE = /^[A-Z][a-zA-Z0-9]*$/\nexport const KEBAB_CASE = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/\nexport const HOOK_NAME = /^use[A-Z][a-zA-Z0-9]*$/\n/** Dynamic route segment: [id], [userId], … */\nexport const DYNAMIC_SEGMENT = /^\\[[a-z][a-zA-Z0-9]*\\]$/\n\nexport function frontendSrc(root: string): string {\n return path.join(root, 'frontend', 'src')\n}\n\nexport function diag(\n root: string,\n absPath: string,\n severity: Severity,\n message: string,\n): RawDiagnostic {\n return { file: path.relative(root, absPath), line: 1, col: 1, severity, message }\n}\n\n/**\n * Recursively collect directories named `name` under `dir`.\n * Never descends into `$misc` (exempt from checks) or `node_modules`,\n * but a `$misc` directory itself is still reported when it matches `name`.\n */\nexport function findDirsNamed(dir: string, name: string): string[] {\n const found: string[] = []\n if (!existsSync(dir)) return found\n for (const entry of readdirSync(dir, { withFileTypes: true })) {\n if (!entry.isDirectory() || entry.name === 'node_modules') continue\n const full = path.join(dir, entry.name)\n if (entry.name === name) found.push(full)\n if (entry.name === '$misc') continue\n found.push(...findDirsNamed(full, name))\n }\n return found\n}\n\n/**\n * Collect page nodes under `pagesDir` as route paths relative to pages/\n * ('' = pages root). A page node is a directory whose index.tsx defines a\n * route. `$`-prefixed directories are structural, never route segments.\n */\nexport function collectPageNodes(pagesDir: string): string[] {\n const nodes: string[] = []\n if (!existsSync(pagesDir)) return nodes\n\n function walk(dir: string, route: string): void {\n if (existsSync(path.join(dir, 'index.tsx'))) nodes.push(route)\n for (const entry of readdirSync(dir, { withFileTypes: true })) {\n if (!entry.isDirectory() || entry.name.startsWith('$')) continue\n walk(path.join(dir, entry.name), route === '' ? entry.name : `${route}/${entry.name}`)\n }\n }\n\n walk(pagesDir, '')\n return nodes\n}\n"],"mappings":";AAAA,SAAS,eAAAA,cAAa,cAAAC,mBAAkB;AACxC,OAAOC,WAAU;;;ACWjB,SAAS,aAAa,kBAAkB;AACxC,OAAO,UAAU;AAwBV,SAAS,YAAY,MAAsB;AAChD,SAAO,KAAK,KAAK,MAAM,YAAY,KAAK;AAC1C;AAEO,SAAS,KACd,MACA,SACA,UACA,SACe;AACf,SAAO,EAAE,MAAM,KAAK,SAAS,MAAM,OAAO,GAAG,MAAM,GAAG,KAAK,GAAG,UAAU,QAAQ;AAClF;;;AD3CA,IAAM,qBAAqB,oBAAI,IAAI,CAAC,WAAW,YAA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xB,eAAW,SAASC,aAAY,UAAU,EAAE,eAAe,KAAK,CAAC,GAAG;AAClE,UAAI,MAAM,YAAY,KAAK,CAAC,MAAM,KAAK,SAAS,OAAO,GAAG;AACxD,gBAAQ;AAAA,UACN;AAAA,YACE;AAAA,YACAC,MAAK,KAAK,UAAU,MAAM,IAAI;AAAA,YAC9B;AAAA,YACA,IAAI,MAAM,IAAI;AAAA,UAChB;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAGA,WAAS,aAAa,KAAmB;AACvC,eAAW,SAASD,aAAY,KAAK,EAAE,eAAe,KAAK,CAAC,GAAG;AAC7D,YAAM,YAAYC,MAAK,KAAK,KAAK,MAAM,IAAI;AAC3C,UAAI,MAAM,YAAY,GAAG;AACvB,YAAI,MAAM,SAAS,WAAW,MAAM,SAAS,YAAY,MAAM,SAAS;AACtE;AACF,qBAAa,SAAS;AAAA,MACxB,WAAW,MAAM,KAAK,SAAS,OAAO,GAAG;AACvC,gBAAQ;AAAA,UACN;AAAA,YACE;AAAA,YACA;AAAA,YACA;AAAA,YACA,qBAAqB,MAAM,IAAI;AAAA,UACjC;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,eAAa,MAAM;AAEnB,SAAO;AACT;","names":["readdirSync","existsSync","path","existsSync","readdirSync","path"]}
@@ -0,0 +1,6 @@
1
+ import { RawDiagnostic } from '@cubocicloide/dude';
2
+
3
+ /** FE011 — discourage $misc: it is exempt from structure checks, but flag every use of it */
4
+ declare function check(root: string): RawDiagnostic[];
5
+
6
+ export { check as default };
@@ -0,0 +1,43 @@
1
+ // src/commands/lint/checks/FE/011.ts
2
+ import { existsSync as existsSync2, readdirSync as readdirSync2 } from "fs";
3
+
4
+ // src/commands/lint/frontend-structure.ts
5
+ import { readdirSync, existsSync } from "fs";
6
+ import path from "pathe";
7
+ function frontendSrc(root) {
8
+ return path.join(root, "frontend", "src");
9
+ }
10
+ function diag(root, absPath, severity, message) {
11
+ return { file: path.relative(root, absPath), line: 1, col: 1, severity, message };
12
+ }
13
+ function findDirsNamed(dir, name) {
14
+ const found = [];
15
+ if (!existsSync(dir)) return found;
16
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
17
+ if (!entry.isDirectory() || entry.name === "node_modules") continue;
18
+ const full = path.join(dir, entry.name);
19
+ if (entry.name === name) found.push(full);
20
+ if (entry.name === "$misc") continue;
21
+ found.push(...findDirsNamed(full, name));
22
+ }
23
+ return found;
24
+ }
25
+
26
+ // src/commands/lint/checks/FE/011.ts
27
+ function check(root) {
28
+ const srcDir = frontendSrc(root);
29
+ if (!existsSync2(srcDir)) return [];
30
+ return findDirsNamed(srcDir, "$misc").map((miscDir) => {
31
+ const count = readdirSync2(miscDir).length;
32
+ return diag(
33
+ root,
34
+ miscDir,
35
+ "warning",
36
+ `Avoid $misc (${count} ${count === 1 ? "entry" : "entries"}) \u2014 it is a temporary escape hatch. Relocate its content: components \u2192 $components/, hooks \u2192 $hooks/, shared types \u2192 types.tsx, pure functions \u2192 functions.tsx, constants \u2192 constants.tsx, static files \u2192 $assets/`
37
+ );
38
+ });
39
+ }
40
+ export {
41
+ check as default
42
+ };
43
+ //# sourceMappingURL=011.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/commands/lint/checks/FE/011.ts","../../../../../src/commands/lint/frontend-structure.ts"],"sourcesContent":["import { existsSync, readdirSync } from 'node:fs'\nimport type { RawDiagnostic } from '@cubocicloide/dude'\nimport { diag, findDirsNamed, frontendSrc } from '../../frontend-structure'\n\n/** FE011 — discourage $misc: it is exempt from structure checks, but flag every use of it */\nexport default function check(root: string): RawDiagnostic[] {\n const srcDir = frontendSrc(root)\n if (!existsSync(srcDir)) return []\n\n return findDirsNamed(srcDir, '$misc').map((miscDir) => {\n const count = readdirSync(miscDir).length\n return diag(\n root,\n miscDir,\n 'warning',\n `Avoid $misc (${count} ${count === 1 ? 'entry' : 'entries'}) — it is a temporary escape hatch. Relocate its content: components → $components/, hooks → $hooks/, shared types → types.tsx, pure functions → functions.tsx, constants → constants.tsx, static files → $assets/`,\n )\n })\n}\n","/**\n * Shared vocabulary for the FE lint checks (frontend `$`-structure).\n *\n * The frontend tree is organised in \"scopes\" (components, hooks, pages, utils\n * domains). Every scope owns the same file set (SCOPE_FILES) plus privileged\n * `$`-prefixed subdirectories ($components, $hooks, $assets, $misc). The `$`\n * prefix sorts these folders on top and makes them impossible to confuse with\n * a route segment or a domain name.\n *\n * Not a check module: it lives outside `checks/` so the runner never tries to\n * load it; tsup inlines it into each check entry.\n */\nimport { readdirSync, existsSync } from 'node:fs'\nimport path from 'pathe'\nimport type { RawDiagnostic, Severity } from '@cubocicloide/dude'\n\n/** Files every scope (component, hook, page, utils domain) may contain. */\nexport const SCOPE_FILES = new Set([\n 'index.tsx',\n 'styles.module.css',\n 'types.tsx',\n 'constants.tsx',\n 'functions.tsx',\n])\n\n/** Human-readable version of SCOPE_FILES for messages. */\nexport const SCOPE_FILES_LABEL = 'index.tsx, styles.module.css, types.tsx, constants.tsx, functions.tsx'\n\n/** The full set of privileged directory names. */\nexport const PRIVILEGED_DIRS = new Set(['$components', '$hooks', '$assets', '$misc', '$types'])\n\nexport const PASCAL_CASE = /^[A-Z][a-zA-Z0-9]*$/\nexport const KEBAB_CASE = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/\nexport const HOOK_NAME = /^use[A-Z][a-zA-Z0-9]*$/\n/** Dynamic route segment: [id], [userId], … */\nexport const DYNAMIC_SEGMENT = /^\\[[a-z][a-zA-Z0-9]*\\]$/\n\nexport function frontendSrc(root: string): string {\n return path.join(root, 'frontend', 'src')\n}\n\nexport function diag(\n root: string,\n absPath: string,\n severity: Severity,\n message: string,\n): RawDiagnostic {\n return { file: path.relative(root, absPath), line: 1, col: 1, severity, message }\n}\n\n/**\n * Recursively collect directories named `name` under `dir`.\n * Never descends into `$misc` (exempt from checks) or `node_modules`,\n * but a `$misc` directory itself is still reported when it matches `name`.\n */\nexport function findDirsNamed(dir: string, name: string): string[] {\n const found: string[] = []\n if (!existsSync(dir)) return found\n for (const entry of readdirSync(dir, { withFileTypes: true })) {\n if (!entry.isDirectory() || entry.name === 'node_modules') continue\n const full = path.join(dir, entry.name)\n if (entry.name === name) found.push(full)\n if (entry.name === '$misc') continue\n found.push(...findDirsNamed(full, name))\n }\n return found\n}\n\n/**\n * Collect page nodes under `pagesDir` as route paths relative to pages/\n * ('' = pages root). A page node is a directory whose index.tsx defines a\n * route. `$`-prefixed directories are structural, never route segments.\n */\nexport function collectPageNodes(pagesDir: string): string[] {\n const nodes: string[] = []\n if (!existsSync(pagesDir)) return nodes\n\n function walk(dir: string, route: string): void {\n if (existsSync(path.join(dir, 'index.tsx'))) nodes.push(route)\n for (const entry of readdirSync(dir, { withFileTypes: true })) {\n if (!entry.isDirectory() || entry.name.startsWith('$')) continue\n walk(path.join(dir, entry.name), route === '' ? entry.name : `${route}/${entry.name}`)\n }\n }\n\n walk(pagesDir, '')\n return nodes\n}\n"],"mappings":";AAAA,SAAS,cAAAA,aAAY,eAAAC,oBAAmB;;;ACYxC,SAAS,aAAa,kBAAkB;AACxC,OAAO,UAAU;AAwBV,SAAS,YAAY,MAAsB;AAChD,SAAO,KAAK,KAAK,MAAM,YAAY,KAAK;AAC1C;AAEO,SAAS,KACd,MACA,SACA,UACA,SACe;AACf,SAAO,EAAE,MAAM,KAAK,SAAS,MAAM,OAAO,GAAG,MAAM,GAAG,KAAK,GAAG,UAAU,QAAQ;AAClF;AAOO,SAAS,cAAc,KAAa,MAAwB;AACjE,QAAM,QAAkB,CAAC;AACzB,MAAI,CAAC,WAAW,GAAG,EAAG,QAAO;AAC7B,aAAW,SAAS,YAAY,KAAK,EAAE,eAAe,KAAK,CAAC,GAAG;AAC7D,QAAI,CAAC,MAAM,YAAY,KAAK,MAAM,SAAS,eAAgB;AAC3D,UAAM,OAAO,KAAK,KAAK,KAAK,MAAM,IAAI;AACtC,QAAI,MAAM,SAAS,KAAM,OAAM,KAAK,IAAI;AACxC,QAAI,MAAM,SAAS,QAAS;AAC5B,UAAM,KAAK,GAAG,cAAc,MAAM,IAAI,CAAC;AAAA,EACzC;AACA,SAAO;AACT;;;AD7De,SAAR,MAAuB,MAA+B;AAC3D,QAAM,SAAS,YAAY,IAAI;AAC/B,MAAI,CAACC,YAAW,MAAM,EAAG,QAAO,CAAC;AAEjC,SAAO,cAAc,QAAQ,OAAO,EAAE,IAAI,CAAC,YAAY;AACrD,UAAM,QAAQC,aAAY,OAAO,EAAE;AACnC,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA,gBAAgB,KAAK,IAAI,UAAU,IAAI,UAAU,SAAS;AAAA,IAC5D;AAAA,EACF,CAAC;AACH;","names":["existsSync","readdirSync","existsSync","readdirSync"]}
@@ -0,0 +1,6 @@
1
+ import { RawDiagnostic } from '@cubocicloide/dude';
2
+
3
+ /** FE012 — index.tsx should only hold its own component/hook/page: types, helpers and extra components belong elsewhere */
4
+ declare function check(root: string): RawDiagnostic[];
5
+
6
+ export { check as default };
@@ -0,0 +1,150 @@
1
+ // src/commands/lint/checks/FE/012.ts
2
+ import { readdirSync as readdirSync2, existsSync as existsSync2, readFileSync } from "fs";
3
+ import path2 from "pathe";
4
+
5
+ // src/commands/lint/frontend-structure.ts
6
+ import { readdirSync, existsSync } from "fs";
7
+ import path from "pathe";
8
+ var PASCAL_CASE = /^[A-Z][a-zA-Z0-9]*$/;
9
+ var HOOK_NAME = /^use[A-Z][a-zA-Z0-9]*$/;
10
+ function frontendSrc(root) {
11
+ return path.join(root, "frontend", "src");
12
+ }
13
+ function diag(root, absPath, severity, message) {
14
+ return { file: path.relative(root, absPath), line: 1, col: 1, severity, message };
15
+ }
16
+ function findDirsNamed(dir, name) {
17
+ const found = [];
18
+ if (!existsSync(dir)) return found;
19
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
20
+ if (!entry.isDirectory() || entry.name === "node_modules") continue;
21
+ const full = path.join(dir, entry.name);
22
+ if (entry.name === name) found.push(full);
23
+ if (entry.name === "$misc") continue;
24
+ found.push(...findDirsNamed(full, name));
25
+ }
26
+ return found;
27
+ }
28
+ function collectPageNodes(pagesDir) {
29
+ const nodes = [];
30
+ if (!existsSync(pagesDir)) return nodes;
31
+ function walk(dir, route) {
32
+ if (existsSync(path.join(dir, "index.tsx"))) nodes.push(route);
33
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
34
+ if (!entry.isDirectory() || entry.name.startsWith("$")) continue;
35
+ walk(path.join(dir, entry.name), route === "" ? entry.name : `${route}/${entry.name}`);
36
+ }
37
+ }
38
+ walk(pagesDir, "");
39
+ return nodes;
40
+ }
41
+
42
+ // src/commands/lint/checks/FE/012.ts
43
+ var TYPE_RE = /^(?:export\s+)?(?:declare\s+)?(?:interface|type)\s+([A-Za-z_$][\w$]*)/gm;
44
+ var FUNCTION_RE = /^(?:export\s+)?(?:default\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)/gm;
45
+ var ARROW_RE = /^(?:export\s+)?const\s+([A-Za-z_$][\w$]*)[^=\n]*=\s*(?:async\s+)?(?:\([^)]*\)|[A-Za-z_$][\w$]*)\s*=>/gm;
46
+ var DEFAULT_EXPORT_RE = /^export\s+default\s+(?:async\s+)?(?:function\s+)?([A-Za-z_$][\w$]*)/m;
47
+ function matchNames(content, re) {
48
+ return [...content.matchAll(re)].map((m) => m[1]);
49
+ }
50
+ function check(root) {
51
+ const srcDir = frontendSrc(root);
52
+ if (!existsSync2(srcDir)) return [];
53
+ const results = [];
54
+ function inspect(indexFile, scope) {
55
+ if (!existsSync2(indexFile)) return;
56
+ const content = readFileSync(indexFile, "utf8");
57
+ const types = matchNames(content, TYPE_RE);
58
+ if (types.length > 0) {
59
+ results.push(
60
+ diag(
61
+ root,
62
+ indexFile,
63
+ "warning",
64
+ `index.tsx declares type(s) ${types.join(", ")} \u2014 move them to types.tsx in the same directory`
65
+ )
66
+ );
67
+ }
68
+ const declared = [...matchNames(content, FUNCTION_RE), ...matchNames(content, ARROW_RE)];
69
+ const components = declared.filter((n) => PASCAL_CASE.test(n));
70
+ const hooks = declared.filter((n) => HOOK_NAME.test(n));
71
+ const helpers = declared.filter((n) => !PASCAL_CASE.test(n) && !HOOK_NAME.test(n));
72
+ const mainName = content.match(DEFAULT_EXPORT_RE)?.[1];
73
+ const main = scope === "hook" ? hooks : components;
74
+ const extras = main.filter((n) => n !== (mainName ?? main[0]));
75
+ if (scope === "hook") {
76
+ if (extras.length > 0) {
77
+ results.push(
78
+ diag(
79
+ root,
80
+ indexFile,
81
+ "warning",
82
+ `index.tsx declares extra hook(s) ${extras.join(", ")} \u2014 give each hook its own directory under a $hooks/`
83
+ )
84
+ );
85
+ }
86
+ if (components.length > 0) {
87
+ results.push(
88
+ diag(
89
+ root,
90
+ indexFile,
91
+ "warning",
92
+ `index.tsx declares component(s) ${components.join(", ")} \u2014 a hook should not define components; move them to a $components/ scope`
93
+ )
94
+ );
95
+ }
96
+ } else {
97
+ if (extras.length > 0) {
98
+ results.push(
99
+ diag(
100
+ root,
101
+ indexFile,
102
+ "warning",
103
+ `index.tsx declares extra component(s) ${extras.join(", ")} \u2014 move each into its own directory under $components/`
104
+ )
105
+ );
106
+ }
107
+ if (hooks.length > 0) {
108
+ results.push(
109
+ diag(
110
+ root,
111
+ indexFile,
112
+ "warning",
113
+ `index.tsx declares hook(s) ${hooks.join(", ")} \u2014 move each into its own directory under $hooks/`
114
+ )
115
+ );
116
+ }
117
+ }
118
+ if (helpers.length > 0) {
119
+ results.push(
120
+ diag(
121
+ root,
122
+ indexFile,
123
+ "warning",
124
+ `index.tsx declares helper function(s) ${helpers.join(", ")} \u2014 move them to functions.tsx in the same directory`
125
+ )
126
+ );
127
+ }
128
+ }
129
+ for (const componentsDir of findDirsNamed(srcDir, "$components")) {
130
+ for (const entry of readdirSync2(componentsDir, { withFileTypes: true })) {
131
+ if (!entry.isDirectory() || !PASCAL_CASE.test(entry.name)) continue;
132
+ inspect(path2.join(componentsDir, entry.name, "index.tsx"), "component");
133
+ }
134
+ }
135
+ for (const hooksDir of findDirsNamed(srcDir, "$hooks")) {
136
+ for (const entry of readdirSync2(hooksDir, { withFileTypes: true })) {
137
+ if (!entry.isDirectory() || !HOOK_NAME.test(entry.name)) continue;
138
+ inspect(path2.join(hooksDir, entry.name, "index.tsx"), "hook");
139
+ }
140
+ }
141
+ const pagesDir = path2.join(srcDir, "pages");
142
+ for (const route of collectPageNodes(pagesDir)) {
143
+ inspect(path2.join(pagesDir, route, "index.tsx"), "page");
144
+ }
145
+ return results;
146
+ }
147
+ export {
148
+ check as default
149
+ };
150
+ //# sourceMappingURL=012.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/commands/lint/checks/FE/012.ts","../../../../../src/commands/lint/frontend-structure.ts"],"sourcesContent":["import { readdirSync, existsSync, readFileSync } from 'node:fs'\nimport path from 'pathe'\nimport type { RawDiagnostic } from '@cubocicloide/dude'\nimport {\n HOOK_NAME,\n PASCAL_CASE,\n collectPageNodes,\n diag,\n findDirsNamed,\n frontendSrc,\n} from '../../frontend-structure'\n\ntype Scope = 'component' | 'hook' | 'page'\n\nconst TYPE_RE = /^(?:export\\s+)?(?:declare\\s+)?(?:interface|type)\\s+([A-Za-z_$][\\w$]*)/gm\nconst FUNCTION_RE = /^(?:export\\s+)?(?:default\\s+)?(?:async\\s+)?function\\s+([A-Za-z_$][\\w$]*)/gm\nconst ARROW_RE = /^(?:export\\s+)?const\\s+([A-Za-z_$][\\w$]*)[^=\\n]*=\\s*(?:async\\s+)?(?:\\([^)]*\\)|[A-Za-z_$][\\w$]*)\\s*=>/gm\nconst DEFAULT_EXPORT_RE = /^export\\s+default\\s+(?:async\\s+)?(?:function\\s+)?([A-Za-z_$][\\w$]*)/m\n\nfunction matchNames(content: string, re: RegExp): string[] {\n return [...content.matchAll(re)].map((m) => m[1]!)\n}\n\n/** FE012 — index.tsx should only hold its own component/hook/page: types, helpers and extra components belong elsewhere */\nexport default function check(root: string): RawDiagnostic[] {\n const srcDir = frontendSrc(root)\n if (!existsSync(srcDir)) return []\n\n const results: RawDiagnostic[] = []\n\n function inspect(indexFile: string, scope: Scope): void {\n if (!existsSync(indexFile)) return\n const content = readFileSync(indexFile, 'utf8')\n\n const types = matchNames(content, TYPE_RE)\n if (types.length > 0) {\n results.push(\n diag(\n root,\n indexFile,\n 'warning',\n `index.tsx declares type(s) ${types.join(', ')} — move them to types.tsx in the same directory`,\n ),\n )\n }\n\n const declared = [...matchNames(content, FUNCTION_RE), ...matchNames(content, ARROW_RE)]\n const components = declared.filter((n) => PASCAL_CASE.test(n))\n const hooks = declared.filter((n) => HOOK_NAME.test(n))\n const helpers = declared.filter((n) => !PASCAL_CASE.test(n) && !HOOK_NAME.test(n))\n\n const mainName = content.match(DEFAULT_EXPORT_RE)?.[1]\n const main = scope === 'hook' ? hooks : components\n const extras = main.filter((n) => n !== (mainName ?? main[0]))\n\n if (scope === 'hook') {\n if (extras.length > 0) {\n results.push(\n diag(\n root,\n indexFile,\n 'warning',\n `index.tsx declares extra hook(s) ${extras.join(', ')} — give each hook its own directory under a $hooks/`,\n ),\n )\n }\n if (components.length > 0) {\n results.push(\n diag(\n root,\n indexFile,\n 'warning',\n `index.tsx declares component(s) ${components.join(', ')} — a hook should not define components; move them to a $components/ scope`,\n ),\n )\n }\n } else {\n if (extras.length > 0) {\n results.push(\n diag(\n root,\n indexFile,\n 'warning',\n `index.tsx declares extra component(s) ${extras.join(', ')} — move each into its own directory under $components/`,\n ),\n )\n }\n if (hooks.length > 0) {\n results.push(\n diag(\n root,\n indexFile,\n 'warning',\n `index.tsx declares hook(s) ${hooks.join(', ')} — move each into its own directory under $hooks/`,\n ),\n )\n }\n }\n\n if (helpers.length > 0) {\n results.push(\n diag(\n root,\n indexFile,\n 'warning',\n `index.tsx declares helper function(s) ${helpers.join(', ')} — move them to functions.tsx in the same directory`,\n ),\n )\n }\n }\n\n for (const componentsDir of findDirsNamed(srcDir, '$components')) {\n for (const entry of readdirSync(componentsDir, { withFileTypes: true })) {\n if (!entry.isDirectory() || !PASCAL_CASE.test(entry.name)) continue\n inspect(path.join(componentsDir, entry.name, 'index.tsx'), 'component')\n }\n }\n for (const hooksDir of findDirsNamed(srcDir, '$hooks')) {\n for (const entry of readdirSync(hooksDir, { withFileTypes: true })) {\n if (!entry.isDirectory() || !HOOK_NAME.test(entry.name)) continue\n inspect(path.join(hooksDir, entry.name, 'index.tsx'), 'hook')\n }\n }\n const pagesDir = path.join(srcDir, 'pages')\n for (const route of collectPageNodes(pagesDir)) {\n inspect(path.join(pagesDir, route, 'index.tsx'), 'page')\n }\n\n return results\n}\n","/**\n * Shared vocabulary for the FE lint checks (frontend `$`-structure).\n *\n * The frontend tree is organised in \"scopes\" (components, hooks, pages, utils\n * domains). Every scope owns the same file set (SCOPE_FILES) plus privileged\n * `$`-prefixed subdirectories ($components, $hooks, $assets, $misc). The `$`\n * prefix sorts these folders on top and makes them impossible to confuse with\n * a route segment or a domain name.\n *\n * Not a check module: it lives outside `checks/` so the runner never tries to\n * load it; tsup inlines it into each check entry.\n */\nimport { readdirSync, existsSync } from 'node:fs'\nimport path from 'pathe'\nimport type { RawDiagnostic, Severity } from '@cubocicloide/dude'\n\n/** Files every scope (component, hook, page, utils domain) may contain. */\nexport const SCOPE_FILES = new Set([\n 'index.tsx',\n 'styles.module.css',\n 'types.tsx',\n 'constants.tsx',\n 'functions.tsx',\n])\n\n/** Human-readable version of SCOPE_FILES for messages. */\nexport const SCOPE_FILES_LABEL = 'index.tsx, styles.module.css, types.tsx, constants.tsx, functions.tsx'\n\n/** The full set of privileged directory names. */\nexport const PRIVILEGED_DIRS = new Set(['$components', '$hooks', '$assets', '$misc', '$types'])\n\nexport const PASCAL_CASE = /^[A-Z][a-zA-Z0-9]*$/\nexport const KEBAB_CASE = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/\nexport const HOOK_NAME = /^use[A-Z][a-zA-Z0-9]*$/\n/** Dynamic route segment: [id], [userId], … */\nexport const DYNAMIC_SEGMENT = /^\\[[a-z][a-zA-Z0-9]*\\]$/\n\nexport function frontendSrc(root: string): string {\n return path.join(root, 'frontend', 'src')\n}\n\nexport function diag(\n root: string,\n absPath: string,\n severity: Severity,\n message: string,\n): RawDiagnostic {\n return { file: path.relative(root, absPath), line: 1, col: 1, severity, message }\n}\n\n/**\n * Recursively collect directories named `name` under `dir`.\n * Never descends into `$misc` (exempt from checks) or `node_modules`,\n * but a `$misc` directory itself is still reported when it matches `name`.\n */\nexport function findDirsNamed(dir: string, name: string): string[] {\n const found: string[] = []\n if (!existsSync(dir)) return found\n for (const entry of readdirSync(dir, { withFileTypes: true })) {\n if (!entry.isDirectory() || entry.name === 'node_modules') continue\n const full = path.join(dir, entry.name)\n if (entry.name === name) found.push(full)\n if (entry.name === '$misc') continue\n found.push(...findDirsNamed(full, name))\n }\n return found\n}\n\n/**\n * Collect page nodes under `pagesDir` as route paths relative to pages/\n * ('' = pages root). A page node is a directory whose index.tsx defines a\n * route. `$`-prefixed directories are structural, never route segments.\n */\nexport function collectPageNodes(pagesDir: string): string[] {\n const nodes: string[] = []\n if (!existsSync(pagesDir)) return nodes\n\n function walk(dir: string, route: string): void {\n if (existsSync(path.join(dir, 'index.tsx'))) nodes.push(route)\n for (const entry of readdirSync(dir, { withFileTypes: true })) {\n if (!entry.isDirectory() || entry.name.startsWith('$')) continue\n walk(path.join(dir, entry.name), route === '' ? entry.name : `${route}/${entry.name}`)\n }\n }\n\n walk(pagesDir, '')\n return nodes\n}\n"],"mappings":";AAAA,SAAS,eAAAA,cAAa,cAAAC,aAAY,oBAAoB;AACtD,OAAOC,WAAU;;;ACWjB,SAAS,aAAa,kBAAkB;AACxC,OAAO,UAAU;AAkBV,IAAM,cAAc;AAEpB,IAAM,YAAY;AAIlB,SAAS,YAAY,MAAsB;AAChD,SAAO,KAAK,KAAK,MAAM,YAAY,KAAK;AAC1C;AAEO,SAAS,KACd,MACA,SACA,UACA,SACe;AACf,SAAO,EAAE,MAAM,KAAK,SAAS,MAAM,OA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T;","names":["readdirSync","existsSync","path","existsSync","readdirSync","path"]}
@@ -0,0 +1,5 @@
1
+ import * as _cubocicloide_dude from '@cubocicloide/dude';
2
+
3
+ declare const _default: _cubocicloide_dude.StackDefinition;
4
+
5
+ export { _default as default };