@cubocicloide/stack-react-django 3.0.4
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/LICENSE +33 -0
- package/README.md +66 -0
- package/dist/commands/lint/checks/BE/001.d.ts +6 -0
- package/dist/commands/lint/checks/BE/001.js +94 -0
- package/dist/commands/lint/checks/BE/001.js.map +1 -0
- package/dist/commands/lint/checks/BE/002.d.ts +6 -0
- package/dist/commands/lint/checks/BE/002.js +136 -0
- package/dist/commands/lint/checks/BE/002.js.map +1 -0
- package/dist/commands/lint/checks/BE/003.d.ts +6 -0
- package/dist/commands/lint/checks/BE/003.js +89 -0
- package/dist/commands/lint/checks/BE/003.js.map +1 -0
- package/dist/commands/lint/checks/BE/004.d.ts +6 -0
- package/dist/commands/lint/checks/BE/004.js +68 -0
- package/dist/commands/lint/checks/BE/004.js.map +1 -0
- package/dist/commands/lint/checks/BE/005.d.ts +6 -0
- package/dist/commands/lint/checks/BE/005.js +55 -0
- package/dist/commands/lint/checks/BE/005.js.map +1 -0
- package/dist/commands/lint/checks/BE/006.d.ts +6 -0
- package/dist/commands/lint/checks/BE/006.js +95 -0
- package/dist/commands/lint/checks/BE/006.js.map +1 -0
- package/dist/commands/lint/checks/BE/007.d.ts +6 -0
- package/dist/commands/lint/checks/BE/007.js +53 -0
- package/dist/commands/lint/checks/BE/007.js.map +1 -0
- package/dist/commands/lint/checks/BE/008.d.ts +6 -0
- package/dist/commands/lint/checks/BE/008.js +70 -0
- package/dist/commands/lint/checks/BE/008.js.map +1 -0
- package/dist/commands/lint/checks/BE/009.d.ts +6 -0
- package/dist/commands/lint/checks/BE/009.js +112 -0
- package/dist/commands/lint/checks/BE/009.js.map +1 -0
- package/dist/commands/lint/checks/BE/010.d.ts +6 -0
- package/dist/commands/lint/checks/BE/010.js +76 -0
- package/dist/commands/lint/checks/BE/010.js.map +1 -0
- package/dist/commands/lint/checks/BE/011.d.ts +6 -0
- package/dist/commands/lint/checks/BE/011.js +76 -0
- package/dist/commands/lint/checks/BE/011.js.map +1 -0
- package/dist/commands/lint/checks/BE/012.d.ts +6 -0
- package/dist/commands/lint/checks/BE/012.js +61 -0
- package/dist/commands/lint/checks/BE/012.js.map +1 -0
- package/dist/commands/lint/checks/BE/013.d.ts +6 -0
- package/dist/commands/lint/checks/BE/013.js +98 -0
- package/dist/commands/lint/checks/BE/013.js.map +1 -0
- package/dist/commands/lint/checks/BE/014.d.ts +6 -0
- package/dist/commands/lint/checks/BE/014.js +64 -0
- package/dist/commands/lint/checks/BE/014.js.map +1 -0
- package/dist/commands/lint/checks/E2E/001.d.ts +6 -0
- package/dist/commands/lint/checks/E2E/001.js +35 -0
- package/dist/commands/lint/checks/E2E/001.js.map +1 -0
- package/dist/commands/lint/checks/E2E/002.d.ts +6 -0
- package/dist/commands/lint/checks/E2E/002.js +37 -0
- package/dist/commands/lint/checks/E2E/002.js.map +1 -0
- package/dist/commands/lint/checks/E2E/003.d.ts +6 -0
- package/dist/commands/lint/checks/E2E/003.js +42 -0
- package/dist/commands/lint/checks/E2E/003.js.map +1 -0
- package/dist/commands/lint/checks/E2E/004.d.ts +6 -0
- package/dist/commands/lint/checks/E2E/004.js +37 -0
- package/dist/commands/lint/checks/E2E/004.js.map +1 -0
- package/dist/commands/lint/checks/E2E/005.d.ts +6 -0
- package/dist/commands/lint/checks/E2E/005.js +47 -0
- package/dist/commands/lint/checks/E2E/005.js.map +1 -0
- package/dist/commands/lint/checks/E2E/006.d.ts +6 -0
- package/dist/commands/lint/checks/E2E/006.js +28 -0
- package/dist/commands/lint/checks/E2E/006.js.map +1 -0
- package/dist/commands/lint/checks/E2E/007.d.ts +6 -0
- package/dist/commands/lint/checks/E2E/007.js +47 -0
- package/dist/commands/lint/checks/E2E/007.js.map +1 -0
- package/dist/commands/lint/checks/FE/001.d.ts +6 -0
- package/dist/commands/lint/checks/FE/001.js +56 -0
- package/dist/commands/lint/checks/FE/001.js.map +1 -0
- package/dist/commands/lint/checks/FE/002.d.ts +6 -0
- package/dist/commands/lint/checks/FE/002.js +80 -0
- package/dist/commands/lint/checks/FE/002.js.map +1 -0
- package/dist/commands/lint/checks/FE/003.d.ts +6 -0
- package/dist/commands/lint/checks/FE/003.js +65 -0
- package/dist/commands/lint/checks/FE/003.js.map +1 -0
- package/dist/commands/lint/checks/FE/004.d.ts +6 -0
- package/dist/commands/lint/checks/FE/004.js +72 -0
- package/dist/commands/lint/checks/FE/004.js.map +1 -0
- package/dist/commands/lint/checks/FE/005.d.ts +6 -0
- package/dist/commands/lint/checks/FE/005.js +103 -0
- package/dist/commands/lint/checks/FE/005.js.map +1 -0
- package/dist/commands/lint/checks/FE/006.d.ts +6 -0
- package/dist/commands/lint/checks/FE/006.js +102 -0
- package/dist/commands/lint/checks/FE/006.js.map +1 -0
- package/dist/commands/lint/checks/FE/007.d.ts +6 -0
- package/dist/commands/lint/checks/FE/007.js +60 -0
- package/dist/commands/lint/checks/FE/007.js.map +1 -0
- package/dist/commands/lint/checks/FE/008.d.ts +6 -0
- package/dist/commands/lint/checks/FE/008.js +115 -0
- package/dist/commands/lint/checks/FE/008.js.map +1 -0
- package/dist/commands/lint/checks/FE/009.d.ts +6 -0
- package/dist/commands/lint/checks/FE/009.js +83 -0
- package/dist/commands/lint/checks/FE/009.js.map +1 -0
- package/dist/commands/lint/checks/FE/010.d.ts +6 -0
- package/dist/commands/lint/checks/FE/010.js +105 -0
- package/dist/commands/lint/checks/FE/010.js.map +1 -0
- package/dist/commands/lint/checks/FE/011.d.ts +6 -0
- package/dist/commands/lint/checks/FE/011.js +43 -0
- package/dist/commands/lint/checks/FE/011.js.map +1 -0
- package/dist/commands/lint/checks/FE/012.d.ts +6 -0
- package/dist/commands/lint/checks/FE/012.js +150 -0
- package/dist/commands/lint/checks/FE/012.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +3436 -0
- package/dist/index.js.map +1 -0
- package/dude.stack.json +13 -0
- package/package.json +43 -0
- package/templates/aws-ecs/backend/Dockerfile.prod +34 -0
- package/templates/aws-ecs/docs/docs/deploy.md.hbs +54 -0
- package/templates/aws-ecs/frontend/Dockerfile.prod +28 -0
- package/templates/aws-ecs/frontend/nginx.conf +21 -0
- package/templates/aws-ecs/iac/README.md.hbs +75 -0
- package/templates/aws-ecs/iac/_gitignore +14 -0
- package/templates/aws-ecs/iac/runner/Dockerfile +35 -0
- package/templates/aws-ecs/iac/terraform/bootstrap/main.tf.hbs +102 -0
- package/templates/aws-ecs/iac/terraform/bootstrap/outputs.tf +19 -0
- package/templates/aws-ecs/iac/terraform/bootstrap/variables.tf.hbs +17 -0
- package/templates/aws-ecs/iac/terraform/environments/dev/backend.hcl.hbs +12 -0
- package/templates/aws-ecs/iac/terraform/environments/dev/terraform.tfvars.hbs +43 -0
- package/templates/aws-ecs/iac/terraform/main.tf.hbs +949 -0
- package/templates/aws-ecs/iac/terraform/outputs.tf.hbs +71 -0
- package/templates/aws-ecs/iac/terraform/providers.tf +19 -0
- package/templates/aws-ecs/iac/terraform/variables.tf.hbs +113 -0
- package/templates/aws-ecs/iac/terraform/versions.tf +19 -0
- package/templates/base/.claude/agents/issue-fixer.md +190 -0
- package/templates/base/.claude/agents/security-fixer.md +250 -0
- package/templates/base/.claude/rules/BE/001.md +19 -0
- package/templates/base/.claude/rules/BE/002.md +21 -0
- package/templates/base/.claude/rules/BE/003.md +19 -0
- package/templates/base/.claude/rules/BE/004.md +16 -0
- package/templates/base/.claude/rules/BE/005.md +23 -0
- package/templates/base/.claude/rules/BE/006.md +13 -0
- package/templates/base/.claude/rules/BE/007.md +24 -0
- package/templates/base/.claude/rules/BE/008.md +19 -0
- package/templates/base/.claude/rules/BE/009.md +18 -0
- package/templates/base/.claude/rules/BE/010.md +15 -0
- package/templates/base/.claude/rules/BE/011.md +17 -0
- package/templates/base/.claude/rules/BE/012.md +18 -0
- package/templates/base/.claude/rules/BE/013.md +22 -0
- package/templates/base/.claude/rules/BE/014.md +15 -0
- package/templates/base/.claude/rules/E2E/001.md +13 -0
- package/templates/base/.claude/rules/E2E/002.md +14 -0
- package/templates/base/.claude/rules/E2E/003.md +10 -0
- package/templates/base/.claude/rules/E2E/004.md +23 -0
- package/templates/base/.claude/rules/E2E/005.md +15 -0
- package/templates/base/.claude/rules/E2E/006.md +13 -0
- package/templates/base/.claude/rules/E2E/007.md +18 -0
- package/templates/base/.claude/rules/FE/001.md +22 -0
- package/templates/base/.claude/rules/FE/002.md +39 -0
- package/templates/base/.claude/rules/FE/003.md +19 -0
- package/templates/base/.claude/rules/FE/004.md +21 -0
- package/templates/base/.claude/rules/FE/005.md +33 -0
- package/templates/base/.claude/rules/FE/006.md +24 -0
- package/templates/base/.claude/rules/FE/007.md +19 -0
- package/templates/base/.claude/rules/FE/008.md +26 -0
- package/templates/base/.claude/rules/FE/009.md +30 -0
- package/templates/base/.claude/rules/FE/010.md +25 -0
- package/templates/base/.claude/rules/FE/011.md +22 -0
- package/templates/base/.claude/rules/FE/012.md +32 -0
- package/templates/base/.claude/settings.json +53 -0
- package/templates/base/.claude/skills/clean-branches/SKILL.md +100 -0
- package/templates/base/.claude/skills/create/SKILL.md +47 -0
- package/templates/base/.claude/skills/create-jira-issue/SKILL.md +174 -0
- package/templates/base/.claude/skills/create-page/SKILL.md +195 -0
- package/templates/base/.claude/skills/create-route/SKILL.md +156 -0
- package/templates/base/.claude/skills/draft-email/SKILL.md +104 -0
- package/templates/base/.claude/skills/fix-issues/SKILL.md +238 -0
- package/templates/base/.claude/skills/security-scan/SKILL.md +297 -0
- package/templates/base/.claude/skills/verify-security-fixes/SKILL.md +180 -0
- package/templates/base/.dude/commands/README.md +85 -0
- package/templates/base/.dude/commands/hello.ts +34 -0
- package/templates/base/.dude/lint/checks/PRJ/001.ts +26 -0
- package/templates/base/.dude/lint/checks/README.md +69 -0
- package/templates/base/.vscode/tasks.json +44 -0
- package/templates/base/.worktreeinclude +2 -0
- package/templates/base/CLAUDE.md.hbs +391 -0
- package/templates/base/README.md.hbs +188 -0
- package/templates/base/_env.example.hbs +39 -0
- package/templates/base/_env.hbs +35 -0
- package/templates/base/_gitignore +31 -0
- package/templates/base/_npmrc +2 -0
- package/templates/base/backend/Dockerfile +16 -0
- package/templates/base/backend/README.md.hbs +90 -0
- package/templates/base/backend/_dockerignore +12 -0
- package/templates/base/backend/apps/__init__.py +0 -0
- package/templates/base/backend/apps/core/__init__.py +0 -0
- package/templates/base/backend/apps/core/apps.py +6 -0
- package/templates/base/backend/apps/core/serializers.py +7 -0
- package/templates/base/backend/apps/core/tests/__init__.py +0 -0
- package/templates/base/backend/apps/core/tests/test_views.py +16 -0
- package/templates/base/backend/apps/core/urls.py +9 -0
- package/templates/base/backend/apps/core/views.py +24 -0
- package/templates/base/backend/apps/users/__init__.py +0 -0
- package/templates/base/backend/apps/users/admin.py +6 -0
- package/templates/base/backend/apps/users/apps.py +6 -0
- package/templates/base/backend/apps/users/migrations/0001_initial.py +41 -0
- package/templates/base/backend/apps/users/migrations/__init__.py +0 -0
- package/templates/base/backend/apps/users/models.py +15 -0
- package/templates/base/backend/apps/users/serializers.py +16 -0
- package/templates/base/backend/apps/users/services.py +25 -0
- package/templates/base/backend/apps/users/tests/__init__.py +0 -0
- package/templates/base/backend/apps/users/tests/test_models.py +30 -0
- package/templates/base/backend/apps/users/tests/test_views.py +55 -0
- package/templates/base/backend/apps/users/urls.py +10 -0
- package/templates/base/backend/apps/users/views.py +20 -0
- package/templates/base/backend/config/__init__.py.hbs +5 -0
- package/templates/base/backend/config/asgi.py +9 -0
- package/templates/base/backend/config/settings/__init__.py +0 -0
- package/templates/base/backend/config/settings/base.py.hbs +197 -0
- package/templates/base/backend/config/settings/local.py +31 -0
- package/templates/base/backend/config/settings/production.py.hbs +37 -0
- package/templates/base/backend/config/urls.py.hbs +22 -0
- package/templates/base/backend/config/wsgi.py +9 -0
- package/templates/base/backend/manage.py +23 -0
- package/templates/base/backend/pyproject.toml.hbs +48 -0
- package/templates/base/backend/start.sh +5 -0
- package/templates/base/docker-compose.yml.hbs +196 -0
- package/templates/base/docs/docs/api.md +21 -0
- package/templates/base/docs/docs/dude.md.hbs +305 -0
- package/templates/base/docs/docs/index.md.hbs +92 -0
- package/templates/base/docs/docs/mkdocs.md +231 -0
- package/templates/base/docs/mkdocs.yml.hbs +52 -0
- package/templates/base/e2e/.prettierrc.json +1 -0
- package/templates/base/e2e/_prettierignore +3 -0
- package/templates/base/e2e/cucumber.js +21 -0
- package/templates/base/e2e/eslint.config.mjs +14 -0
- package/templates/base/e2e/features/example.feature +13 -0
- package/templates/base/e2e/package.json.hbs +30 -0
- package/templates/base/e2e/pages/ExamplePage.ts +16 -0
- package/templates/base/e2e/playwright.config.ts +27 -0
- package/templates/base/e2e/steps/common.steps.ts +32 -0
- package/templates/base/e2e/steps/example.steps.ts +4 -0
- package/templates/base/e2e/support/hooks.ts +72 -0
- package/templates/base/e2e/support/world.ts +24 -0
- package/templates/base/e2e/tsconfig.json +22 -0
- package/templates/base/frontend/.prettierrc.json +6 -0
- package/templates/base/frontend/Dockerfile +10 -0
- package/templates/base/frontend/_dockerignore +4 -0
- package/templates/base/frontend/eslint.config.js +32 -0
- package/templates/base/frontend/index.html.hbs +13 -0
- package/templates/base/frontend/package.json.hbs +38 -0
- package/templates/base/frontend/public/favicon.svg +5 -0
- package/templates/base/frontend/src/$components/Layout/$assets/logo.svg +5 -0
- package/templates/base/frontend/src/$components/Layout/constants.tsx +8 -0
- package/templates/base/frontend/src/$components/Layout/index.tsx +80 -0
- package/templates/base/frontend/src/$components/Layout/types.tsx +9 -0
- package/templates/base/frontend/src/$components/index.tsx +1 -0
- package/templates/base/frontend/src/$hooks/index.tsx +2 -0
- package/templates/base/frontend/src/$hooks/useCounterStore/index.tsx +28 -0
- package/templates/base/frontend/src/$hooks/useCounterStore/types.tsx +7 -0
- package/templates/base/frontend/src/$hooks/usePageTitle/index.tsx +21 -0
- package/templates/base/frontend/src/$types/vite-env.d.ts +10 -0
- package/templates/base/frontend/src/App.tsx +36 -0
- package/templates/base/frontend/src/main.tsx +10 -0
- package/templates/base/frontend/src/openapi/utils/openapi.yaml.hbs +129 -0
- package/templates/base/frontend/src/pages/constants.tsx +31 -0
- package/templates/base/frontend/src/pages/index.tsx +192 -0
- package/templates/base/frontend/src/pages/types.tsx +6 -0
- package/templates/base/frontend/src/pages/users/[id]/index.tsx +53 -0
- package/templates/base/frontend/src/pages/users/index.tsx +57 -0
- package/templates/base/frontend/src/pages/users/types.tsx +4 -0
- package/templates/base/frontend/src/styles.module.css +7 -0
- package/templates/base/frontend/src/utils/constants.tsx +11 -0
- package/templates/base/frontend/src/utils/formatters/index.tsx +49 -0
- package/templates/base/frontend/src/utils/functions.tsx +70 -0
- package/templates/base/frontend/src/utils/index.tsx +3 -0
- package/templates/base/frontend/tsconfig.json +24 -0
- package/templates/base/frontend/vite.config.ts +20 -0
- package/templates/base/package.json.hbs +11 -0
- package/templates/base/security/baseline.json +4 -0
- package/templates/celery/backend/apps/core/tasks.py +14 -0
- package/templates/celery/backend/apps/core/tests/test_tasks.py +6 -0
- package/templates/celery/backend/config/celery.py.hbs +26 -0
- package/templates/celerybeat/backend/apps/core/tasks_scheduled.py +18 -0
- package/templates/celerybeat/backend/apps/core/tests/test_tasks_scheduled.py +6 -0
- package/templates/postgres/.dude/commands/reset.ts +83 -0
- package/templates/s3/backend/apps/files/__init__.py +0 -0
- package/templates/s3/backend/apps/files/admin.py +9 -0
- package/templates/s3/backend/apps/files/apps.py +6 -0
- package/templates/s3/backend/apps/files/migrations/0001_initial.py +29 -0
- package/templates/s3/backend/apps/files/migrations/__init__.py +0 -0
- package/templates/s3/backend/apps/files/models.py +21 -0
- package/templates/s3/backend/apps/files/serializers.py +27 -0
- package/templates/s3/backend/apps/files/services.py +19 -0
- package/templates/s3/backend/apps/files/tests/__init__.py +0 -0
- package/templates/s3/backend/apps/files/tests/test_models.py +10 -0
- package/templates/s3/backend/apps/files/tests/test_views.py +32 -0
- package/templates/s3/backend/apps/files/urls.py +10 -0
- package/templates/s3/backend/apps/files/views.py +29 -0
- package/templates/s3/frontend/src/openapi/utils/openapi.yaml.hbs +253 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// src/commands/lint/checks/FE/006.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
|
+
var SCOPE_FILES = /* @__PURE__ */ new Set([
|
|
9
|
+
"index.tsx",
|
|
10
|
+
"styles.module.css",
|
|
11
|
+
"types.tsx",
|
|
12
|
+
"constants.tsx",
|
|
13
|
+
"functions.tsx"
|
|
14
|
+
]);
|
|
15
|
+
var SCOPE_FILES_LABEL = "index.tsx, styles.module.css, types.tsx, constants.tsx, functions.tsx";
|
|
16
|
+
var HOOK_NAME = /^use[A-Z][a-zA-Z0-9]*$/;
|
|
17
|
+
function frontendSrc(root) {
|
|
18
|
+
return path.join(root, "frontend", "src");
|
|
19
|
+
}
|
|
20
|
+
function diag(root, absPath, severity, message) {
|
|
21
|
+
return { file: path.relative(root, absPath), line: 1, col: 1, severity, message };
|
|
22
|
+
}
|
|
23
|
+
function findDirsNamed(dir, name) {
|
|
24
|
+
const found = [];
|
|
25
|
+
if (!existsSync(dir)) return found;
|
|
26
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
27
|
+
if (!entry.isDirectory() || entry.name === "node_modules") continue;
|
|
28
|
+
const full = path.join(dir, entry.name);
|
|
29
|
+
if (entry.name === name) found.push(full);
|
|
30
|
+
if (entry.name === "$misc") continue;
|
|
31
|
+
found.push(...findDirsNamed(full, name));
|
|
32
|
+
}
|
|
33
|
+
return found;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// src/commands/lint/checks/FE/006.ts
|
|
37
|
+
var ALLOWED_DIRS = /* @__PURE__ */ new Set(["$assets", "$misc"]);
|
|
38
|
+
function check(root) {
|
|
39
|
+
const results = [];
|
|
40
|
+
for (const hooksDir of findDirsNamed(frontendSrc(root), "$hooks")) {
|
|
41
|
+
for (const entry of readdirSync2(hooksDir, { withFileTypes: true })) {
|
|
42
|
+
if (!entry.isDirectory()) continue;
|
|
43
|
+
const hookDir = path2.join(hooksDir, entry.name);
|
|
44
|
+
if (entry.name.startsWith("$")) {
|
|
45
|
+
results.push(
|
|
46
|
+
diag(
|
|
47
|
+
root,
|
|
48
|
+
hookDir,
|
|
49
|
+
"error",
|
|
50
|
+
`Privileged directory "${entry.name}" is not allowed directly inside $hooks/ \u2014 it belongs inside a hook directory`
|
|
51
|
+
)
|
|
52
|
+
);
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (!HOOK_NAME.test(entry.name)) {
|
|
56
|
+
results.push(
|
|
57
|
+
diag(
|
|
58
|
+
root,
|
|
59
|
+
hookDir,
|
|
60
|
+
"error",
|
|
61
|
+
`Hook directory "${entry.name}" must match use[A-Z]\u2026 (e.g. useAttachments)`
|
|
62
|
+
)
|
|
63
|
+
);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (!existsSync2(path2.join(hookDir, "index.tsx"))) {
|
|
67
|
+
results.push(
|
|
68
|
+
diag(root, hookDir, "error", `Hook "${entry.name}" is missing its index.tsx`)
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
for (const child of readdirSync2(hookDir, { withFileTypes: true })) {
|
|
72
|
+
const childPath = path2.join(hookDir, child.name);
|
|
73
|
+
if (child.isDirectory()) {
|
|
74
|
+
if (!ALLOWED_DIRS.has(child.name)) {
|
|
75
|
+
results.push(
|
|
76
|
+
diag(
|
|
77
|
+
root,
|
|
78
|
+
childPath,
|
|
79
|
+
"error",
|
|
80
|
+
`Unexpected directory "${child.name}" in hook directory. Allowed: $assets/, $misc/`
|
|
81
|
+
)
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
} else if (!SCOPE_FILES.has(child.name)) {
|
|
85
|
+
results.push(
|
|
86
|
+
diag(
|
|
87
|
+
root,
|
|
88
|
+
childPath,
|
|
89
|
+
"error",
|
|
90
|
+
`Unexpected file "${child.name}" in hook directory. Allowed: ${SCOPE_FILES_LABEL}`
|
|
91
|
+
)
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return results;
|
|
98
|
+
}
|
|
99
|
+
export {
|
|
100
|
+
check as default
|
|
101
|
+
};
|
|
102
|
+
//# sourceMappingURL=006.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/commands/lint/checks/FE/006.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 {\n HOOK_NAME,\n SCOPE_FILES,\n SCOPE_FILES_LABEL,\n diag,\n findDirsNamed,\n frontendSrc,\n} from '../../frontend-structure'\n\nconst ALLOWED_DIRS = new Set(['$assets', '$misc'])\n\n/** FE006 — $hooks/ holds use* dirs; each hook dir has index.tsx + scope files + $assets/$misc */\nexport default function check(root: string): RawDiagnostic[] {\n const results: RawDiagnostic[] = []\n\n for (const hooksDir of findDirsNamed(frontendSrc(root), '$hooks')) {\n for (const entry of readdirSync(hooksDir, { withFileTypes: true })) {\n if (!entry.isDirectory()) continue\n const hookDir = path.join(hooksDir, entry.name)\n\n if (entry.name.startsWith('$')) {\n results.push(\n diag(\n root,\n hookDir,\n 'error',\n `Privileged directory \"${entry.name}\" is not allowed directly inside $hooks/ — it belongs inside a hook directory`,\n ),\n )\n continue\n }\n if (!HOOK_NAME.test(entry.name)) {\n results.push(\n diag(\n root,\n hookDir,\n 'error',\n `Hook directory \"${entry.name}\" must match use[A-Z]… (e.g. useAttachments)`,\n ),\n )\n continue\n }\n\n if (!existsSync(path.join(hookDir, 'index.tsx'))) {\n results.push(\n diag(root, hookDir, 'error', `Hook \"${entry.name}\" is missing its index.tsx`),\n )\n }\n\n for (const child of readdirSync(hookDir, { withFileTypes: true })) {\n const childPath = path.join(hookDir, child.name)\n if (child.isDirectory()) {\n if (!ALLOWED_DIRS.has(child.name)) {\n results.push(\n diag(\n root,\n childPath,\n 'error',\n `Unexpected directory \"${child.name}\" in hook directory. Allowed: $assets/, $misc/`,\n ),\n )\n }\n } else if (!SCOPE_FILES.has(child.name)) {\n results.push(\n diag(\n root,\n childPath,\n 'error',\n `Unexpected file \"${child.name}\" in hook directory. Allowed: ${SCOPE_FILES_LABEL}`,\n ),\n )\n }\n }\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,mBAAkB;AACxC,OAAOC,WAAU;;;ACWjB,SAAS,aAAa,kBAAkB;AACxC,OAAO,UAAU;AAIV,IAAM,cAAc,oBAAI,IAAI;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAGM,IAAM,oBAAoB;AAO1B,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,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;;;ADtDA,IAAM,eAAe,oBAAI,IAAI,CAAC,WAAW,OAAO,CAAC;AAGlC,SAAR,MAAuB,MAA+B;AAC3D,QAAM,UAA2B,CAAC;AAElC,aAAW,YAAY,cAAc,YAAY,IAAI,GAAG,QAAQ,GAAG;AACjE,eAAW,SAASC,aAAY,UAAU,EAAE,eAAe,KAAK,CAAC,GAAG;AAClE,UAAI,CAAC,MAAM,YAAY,EAAG;AAC1B,YAAM,UAAUC,MAAK,KAAK,UAAU,MAAM,IAAI;AAE9C,UAAI,MAAM,KAAK,WAAW,GAAG,GAAG;AAC9B,gBAAQ;AAAA,UACN;AAAA,YACE;AAAA,YACA;AAAA,YACA;AAAA,YACA,yBAAyB,MAAM,IAAI;AAAA,UACrC;AAAA,QACF;AACA;AAAA,MACF;AACA,UAAI,CAAC,UAAU,KAAK,MAAM,IAAI,GAAG;AAC/B,gBAAQ;AAAA,UACN;AAAA,YACE;AAAA,YACA;AAAA,YACA;AAAA,YACA,mBAAmB,MAAM,IAAI;AAAA,UAC/B;AAAA,QACF;AACA;AAAA,MACF;AAEA,UAAI,CAACC,YAAWD,MAAK,KAAK,SAAS,WAAW,CAAC,GAAG;AAChD,gBAAQ;AAAA,UACN,KAAK,MAAM,SAAS,SAAS,SAAS,MAAM,IAAI,4BAA4B;AAAA,QAC9E;AAAA,MACF;AAEA,iBAAW,SAASD,aAAY,SAAS,EAAE,eAAe,KAAK,CAAC,GAAG;AACjE,cAAM,YAAYC,MAAK,KAAK,SAAS,MAAM,IAAI;AAC/C,YAAI,MAAM,YAAY,GAAG;AACvB,cAAI,CAAC,aAAa,IAAI,MAAM,IAAI,GAAG;AACjC,oBAAQ;AAAA,cACN;AAAA,gBACE;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA,yBAAyB,MAAM,IAAI;AAAA,cACrC;AAAA,YACF;AAAA,UACF;AAAA,QACF,WAAW,CAAC,YAAY,IAAI,MAAM,IAAI,GAAG;AACvC,kBAAQ;AAAA,YACN;AAAA,cACE;AAAA,cACA;AAAA,cACA;AAAA,cACA,oBAAoB,MAAM,IAAI,iCAAiC,iBAAiB;AAAA,YAClF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;","names":["readdirSync","existsSync","path","readdirSync","path","existsSync"]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// src/commands/lint/checks/FE/007.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 HOOK_NAME = /^use[A-Z][a-zA-Z0-9]*$/;
|
|
9
|
+
function frontendSrc(root) {
|
|
10
|
+
return path.join(root, "frontend", "src");
|
|
11
|
+
}
|
|
12
|
+
function diag(root, absPath, severity, message) {
|
|
13
|
+
return { file: path.relative(root, absPath), line: 1, col: 1, severity, message };
|
|
14
|
+
}
|
|
15
|
+
function findDirsNamed(dir, name) {
|
|
16
|
+
const found = [];
|
|
17
|
+
if (!existsSync(dir)) return found;
|
|
18
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
19
|
+
if (!entry.isDirectory() || entry.name === "node_modules") continue;
|
|
20
|
+
const full = path.join(dir, entry.name);
|
|
21
|
+
if (entry.name === name) found.push(full);
|
|
22
|
+
if (entry.name === "$misc") continue;
|
|
23
|
+
found.push(...findDirsNamed(full, name));
|
|
24
|
+
}
|
|
25
|
+
return found;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// src/commands/lint/checks/FE/007.ts
|
|
29
|
+
function check(root) {
|
|
30
|
+
const results = [];
|
|
31
|
+
for (const hooksDir of findDirsNamed(frontendSrc(root), "$hooks")) {
|
|
32
|
+
const hookNames = readdirSync2(hooksDir, { withFileTypes: true }).filter((e) => e.isDirectory() && HOOK_NAME.test(e.name)).map((e) => e.name);
|
|
33
|
+
if (hookNames.length === 0) continue;
|
|
34
|
+
const barrelFile = path2.join(hooksDir, "index.tsx");
|
|
35
|
+
if (!existsSync2(barrelFile)) {
|
|
36
|
+
results.push(
|
|
37
|
+
diag(
|
|
38
|
+
root,
|
|
39
|
+
hooksDir,
|
|
40
|
+
"error",
|
|
41
|
+
`$hooks/ is missing its index.tsx barrel (must export: ${hookNames.join(", ")})`
|
|
42
|
+
)
|
|
43
|
+
);
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const barrel = readFileSync(barrelFile, "utf8");
|
|
47
|
+
for (const name of hookNames) {
|
|
48
|
+
if (!barrel.includes(`from './${name}'`) && !barrel.includes(`from "./${name}"`)) {
|
|
49
|
+
results.push(
|
|
50
|
+
diag(root, barrelFile, "error", `$hooks/index.tsx is missing a barrel export for "${name}"`)
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return results;
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
check as default
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=007.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/commands/lint/checks/FE/007.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 { HOOK_NAME, diag, findDirsNamed, frontendSrc } from '../../frontend-structure'\n\n/** FE007 — every $hooks/ has an index.tsx barrel exporting all use* directories */\nexport default function check(root: string): RawDiagnostic[] {\n const results: RawDiagnostic[] = []\n\n for (const hooksDir of findDirsNamed(frontendSrc(root), '$hooks')) {\n const hookNames = readdirSync(hooksDir, { withFileTypes: true })\n .filter((e) => e.isDirectory() && HOOK_NAME.test(e.name))\n .map((e) => e.name)\n if (hookNames.length === 0) continue\n\n const barrelFile = path.join(hooksDir, 'index.tsx')\n if (!existsSync(barrelFile)) {\n results.push(\n diag(\n root,\n hooksDir,\n 'error',\n `$hooks/ is missing its index.tsx barrel (must export: ${hookNames.join(', ')})`,\n ),\n )\n continue\n }\n\n const barrel = readFileSync(barrelFile, 'utf8')\n for (const name of hookNames) {\n if (!barrel.includes(`from './${name}'`) && !barrel.includes(`from \"./${name}\"`)) {\n results.push(\n diag(root, barrelFile, 'error', `$hooks/index.tsx is missing a barrel export for \"${name}\"`),\n )\n }\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;AAoBV,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,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;;;AD5De,SAAR,MAAuB,MAA+B;AAC3D,QAAM,UAA2B,CAAC;AAElC,aAAW,YAAY,cAAc,YAAY,IAAI,GAAG,QAAQ,GAAG;AACjE,UAAM,YAAYC,aAAY,UAAU,EAAE,eAAe,KAAK,CAAC,EAC5D,OAAO,CAAC,MAAM,EAAE,YAAY,KAAK,UAAU,KAAK,EAAE,IAAI,CAAC,EACvD,IAAI,CAAC,MAAM,EAAE,IAAI;AACpB,QAAI,UAAU,WAAW,EAAG;AAE5B,UAAM,aAAaC,MAAK,KAAK,UAAU,WAAW;AAClD,QAAI,CAACC,YAAW,UAAU,GAAG;AAC3B,cAAQ;AAAA,QACN;AAAA,UACE;AAAA,UACA;AAAA,UACA;AAAA,UACA,yDAAyD,UAAU,KAAK,IAAI,CAAC;AAAA,QAC/E;AAAA,MACF;AACA;AAAA,IACF;AAEA,UAAM,SAAS,aAAa,YAAY,MAAM;AAC9C,eAAW,QAAQ,WAAW;AAC5B,UAAI,CAAC,OAAO,SAAS,WAAW,IAAI,GAAG,KAAK,CAAC,OAAO,SAAS,WAAW,IAAI,GAAG,GAAG;AAChF,gBAAQ;AAAA,UACN,KAAK,MAAM,YAAY,SAAS,oDAAoD,IAAI,GAAG;AAAA,QAC7F;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;","names":["readdirSync","existsSync","path","readdirSync","path","existsSync"]}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// src/commands/lint/checks/FE/008.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
|
+
var KEBAB_CASE = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
|
|
9
|
+
function frontendSrc(root) {
|
|
10
|
+
return path.join(root, "frontend", "src");
|
|
11
|
+
}
|
|
12
|
+
function diag(root, absPath, severity, message) {
|
|
13
|
+
return { file: path.relative(root, absPath), line: 1, col: 1, severity, message };
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// src/commands/lint/checks/FE/008.ts
|
|
17
|
+
var ASSET_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
18
|
+
".svg",
|
|
19
|
+
".png",
|
|
20
|
+
".jpg",
|
|
21
|
+
".jpeg",
|
|
22
|
+
".gif",
|
|
23
|
+
".webp",
|
|
24
|
+
".avif",
|
|
25
|
+
".ico",
|
|
26
|
+
".pdf",
|
|
27
|
+
".json",
|
|
28
|
+
".txt",
|
|
29
|
+
".csv",
|
|
30
|
+
".mp4",
|
|
31
|
+
".webm",
|
|
32
|
+
".mp3",
|
|
33
|
+
".wav",
|
|
34
|
+
".ogg",
|
|
35
|
+
".woff",
|
|
36
|
+
".woff2",
|
|
37
|
+
".ttf",
|
|
38
|
+
".otf",
|
|
39
|
+
".eot"
|
|
40
|
+
]);
|
|
41
|
+
var ASSET_NAME = /^[a-z0-9]+(?:[-.][a-z0-9]+)*\.[a-z0-9]+$/;
|
|
42
|
+
function check(root) {
|
|
43
|
+
const srcDir = frontendSrc(root);
|
|
44
|
+
if (!existsSync2(srcDir)) return [];
|
|
45
|
+
const results = [];
|
|
46
|
+
function walkAssets(dir) {
|
|
47
|
+
for (const entry of readdirSync2(dir, { withFileTypes: true })) {
|
|
48
|
+
const entryPath = path2.join(dir, entry.name);
|
|
49
|
+
if (entry.isDirectory()) {
|
|
50
|
+
if (!KEBAB_CASE.test(entry.name)) {
|
|
51
|
+
results.push(
|
|
52
|
+
diag(
|
|
53
|
+
root,
|
|
54
|
+
entryPath,
|
|
55
|
+
"warning",
|
|
56
|
+
`Asset subdirectory "${entry.name}" should be kebab-case`
|
|
57
|
+
)
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
walkAssets(entryPath);
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
const ext = path2.extname(entry.name).toLowerCase();
|
|
64
|
+
if (!ASSET_EXTENSIONS.has(ext)) {
|
|
65
|
+
results.push(
|
|
66
|
+
diag(
|
|
67
|
+
root,
|
|
68
|
+
entryPath,
|
|
69
|
+
"error",
|
|
70
|
+
`"${entry.name}" is not a static asset \u2014 $assets/ may only contain asset files (images, fonts, media, documents, data), never code`
|
|
71
|
+
)
|
|
72
|
+
);
|
|
73
|
+
} else if (!ASSET_NAME.test(entry.name)) {
|
|
74
|
+
results.push(
|
|
75
|
+
diag(
|
|
76
|
+
root,
|
|
77
|
+
entryPath,
|
|
78
|
+
"warning",
|
|
79
|
+
`Asset "${entry.name}" should be kebab-case with a lowercase extension (e.g. "user-guide.pdf")`
|
|
80
|
+
)
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function walk(dir) {
|
|
86
|
+
for (const entry of readdirSync2(dir, { withFileTypes: true })) {
|
|
87
|
+
const entryPath = path2.join(dir, entry.name);
|
|
88
|
+
if (entry.isDirectory()) {
|
|
89
|
+
if (entry.name === "$misc" || entry.name === "node_modules") continue;
|
|
90
|
+
if (entry.name === "$assets") {
|
|
91
|
+
walkAssets(entryPath);
|
|
92
|
+
} else {
|
|
93
|
+
walk(entryPath);
|
|
94
|
+
}
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (ASSET_EXTENSIONS.has(path2.extname(entry.name).toLowerCase())) {
|
|
98
|
+
results.push(
|
|
99
|
+
diag(
|
|
100
|
+
root,
|
|
101
|
+
entryPath,
|
|
102
|
+
"error",
|
|
103
|
+
`Asset "${entry.name}" must live in a $assets/ directory of its owning scope (found in ${path2.relative(root, dir)})`
|
|
104
|
+
)
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
walk(srcDir);
|
|
110
|
+
return results;
|
|
111
|
+
}
|
|
112
|
+
export {
|
|
113
|
+
check as default
|
|
114
|
+
};
|
|
115
|
+
//# sourceMappingURL=008.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/commands/lint/checks/FE/008.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 { KEBAB_CASE, diag, frontendSrc } from '../../frontend-structure'\n\n/** Non-code file extensions that belong in a $assets/ directory. */\nconst ASSET_EXTENSIONS = new Set([\n '.svg',\n '.png',\n '.jpg',\n '.jpeg',\n '.gif',\n '.webp',\n '.avif',\n '.ico',\n '.pdf',\n '.json',\n '.txt',\n '.csv',\n '.mp4',\n '.webm',\n '.mp3',\n '.wav',\n '.ogg',\n '.woff',\n '.woff2',\n '.ttf',\n '.otf',\n '.eot',\n])\n\n/** kebab-case base name (dots allowed as extra separators), lowercase extension. */\nconst ASSET_NAME = /^[a-z0-9]+(?:[-.][a-z0-9]+)*\\.[a-z0-9]+$/\n\n/** FE008 — static assets live only in $assets/ folders; $assets/ contains only kebab-case asset files */\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 walkAssets(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 (!KEBAB_CASE.test(entry.name)) {\n results.push(\n diag(\n root,\n entryPath,\n 'warning',\n `Asset subdirectory \"${entry.name}\" should be kebab-case`,\n ),\n )\n }\n walkAssets(entryPath)\n continue\n }\n const ext = path.extname(entry.name).toLowerCase()\n if (!ASSET_EXTENSIONS.has(ext)) {\n results.push(\n diag(\n root,\n entryPath,\n 'error',\n `\"${entry.name}\" is not a static asset — $assets/ may only contain asset files (images, fonts, media, documents, data), never code`,\n ),\n )\n } else if (!ASSET_NAME.test(entry.name)) {\n results.push(\n diag(\n root,\n entryPath,\n 'warning',\n `Asset \"${entry.name}\" should be kebab-case with a lowercase extension (e.g. \"user-guide.pdf\")`,\n ),\n )\n }\n }\n }\n\n function walk(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 === 'node_modules') continue\n if (entry.name === '$assets') {\n walkAssets(entryPath)\n } else {\n walk(entryPath)\n }\n continue\n }\n if (ASSET_EXTENSIONS.has(path.extname(entry.name).toLowerCase())) {\n results.push(\n diag(\n root,\n entryPath,\n 'error',\n `Asset \"${entry.name}\" must live in a $assets/ directory of its owning scope (found in ${path.relative(root, dir)})`,\n ),\n )\n }\n }\n }\n\n walk(srcDir)\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;AAmBV,IAAM,aAAa;AAKnB,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;;;AD1CA,IAAM,mBAAmB,oBAAI,IAAI;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAGD,IAAM,aAAa;AAGJ,SAAR,MAAuB,MAA+B;AAC3D,QAAM,SAAS,YAAY,IAAI;AAC/B,MAAI,CAACC,YAAW,MAAM,EAAG,QAAO,CAAC;AAEjC,QAAM,UAA2B,CAAC;AAElC,WAAS,WAAW,KAAmB;AACrC,eAAW,SAASC,aAAY,KAAK,EAAE,eAAe,KAAK,CAAC,GAAG;AAC7D,YAAM,YAAYC,MAAK,KAAK,KAAK,MAAM,IAAI;AAC3C,UAAI,MAAM,YAAY,GAAG;AACvB,YAAI,CAAC,WAAW,KAAK,MAAM,IAAI,GAAG;AAChC,kBAAQ;AAAA,YACN;AAAA,cACE;AAAA,cACA;AAAA,cACA;AAAA,cACA,uBAAuB,MAAM,IAAI;AAAA,YACnC;AAAA,UACF;AAAA,QACF;AACA,mBAAW,SAAS;AACpB;AAAA,MACF;AACA,YAAM,MAAMA,MAAK,QAAQ,MAAM,IAAI,EAAE,YAAY;AACjD,UAAI,CAAC,iBAAiB,IAAI,GAAG,GAAG;AAC9B,gBAAQ;AAAA,UACN;AAAA,YACE;AAAA,YACA;AAAA,YACA;AAAA,YACA,IAAI,MAAM,IAAI;AAAA,UAChB;AAAA,QACF;AAAA,MACF,WAAW,CAAC,WAAW,KAAK,MAAM,IAAI,GAAG;AACvC,gBAAQ;AAAA,UACN;AAAA,YACE;AAAA,YACA;AAAA,YACA;AAAA,YACA,UAAU,MAAM,IAAI;AAAA,UACtB;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,WAAS,KAAK,KAAmB;AAC/B,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,eAAgB;AAC7D,YAAI,MAAM,SAAS,WAAW;AAC5B,qBAAW,SAAS;AAAA,QACtB,OAAO;AACL,eAAK,SAAS;AAAA,QAChB;AACA;AAAA,MACF;AACA,UAAI,iBAAiB,IAAIA,MAAK,QAAQ,MAAM,IAAI,EAAE,YAAY,CAAC,GAAG;AAChE,gBAAQ;AAAA,UACN;AAAA,YACE;AAAA,YACA;AAAA,YACA;AAAA,YACA,UAAU,MAAM,IAAI,qEAAqEA,MAAK,SAAS,MAAM,GAAG,CAAC;AAAA,UACnH;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,OAAK,MAAM;AACX,SAAO;AACT;","names":["readdirSync","existsSync","path","existsSync","readdirSync","path"]}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// src/commands/lint/checks/FE/009.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
|
+
var SCOPE_FILES = /* @__PURE__ */ new Set([
|
|
9
|
+
"index.tsx",
|
|
10
|
+
"styles.module.css",
|
|
11
|
+
"types.tsx",
|
|
12
|
+
"constants.tsx",
|
|
13
|
+
"functions.tsx"
|
|
14
|
+
]);
|
|
15
|
+
var SCOPE_FILES_LABEL = "index.tsx, styles.module.css, types.tsx, constants.tsx, functions.tsx";
|
|
16
|
+
var KEBAB_CASE = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
|
|
17
|
+
function frontendSrc(root) {
|
|
18
|
+
return path.join(root, "frontend", "src");
|
|
19
|
+
}
|
|
20
|
+
function diag(root, absPath, severity, message) {
|
|
21
|
+
return { file: path.relative(root, absPath), line: 1, col: 1, severity, message };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// src/commands/lint/checks/FE/009.ts
|
|
25
|
+
var ALLOWED_DIRS = /* @__PURE__ */ new Set(["$assets", "$misc"]);
|
|
26
|
+
function check(root) {
|
|
27
|
+
const utilsDir = path2.join(frontendSrc(root), "utils");
|
|
28
|
+
if (!existsSync2(utilsDir)) return [];
|
|
29
|
+
const results = [];
|
|
30
|
+
function walk(dir) {
|
|
31
|
+
for (const entry of readdirSync2(dir, { withFileTypes: true })) {
|
|
32
|
+
const entryPath = path2.join(dir, entry.name);
|
|
33
|
+
if (!entry.isDirectory()) {
|
|
34
|
+
if (!SCOPE_FILES.has(entry.name)) {
|
|
35
|
+
results.push(
|
|
36
|
+
diag(
|
|
37
|
+
root,
|
|
38
|
+
entryPath,
|
|
39
|
+
"error",
|
|
40
|
+
`Unexpected file "${entry.name}" in utils. Allowed: ${SCOPE_FILES_LABEL}`
|
|
41
|
+
)
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (entry.name.startsWith("$")) {
|
|
47
|
+
if (!ALLOWED_DIRS.has(entry.name)) {
|
|
48
|
+
results.push(
|
|
49
|
+
diag(
|
|
50
|
+
root,
|
|
51
|
+
entryPath,
|
|
52
|
+
"error",
|
|
53
|
+
`Unknown privileged directory "${entry.name}" in utils. Allowed: $assets/, $misc/`
|
|
54
|
+
)
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (!KEBAB_CASE.test(entry.name)) {
|
|
60
|
+
results.push(
|
|
61
|
+
diag(
|
|
62
|
+
root,
|
|
63
|
+
entryPath,
|
|
64
|
+
"error",
|
|
65
|
+
`Utils domain "${entry.name}" must be kebab-case (e.g. "date-helpers")`
|
|
66
|
+
)
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
if (!existsSync2(path2.join(entryPath, "index.tsx"))) {
|
|
70
|
+
results.push(
|
|
71
|
+
diag(root, entryPath, "error", `Utils domain "${entry.name}" is missing its index.tsx`)
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
walk(entryPath);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
walk(utilsDir);
|
|
78
|
+
return results;
|
|
79
|
+
}
|
|
80
|
+
export {
|
|
81
|
+
check as default
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=009.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/commands/lint/checks/FE/009.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 {\n KEBAB_CASE,\n SCOPE_FILES,\n SCOPE_FILES_LABEL,\n diag,\n frontendSrc,\n} from '../../frontend-structure'\n\nconst ALLOWED_DIRS = new Set(['$assets', '$misc'])\n\n/** FE009 — utils/ is organised in kebab-case domain dirs, each with the scope files + $assets/$misc */\nexport default function check(root: string): RawDiagnostic[] {\n const utilsDir = path.join(frontendSrc(root), 'utils')\n if (!existsSync(utilsDir)) return []\n\n const results: RawDiagnostic[] = []\n\n function walk(dir: string): void {\n for (const entry of readdirSync(dir, { withFileTypes: true })) {\n const entryPath = path.join(dir, entry.name)\n\n if (!entry.isDirectory()) {\n if (!SCOPE_FILES.has(entry.name)) {\n results.push(\n diag(\n root,\n entryPath,\n 'error',\n `Unexpected file \"${entry.name}\" in utils. Allowed: ${SCOPE_FILES_LABEL}`,\n ),\n )\n }\n continue\n }\n\n if (entry.name.startsWith('$')) {\n if (!ALLOWED_DIRS.has(entry.name)) {\n results.push(\n diag(\n root,\n entryPath,\n 'error',\n `Unknown privileged directory \"${entry.name}\" in utils. Allowed: $assets/, $misc/`,\n ),\n )\n }\n continue\n }\n\n // Any other directory is a utils domain.\n if (!KEBAB_CASE.test(entry.name)) {\n results.push(\n diag(\n root,\n entryPath,\n 'error',\n `Utils domain \"${entry.name}\" must be kebab-case (e.g. \"date-helpers\")`,\n ),\n )\n }\n if (!existsSync(path.join(entryPath, 'index.tsx'))) {\n results.push(\n diag(root, entryPath, 'error', `Utils domain \"${entry.name}\" is missing its index.tsx`),\n )\n }\n walk(entryPath)\n }\n }\n\n walk(utilsDir)\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;AAIV,IAAM,cAAc,oBAAI,IAAI;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAGM,IAAM,oBAAoB;AAM1B,IAAM,aAAa;AAKnB,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;;;ADrCA,IAAM,eAAe,oBAAI,IAAI,CAAC,WAAW,OAAO,CAAC;AAGlC,SAAR,MAAuB,MAA+B;AAC3D,QAAM,WAAWC,MAAK,KAAK,YAAY,IAAI,GAAG,OAAO;AACrD,MAAI,CAACC,YAAW,QAAQ,EAAG,QAAO,CAAC;AAEnC,QAAM,UAA2B,CAAC;AAElC,WAAS,KAAK,KAAmB;AAC/B,eAAW,SAASC,aAAY,KAAK,EAAE,eAAe,KAAK,CAAC,GAAG;AAC7D,YAAM,YAAYF,MAAK,KAAK,KAAK,MAAM,IAAI;AAE3C,UAAI,CAAC,MAAM,YAAY,GAAG;AACxB,YAAI,CAAC,YAAY,IAAI,MAAM,IAAI,GAAG;AAChC,kBAAQ;AAAA,YACN;AAAA,cACE;AAAA,cACA;AAAA,cACA;AAAA,cACA,oBAAoB,MAAM,IAAI,wBAAwB,iBAAiB;AAAA,YACzE;AAAA,UACF;AAAA,QACF;AACA;AAAA,MACF;AAEA,UAAI,MAAM,KAAK,WAAW,GAAG,GAAG;AAC9B,YAAI,CAAC,aAAa,IAAI,MAAM,IAAI,GAAG;AACjC,kBAAQ;AAAA,YACN;AAAA,cACE;AAAA,cACA;AAAA,cACA;AAAA,cACA,iCAAiC,MAAM,IAAI;AAAA,YAC7C;AAAA,UACF;AAAA,QACF;AACA;AAAA,MACF;AAGA,UAAI,CAAC,WAAW,KAAK,MAAM,IAAI,GAAG;AAChC,gBAAQ;AAAA,UACN;AAAA,YACE;AAAA,YACA;AAAA,YACA;AAAA,YACA,iBAAiB,MAAM,IAAI;AAAA,UAC7B;AAAA,QACF;AAAA,MACF;AACA,UAAI,CAACC,YAAWD,MAAK,KAAK,WAAW,WAAW,CAAC,GAAG;AAClD,gBAAQ;AAAA,UACN,KAAK,MAAM,WAAW,SAAS,iBAAiB,MAAM,IAAI,4BAA4B;AAAA,QACxF;AAAA,MACF;AACA,WAAK,SAAS;AAAA,IAChB;AAAA,EACF;AAEA,OAAK,QAAQ;AACb,SAAO;AACT;","names":["readdirSync","existsSync","path","path","existsSync","readdirSync"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { RawDiagnostic } from '@cubocicloide/dude';
|
|
2
|
+
|
|
3
|
+
/** FE010 — src root contains only the app entry files + $types/$components/$hooks/openapi/pages/utils; *.d.ts live in $types/ */
|
|
4
|
+
declare function check(root: string): RawDiagnostic[];
|
|
5
|
+
|
|
6
|
+
export { check as default };
|
|
@@ -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,YAAY,mBAAmB,CAAC;AAC/E,IAAM,oBAAoB,oBAAI,IAAI,CAAC,UAAU,eAAe,UAAU,WAAW,SAAS,OAAO,CAAC;AAGlG,IAAM,iBAAiB,oBAAI,IAAI;AAAA,EAC7B,CAAC,cAAc,yBAAyB;AAAA,EACxC,CAAC,SAAS,oBAAoB;AAAA,EAC9B,CAAC,UAAU,8DAA8D;AAAA,EACzE,CAAC,aAAa,gCAAgC;AAAA,EAC9C,CAAC,iBAAiB,iCAAiC;AACrD,CAAC;AAGc,SAAR,MAAuB,MAA+B;AAC3D,QAAM,SAAS,YAAY,IAAI;AAC/B,MAAI,CAACC,YAAW,MAAM,EAAG,QAAO,CAAC;AAEjC,QAAM,UAA2B,CAAC;AAElC,aAAW,SAASC,aAAY,QAAQ,EAAE,eAAe,KAAK,CAAC,GAAG;AAChE,UAAM,YAAYC,MAAK,KAAK,QAAQ,MAAM,IAAI;AAC9C,UAAM,aAAa,eAAe,IAAI,MAAM,IAAI;AAChD,QAAI,YAAY;AACd,cAAQ;AAAA,QACN;AAAA,UACE;AAAA,UACA;AAAA,UACA;AAAA,UACA,IAAI,MAAM,IAAI,kDAA6C,UAAU;AAAA,QACvE;AAAA,MACF;AACA;AAAA,IACF;AACA,QAAI,MAAM,YAAY,GAAG;AACvB,UAAI,CAAC,kBAAkB,IAAI,MAAM,IAAI,GAAG;AACtC,gBAAQ;AAAA,UACN;AAAA,YACE;AAAA,YACA;AAAA,YACA;AAAA,YACA,yBAAyB,MAAM,IAAI;AAAA,UACrC;AAAA,QACF;AAAA,MACF;AAAA,IACF,WAAW,CAAC,mBAAmB,IAAI,MAAM,IAAI,GAAG;AAC9C,cAAQ;AAAA,QACN;AAAA,UACE;AAAA,UACA;AAAA,UACA;AAAA,UACA,oBAAoB,MAAM,IAAI;AAAA,QAChC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAGA,QAAM,WAAWA,MAAK,KAAK,QAAQ,QAAQ;AAC3C,MAAIF,YAAW,QAAQ,GAAG;AACxB,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,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
|