@webpieces/rules-config 0.4.844 → 0.4.846

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