@webpieces/rules-config 0.4.843 → 0.4.845

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/package.json +9 -4
  2. package/src/WebpiecesRulesConfig.d.ts +3 -49
  3. package/src/WebpiecesRulesConfig.js +1 -44
  4. package/src/WebpiecesRulesConfig.js.map +1 -1
  5. package/src/abstract-rule.d.ts +1 -1
  6. package/src/abstract-rule.js.map +1 -1
  7. package/src/config-pruner.d.ts +3 -1
  8. package/src/config-pruner.js +13 -9
  9. package/src/config-pruner.js.map +1 -1
  10. package/src/constants.d.ts +0 -37
  11. package/src/constants.js +1 -38
  12. package/src/constants.js.map +1 -1
  13. package/src/index.d.ts +7 -24
  14. package/src/index.js +14 -105
  15. package/src/index.js.map +1 -1
  16. package/src/load-config.d.ts +6 -2
  17. package/src/load-config.js +17 -11
  18. package/src/load-config.js.map +1 -1
  19. package/src/match-rules-config.d.ts +2 -1
  20. package/src/match-rules-config.js +2 -2
  21. package/src/match-rules-config.js.map +1 -1
  22. package/src/no-custom-css-scope.d.ts +9 -25
  23. package/src/no-custom-css-scope.js +10 -24
  24. package/src/no-custom-css-scope.js.map +1 -1
  25. package/src/retired-config-keys.d.ts +3 -64
  26. package/src/retired-config-keys.js +14 -152
  27. package/src/retired-config-keys.js.map +1 -1
  28. package/src/rule-pack-registry.d.ts +41 -0
  29. package/src/rule-pack-registry.js +231 -0
  30. package/src/rule-pack-registry.js.map +1 -0
  31. package/src/rule-pack-selection.d.ts +6 -0
  32. package/src/rule-pack-selection.js +50 -0
  33. package/src/rule-pack-selection.js.map +1 -0
  34. package/src/rule-schemas.d.ts +4 -14
  35. package/src/rule-schemas.js +6 -92
  36. package/src/rule-schemas.js.map +1 -1
  37. package/src/sections.d.ts +5 -46
  38. package/src/sections.js +5 -56
  39. package/src/sections.js.map +1 -1
  40. package/src/seed-entry.d.ts +5 -16
  41. package/src/seed-entry.js +14 -141
  42. package/src/seed-entry.js.map +1 -1
  43. package/src/validate-config.d.ts +3 -2
  44. package/src/validate-config.js +62 -73
  45. package/src/validate-config.js.map +1 -1
  46. package/templates/webpieces.branch-state-matrix.md +1 -1
  47. package/src/api-doc-rules-config.d.ts +0 -60
  48. package/src/api-doc-rules-config.js +0 -71
  49. package/src/api-doc-rules-config.js.map +0 -1
  50. package/src/api-lib-spelling-configs.d.ts +0 -40
  51. package/src/api-lib-spelling-configs.js +0 -52
  52. package/src/api-lib-spelling-configs.js.map +0 -1
  53. package/src/default-rules.d.ts +0 -2
  54. package/src/default-rules.js +0 -119
  55. package/src/default-rules.js.map +0 -1
  56. package/src/field-def.d.ts +0 -24
  57. package/src/field-def.js +0 -59
  58. package/src/field-def.js.map +0 -1
  59. package/src/main-sync-guard-configs.d.ts +0 -38
  60. package/src/main-sync-guard-configs.js +0 -54
  61. package/src/main-sync-guard-configs.js.map +0 -1
  62. package/src/no-client-creation-config.d.ts +0 -12
  63. package/src/no-client-creation-config.js +0 -40
  64. package/src/no-client-creation-config.js.map +0 -1
  65. package/src/no-root-union-config.d.ts +0 -25
  66. package/src/no-root-union-config.js +0 -33
  67. package/src/no-root-union-config.js.map +0 -1
  68. package/src/no-state-paths-config.d.ts +0 -41
  69. package/src/no-state-paths-config.js +0 -51
  70. package/src/no-state-paths-config.js.map +0 -1
  71. package/src/no-utility-types-config.d.ts +0 -30
  72. package/src/no-utility-types-config.js +0 -39
  73. package/src/no-utility-types-config.js.map +0 -1
  74. package/src/required-type-suffix-config.d.ts +0 -49
  75. package/src/required-type-suffix-config.js +0 -62
  76. package/src/required-type-suffix-config.js.map +0 -1
  77. package/src/rule-configs.d.ts +0 -273
  78. package/src/rule-configs.js +0 -595
  79. package/src/rule-configs.js.map +0 -1
  80. package/src/spec-temp-dirs.d.ts +0 -37
  81. package/src/spec-temp-dirs.js +0 -113
  82. package/src/spec-temp-dirs.js.map +0 -1
  83. package/src/tag-truth-configs.d.ts +0 -137
  84. package/src/tag-truth-configs.js +0 -175
  85. package/src/tag-truth-configs.js.map +0 -1
@@ -1,595 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ValidateEslintSyncConfig = exports.ValidateVersionsLockedConfig = exports.ValidatePackageJsonConfig = exports.ValidateNoArchitectureCyclesConfig = exports.ValidateArchitectureUnchangedConfig = exports.NoJsFilesConfig = exports.MissingDesignAnnotationConfig = exports.DiGraphConfig = exports.NxWiringConfig = exports.RuntimeArchitectureConfig = exports.NoFileImportCyclesConfig = exports.PrLifecycleGuardConfig = exports.BranchCreationGuardConfig = exports.EnsureWeAreSecureConfig = exports.RoleTagConfig = exports.FrameworkTagConfig = exports.InjectAnnotationNotNeededForConcreteClassConfig = exports.NoFunctionOutsideClassConfig = exports.NoProcessExitOutsideMainConfig = exports.NoSymbolDiTokensConfig = exports.NoCustomCssConfig = exports.AngularNoDirectApiInResolverConfig = exports.ThrowCauseRequiredConfig = exports.CatchErrorPatternConfig = exports.NoUnmanagedExceptionsConfig = exports.NoDestructureConfig = exports.PrismaConverterConfig = exports.PrismaValidateDtosConfig = exports.NoImplicitAnyConfig = exports.NoAnyUnknownConfig = exports.NoInlineTypeLiteralsConfig = exports.RequireReturnTypeConfig = exports.MaxFileLinesConfig = exports.MaxMethodLinesConfig = exports.BASE_RULE_SCHEMA = exports.BaseRuleConfig = exports.STRUCTURAL_MODES = exports.VALIDATE_TS_MODES = exports.BRANCH_GUARD_MODES = exports.ON_OFF_MODES = exports.THROW_CAUSE_MODES = exports.DIRECT_API_RESOLVER_MODES = exports.PRISMA_CONVERTER_MODES = exports.PRISMA_DTOS_MODES = exports.PROJECT_MODES = exports.MODIFIED_CODE_MODES = exports.INLINE_TYPE_MODES = exports.RETURN_TYPE_MODES = exports.FILE_LIMIT_MODES = exports.METHOD_LIMIT_MODES = void 0;
4
- exports.ValidateTsInSrcConfig = void 0;
5
- const field_def_1 = require("./field-def");
6
- // Mode const arrays — TypeScript union types derived from them, and FieldDef enum
7
- // values reference the same array. Impossible for the type and runtime check to diverge.
8
- // Single source of truth for rule "mode" values. Exported so code-rules (and any other
9
- // consumer) imports these instead of re-declaring the same unions — a rename here ripples
10
- // everywhere at compile time. The FieldDef SCHEMA below references the same arrays, so the
11
- // type and the runtime validation can never diverge.
12
- exports.METHOD_LIMIT_MODES = ['OFF', 'NEW_METHODS', 'NEW_AND_MODIFIED_METHODS', 'NEW_AND_MODIFIED_FILES'];
13
- exports.FILE_LIMIT_MODES = ['OFF', 'NEW_AND_MODIFIED_FILES'];
14
- exports.RETURN_TYPE_MODES = ['OFF', 'NEW_METHODS', 'NEW_AND_MODIFIED_METHODS', 'NEW_AND_MODIFIED_FILES'];
15
- exports.INLINE_TYPE_MODES = ['OFF', 'NEW_METHODS', 'NEW_AND_MODIFIED_METHODS', 'NEW_AND_MODIFIED_FILES'];
16
- // The two WHOLE-SCOPE modes (#1027) reuse the existing vocabulary rather than inventing names:
17
- // MODIFIED_PROJECTS — every in-scope file of every project the diff touches (plus the changed files
18
- // themselves, so it is never narrower than NEW_AND_MODIFIED_FILES).
19
- // RUN_EVERY_TIME — every in-scope file in the repo, every run.
20
- // Both judge WHOLE files, exactly like NEW_AND_MODIFIED_FILES — only the file SET differs. They exist so
21
- // a rule adopted at NEW_AND_MODIFIED_CODE can be measured ("what is left?") or finished off without a
22
- // hack, and they are what `wp-validate-code --rule=<name> --mode=<mode> --projects=a,b` accepts.
23
- // Edit-time (ai-hooks) treats every non-OFF mode alike: it judges the content being written.
24
- exports.MODIFIED_CODE_MODES = ['OFF', 'NEW_AND_MODIFIED_CODE', 'NEW_AND_MODIFIED_FILES', 'MODIFIED_PROJECTS', 'RUN_EVERY_TIME'];
25
- // PROJECT-level rules (e.g. framework-tag): the check is neither line- nor file-scoped — it runs
26
- // for a whole project when ANY file the project owns is touched. `MODIFIED_PROJECTS` names that
27
- // honestly (nx `affected` already narrows execution to the changed projects).
28
- exports.PROJECT_MODES = ['OFF', 'MODIFIED_PROJECTS'];
29
- exports.PRISMA_DTOS_MODES = ['OFF', 'MODIFIED_CLASS', 'NEW_AND_MODIFIED_FILES'];
30
- exports.PRISMA_CONVERTER_MODES = ['OFF', 'NEW_AND_MODIFIED_METHODS', 'NEW_AND_MODIFIED_FILES'];
31
- exports.DIRECT_API_RESOLVER_MODES = ['OFF', 'NEW_AND_MODIFIED_CODE', 'NEW_AND_MODIFIED_METHODS', 'NEW_AND_MODIFIED_FILES'];
32
- exports.THROW_CAUSE_MODES = ['OFF', 'NEW_AND_MODIFIED_CODE'];
33
- exports.ON_OFF_MODES = ['ON', 'OFF'];
34
- // branch-creation-guard modes. ON_NO_SUBBRANCHES is the strict variant: it hard-blocks
35
- // creating a branch off any non-main branch (no sub-branch affordance), pointing the agent
36
- // back to `git checkout main && git pull && git checkout -b <branch>`. Temporarily overridable
37
- // via the universal turnOffRuleUntilEpoch escape hatch.
38
- exports.BRANCH_GUARD_MODES = ['ON', 'OFF', 'ON_NO_SUBBRANCHES'];
39
- exports.VALIDATE_TS_MODES = ['OFF', 'NEW_AND_MODIFIED_FILES'];
40
- // Structural / whole-graph rules (import-cycle, runtime-architecture, nx-wiring). They can't be
41
- // scoped to changed lines/files — a cycle or wiring break can route through a project that wasn't
42
- // itself edited — so when active they run the FULL check every time (nx-affected already limits
43
- // them to affected projects externally). RUN_EVERY_TIME replaces the old, vaguer "ON".
44
- exports.STRUCTURAL_MODES = ['OFF', 'RUN_EVERY_TIME'];
45
- // ---------------------------------------------------------------------------
46
- // Universal escape hatches — EVERY rule supports temporarily disabling itself
47
- // either while on a named git branch (turnOffRuleWhileOnBranch) or until an
48
- // epoch passes (turnOffRuleUntilEpoch). They live on a shared base class so the
49
- // fields (and their schema entries) are declared once instead of repeated per
50
- // rule. `mode` stays per-rule because its allowed values vary (ON/OFF vs
51
- // NEW_AND_MODIFIED_CODE vs NEW_AND_MODIFIED_METHODS, etc).
52
- //
53
- // BOTH fields are REQUIRED on every rule so both hatches are ALWAYS VISIBLE in the config — an AI
54
- // editing webpieces.config.json sees them on every rule and cannot miss that a rule can be time-boxed
55
- // or branch-scoped off. Convention:
56
- // turnOffRuleUntilEpoch: 0 = rule active (epoch in the past); a future unix epoch IN SECONDS =
57
- // temporarily disabled until that moment.
58
- // turnOffRuleWhileOnBranch: null = always on; a branch name = disabled while that branch is checked out.
59
- // The name is matched EXACTLY (===). Globs/wildcards are NOT supported and
60
- // must not be added: a pattern would switch a rule off on branches nobody
61
- // enumerated. It is also ignored (loudly — shouldSkipRule throws) on a pull
62
- // request from a FORK, where the branch name is the contributor's to choose.
63
- // Required-but-nullable so its "unset" state is present-and-visible (null)
64
- // rather than omitted.
65
- // The earlier spellings of these two fields were RENAMED to the names above and are no longer accepted —
66
- // the validator rejects them with a "renamed to X" hint. RENAMED_FIELD_ALIASES in validate-config.ts is
67
- // the ONE place in src/ a dead spelling may still be written (see escape-hatch-key-spelling.spec.ts).
68
- // ---------------------------------------------------------------------------
69
- class BaseRuleConfig {
70
- // `mode` is declared here (loosely typed) so the shared AbstractRule base can read it for
71
- // on/off. Each concrete *Config narrows it to its own union (e.g. `mode?: ModifiedCodeMode`),
72
- // which is an assignable (covariant) override.
73
- mode;
74
- // TS-optional, but schema-REQUIRED (see BASE_RULE_SCHEMA) — same split as `mode`. Read directly by
75
- // AbstractRule.shouldRun, RuleGate, and the code-rules validators.
76
- turnOffRuleUntilEpoch;
77
- turnOffRuleWhileOnBranch;
78
- }
79
- exports.BaseRuleConfig = BaseRuleConfig;
80
- exports.BASE_RULE_SCHEMA = {
81
- turnOffRuleUntilEpoch: new field_def_1.FieldDef('number'),
82
- turnOffRuleWhileOnBranch: field_def_1.FieldDef.nullableString(),
83
- };
84
- class MaxMethodLinesConfig extends BaseRuleConfig {
85
- limit;
86
- disableAllowed;
87
- static SCHEMA = {
88
- mode: new field_def_1.FieldDef('string', exports.METHOD_LIMIT_MODES),
89
- limit: field_def_1.FieldDef.optional('number'),
90
- disableAllowed: field_def_1.FieldDef.optional('boolean'),
91
- ...exports.BASE_RULE_SCHEMA,
92
- };
93
- }
94
- exports.MaxMethodLinesConfig = MaxMethodLinesConfig;
95
- // max-file-lines — caps a file's line count.
96
- //
97
- // `allowedPaths` exempts whole file trees, matched with the shared `isPathExcluded` glob/prefix/segment
98
- // semantics (the same field, same matcher and same meaning as no-function-outside-class / no-js-files /
99
- // no-destructure). It is for files the repo did NOT author and cannot shrink — never a standing amnesty
100
- // for hand-written code, which is what the inline disable and a refactor are for.
101
- //
102
- // The machine-generated trees in GENERATED_CODE_PATHS are exempt WITHOUT configuration, and
103
- // `allowedPaths` ADDS to that floor rather than replacing it — see generated-code-paths.ts for why a
104
- // 42,000-line graphql-codegen output must not be able to cost a repo the whole rule.
105
- class MaxFileLinesConfig extends BaseRuleConfig {
106
- limit;
107
- disableAllowed;
108
- allowedPaths;
109
- static SCHEMA = {
110
- mode: new field_def_1.FieldDef('string', exports.FILE_LIMIT_MODES),
111
- limit: field_def_1.FieldDef.optional('number'),
112
- disableAllowed: field_def_1.FieldDef.optional('boolean'),
113
- allowedPaths: field_def_1.FieldDef.optional('string[]'),
114
- ...exports.BASE_RULE_SCHEMA,
115
- };
116
- }
117
- exports.MaxFileLinesConfig = MaxFileLinesConfig;
118
- class RequireReturnTypeConfig extends BaseRuleConfig {
119
- disableAllowed;
120
- static SCHEMA = {
121
- mode: new field_def_1.FieldDef('string', exports.RETURN_TYPE_MODES),
122
- disableAllowed: field_def_1.FieldDef.optional('boolean'),
123
- ...exports.BASE_RULE_SCHEMA,
124
- };
125
- }
126
- exports.RequireReturnTypeConfig = RequireReturnTypeConfig;
127
- class NoInlineTypeLiteralsConfig extends BaseRuleConfig {
128
- disableAllowed;
129
- static SCHEMA = {
130
- mode: new field_def_1.FieldDef('string', exports.INLINE_TYPE_MODES),
131
- disableAllowed: field_def_1.FieldDef.optional('boolean'),
132
- ...exports.BASE_RULE_SCHEMA,
133
- };
134
- }
135
- exports.NoInlineTypeLiteralsConfig = NoInlineTypeLiteralsConfig;
136
- class NoAnyUnknownConfig extends BaseRuleConfig {
137
- disableAllowed;
138
- static SCHEMA = {
139
- mode: new field_def_1.FieldDef('string', exports.MODIFIED_CODE_MODES),
140
- disableAllowed: field_def_1.FieldDef.optional('boolean'),
141
- ...exports.BASE_RULE_SCHEMA,
142
- };
143
- }
144
- exports.NoAnyUnknownConfig = NoAnyUnknownConfig;
145
- class NoImplicitAnyConfig extends BaseRuleConfig {
146
- disableAllowed;
147
- static SCHEMA = {
148
- mode: new field_def_1.FieldDef('string', exports.MODIFIED_CODE_MODES),
149
- disableAllowed: field_def_1.FieldDef.optional('boolean'),
150
- ...exports.BASE_RULE_SCHEMA,
151
- };
152
- }
153
- exports.NoImplicitAnyConfig = NoImplicitAnyConfig;
154
- class PrismaValidateDtosConfig extends BaseRuleConfig {
155
- disableAllowed;
156
- prismaSchemaPath;
157
- dtoSourcePaths;
158
- static SCHEMA = {
159
- mode: new field_def_1.FieldDef('string', exports.PRISMA_DTOS_MODES),
160
- disableAllowed: field_def_1.FieldDef.optional('boolean'),
161
- prismaSchemaPath: field_def_1.FieldDef.optional('string'),
162
- dtoSourcePaths: field_def_1.FieldDef.optional('string[]'),
163
- ...exports.BASE_RULE_SCHEMA,
164
- };
165
- }
166
- exports.PrismaValidateDtosConfig = PrismaValidateDtosConfig;
167
- class PrismaConverterConfig extends BaseRuleConfig {
168
- disableAllowed;
169
- schemaPath;
170
- convertersPaths;
171
- enforcePaths;
172
- static SCHEMA = {
173
- mode: new field_def_1.FieldDef('string', exports.PRISMA_CONVERTER_MODES),
174
- disableAllowed: field_def_1.FieldDef.optional('boolean'),
175
- schemaPath: field_def_1.FieldDef.optional('string'),
176
- convertersPaths: field_def_1.FieldDef.optional('string[]'),
177
- enforcePaths: field_def_1.FieldDef.optional('string[]'),
178
- ...exports.BASE_RULE_SCHEMA,
179
- };
180
- }
181
- exports.PrismaConverterConfig = PrismaConverterConfig;
182
- // `allowedPaths` exempts whole file trees whose idioms are destructuring by construction (React /
183
- // React Native components and hooks — `const [x, setX] = useState()`, destructured props — framework
184
- // glue), matched with the shared glob/prefix/segment semantics of `isPathExcluded`. It is the ONLY
185
- // escape when `disableAllowed: false`, since that setting deliberately ignores inline disables.
186
- class NoDestructureConfig extends BaseRuleConfig {
187
- allowTopLevel;
188
- disableAllowed;
189
- allowedPaths;
190
- static SCHEMA = {
191
- mode: new field_def_1.FieldDef('string', exports.MODIFIED_CODE_MODES),
192
- allowTopLevel: field_def_1.FieldDef.optional('boolean'),
193
- disableAllowed: field_def_1.FieldDef.optional('boolean'),
194
- allowedPaths: field_def_1.FieldDef.optional('string[]'),
195
- ...exports.BASE_RULE_SCHEMA,
196
- };
197
- }
198
- exports.NoDestructureConfig = NoDestructureConfig;
199
- class NoUnmanagedExceptionsConfig extends BaseRuleConfig {
200
- disableAllowed;
201
- static SCHEMA = {
202
- mode: new field_def_1.FieldDef('string', exports.MODIFIED_CODE_MODES),
203
- disableAllowed: field_def_1.FieldDef.optional('boolean'),
204
- ...exports.BASE_RULE_SCHEMA,
205
- };
206
- }
207
- exports.NoUnmanagedExceptionsConfig = NoUnmanagedExceptionsConfig;
208
- class CatchErrorPatternConfig extends BaseRuleConfig {
209
- disableAllowed;
210
- static SCHEMA = {
211
- mode: new field_def_1.FieldDef('string', exports.MODIFIED_CODE_MODES),
212
- disableAllowed: field_def_1.FieldDef.optional('boolean'),
213
- ...exports.BASE_RULE_SCHEMA,
214
- };
215
- }
216
- exports.CatchErrorPatternConfig = CatchErrorPatternConfig;
217
- class ThrowCauseRequiredConfig extends BaseRuleConfig {
218
- disableAllowed;
219
- static SCHEMA = {
220
- mode: new field_def_1.FieldDef('string', exports.THROW_CAUSE_MODES),
221
- disableAllowed: field_def_1.FieldDef.optional('boolean'),
222
- ...exports.BASE_RULE_SCHEMA,
223
- };
224
- }
225
- exports.ThrowCauseRequiredConfig = ThrowCauseRequiredConfig;
226
- class AngularNoDirectApiInResolverConfig extends BaseRuleConfig {
227
- disableAllowed;
228
- enforcePaths;
229
- static SCHEMA = {
230
- mode: new field_def_1.FieldDef('string', exports.DIRECT_API_RESOLVER_MODES),
231
- disableAllowed: field_def_1.FieldDef.optional('boolean'),
232
- enforcePaths: field_def_1.FieldDef.optional('string[]'),
233
- ...exports.BASE_RULE_SCHEMA,
234
- };
235
- }
236
- exports.AngularNoDirectApiInResolverConfig = AngularNoDirectApiInResolverConfig;
237
- // Bans hand-written CSS in Angular sources (styles:/styleUrls:/styleUrl: in @Component, and inline
238
- // style=/[style.x]/[ngStyle] in templates) so teams style with Tailwind utility classes. `allowGlobs`
239
- // exempts paths WITHIN the Angular scope (e.g. a vendored Fuse kit copied verbatim with its own CSS).
240
- class NoCustomCssConfig extends BaseRuleConfig {
241
- disableAllowed;
242
- allowGlobs;
243
- static SCHEMA = {
244
- mode: new field_def_1.FieldDef('string', exports.MODIFIED_CODE_MODES),
245
- disableAllowed: field_def_1.FieldDef.optional('boolean'),
246
- allowGlobs: field_def_1.FieldDef.optional('string[]'),
247
- ...exports.BASE_RULE_SCHEMA,
248
- };
249
- }
250
- exports.NoCustomCssConfig = NoCustomCssConfig;
251
- class NoSymbolDiTokensConfig extends BaseRuleConfig {
252
- disableAllowed;
253
- allowedPaths;
254
- static SCHEMA = {
255
- mode: new field_def_1.FieldDef('string', exports.MODIFIED_CODE_MODES),
256
- disableAllowed: field_def_1.FieldDef.optional('boolean'),
257
- allowedPaths: field_def_1.FieldDef.optional('string[]'),
258
- ...exports.BASE_RULE_SCHEMA,
259
- };
260
- }
261
- exports.NoSymbolDiTokensConfig = NoSymbolDiTokensConfig;
262
- // Flags `process.exit(...)` outside a main()/runMain wrapper (and `import { main }`) so a deep exit
263
- // can't silently kill a reused server/command. Gradual-rollout knobs via the standard base: mode
264
- // (OFF | NEW_AND_MODIFIED_CODE | NEW_AND_MODIFIED_FILES), turnOffRuleUntilEpoch, branch, and
265
- // disableAllowed for the inline `// webpieces-disable` escape at genuine terminal boundaries.
266
- class NoProcessExitOutsideMainConfig extends BaseRuleConfig {
267
- disableAllowed;
268
- static SCHEMA = {
269
- mode: new field_def_1.FieldDef('string', exports.MODIFIED_CODE_MODES),
270
- disableAllowed: field_def_1.FieldDef.optional('boolean'),
271
- ...exports.BASE_RULE_SCHEMA,
272
- };
273
- }
274
- exports.NoProcessExitOutsideMainConfig = NoProcessExitOutsideMainConfig;
275
- // Flags a function CREATED OUTSIDE A CLASS at module scope: a top-level `function foo()` declaration
276
- // or a top-level `const foo = () => {}` / `= function(){}`. The point is that webpieces DI +
277
- // @DocumentDesign only work when behavior lives in injectable classes — a module-scope function is a
278
- // dead-end the DI graph can't reach. Inline callbacks, nested functions inside methods, and non-function
279
- // top-level consts (objects, zod schemas, primitives) are NOT flagged. Standard rollout knobs via the
280
- // base: mode (OFF | NEW_AND_MODIFIED_CODE | NEW_AND_MODIFIED_FILES), turnOffRuleUntilEpoch, branch,
281
- // and disableAllowed for the inline `// webpieces-disable` escape. `allowedPaths` exempts whole file
282
- // trees that legitimately live outside the class-per-behavior model (e.g. React component/hook files,
283
- // framework glue), matched with the shared glob/prefix/segment semantics of `isPathExcluded`.
284
- class NoFunctionOutsideClassConfig extends BaseRuleConfig {
285
- disableAllowed;
286
- allowedPaths;
287
- static SCHEMA = {
288
- mode: new field_def_1.FieldDef('string', exports.MODIFIED_CODE_MODES),
289
- disableAllowed: field_def_1.FieldDef.optional('boolean'),
290
- allowedPaths: field_def_1.FieldDef.optional('string[]'),
291
- ...exports.BASE_RULE_SCHEMA,
292
- };
293
- }
294
- exports.NoFunctionOutsideClassConfig = NoFunctionOutsideClassConfig;
295
- // inject-annotation-not-needed-for-concrete-class — flags a REDUNDANT `@inject(X)` whose token is
296
- // textually identical to the parameter's own declared type (`@inject(Foo) private readonly foo: Foo`).
297
- // In this inversify setup the decorator is pure noise there: reflect-metadata (emitDecoratorMetadata)
298
- // already resolves a constructor parameter by its class type, so `private readonly foo: Foo` binds on
299
- // its own (see CLAUDE.md, and the no-symbol-di-tokens rule that pushes the same way). Symbol/interface
300
- // tokens are NOT flagged because they never equal the type (`@inject(FOO_TOKEN) x: Provider<Foo>`).
301
- // AI keeps carpet-bombing `@inject`; this fails the build on the redundant form. Standard rollout knobs
302
- // via the base: mode (OFF | NEW_AND_MODIFIED_CODE | NEW_AND_MODIFIED_FILES), turnOffRuleUntilEpoch,
303
- // branch, and disableAllowed for the inline `// webpieces-disable` escape. `allowedPaths` exempts whole
304
- // file trees, matched with the shared glob/prefix/segment semantics.
305
- class InjectAnnotationNotNeededForConcreteClassConfig extends BaseRuleConfig {
306
- disableAllowed;
307
- allowedPaths;
308
- static SCHEMA = {
309
- mode: new field_def_1.FieldDef('string', exports.MODIFIED_CODE_MODES),
310
- disableAllowed: field_def_1.FieldDef.optional('boolean'),
311
- allowedPaths: field_def_1.FieldDef.optional('string[]'),
312
- ...exports.BASE_RULE_SCHEMA,
313
- };
314
- }
315
- exports.InjectAnnotationNotNeededForConcreteClassConfig = InjectAnnotationNotNeededForConcreteClassConfig;
316
- // framework-tag — every project that a changed source file belongs to must carry >=1
317
- // `framework:<browser|react|angular|node|express|react-native>` nx tag in its project.json. Those tags are the
318
- // project's "libType" — the SET of runtime environments it runs in — and the source of truth for
319
- // the dependencies.json `framework` field and the `library-types-match-client` rule. Multiple tags
320
- // are allowed (the env set) and values are validated against the known set (`framework:all` is a
321
- // hard error). `knownTypes` customizes that set (defaults to browser, react, angular, node, express,
322
- // react-native — the last a first-class runtime, not a browser, #1064).
323
- class FrameworkTagConfig extends BaseRuleConfig {
324
- knownTypes;
325
- static SCHEMA = {
326
- mode: new field_def_1.FieldDef('string', exports.PROJECT_MODES),
327
- knownTypes: field_def_1.FieldDef.optional('string[]'),
328
- ...exports.BASE_RULE_SCHEMA,
329
- };
330
- }
331
- exports.FrameworkTagConfig = FrameworkTagConfig;
332
- // role-tag — every project that a changed source file belongs to must carry a
333
- // `role:<server|app|bundle|designed-lib|lib|client|api-lib|api-client>` nx tag in its project.json. That tag is the project's
334
- // ROLE (orthogonal to `framework` libType) — the source of truth for the dependencies.json `role`
335
- // field, the `role-dependency` edge rule (apps are never depended upon), and DI-design generation
336
- // (server→@Controller, designed-lib→@ApiImplementation, lib→none, client→angular design).
337
- // `knownTypes` customizes the list suggested to the author when a tag is missing.
338
- class RoleTagConfig extends BaseRuleConfig {
339
- knownTypes;
340
- static SCHEMA = {
341
- mode: new field_def_1.FieldDef('string', exports.PROJECT_MODES),
342
- knownTypes: field_def_1.FieldDef.optional('string[]'),
343
- ...exports.BASE_RULE_SCHEMA,
344
- };
345
- }
346
- exports.RoleTagConfig = RoleTagConfig;
347
- // Touching a project audits every production API contract it directly owns.
348
- class EnsureWeAreSecureConfig extends BaseRuleConfig {
349
- static SCHEMA = {
350
- mode: new field_def_1.FieldDef('string', exports.PROJECT_MODES),
351
- ...exports.BASE_RULE_SCHEMA,
352
- };
353
- }
354
- exports.EnsureWeAreSecureConfig = EnsureWeAreSecureConfig;
355
- class BranchCreationGuardConfig extends BaseRuleConfig {
356
- // Naming pattern for stacked SUB-branches only (branches created off another feature branch,
357
- // which require human approval). Never applied to branches created off main.
358
- //
359
- // Schema-REQUIRED (#1017), like `mode` and `autoReapMergedBranches`, and for the same reason: it
360
- // is BEHAVIOUR, not a knob. This string decides which branch names the guard BLOCKS, and the
361
- // refusal quotes it back at the agent as the convention to follow — so a repo running webpieces'
362
- // shipped value is a repo whose branch-naming convention was chosen by a framework author who
363
- // never saw it. TS-optional but schema-required, the split `mode` uses: absent at RUNTIME means
364
- // the config never passed validation.
365
- subBranchNaming;
366
- // Human-sentence instruction telling the AI how to name a NEW branch off main. Surfaced back
367
- // to the agent in the guard's fix hints. May mirror no-edit-on-main.branchNamingConvention.
368
- branchFormat;
369
- // Hard cap on local feature branches (excluding main). Creating one past the cap is BLOCKED until
370
- // already-merged branches are reaped, which is what keeps the branch list from growing without
371
- // bound. Branch creation is the gate because it is the only moment cleanup is both cheap and
372
- // obviously worth it. See merged-branches.ts for how "already merged" is determined.
373
- maxLocalBranches;
374
- // Hard cap on LINKED worktrees (the primary clone is never counted). A separate budget from
375
- // maxLocalBranches: every worktree holds a branch, so if worktree-held branches also spent the
376
- // branch budget, five worktrees would leave room for zero branches. Held branches count here;
377
- // parked branches count against maxLocalBranches. Enforced at `git worktree add`.
378
- maxWorktrees;
379
- // Let the detached background refresher DELETE dead branches on its own, instead of only
380
- // reporting them. Every candidate is provably dead (a MERGED PR — its own, or the PR of the branch
381
- // it snapshots; nothing else qualifies) and
382
- // recoverable by the SHA logged to branch-mutations.log — but it is still UNATTENDED deletion,
383
- // so this is schema-REQUIRED like `mode` and `turnOffRuleUntilEpoch`. "Every built-in rule
384
- // must be explicitly configured — no silent defaults" (validate-config.ts) applies with extra
385
- // force here: branches disappearing on a preference nobody ever stated is precisely the kind of
386
- // default that must not exist. Validation makes each consumer answer the question once.
387
- //
388
- // TS-optional but schema-required — the same split `mode` uses. Absent at RUNTIME therefore means
389
- // the config never passed validation, and the only safe reading of "nobody has answered" is: do
390
- // not delete anything.
391
- autoReapMergedBranches;
392
- static SCHEMA = {
393
- mode: new field_def_1.FieldDef('string', exports.BRANCH_GUARD_MODES),
394
- subBranchNaming: new field_def_1.FieldDef('string'),
395
- branchFormat: field_def_1.FieldDef.optional('string'),
396
- maxLocalBranches: field_def_1.FieldDef.optional('number'),
397
- maxWorktrees: field_def_1.FieldDef.optional('number'),
398
- autoReapMergedBranches: new field_def_1.FieldDef('boolean'),
399
- ...exports.BASE_RULE_SCHEMA,
400
- };
401
- }
402
- exports.BranchCreationGuardConfig = BranchCreationGuardConfig;
403
- /**
404
- * `pr-lifecycle-guard` — ONE key, ONE policy: *PRs and merges go through the gated flow.*
405
- *
406
- * Four CLASSES implement it, and their names are unchanged (they are the operator identity every
407
- * decision-log line and every deny report carries):
408
- *
409
- * pr-creation-or-push-guard a manual `git push` / `gh pr create|edit` / a raw pulls API call
410
- * merge-in-progress-guard a PR command while a 3-point merge is half-finished
411
- * pr-merge-guard a bare `gh pr merge`
412
- * redirect-how-to-merge-main "how do I get main into my branch?" → the documented flow
413
- *
414
- * ## Say this out loud: `"mode": "OFF"` releases the unvalidated-merge gate too
415
- *
416
- * Three of the four are pure COMMAND-SHAPE blocks and can never fire spuriously. The fourth,
417
- * merge-in-progress-guard, is STATE-conditional — it fires only while a 3-point merge is actually in
418
- * progress, and it is the one state L2 explicitly stands down for. So turning this key OFF to unblock
419
- * `gh pr merge` ALSO drops the "you have an unfinished merge" gate. That is the honest cost of one key
420
- * per policy, and it is stated here, in guards/L4-pr-lifecycle.md, and in the error path, rather than
421
- * being papered over with a granular sub-mode (which would be four knobs wearing one key's name).
422
- *
423
- * ## The command strings are NOT here
424
- *
425
- * `upsertPrCommand` and `mergeCompleteCommand` used to sit on the two guards, and — being read at the
426
- * point of use — they BEAT `commands.guardHints`, so `guardHintsWhy`'s claim that renaming a gated
427
- * command there makes "every guard message follow" was simply false. They are DELETED, not deprecated.
428
- * `commands.guardHints.prCreationOrPush` / `.mergeInProgress` is the one place those strings live, and
429
- * the loader hands the resolved values to the two rules directly. A consumer that still sets the old
430
- * per-guard field gets a RETIRED_FIELD_HINTS error naming the destination.
431
- */
432
- class PrLifecycleGuardConfig extends BaseRuleConfig {
433
- static SCHEMA = {
434
- mode: new field_def_1.FieldDef('string', exports.ON_OFF_MODES),
435
- ...exports.BASE_RULE_SCHEMA,
436
- };
437
- }
438
- exports.PrLifecycleGuardConfig = PrLifecycleGuardConfig;
439
- // NOTE: there is deliberately no `WholeRepoBuildGuardConfig`. That guard has NO webpieces.config.json
440
- // entry — it is EXPERIMENTAL and OFF by default, and its only switch is the OPT-IN
441
- // `experimental.whole-repo-build-guard: true` in the optional machine-local ~/.webpieces/config.json
442
- // (see home-config.ts). The build command it prints
443
- // is handed to it directly from `commands.pr-gate.buildCommand` by ai-hook-rules' runner. Re-adding a
444
- // config class here puts the guard back in RULE_SCHEMAS and makes it a fault-Y rule again.
445
- class NoFileImportCyclesConfig extends BaseRuleConfig {
446
- ignoreTypeOnly;
447
- excludePackages;
448
- // Raw regex escape hatch for a cycle inside the project being checked — generated code, a
449
- // vendored tree, or a deliberate bidirectional domain model — that `excludePackages` cannot reach
450
- // (it resolves npm package NAMES, so it only excludes a *sibling* package, never a directory
451
- // inside this one). Patterns are handed to madge verbatim and matched against ids RELATIVE TO THE
452
- // PROJECT (e.g. "^src/generated/", "^src/modules/(item|category)/") — NOT workspace-rooted or
453
- // absolute, which silently match nothing. The executor warns when a pattern matches zero
454
- // traversed files, so a mis-anchored pattern is visible rather than a silent no-op.
455
- excludeRegExp;
456
- static SCHEMA = {
457
- mode: new field_def_1.FieldDef('string', exports.STRUCTURAL_MODES),
458
- ignoreTypeOnly: field_def_1.FieldDef.optional('boolean'),
459
- excludePackages: field_def_1.FieldDef.optional('string[]'),
460
- excludeRegExp: field_def_1.FieldDef.optional('string[]'),
461
- ...exports.BASE_RULE_SCHEMA,
462
- };
463
- }
464
- exports.NoFileImportCyclesConfig = NoFileImportCyclesConfig;
465
- class RuntimeArchitectureConfig extends BaseRuleConfig {
466
- // NOTE: `servicePaths` / `apiProjectPaths` were removed — they were never read. The runtime graph
467
- // is derived SOLELY from architecture/dependencies.json apiRelations + project roles (see
468
- // nx-webpieces-rules/src/lib/runtime-graph.ts), so any config still listing them (a hand-maintained
469
- // enumeration of api libs) now fails the unknown-field check in validateWebpiecesConfig. There is
470
- // nothing to enumerate — delete the keys.
471
- // NOTE: `allowedCycles` was removed — a runtime cycle is no longer allowable at all. CD deploys
472
- // services in dependency order and a cyclic architecture has no such order, so the runtime graph
473
- // now THROWS while it is being levelled rather than emitting a flat, unlevellable diagram (see
474
- // nx-webpieces-rules/src/lib/runtime-graph-levels.ts). A repo that genuinely cannot break a cycle
475
- // yet declares it PER EDGE with a `cutLegacyCycle:<targetService>` nx tag on the CALLING project,
476
- // which admits the debt in a place `grep -rn cutLegacyCycle` can enumerate. Delete the key.
477
- /**
478
- * Draw a dashed terminal node for every contract a service calls that NOTHING in-repo
479
- * implements (firestore, gmail, ...) — the vendor systems the runtime graph otherwise stops one
480
- * hop short of. Defaults to true; set false in a repo whose external surface is noisy. Purely a
481
- * RENDER switch: levels, cycle detection and runtime-dependencies.json are identical either way.
482
- */
483
- showExternalNodes;
484
- /**
485
- * Project roots whose exported `*Api` types are contracts for systems OUTSIDE this repo
486
- * (firestore, gmail, gcp-storage, ...), e.g. `["libraries/apis/external/**"]`. Globs, matched
487
- * against the nx project root.
488
- *
489
- * Needed because an external contract does NOT look like an in-repo one: it is a plain
490
- * `interface` bound to a Symbol token and injected, never an `abstract class` carrying @ApiPath
491
- * reached through `createRpcClient`. Without this list the scanner has no way to tell a vendor
492
- * seam from any other library, so every call leaving the repo is invisible to the runtime graph.
493
- *
494
- * Defaults to none, which is correct for a repo with no vendor wrapper libraries.
495
- */
496
- externalApiPaths;
497
- static SCHEMA = {
498
- mode: new field_def_1.FieldDef('string', exports.STRUCTURAL_MODES),
499
- showExternalNodes: field_def_1.FieldDef.optional('boolean'),
500
- externalApiPaths: field_def_1.FieldDef.optional('string[]'),
501
- ...exports.BASE_RULE_SCHEMA,
502
- };
503
- }
504
- exports.RuntimeArchitectureConfig = RuntimeArchitectureConfig;
505
- class NxWiringConfig extends BaseRuleConfig {
506
- static SCHEMA = {
507
- mode: new field_def_1.FieldDef('string', exports.STRUCTURAL_MODES),
508
- ...exports.BASE_RULE_SCHEMA,
509
- };
510
- }
511
- exports.NxWiringConfig = NxWiringConfig;
512
- class DiGraphConfig extends BaseRuleConfig {
513
- static SCHEMA = {
514
- mode: new field_def_1.FieldDef('string', exports.STRUCTURAL_MODES),
515
- ...exports.BASE_RULE_SCHEMA,
516
- };
517
- }
518
- exports.DiGraphConfig = DiGraphConfig;
519
- class MissingDesignAnnotationConfig extends BaseRuleConfig {
520
- static SCHEMA = {
521
- mode: new field_def_1.FieldDef('string', exports.STRUCTURAL_MODES),
522
- ...exports.BASE_RULE_SCHEMA,
523
- };
524
- }
525
- exports.MissingDesignAnnotationConfig = MissingDesignAnnotationConfig;
526
- class NoJsFilesConfig extends BaseRuleConfig {
527
- allowedPaths;
528
- static SCHEMA = {
529
- mode: new field_def_1.FieldDef('string', exports.FILE_LIMIT_MODES),
530
- allowedPaths: field_def_1.FieldDef.optional('string[]'),
531
- ...exports.BASE_RULE_SCHEMA,
532
- };
533
- }
534
- exports.NoJsFilesConfig = NoJsFilesConfig;
535
- // ---------------------------------------------------------------------------
536
- // The five Nx infrastructure validators (architecture-unchanged, no-architecture-cycles,
537
- // packagejson, versions-locked, eslint-sync). Each is whole-graph / whole-repo by nature (a cycle, a
538
- // drifted dependencies.json, an unlocked version can be introduced by a file nobody in this diff
539
- // touched), so the only honest mode set is STRUCTURAL_MODES: RUN_EVERY_TIME (the default) or OFF.
540
- //
541
- // All five now honor the universal escape hatches (turnOffRuleUntilEpoch / turnOffRuleWhileOnBranch)
542
- // via shouldSkipRule — the RuleGate is called with honorEpoch:true from
543
- // every executor. This lets a repo time-box or branch-scope a failing infrastructure check (e.g. hold
544
- // validate-packagejson off until an upgrade PR lands) with a one-value edit, instead of only the
545
- // blunt "mode": "OFF". Originally packagejson/versions-locked/eslint-sync were all-or-nothing on the
546
- // theory that "no blessed baseline" made grandfathering meaningless, but a time-box is a schedule, not
547
- // a baseline: "do not enforce this until <epoch>/off <branch>" is coherent for any rule.
548
- // ---------------------------------------------------------------------------
549
- class ValidateArchitectureUnchangedConfig extends BaseRuleConfig {
550
- static SCHEMA = {
551
- mode: new field_def_1.FieldDef('string', exports.STRUCTURAL_MODES),
552
- ...exports.BASE_RULE_SCHEMA,
553
- };
554
- }
555
- exports.ValidateArchitectureUnchangedConfig = ValidateArchitectureUnchangedConfig;
556
- class ValidateNoArchitectureCyclesConfig extends BaseRuleConfig {
557
- static SCHEMA = {
558
- mode: new field_def_1.FieldDef('string', exports.STRUCTURAL_MODES),
559
- ...exports.BASE_RULE_SCHEMA,
560
- };
561
- }
562
- exports.ValidateNoArchitectureCyclesConfig = ValidateNoArchitectureCyclesConfig;
563
- class ValidatePackageJsonConfig extends BaseRuleConfig {
564
- static SCHEMA = {
565
- mode: new field_def_1.FieldDef('string', exports.STRUCTURAL_MODES),
566
- ...exports.BASE_RULE_SCHEMA,
567
- };
568
- }
569
- exports.ValidatePackageJsonConfig = ValidatePackageJsonConfig;
570
- class ValidateVersionsLockedConfig extends BaseRuleConfig {
571
- static SCHEMA = {
572
- mode: new field_def_1.FieldDef('string', exports.STRUCTURAL_MODES),
573
- ...exports.BASE_RULE_SCHEMA,
574
- };
575
- }
576
- exports.ValidateVersionsLockedConfig = ValidateVersionsLockedConfig;
577
- class ValidateEslintSyncConfig extends BaseRuleConfig {
578
- static SCHEMA = {
579
- mode: new field_def_1.FieldDef('string', exports.STRUCTURAL_MODES),
580
- ...exports.BASE_RULE_SCHEMA,
581
- };
582
- }
583
- exports.ValidateEslintSyncConfig = ValidateEslintSyncConfig;
584
- class ValidateTsInSrcConfig extends BaseRuleConfig {
585
- allowedRootFiles;
586
- excludePaths;
587
- static SCHEMA = {
588
- mode: new field_def_1.FieldDef('string', exports.VALIDATE_TS_MODES),
589
- allowedRootFiles: field_def_1.FieldDef.optional('string[]'),
590
- excludePaths: field_def_1.FieldDef.optional('string[]'),
591
- ...exports.BASE_RULE_SCHEMA,
592
- };
593
- }
594
- exports.ValidateTsInSrcConfig = ValidateTsInSrcConfig;
595
- //# sourceMappingURL=rule-configs.js.map