architecture-harness 0.25.0 → 0.26.0
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/package.json +3 -22
- package/src/cli/ask.mjs +42 -0
- package/src/cli/ask.test.mjs +40 -0
- package/src/cli/branch-sync.mjs +126 -0
- package/src/cli/branch-sync.test.mjs +428 -0
- package/src/cli/budget-guard.mjs +74 -5
- package/src/cli/budget-guard.test.mjs +185 -2
- package/src/cli/budget-report.mjs +85 -0
- package/src/cli/budget-report.test.mjs +173 -0
- package/src/cli/budget.mjs +8 -5
- package/src/cli/check-commands.mjs +123 -11
- package/src/cli/check-commands.test.mjs +360 -6
- package/src/cli/check-feature-switches.test.mjs +110 -0
- package/src/cli/check-full.test.mjs +152 -0
- package/src/cli/check-verdict.mjs +46 -0
- package/src/cli/check-verdict.test.mjs +32 -0
- package/src/cli/check.mjs +137 -4
- package/src/cli/check.test.mjs +45 -0
- package/src/cli/checkpoint.mjs +143 -0
- package/src/cli/checkpoint.test.mjs +146 -0
- package/src/cli/child-run.mjs +7 -2
- package/src/cli/child-run.test.mjs +17 -2
- package/src/cli/ci-failures.mjs +304 -0
- package/src/cli/ci-failures.test.mjs +615 -0
- package/src/cli/ci-preview.mjs +62 -0
- package/src/cli/ci-preview.test.mjs +85 -0
- package/src/cli/ci-state.mjs +25 -29
- package/src/cli/ci-state.test.mjs +174 -2
- package/src/cli/ci-template.test.mjs +86 -0
- package/src/cli/claude-core.test.mjs +37 -0
- package/src/cli/codex-implement.mjs +580 -47
- package/src/cli/codex-implement.test.mjs +1946 -29
- package/src/cli/codex-limit.mjs +85 -0
- package/src/cli/codex-limit.test.mjs +179 -0
- package/src/cli/codex-reset.mjs +78 -0
- package/src/cli/codex-reset.test.mjs +192 -0
- package/src/cli/codex-verify.mjs +230 -0
- package/src/cli/codex-verify.test.mjs +402 -0
- package/src/cli/comment-watch.mjs +391 -0
- package/src/cli/comment-watch.test.mjs +392 -0
- package/src/cli/commit-guard.mjs +219 -0
- package/src/cli/commit-guard.test.mjs +809 -0
- package/src/cli/context-budgets.mjs +47 -0
- package/src/cli/context-budgets.test.mjs +96 -0
- package/src/cli/context-watch.mjs +116 -0
- package/src/cli/context-watch.test.mjs +395 -0
- package/src/cli/contract-history.mjs +1 -1
- package/src/cli/controller-guard.mjs +38 -0
- package/src/cli/controller-guard.test.mjs +66 -2
- package/src/cli/cost-stop.mjs +5 -1
- package/src/cli/cost-stop.test.mjs +26 -0
- package/src/cli/diff-shape.mjs +162 -0
- package/src/cli/diff-shape.test.mjs +200 -0
- package/src/cli/direct-lane.mjs +32 -19
- package/src/cli/direct-lane.test.mjs +21 -3
- package/src/cli/dispatch-guard.mjs +11 -0
- package/src/cli/dispatch-guard.test.mjs +145 -10
- package/src/cli/dispatch-reminder.mjs +23 -10
- package/src/cli/dispatch-reminder.test.mjs +63 -11
- package/src/cli/dispatch-route.mjs +54 -0
- package/src/cli/dispatch-route.test.mjs +101 -0
- package/src/cli/dispatch-slot.mjs +2 -2
- package/src/cli/dispatch-slot.test.mjs +18 -19
- package/src/cli/dispatch.test.mjs +3 -3
- package/src/cli/e2e-affected.mjs +15 -0
- package/src/cli/e2e-affected.test.mjs +73 -0
- package/src/cli/fleet.mjs +180 -0
- package/src/cli/fleet.test.mjs +213 -0
- package/src/cli/gate-slot.mjs +2 -1
- package/src/cli/gh-merge-command.mjs +96 -31
- package/src/cli/gh-merge-command.test.mjs +74 -0
- package/src/cli/gh-run.mjs +64 -3
- package/src/cli/gh-run.test.mjs +66 -1
- package/src/cli/git-hooks.test.mjs +25 -3
- package/src/cli/git-read.mjs +2 -1
- package/src/cli/integrate-tree.mjs +47 -0
- package/src/cli/integrate.mjs +143 -40
- package/src/cli/integrate.test.mjs +347 -1
- package/src/cli/integration-lane.mjs +62 -0
- package/src/cli/integration-lane.test.mjs +213 -0
- package/src/cli/ledger.mjs +4 -2
- package/src/cli/ledger.test.mjs +12 -3
- package/src/cli/legs.mjs +53 -0
- package/src/cli/legs.test.mjs +70 -0
- package/src/cli/lint-changed.mjs +59 -10
- package/src/cli/lint-changed.test.mjs +112 -1
- package/src/cli/locked-tests.mjs +134 -0
- package/src/cli/locked-tests.test.mjs +188 -0
- package/src/cli/merge-guard.mjs +234 -62
- package/src/cli/merge-guard.test.mjs +768 -39
- package/src/cli/metrics.mjs +53 -0
- package/src/cli/metrics.test.mjs +73 -0
- package/src/cli/milestone.mjs +297 -0
- package/src/cli/milestone.test.mjs +294 -0
- package/src/cli/mutate.mjs +203 -0
- package/src/cli/mutate.test.mjs +134 -0
- package/src/cli/output-redaction.mjs +26 -0
- package/src/cli/output-redaction.test.mjs +117 -0
- package/src/cli/overview.mjs +131 -0
- package/src/cli/overview.test.mjs +137 -0
- package/src/cli/pause.mjs +93 -0
- package/src/cli/pause.test.mjs +109 -0
- package/src/cli/plan-check.mjs +84 -12
- package/src/cli/plan-check.test.mjs +152 -2
- package/src/cli/plan-stop.mjs +7 -4
- package/src/cli/plan-stop.test.mjs +87 -0
- package/src/cli/platform-risk.mjs +46 -0
- package/src/cli/platform-risk.test.mjs +38 -0
- package/src/cli/plugin-skills.test.mjs +25 -0
- package/src/cli/pr-guard.mjs +128 -0
- package/src/cli/pr-guard.test.mjs +154 -0
- package/src/cli/promotion-branch.mjs +2 -0
- package/src/cli/qc.mjs +160 -27
- package/src/cli/qc.test.mjs +93 -0
- package/src/cli/report-stop.mjs +5 -0
- package/src/cli/report-stop.test.mjs +23 -1
- package/src/cli/retry-failed.mjs +3 -1
- package/src/cli/review-gate.mjs +24 -6
- package/src/cli/review-gate.test.mjs +116 -0
- package/src/cli/review-promotion.mjs +107 -0
- package/src/cli/review-promotion.test.mjs +251 -0
- package/src/cli/role-budget.mjs +50 -0
- package/src/cli/role-budget.test.mjs +91 -0
- package/src/cli/run-log.mjs +73 -0
- package/src/cli/run-log.test.mjs +121 -0
- package/src/cli/secret-patterns.mjs +16 -0
- package/src/cli/secret-patterns.test.mjs +73 -0
- package/src/cli/setup-block.mjs +24 -0
- package/src/cli/setup-block.test.mjs +96 -0
- package/src/cli/setup-checks.mjs +65 -0
- package/src/cli/setup-checks.test.mjs +158 -0
- package/src/cli/setup-compaction.mjs +55 -0
- package/src/cli/setup-compaction.test.mjs +115 -0
- package/src/cli/setup-skills.mjs +65 -0
- package/src/cli/setup-skills.test.mjs +171 -0
- package/src/cli/setup.mjs +107 -0
- package/src/cli/setup.test.mjs +275 -0
- package/src/cli/skill-length.test.mjs +8 -0
- package/src/cli/spawn-command.mjs +47 -0
- package/src/cli/spawn-command.test.mjs +64 -0
- package/src/cli/task-gate-review.test.mjs +21 -2
- package/src/cli/task-gate.mjs +25 -12
- package/src/cli/task-gate.test.mjs +43 -5
- package/src/cli/tokens.mjs +46 -3
- package/src/cli/tokens.test.mjs +103 -3
- package/src/cli/tools.mjs +49 -0
- package/src/cli/tools.test.mjs +89 -0
- package/src/cli/transcript-usage.mjs +27 -0
- package/src/cli/transcript-usage.test.mjs +34 -0
- package/src/cli/user-config-package.mjs +1 -1
- package/src/cli/user-config-toml.mjs +63 -7
- package/src/cli/user-config.mjs +39 -7
- package/src/cli/user-config.test.mjs +238 -5
- package/src/cli/watch-arm.mjs +39 -0
- package/src/cli/watch-arm.test.mjs +87 -0
- package/src/cli/watch.mjs +80 -35
- package/src/cli/watch.test.mjs +233 -27
- package/src/cli/work-order-guard.mjs +2 -1
- package/src/cli/workflow-hooks.test.mjs +18 -4
- package/src/cli/workflow-settings.mjs +44 -8
- package/src/cli/workflow-settings.test.mjs +124 -1
- package/src/cli/worktree.mjs +14 -1
- package/src/cli/worktree.test.mjs +20 -1
- package/src/config.mjs +174 -7
- package/src/config.test.mjs +327 -5
- package/src/consumer-package.mjs +31 -0
- package/src/consumer-package.test.mjs +54 -0
- package/src/descriptions.mjs +2 -0
- package/src/eslint/index.mjs +12 -0
- package/src/eslint/jsx.mjs +20 -0
- package/src/eslint/preset.mjs +26 -2
- package/src/eslint/preset.test.mjs +104 -2
- package/src/eslint/rules/no-arbitrary-class-value.mjs +32 -0
- package/src/eslint/rules/no-literal-color.mjs +94 -0
- package/src/eslint/rules/no-static-inline-style.mjs +41 -0
- package/src/eslint/rules/one-component-per-file.mjs +70 -0
- package/src/eslint/rules/raw-element-in-primitive.mjs +31 -0
- package/src/eslint/rules/timeless-comment.mjs +92 -0
- package/src/eslint/rules.test.mjs +189 -0
- package/src/eslint/ui-regressions.test.mjs +39 -0
- package/src/gates/contract-operations.mjs +3 -3
- package/src/gates/contract-operations.test.mjs +28 -0
- package/src/gates/feature-switches.mjs +19 -0
- package/src/gates/feature-switches.test.mjs +55 -0
- package/src/gates/plain-language.mjs +396 -0
- package/src/gates/plain-language.test.mjs +210 -0
- package/src/gates/runtime-imports.test.mjs +114 -0
- package/src/gates/saga-key.test.mjs +1 -1
- package/src/global-skills.mjs +9 -0
- package/src/global-skills.test.mjs +53 -0
- package/src/plugin.test.mjs +3 -2
- package/src/ui/class-sites.mjs +38 -6
- package/src/ui/codemod.mjs +4 -1
- package/src/ui/codemod.test.mjs +52 -0
- package/src/ui/components.mjs +5 -3
- package/src/ui/components.test.mjs +8 -0
- package/src/ui/dupes.test.mjs +18 -0
- package/templates/docs/enforcement.md +12 -2
- package/templates/docs/ui.md +33 -0
- package/templates/githooks/pre-commit +1 -0
- package/templates/githooks/pre-push +11 -2
- package/templates/github/workflows/ci.yml +57 -3
- package/user-config/claude/CLAUDE.core.md +28 -0
- package/user-config/claude/settings.shared.json +41 -1
- package/src/cli/screens-discovery.mjs +0 -60
- package/src/cli/screens.mjs +0 -84
- package/src/cli/stack.mjs +0 -14
- package/src/cli/throwaway-db.mjs +0 -127
- package/src/cli/throwaway-db.test.mjs +0 -83
- package/src/screens/auth-context.test.mjs +0 -41
- package/src/screens/auth-run.test.mjs +0 -147
- package/src/screens/auth.mjs +0 -223
- package/src/screens/auth.test.mjs +0 -76
- package/src/screens/capture-idle.test.mjs +0 -27
- package/src/screens/capture.browser-test.mjs +0 -73
- package/src/screens/capture.mjs +0 -175
- package/src/screens/capture.test.mjs +0 -28
- package/src/screens/catalog.browser-test.mjs +0 -32
- package/src/screens/catalog.mjs +0 -72
- package/src/screens/catalog.test.mjs +0 -36
- package/src/screens/chrome.mjs +0 -21
- package/src/screens/compare.mjs +0 -40
- package/src/screens/compare.test.mjs +0 -30
- package/src/screens/discovery.browser-test.mjs +0 -29
- package/src/screens/discovery.mjs +0 -158
- package/src/screens/discovery.test.mjs +0 -27
- package/src/screens/inventory.mjs +0 -69
- package/src/screens/inventory.test.mjs +0 -10
- package/src/screens/map.mjs +0 -63
- package/src/screens/map.test.mjs +0 -35
- package/src/screens/open.browser-test.mjs +0 -50
- package/src/screens/regions.mjs +0 -137
- package/src/screens/regions.test.mjs +0 -38
- package/src/screens/session-files.mjs +0 -39
- package/src/screens/session-files.test.mjs +0 -39
- package/src/screens/setup.browser-test.mjs +0 -49
- package/src/screens/setup.mjs +0 -78
- package/src/screens/stack-auth.browser-test.mjs +0 -30
- package/src/screens/stack-auth.mjs +0 -106
- package/src/screens/stack-auth.test.mjs +0 -65
- package/src/screens/write-guard.mjs +0 -26
- package/src/stack/stack.mjs +0 -131
- package/src/stack/stack.test.mjs +0 -40
- package/src/stack/supervisor.mjs +0 -30
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// A comment states what is true, never when it became true. A reader meets it long after the
|
|
2
|
+
// change that prompted it, so a promise or a date inside it is a fact that has already rotted.
|
|
3
|
+
// git holds the history, an issue holds the promise, and a decision record holds the decision.
|
|
4
|
+
//
|
|
5
|
+
// Comments only. The same word inside a string is someone's data, not this repository dating itself.
|
|
6
|
+
// no-supersession-trail owns the past tense. This rule owns the promise and the moment.
|
|
7
|
+
|
|
8
|
+
import { escape, optionsOf, schemaOf } from "../options.mjs";
|
|
9
|
+
|
|
10
|
+
// Work a comment says is still owed. The comment outlives the intent every time.
|
|
11
|
+
const DEFAULT_PROMISES = [
|
|
12
|
+
"todo",
|
|
13
|
+
"fixme",
|
|
14
|
+
"for now",
|
|
15
|
+
"temporarily",
|
|
16
|
+
"temporary fix",
|
|
17
|
+
"temporary workaround",
|
|
18
|
+
"temporary until",
|
|
19
|
+
"not yet implemented",
|
|
20
|
+
"not implemented yet",
|
|
21
|
+
"coming soon",
|
|
22
|
+
"in a future",
|
|
23
|
+
"in future",
|
|
24
|
+
"revisit",
|
|
25
|
+
"stopgap",
|
|
26
|
+
"will be replaced",
|
|
27
|
+
"will be removed",
|
|
28
|
+
"will be renamed",
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
// Wording that pins the comment to the day someone wrote it. A phrase a repository reads as
|
|
32
|
+
// ordinary prose belongs in its own config, not here: a rule nobody can satisfy gets switched off.
|
|
33
|
+
const DEFAULT_MOMENTS = [
|
|
34
|
+
"currently",
|
|
35
|
+
"at the moment",
|
|
36
|
+
"at present",
|
|
37
|
+
"right now",
|
|
38
|
+
"as of",
|
|
39
|
+
"recently",
|
|
40
|
+
"nowadays",
|
|
41
|
+
"these days",
|
|
42
|
+
"newly added",
|
|
43
|
+
"just added",
|
|
44
|
+
"previously",
|
|
45
|
+
"originally",
|
|
46
|
+
"for the time being",
|
|
47
|
+
"since the refactor",
|
|
48
|
+
"after the refactor",
|
|
49
|
+
"renamed from",
|
|
50
|
+
"we now",
|
|
51
|
+
];
|
|
52
|
+
|
|
53
|
+
/** An empty list matches nothing, so a repository can switch off one half and keep the other. */
|
|
54
|
+
function group(phrases) {
|
|
55
|
+
if (phrases.length === 0) return /(?!)/;
|
|
56
|
+
return new RegExp(`\\b(${phrases.map(escape).join("|")})\\b`, "i");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export default {
|
|
60
|
+
meta: {
|
|
61
|
+
type: "problem",
|
|
62
|
+
docs: { description: "a comment states what is true, never when it became true or what is still owed" },
|
|
63
|
+
schema: schemaOf({
|
|
64
|
+
promises: { type: "array", items: { type: "string" } },
|
|
65
|
+
moments: { type: "array", items: { type: "string" } },
|
|
66
|
+
}),
|
|
67
|
+
messages: {
|
|
68
|
+
promise: "'{{phrase}}' owes future work. A comment states what is true. Put the promise in an issue or a decision record.",
|
|
69
|
+
moment: "'{{phrase}}' dates this comment. State what is true, not when it became true.",
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
create(context) {
|
|
73
|
+
const options = optionsOf(context);
|
|
74
|
+
const groups = [
|
|
75
|
+
{ id: "promise", pattern: group(options.promises ?? DEFAULT_PROMISES) },
|
|
76
|
+
{ id: "moment", pattern: group(options.moments ?? DEFAULT_MOMENTS) },
|
|
77
|
+
];
|
|
78
|
+
return {
|
|
79
|
+
Program() {
|
|
80
|
+
for (const comment of context.sourceCode.getAllComments()) {
|
|
81
|
+
for (const { id, pattern } of groups) {
|
|
82
|
+
const found = pattern.exec(comment.value);
|
|
83
|
+
if (found === null) continue;
|
|
84
|
+
// One finding per comment: a reader fixes the sentence, not each word in it.
|
|
85
|
+
context.report({ node: comment, messageId: id, data: { phrase: found[1].toLowerCase() } });
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
},
|
|
92
|
+
};
|
|
@@ -500,6 +500,40 @@ tester.run("no-supersession-trail", rules["no-supersession-trail"], {
|
|
|
500
500
|
],
|
|
501
501
|
});
|
|
502
502
|
|
|
503
|
+
console.log("→", "timeless-comment");
|
|
504
|
+
tester.run("timeless-comment", rules["timeless-comment"], {
|
|
505
|
+
valid: [
|
|
506
|
+
{ code: "// the one place a caller resolves a name\nconst a = 1;" },
|
|
507
|
+
{ code: 'const label = "todo";' },
|
|
508
|
+
{ code: "// the repository states what is true now\nconst a = 1;" },
|
|
509
|
+
{ code: "// the reader writes to a temporary file\nconst a = 1;" },
|
|
510
|
+
{ code: "// the retry eventually succeeds\nconst a = 1;" },
|
|
511
|
+
{ code: "// the rows read so far are returned\nconst a = 1;" },
|
|
512
|
+
],
|
|
513
|
+
invalid: [
|
|
514
|
+
{ code: "// TODO: wire the runner\nconst a = 1;", errors: [{ messageId: "promise" }] },
|
|
515
|
+
{ code: "// for now the cache is in memory\nconst a = 1;", errors: [{ messageId: "promise" }] },
|
|
516
|
+
{ code: "/* this will be removed with the runner */\nconst a = 1;", errors: [{ messageId: "promise" }] },
|
|
517
|
+
{ code: "// a temporary fix until the queue lands\nconst a = 1;", errors: [{ messageId: "promise" }] },
|
|
518
|
+
{ code: "// currently the queue holds one job\nconst a = 1;", errors: [{ messageId: "moment" }] },
|
|
519
|
+
{ code: "/* as of the last release this is the only caller */\nconst a = 1;", errors: [{ messageId: "moment" }] },
|
|
520
|
+
{ code: "// we now read the key from the header\nconst a = 1;", errors: [{ messageId: "moment" }] },
|
|
521
|
+
{ code: "// renamed from the ledger block\nconst a = 1;", errors: [{ messageId: "moment" }] },
|
|
522
|
+
// Both halves in one sentence is still one sentence to rewrite.
|
|
523
|
+
{ code: "// TODO: currently broken\nconst a = 1;", errors: [{ messageId: "promise" }] },
|
|
524
|
+
],
|
|
525
|
+
});
|
|
526
|
+
|
|
527
|
+
tester.run("timeless-comment", rules["timeless-comment"], {
|
|
528
|
+
valid: [
|
|
529
|
+
{ code: "// todo\nconst a = 1;", options: [{ promises: ["obsolete"] }] },
|
|
530
|
+
{ code: "// currently the queue holds one job\nconst a = 1;", options: [{ moments: [] }] },
|
|
531
|
+
],
|
|
532
|
+
invalid: [
|
|
533
|
+
{ code: "// obsolete soon\nconst a = 1;", options: [{ promises: ["obsolete"] }], errors: [{ messageId: "promise" }] },
|
|
534
|
+
],
|
|
535
|
+
});
|
|
536
|
+
|
|
503
537
|
console.log("→", "options: the new rules take their vocabulary from config");
|
|
504
538
|
tester.run("durable-idempotency-key", rules["durable-idempotency-key"], {
|
|
505
539
|
valid: [{ code: "send({ mutationId: ulid() });", options: [{ volatile: ["nanoid"] }] }],
|
|
@@ -828,8 +862,163 @@ tester.run("registry-literal", rules["registry-literal"], {
|
|
|
828
862
|
],
|
|
829
863
|
});
|
|
830
864
|
|
|
865
|
+
const tsx = new RuleTester({
|
|
866
|
+
languageOptions: { parser: tsparser, ecmaVersion: 2023, sourceType: "module" },
|
|
867
|
+
});
|
|
868
|
+
console.log("→", "no-static-inline-style");
|
|
869
|
+
tsx.run("no-static-inline-style", rules["no-static-inline-style"], {
|
|
870
|
+
valid: [
|
|
871
|
+
{ code: '<div className="w-full" />;', filename: "view.tsx" },
|
|
872
|
+
{ code: '<div style={{ width: size }} />;', filename: "view.tsx" },
|
|
873
|
+
{ code: '<div style={{ width: size, display: "flex" }} />;', filename: "view.tsx" },
|
|
874
|
+
{ code: '<div style={{ width: getSize() }} />;', filename: "view.tsx" },
|
|
875
|
+
{ code: '<div style={{ width: sizes.width }} />;', filename: "view.tsx" },
|
|
876
|
+
{ code: '<div style={{ width: `${size}px` }} />;', filename: "view.tsx" },
|
|
877
|
+
{ code: '<div style={{ ...styles, display: "flex" }} />;', filename: "view.tsx" },
|
|
878
|
+
{ code: '<div style={{ [property]: "flex" }} />;', filename: "view.tsx" },
|
|
879
|
+
{ code: '<div style={styles} />;', filename: "view.tsx" },
|
|
880
|
+
{ code: '<div style={enabled ? styles : undefined} />;', filename: "view.tsx" },
|
|
881
|
+
{ code: '<div style={{}} />;', filename: "view.tsx" },
|
|
882
|
+
{ code: '<div data-style={{ width: 12 }} />;', filename: "view.tsx" },
|
|
883
|
+
{ code: '<div style />;', filename: "view.tsx" },
|
|
884
|
+
],
|
|
885
|
+
invalid: [
|
|
886
|
+
{ code: '<div style={{ width: 12 }} />;', filename: "view.tsx", errors: [{ messageId: "static" }] },
|
|
887
|
+
{ code: '<div style={{ display: "flex", opacity: 1 }} />;', filename: "view.tsx", errors: [{ messageId: "static" }] },
|
|
888
|
+
{ code: '<Box style={{ marginTop: -2, zIndex: +1 }} />;', filename: "view.tsx", errors: [{ messageId: "static" }] },
|
|
889
|
+
{ code: '<div style={{ display: `flex` }} />;', filename: "view.tsx", errors: [{ messageId: "static" }] },
|
|
890
|
+
{ code: '<Box style={{ visible: false, color: null }} />;', filename: "view.tsx", errors: [{ messageId: "static" }] },
|
|
891
|
+
{ code: '<div style={{ ["display"]: "flex" }} />;', filename: "view.tsx", errors: [{ messageId: "static" }] },
|
|
892
|
+
{ code: '<div style={({ width: 12 } as const)} />;', filename: "view.tsx", errors: [{ messageId: "static" }] },
|
|
893
|
+
{ code: '<div style={{ width: 12 as number }} />;', filename: "view.tsx", errors: [{ messageId: "static" }] },
|
|
894
|
+
{ code: '<div style={{ width: 12 } satisfies CSSProperties} />;', filename: "view.tsx", errors: [{ messageId: "static" }] },
|
|
895
|
+
{ code: '<><div style={{ width: 12 }} /><div style={{ height: 8 }} /></>;', filename: "view.tsx", errors: [{ messageId: "static" }, { messageId: "static" }] },
|
|
896
|
+
],
|
|
897
|
+
});
|
|
898
|
+
|
|
899
|
+
const componentFile = "/repo/frontend/src/features/pins/view.tsx";
|
|
900
|
+
const componentPair = { messageId: "multiple", data: { first: "First", second: "Second" } };
|
|
901
|
+
|
|
902
|
+
console.log("→", "one-component-per-file");
|
|
903
|
+
tsx.run("one-component-per-file", rules["one-component-per-file"], {
|
|
904
|
+
valid: [
|
|
905
|
+
{ code: "function First() { return <div />; }", filename: componentFile },
|
|
906
|
+
{ code: "const First = () => <>one</>; const helper = () => <span />;", filename: componentFile },
|
|
907
|
+
{ code: "function First() { return <div />; } function Second() { return null; }", filename: componentFile },
|
|
908
|
+
{ code: "const First = memo(forwardRef(function Inner() { return <div />; }));", filename: componentFile },
|
|
909
|
+
{ code: "function First() { return <div />; } function Second() { return () => <span />; }", filename: componentFile },
|
|
910
|
+
{ code: "const First = () => <div />; const Second = () => ({ icon: <span /> });", filename: componentFile },
|
|
911
|
+
{ code: "const First = () => <div />; const Second = () => <span />;", filename: "/repo/view.jsx" },
|
|
912
|
+
],
|
|
913
|
+
invalid: [
|
|
914
|
+
{ code: "function First() { return <div />; } const Second = () => <span />;", filename: componentFile, errors: [componentPair, componentPair] },
|
|
915
|
+
{ code: "const First = () => <>one</>; const Second = () => <span />;", filename: componentFile, errors: [componentPair, componentPair] },
|
|
916
|
+
{ code: "const First = React.forwardRef(() => null); const Second = React.memo(Other);", filename: componentFile, errors: [componentPair, componentPair] },
|
|
917
|
+
{ code: "const First = memo(forwardRef(() => <div />)); const Second = () => <span />;", filename: componentFile, errors: [componentPair, componentPair] },
|
|
918
|
+
{ code: "const First = function Named() { return <div />; }; function Second() { if (ready) return <span />; return null; }", filename: componentFile, errors: [componentPair, componentPair] },
|
|
919
|
+
{ code: "const First = () => ready ? <div /> : null; const Second = () => (ready && <span />) as React.ReactNode;", filename: componentFile, errors: [componentPair, componentPair] },
|
|
920
|
+
{ code: "function First() { const Second = () => <span />; return <div />; }", filename: componentFile, errors: [componentPair, componentPair] },
|
|
921
|
+
{ code: "const First = () => <div />; const Second = () => <span />;", filename: "C:\\repo\\view.tsx", errors: [componentPair, componentPair] },
|
|
922
|
+
{
|
|
923
|
+
code: "const First = () => <div />; const Second = () => <span />; const Third = () => <p />;",
|
|
924
|
+
filename: componentFile,
|
|
925
|
+
errors: [componentPair, componentPair, { messageId: "multiple", data: { first: "First", second: "Third" } }],
|
|
926
|
+
},
|
|
927
|
+
],
|
|
928
|
+
});
|
|
929
|
+
|
|
930
|
+
console.log("→", "raw-element-in-primitive");
|
|
931
|
+
tsx.run("raw-element-in-primitive", rules["raw-element-in-primitive"], {
|
|
932
|
+
valid: [
|
|
933
|
+
{ code: "<><form /><dialog /><input /><select /><textarea /><button /></>;", filename: "/repo/frontend/src/platform/ui/primitives/form.tsx" },
|
|
934
|
+
{ code: "<button />;", filename: "C:\\repo\\frontend\\src\\platform\\ui\\primitives\\nested\\button.tsx" },
|
|
935
|
+
{ code: "<><Form /><Dialog /><Input /><Select /><Textarea /><Button /><div /><UI.button /></>;", filename: componentFile },
|
|
936
|
+
{ code: "<button />;", filename: "/repo/shared/primitives/button.tsx", options: [{ primitive: "shared/primitives" }] },
|
|
937
|
+
{ code: "<input />;", filename: "/repo/other/primitives/input.tsx", options: [{ primitive: ["shared/primitives", "other/primitives"] }] },
|
|
938
|
+
{ code: "<button />;", filename: componentFile, options: [{ elements: ["a"] }] },
|
|
939
|
+
{ code: "<button />;", filename: componentFile, options: [{ elements: [] }] },
|
|
940
|
+
],
|
|
941
|
+
invalid: [
|
|
942
|
+
...["form", "dialog", "input", "select", "textarea", "button"].map((element) => ({
|
|
943
|
+
code: `<${element} />;`, filename: componentFile, errors: [{ messageId: "raw", data: { element } }],
|
|
944
|
+
})),
|
|
945
|
+
{ code: "<button />;", filename: "C:\\repo\\frontend\\src\\features\\pins\\view.tsx", errors: [{ messageId: "raw" }] },
|
|
946
|
+
{ code: "<button />;", filename: "/repo/frontend/src/platform/ui/primitives-extra/button.tsx", errors: [{ messageId: "raw" }] },
|
|
947
|
+
{ code: "<form><input /></form>;", filename: componentFile, errors: [{ messageId: "raw" }, { messageId: "raw" }] },
|
|
948
|
+
{ code: "<a />;", filename: componentFile, options: [{ elements: ["a"] }], errors: [{ messageId: "raw", data: { element: "a" } }] },
|
|
949
|
+
{ code: "<button />;", filename: "/repo/frontend/src/platform/ui/primitives/button.tsx", options: [{ primitive: "shared/primitives" }], errors: [{ messageId: "raw" }] },
|
|
950
|
+
{ code: "<input />;", filename: componentFile, options: [{ primitive: [] }], errors: [{ messageId: "raw" }] },
|
|
951
|
+
],
|
|
952
|
+
});
|
|
953
|
+
|
|
831
954
|
const pending = { messageId: "pending" };
|
|
832
955
|
|
|
956
|
+
console.log("→", "no-arbitrary-class-value");
|
|
957
|
+
jsx.run("no-arbitrary-class-value", rules["no-arbitrary-class-value"], {
|
|
958
|
+
valid: [
|
|
959
|
+
{ code: '<div className="text-sm md:hover:bg-primary" />;' },
|
|
960
|
+
{ code: '<div title="text-[11px]" />; const label = "p-[3px]";' },
|
|
961
|
+
{ code: 'cn("p-2", { "text-sm": active });' },
|
|
962
|
+
{ code: 'cva("p-2", { variants: { size: { small: "text-sm" } }, defaultVariants: { size: "text-[11px]" } });' },
|
|
963
|
+
{ code: '<div className="data-[state=open]:text-sm [&>span]:p-2" />;' },
|
|
964
|
+
{ code: '<div className="supports-[display:grid]:grid hover:[&>span]:p-2" />;' },
|
|
965
|
+
{ code: 'other("text-[11px]");' },
|
|
966
|
+
{ code: 'cn("text-[11px]");', options: [{ classCallees: [] }] },
|
|
967
|
+
],
|
|
968
|
+
invalid: [
|
|
969
|
+
...['<div className="text-[11px]" />;', '<div class="md:hover:bg-[#123456]" />;',
|
|
970
|
+
'<div className={active ? "w-[3rem]" : "w-4"} />;',
|
|
971
|
+
'cn("p-2", { "md:hover:text-[11px]": active });',
|
|
972
|
+
'cva("p-2", { variants: { size: { small: "text-[11px]" } } });',
|
|
973
|
+
'cva("p-2", { compoundVariants: [{ size: "small", className: "p-[3px]" }] });',
|
|
974
|
+
'classes("text-[11px]");',
|
|
975
|
+
'cn("!text-[11px]");', 'cn("-mt-[2px]!");', 'cn("bg-primary/[.35]");',
|
|
976
|
+
'<div className="[color:var(--foreground)]" />;',
|
|
977
|
+
'const variants = { size: { small: "text-[11px]" } }; cva("p-2", { variants });',
|
|
978
|
+
].map((code) => ({ code, ...(code.startsWith("classes") ? { options: [{ classCallees: ["classes"] }] } : {}), errors: [{ messageId: "arbitrary" }] })),
|
|
979
|
+
{ code: '<div className={`p-2 ${active ? "text-[11px]" : "text-sm"}`} />;', errors: [{ messageId: "arbitrary" }] },
|
|
980
|
+
{ code: 'cn("p-[3px] text-[11px]");', errors: [{ messageId: "arbitrary" }, { messageId: "arbitrary" }] },
|
|
981
|
+
{ code: '<div className={"text-[11px]" as string} />;', languageOptions: { parser: tsparser }, errors: [{ messageId: "arbitrary" }] },
|
|
982
|
+
{ code: 'const variants = { size: { small: "text-[11px]" } }; cva("p-2", { variants });', filename: "/repo/view.jsx", errors: [{ messageId: "arbitrary" }] },
|
|
983
|
+
],
|
|
984
|
+
});
|
|
985
|
+
|
|
986
|
+
console.log("→", "no-literal-color");
|
|
987
|
+
jsx.run("no-literal-color", rules["no-literal-color"], {
|
|
988
|
+
valid: [
|
|
989
|
+
{ code: '<div className="text-primary" style={{ color: "var(--foreground)" }} />;' },
|
|
990
|
+
{ code: '<Icon fill="currentColor" />; <a href="#abc">Link</a>;' },
|
|
991
|
+
{ code: 'const message = "#123456"; const data = { id: "#abc" };' },
|
|
992
|
+
{ code: 'const styles = { borderColor: "#abc" };' },
|
|
993
|
+
{ code: 'cn("text-primary"); cva("bg-primary", { variants: { tone: { primary: "text-primary" } } });' },
|
|
994
|
+
{ code: 'cva("p-2", { variants: { tone: { "#abc": "text-primary" } }, defaultVariants: { tone: "#abc" } });' },
|
|
995
|
+
{ code: '<div style={{ color: theme.foreground, opacity: 0.5 }} />;' },
|
|
996
|
+
{ code: '<div style={{ color: "var(--rgb)" }} />;' },
|
|
997
|
+
{ code: 'const styles = { color: "rgb(var(--foreground))" }; <div style={styles} />;' },
|
|
998
|
+
{ code: '<div data-testid="#abc" id="#abc" />;' },
|
|
999
|
+
{ code: '<div title="#12345 #123456789" />;' },
|
|
1000
|
+
{ code: 'other("bg-[#abc]");' },
|
|
1001
|
+
{ code: 'cn("bg-[#abc]");', options: [{ classCallees: [] }] },
|
|
1002
|
+
],
|
|
1003
|
+
invalid: [
|
|
1004
|
+
...['<Icon fill="#abc" />;', '<Icon stroke={"#12345678"} />;',
|
|
1005
|
+
'<div color={active ? "rgb(1, 2, 3)" : color} />;',
|
|
1006
|
+
'<div style={{ color: "rgba(1, 2, 3, 0.5)" }} />;',
|
|
1007
|
+
'<div style={{ background: "linear-gradient(#abc, var(--background))" }} />;',
|
|
1008
|
+
'<div className="md:hover:bg-[#123456]" />;',
|
|
1009
|
+
'cn("text-[hsl(120,50%,50%)]");',
|
|
1010
|
+
'cva("p-2", { variants: { tone: { custom: "bg-[hsla(120,50%,50%,0.5)]" } } });',
|
|
1011
|
+
'const styles = { color: "#AbCd" }; <div style={styles} />;',
|
|
1012
|
+
'<div style={{ boxShadow: `0 0 ${size}px #abc` }} />;',
|
|
1013
|
+
'classes("bg-[#abc]");',
|
|
1014
|
+
'cn("shadow-[0_0_rgba(0,0,0,0.5)]");',
|
|
1015
|
+
'<div color={"#abc" || fallback} />;',
|
|
1016
|
+
'const variants = { tone: { custom: "bg-[#abc]" } }; cva("p-2", { variants });',
|
|
1017
|
+
].map((code) => ({ code, ...(code.startsWith("classes") ? { options: [{ classCallees: ["classes"] }] } : {}), errors: [{ messageId: "color" }] })),
|
|
1018
|
+
{ code: 'const variants = { tone: { custom: "bg-[#abc]" } }; cva("p-2", { variants });', filename: "/repo/view.jsx", errors: [{ messageId: "color" }] },
|
|
1019
|
+
],
|
|
1020
|
+
});
|
|
1021
|
+
|
|
833
1022
|
console.log("→", "mutation-control-pending");
|
|
834
1023
|
jsx.run("mutation-control-pending", rules["mutation-control-pending"], {
|
|
835
1024
|
valid: [
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import { Linter } from "eslint";
|
|
4
|
+
import parser from "@typescript-eslint/parser";
|
|
5
|
+
import { rules } from "./index.mjs";
|
|
6
|
+
|
|
7
|
+
function lint(rule, code, filename = "view.tsx") {
|
|
8
|
+
return new Linter().verify(code, [{
|
|
9
|
+
files: ["**/*.tsx", "**/*.ts"],
|
|
10
|
+
languageOptions: { parser },
|
|
11
|
+
plugins: { qc: { rules } },
|
|
12
|
+
rules: { [`qc/${rule}`]: "error" },
|
|
13
|
+
}], filename);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
test("literal colors in text attributes pass", () => {
|
|
17
|
+
const code = '<Input label="PR #186" title="Ticket #123" alt="Order #abc" value="#ffffff" />;';
|
|
18
|
+
assert.deepEqual(lint("no-literal-color", code), []);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test("theme tokens pass while literal colors in a style binding fail", () => {
|
|
22
|
+
assert.deepEqual(lint("no-literal-color", 'export const tokens = { background: "#ffffff", borderColor: "#abc" };', "theme.ts"), []);
|
|
23
|
+
const messages = lint("no-literal-color", 'const styles = { borderColor: "#abc" }; <div style={styles} />;');
|
|
24
|
+
assert.equal(messages.length, 1);
|
|
25
|
+
assert.equal(messages[0].messageId, "color");
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test("local memo and forwardRef wrappers keep one component", () => {
|
|
29
|
+
for (const wrapper of ["memo", "React.memo", "forwardRef", "React.forwardRef"]) {
|
|
30
|
+
const code = `function ItemBase() { return <li />; } export const Item = ${wrapper}(ItemBase);`;
|
|
31
|
+
assert.deepEqual(lint("one-component-per-file", code), [], wrapper);
|
|
32
|
+
}
|
|
33
|
+
assert.deepEqual(lint("one-component-per-file", 'const Item = memo(forwardRef(ItemBase)); function ItemBase() { return <li />; }'), []);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test("each component gets a report on its own declaration line", () => {
|
|
37
|
+
const messages = lint("one-component-per-file", "const Added = () => <i />;\nfunction Existing() { return <li />; }\n");
|
|
38
|
+
assert.deepEqual(messages.map(({ line, messageId }) => [line, messageId]), [[1, "multiple"], [2, "multiple"]]);
|
|
39
|
+
});
|
|
@@ -15,7 +15,7 @@ function peerMissing(error) {
|
|
|
15
15
|
return wrapped;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
const loadYaml = () => import("yaml");
|
|
18
|
+
const loadYaml = async (root) => (await import("../consumer-package.mjs")).importConsumerPackage("yaml", root);
|
|
19
19
|
|
|
20
20
|
async function parser(load) {
|
|
21
21
|
try {
|
|
@@ -91,12 +91,12 @@ function paramNames(document, ...lists) {
|
|
|
91
91
|
|
|
92
92
|
/**
|
|
93
93
|
* @param {string} text the API description, YAML or JSON
|
|
94
|
-
* @param {{load?: () => Promise<{parse: (text: string) => unknown}>}} [options] how the parser
|
|
94
|
+
* @param {{root?: string, load?: () => Promise<{parse: (text: string) => unknown}>}} [options] where and how the parser loads
|
|
95
95
|
* @returns {Promise<{method: string, path: string, id: string, params: string[], bodyProps: string[]}[]>}
|
|
96
96
|
* a path item that is a local `$ref` yields its target's operations, and a method key matches in any case;
|
|
97
97
|
* method is lower-case; id is the operationId, or `METHOD /path` when the operation has none
|
|
98
98
|
*/
|
|
99
|
-
export async function contractOperations(text, { load = loadYaml } = {}) {
|
|
99
|
+
export async function contractOperations(text, { root = process.cwd(), load = () => loadYaml(root) } = {}) {
|
|
100
100
|
const { parse } = await parser(load);
|
|
101
101
|
const document = parse(text) ?? {};
|
|
102
102
|
const operations = [];
|
|
@@ -1,6 +1,34 @@
|
|
|
1
1
|
import test from "node:test";
|
|
2
2
|
import assert from "node:assert/strict";
|
|
3
3
|
import { contractOperations } from "./contract-operations.mjs";
|
|
4
|
+
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
5
|
+
import { tmpdir } from "node:os";
|
|
6
|
+
import { join } from "node:path";
|
|
7
|
+
import { defaults } from "../config.mjs";
|
|
8
|
+
import { runCheck } from "../cli/check.mjs";
|
|
9
|
+
|
|
10
|
+
test("contract readers load yaml from the config root outside the current directory", async () => {
|
|
11
|
+
const root = mkdtempSync(join(tmpdir(), "qc-contract-root-"));
|
|
12
|
+
try {
|
|
13
|
+
const directory = join(root, "node_modules/yaml");
|
|
14
|
+
mkdirSync(directory, { recursive: true });
|
|
15
|
+
writeFileSync(join(directory, "package.json"), JSON.stringify({ type: "module", main: "index.mjs" }));
|
|
16
|
+
writeFileSync(join(directory, "index.mjs"), `export function parse(text) {
|
|
17
|
+
if (text === "consumer sentinel") throw new Error("consumer yaml selected");
|
|
18
|
+
return { paths: { "/consumer": { get: { operationId: "consumerParser" } } } };
|
|
19
|
+
}`);
|
|
20
|
+
const found = await contractOperations("paths: {}", { root });
|
|
21
|
+
assert.equal(found[0]?.id, "consumerParser");
|
|
22
|
+
writeFileSync(join(root, "api.yaml"), "consumer sentinel");
|
|
23
|
+
for (const gate of ["contract-idempotency", "contract-routes"]) {
|
|
24
|
+
const config = { ...defaults, root, featureRoots: [], contract: "api.yaml", gates: Object.fromEntries(Object.keys(defaults.gates).map((name) => [name, name === gate])) };
|
|
25
|
+
const result = await runCheck(config, [], { lister: async () => ["api.yaml"] });
|
|
26
|
+
assert.ok(result.problems.some((problem) => problem.rule === "unreadable-contract" && problem.detail === "consumer yaml selected"), JSON.stringify(result));
|
|
27
|
+
}
|
|
28
|
+
} finally {
|
|
29
|
+
rmSync(root, { recursive: true, force: true });
|
|
30
|
+
}
|
|
31
|
+
});
|
|
4
32
|
|
|
5
33
|
const contract = `
|
|
6
34
|
openapi: 3.0.3
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Branch: validate switch declarations so unwired controls keep their importers in JSX. */
|
|
2
|
+
export function checkFeatureSwitches(files, options, featureRoot) {
|
|
3
|
+
const patterns = options.patterns.map((pattern) => new RegExp(pattern));
|
|
4
|
+
const switchPath = featureRoot === undefined ? null : `${featureRoot.replace(/\\/g, "/").replace(/\/+$/, "")}/${options.file}`;
|
|
5
|
+
const problems = [];
|
|
6
|
+
for (const file of files) {
|
|
7
|
+
if (file.path.replace(/\\/g, "/") === switchPath) continue;
|
|
8
|
+
const declarations = /^[ \t]*(?:export[ \t]+)?(?:const|let|var)[ \t]+([A-Za-z_$][\w$]*)/gm;
|
|
9
|
+
for (const [, name] of file.contents.matchAll(declarations)) {
|
|
10
|
+
if (!patterns.some((pattern) => pattern.test(name))) continue;
|
|
11
|
+
problems.push({
|
|
12
|
+
path: file.path,
|
|
13
|
+
rule: "unwire-constant-outside-switch-file",
|
|
14
|
+
detail: `${name} belongs in ${options.file}, beside the feature's other switches`,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return problems;
|
|
19
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import test from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { checkFeatureSwitches } from "./feature-switches.mjs";
|
|
4
|
+
|
|
5
|
+
const options = { file: "feature-switches.ts", patterns: ["UNWIRED", "^SHOW_", "_WIRED$"] };
|
|
6
|
+
|
|
7
|
+
for (const [name, contents] of [
|
|
8
|
+
["SHOW_DELETE", "const SHOW_DELETE = false;"],
|
|
9
|
+
["PIN_UNWIRED", "export const PIN_UNWIRED = true;"],
|
|
10
|
+
["EXPORT_WIRED", "let EXPORT_WIRED = 1;"],
|
|
11
|
+
["SHOW_ARCHIVE", "\texport\tvar\tSHOW_ARCHIVE = false;"],
|
|
12
|
+
]) {
|
|
13
|
+
test(`${name} belongs in the switch file`, () => {
|
|
14
|
+
const problems = checkFeatureSwitches([{ path: "src/features/pins/view.tsx", contents }], options, "src/features/pins");
|
|
15
|
+
assert.equal(problems.length, 1);
|
|
16
|
+
assert.equal(problems[0].path, "src/features/pins/view.tsx");
|
|
17
|
+
assert.equal(problems[0].rule, "unwire-constant-outside-switch-file");
|
|
18
|
+
assert.ok(problems[0].detail.includes(name));
|
|
19
|
+
assert.ok(problems[0].detail.includes(options.file));
|
|
20
|
+
assert.deepEqual(checkFeatureSwitches([{ path: "src/features/pins/feature-switches.ts", contents }], options, "src/features/pins"), []);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
test("comments, string values, and names outside the patterns pass", () => {
|
|
25
|
+
const contents = [
|
|
26
|
+
"// const SHOW_X = 1;",
|
|
27
|
+
'const label = "SHOW_X";',
|
|
28
|
+
"const showDelete = false;",
|
|
29
|
+
"const SHOWN_ITEMS = [];",
|
|
30
|
+
].join("\n");
|
|
31
|
+
assert.deepEqual(checkFeatureSwitches([{ path: "src/features/pins/view.tsx", contents }], options, "src/features/pins"), []);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test("every matching declaration gives one problem", () => {
|
|
35
|
+
const contents = "const SHOW_DELETE = false;\nexport const PIN_UNWIRED = true;\nlet EXPORT_WIRED = 1;";
|
|
36
|
+
assert.equal(checkFeatureSwitches([{ path: "pins/view.tsx", contents }], options, "src/features/pins").length, 3);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test("the configured filename and patterns apply", () => {
|
|
40
|
+
const custom = { file: "switches.ts", patterns: ["^DISABLED_"] };
|
|
41
|
+
assert.equal(checkFeatureSwitches([{ path: "pins/feature-switches.ts", contents: "const DISABLED_DELETE = true;" }], custom, "pins").length, 1);
|
|
42
|
+
assert.deepEqual(checkFeatureSwitches([{ path: "pins/switches.ts", contents: "const DISABLED_DELETE = true;" }], custom, "pins"), []);
|
|
43
|
+
assert.deepEqual(checkFeatureSwitches([{ path: "pins/view.tsx", contents: "const SHOW_DELETE = false;" }], custom, "pins"), []);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
test("the switch exemption needs the exact feature root on Windows too", () => {
|
|
48
|
+
const files = [
|
|
49
|
+
{ path: "src/features/pins/feature-switches.ts", contents: "const SHOW_ROOT = false;" },
|
|
50
|
+
{ path: "src/features/pins/nested/feature-switches.ts", contents: "const SHOW_NESTED = false;" },
|
|
51
|
+
];
|
|
52
|
+
assert.deepEqual(checkFeatureSwitches(files, options, "src/features/pins").map(({ path }) => path), [files[1].path]);
|
|
53
|
+
const windows = files.map((file) => ({ ...file, path: file.path.replaceAll("/", "\\") }));
|
|
54
|
+
assert.deepEqual(checkFeatureSwitches(windows, options, "src\\features\\pins").map(({ path }) => path), [windows[1].path]);
|
|
55
|
+
});
|