@webpieces/code-rules 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 (139) hide show
  1. package/package.json +12 -4
  2. package/src/api-lib-source-rule.d.ts +4 -1
  3. package/src/api-lib-source-rule.js.map +1 -1
  4. package/src/code-rules-bootstrap.js +8 -7
  5. package/src/code-rules-bootstrap.js.map +1 -1
  6. package/src/code-rules-config-table.d.ts +9 -10
  7. package/src/code-rules-config-table.js +48 -33
  8. package/src/code-rules-config-table.js.map +1 -1
  9. package/src/code-rules-engine.js.map +1 -1
  10. package/src/code-validator.d.ts +2 -1
  11. package/src/code-validator.js.map +1 -1
  12. package/src/configs/api-lib-spelling-configs.d.ts +40 -0
  13. package/src/configs/api-lib-spelling-configs.js +52 -0
  14. package/src/configs/api-lib-spelling-configs.js.map +1 -0
  15. package/src/configs/no-client-creation-config.d.ts +12 -0
  16. package/src/configs/no-client-creation-config.js +40 -0
  17. package/src/configs/no-client-creation-config.js.map +1 -0
  18. package/src/configs/no-state-paths-config.d.ts +41 -0
  19. package/src/configs/no-state-paths-config.js +51 -0
  20. package/src/configs/no-state-paths-config.js.map +1 -0
  21. package/src/configs/no-utility-types-config.d.ts +30 -0
  22. package/src/configs/no-utility-types-config.js +39 -0
  23. package/src/configs/no-utility-types-config.js.map +1 -0
  24. package/src/configs/required-type-suffix-config.d.ts +49 -0
  25. package/src/configs/required-type-suffix-config.js +62 -0
  26. package/src/configs/required-type-suffix-config.js.map +1 -0
  27. package/src/configs/rule-configs.d.ts +131 -0
  28. package/src/configs/rule-configs.js +309 -0
  29. package/src/configs/rule-configs.js.map +1 -0
  30. package/src/configs/tag-truth-configs.d.ts +66 -0
  31. package/src/configs/tag-truth-configs.js +82 -0
  32. package/src/configs/tag-truth-configs.js.map +1 -0
  33. package/src/index.d.ts +10 -0
  34. package/src/index.js +50 -1
  35. package/src/index.js.map +1 -1
  36. package/src/project-scan-targets.d.ts +2 -1
  37. package/src/project-scan-targets.js.map +1 -1
  38. package/src/rule-pack.d.ts +3 -0
  39. package/src/rule-pack.js +10 -0
  40. package/src/rule-pack.js.map +1 -0
  41. package/src/rule-settings.d.ts +5 -0
  42. package/src/rule-settings.js +269 -0
  43. package/src/rule-settings.js.map +1 -0
  44. package/src/scan-scope.d.ts +2 -1
  45. package/src/scan-scope.js.map +1 -1
  46. package/src/tag-rule.d.ts +1 -1
  47. package/src/tag-rule.js.map +1 -1
  48. package/src/validate-catch-error-pattern.d.ts +1 -1
  49. package/src/validate-catch-error-pattern.js +4 -3
  50. package/src/validate-catch-error-pattern.js.map +1 -1
  51. package/src/validate-dtos.d.ts +1 -1
  52. package/src/validate-dtos.js +2 -1
  53. package/src/validate-dtos.js.map +1 -1
  54. package/src/validate-ensure-we-are-secure.d.ts +2 -1
  55. package/src/validate-ensure-we-are-secure.js +3 -2
  56. package/src/validate-ensure-we-are-secure.js.map +1 -1
  57. package/src/validate-framework-packages.d.ts +2 -1
  58. package/src/validate-framework-packages.js +7 -6
  59. package/src/validate-framework-packages.js.map +1 -1
  60. package/src/validate-framework-tag.d.ts +1 -1
  61. package/src/validate-framework-tag.js +2 -2
  62. package/src/validate-framework-tag.js.map +1 -1
  63. package/src/validate-framework-tsconfig.d.ts +2 -1
  64. package/src/validate-framework-tsconfig.js +5 -4
  65. package/src/validate-framework-tsconfig.js.map +1 -1
  66. package/src/validate-inject-annotation-not-needed-for-concrete-class.d.ts +1 -1
  67. package/src/validate-inject-annotation-not-needed-for-concrete-class.js +3 -2
  68. package/src/validate-inject-annotation-not-needed-for-concrete-class.js.map +1 -1
  69. package/src/validate-match-rules.d.ts +1 -1
  70. package/src/validate-match-rules.js.map +1 -1
  71. package/src/validate-modified-files.d.ts +2 -1
  72. package/src/validate-modified-files.js +3 -2
  73. package/src/validate-modified-files.js.map +1 -1
  74. package/src/validate-modified-methods.d.ts +1 -1
  75. package/src/validate-modified-methods.js +4 -3
  76. package/src/validate-modified-methods.js.map +1 -1
  77. package/src/validate-new-methods.d.ts +1 -1
  78. package/src/validate-new-methods.js +1 -1
  79. package/src/validate-new-methods.js.map +1 -1
  80. package/src/validate-no-any-unknown.d.ts +1 -1
  81. package/src/validate-no-any-unknown.js +3 -2
  82. package/src/validate-no-any-unknown.js.map +1 -1
  83. package/src/validate-no-client-creation-outside-server-or-client.d.ts +1 -1
  84. package/src/validate-no-client-creation-outside-server-or-client.js +3 -2
  85. package/src/validate-no-client-creation-outside-server-or-client.js.map +1 -1
  86. package/src/validate-no-custom-css.d.ts +1 -1
  87. package/src/validate-no-custom-css.js +3 -2
  88. package/src/validate-no-custom-css.js.map +1 -1
  89. package/src/validate-no-destructure.d.ts +1 -1
  90. package/src/validate-no-destructure.js +3 -2
  91. package/src/validate-no-destructure.js.map +1 -1
  92. package/src/validate-no-direct-api-resolver.d.ts +1 -1
  93. package/src/validate-no-direct-api-resolver.js +3 -2
  94. package/src/validate-no-direct-api-resolver.js.map +1 -1
  95. package/src/validate-no-function-outside-class.d.ts +1 -1
  96. package/src/validate-no-function-outside-class.js +4 -3
  97. package/src/validate-no-function-outside-class.js.map +1 -1
  98. package/src/validate-no-implicit-any.d.ts +1 -1
  99. package/src/validate-no-implicit-any.js +3 -2
  100. package/src/validate-no-implicit-any.js.map +1 -1
  101. package/src/validate-no-inline-import-in-api-lib.d.ts +2 -1
  102. package/src/validate-no-inline-import-in-api-lib.js +3 -2
  103. package/src/validate-no-inline-import-in-api-lib.js.map +1 -1
  104. package/src/validate-no-inline-types.d.ts +1 -1
  105. package/src/validate-no-inline-types.js +3 -2
  106. package/src/validate-no-inline-types.js.map +1 -1
  107. package/src/validate-no-process-exit-outside-main.d.ts +1 -1
  108. package/src/validate-no-process-exit-outside-main.js +3 -2
  109. package/src/validate-no-process-exit-outside-main.js.map +1 -1
  110. package/src/validate-no-state-paths-in-templates.d.ts +1 -1
  111. package/src/validate-no-state-paths-in-templates.js +7 -6
  112. package/src/validate-no-state-paths-in-templates.js.map +1 -1
  113. package/src/validate-no-symbol-di-tokens.d.ts +1 -1
  114. package/src/validate-no-symbol-di-tokens.js +3 -2
  115. package/src/validate-no-symbol-di-tokens.js.map +1 -1
  116. package/src/validate-no-unmanaged-exceptions.d.ts +1 -1
  117. package/src/validate-no-unmanaged-exceptions.js +3 -2
  118. package/src/validate-no-unmanaged-exceptions.js.map +1 -1
  119. package/src/validate-no-utility-types-in-api-lib.d.ts +2 -1
  120. package/src/validate-no-utility-types-in-api-lib.js +3 -2
  121. package/src/validate-no-utility-types-in-api-lib.js.map +1 -1
  122. package/src/validate-one-enum-spelling-in-api-lib.d.ts +2 -1
  123. package/src/validate-one-enum-spelling-in-api-lib.js +3 -2
  124. package/src/validate-one-enum-spelling-in-api-lib.js.map +1 -1
  125. package/src/validate-prisma-converters.d.ts +1 -1
  126. package/src/validate-prisma-converters.js +3 -2
  127. package/src/validate-prisma-converters.js.map +1 -1
  128. package/src/validate-required-type-suffix.d.ts +2 -1
  129. package/src/validate-required-type-suffix.js +3 -2
  130. package/src/validate-required-type-suffix.js.map +1 -1
  131. package/src/validate-return-types.d.ts +1 -1
  132. package/src/validate-return-types.js +3 -2
  133. package/src/validate-return-types.js.map +1 -1
  134. package/src/validate-role-tag.d.ts +1 -1
  135. package/src/validate-role-tag.js +2 -2
  136. package/src/validate-role-tag.js.map +1 -1
  137. package/src/wp-ci.d.ts +0 -19
  138. package/src/wp-ci.js +4 -4
  139. package/src/wp-ci.js.map +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-lib-spelling-configs.js","sourceRoot":"","sources":["../../../../../../packages/tooling/code-rules/src/configs/api-lib-spelling-configs.ts"],"names":[],"mappings":";;;AAAA,oDAA+F;AAC/F,oDAA6E;AAC7E;;;;;;;;;;;GAWG;AACH,MAAa,4BAA6B,SAAQ,0BAAc;IAE5D,YAAY,CAAY;IAExB,MAAM,CAAU,MAAM,GAA8C;QAChE,IAAI,EAAE,IAAI,oBAAQ,CAAC,QAAQ,EAAE,+BAAmB,CAAC;QACjD,YAAY,EAAE,oBAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC;QAC3C,GAAG,4BAAgB;KACtB,CAAC;;AARN,oEASC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAa,6BAA8B,SAAQ,0BAAc;IAE7D,YAAY,CAAY;IAExB,MAAM,CAAU,MAAM,GAA+C;QACjE,IAAI,EAAE,IAAI,oBAAQ,CAAC,QAAQ,EAAE,+BAAmB,CAAC;QACjD,YAAY,EAAE,oBAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC;QAC3C,GAAG,4BAAgB;KACtB,CAAC;;AARN,sEASC","sourcesContent":["import { FieldDef, SchemaShape, BaseRuleConfig, BASE_RULE_SCHEMA } from \"@webpieces/rules-sdk\";\nimport { ModifiedCodeMode, MODIFIED_CODE_MODES } from \"@webpieces/rules-sdk\";\n/**\n * `no-inline-import-in-api-lib` (#1023) — in every `role:api-lib` project, refuse an `import('…')`\n * TYPE node (`activeAiProvider?: import('@myorg/company-core').AiProvider`) and a dynamic `import()`\n * EXPRESSION. An API imports at the top of the file, only: an inline import hides a cross-library\n * dependency from every reader of the contract and from the tools that read its imports.\n *\n * `mode` is REQUIRED and has no default (`.claude/rules/no-rule-defaults.md`): OFF |\n * NEW_AND_MODIFIED_CODE (only changed lines — grandfathers the rest) | NEW_AND_MODIFIED_FILES (every\n * occurrence in a changed file) | MODIFIED_PROJECTS / RUN_EVERY_TIME (every occurrence in a touched\n * project / in the repo — #1027; count what is left with `wp-validate-code --rule=… --mode=RUN_EVERY_TIME`). `allowedPaths` exempts whole trees. The per-site escape hatch is\n * `// webpieces-disable no-inline-import-in-api-lib -- <reason>` on the line or the line above.\n */\nexport class NoInlineImportInApiLibConfig extends BaseRuleConfig {\n declare mode?: ModifiedCodeMode;\n allowedPaths?: string[];\n\n static readonly SCHEMA: SchemaShape<NoInlineImportInApiLibConfig> = {\n mode: new FieldDef('string', MODIFIED_CODE_MODES),\n allowedPaths: FieldDef.optional('string[]'),\n ...BASE_RULE_SCHEMA,\n };\n}\n\n/**\n * `one-enum-spelling-in-api-lib` (#1023) — in every `role:api-lib` project, a fixed set of string\n * values has ONE spelling: a string `enum` whose every member is explicitly initialised with a string\n * literal (`export enum SpeakerGender { FEMALE = 'female', MALE = 'male' }`), used as the enum, one\n * member of it, or a union of its members. Refused, each with a cure that prints the enum to write:\n * a string-literal union of two or more members (in a type alias, a field or a parameter),\n * `(typeof X)[number]`, `keyof typeof X`, a single string-literal type used as a union discriminator,\n * and a numeric, heterogeneous, `const` or non-initialised enum (a numeric enum puts numbers on the\n * wire).\n *\n * The GENERATOR keeps supporting string-literal unions — for other consumers, and for code this rule's\n * mode grandfathers. This rule is what forbids NEW ones in an api library.\n *\n * `mode` is REQUIRED and has no default (`.claude/rules/no-rule-defaults.md`), with the same three\n * values as above; `allowedPaths` and the per-site disable work the same way.\n */\nexport class OneEnumSpellingInApiLibConfig extends BaseRuleConfig {\n declare mode?: ModifiedCodeMode;\n allowedPaths?: string[];\n\n static readonly SCHEMA: SchemaShape<OneEnumSpellingInApiLibConfig> = {\n mode: new FieldDef('string', MODIFIED_CODE_MODES),\n allowedPaths: FieldDef.optional('string[]'),\n ...BASE_RULE_SCHEMA,\n };\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import { SchemaShape, BaseRuleConfig } from "@webpieces/rules-sdk";
2
+ import { ModifiedCodeMode } from "@webpieces/rules-sdk";
3
+ export declare const CLIENT_CREATION_SEVERITIES: readonly ["warn", "error"];
4
+ export type ClientCreationSeverity = typeof CLIENT_CREATION_SEVERITIES[number];
5
+ export declare class NoClientCreationOutsideServerOrClientConfig extends BaseRuleConfig {
6
+ mode?: ModifiedCodeMode;
7
+ severity?: ClientCreationSeverity;
8
+ disableAllowed?: boolean;
9
+ allowedRoles?: string[];
10
+ allowedPaths?: string[];
11
+ static readonly SCHEMA: SchemaShape<NoClientCreationOutsideServerOrClientConfig>;
12
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NoClientCreationOutsideServerOrClientConfig = exports.CLIENT_CREATION_SEVERITIES = void 0;
4
+ const rules_sdk_1 = require("@webpieces/rules-sdk");
5
+ const rules_sdk_2 = require("@webpieces/rules-sdk");
6
+ // no-client-creation-outside-server-or-client severity. Landed as a hard failure this rule would
7
+ // break every existing Angular repo on upgrade (provideCoreClient-style helpers create the client
8
+ // inside a role:lib on purpose), so it ships WARN — reports + prints the migration but passes the
9
+ // build — and a repo flips it to `error` once it has migrated its libraries.
10
+ exports.CLIENT_CREATION_SEVERITIES = ['warn', 'error'];
11
+ // no-client-creation-outside-server-or-client — flags a project that CONSTRUCTS an rpc/pubsub client
12
+ // (`factory.createRpcClient(...)` / `factory.createPubSubClient(...)`) when the project's `role:` tag
13
+ // is not one of `allowedRoles`. Only a runnable entrypoint (server / client app / app) has a declared
14
+ // identity (`serviceName`) or target (`callsService`), so a client built there is attributable in the
15
+ // runtime graph; a client built inside a `role:lib` reaches the fan-out fallback (one `uses` edge to
16
+ // EVERY implementer of the api) and draws calls that cannot happen. A reusable library takes the api
17
+ // INJECTED — the server/app module binds it to a client. Importing the api type or its DI token is
18
+ // FINE and never flagged; only constructing the transport is.
19
+ //
20
+ // `severity` ships "warn" (report + migration, build passes) so an upgrade can't break an un-migrated
21
+ // Angular repo; flip to "error" once libraries are migrated. `allowedRoles` defaults to the runnable
22
+ // roles; `allowedPaths` exempts whole file trees (shared glob semantics). Standard rollout knobs via
23
+ // the base: mode (OFF | NEW_AND_MODIFIED_CODE | NEW_AND_MODIFIED_FILES), turnOffRuleUntilEpoch,
24
+ // branch, and disableAllowed for the inline `// webpieces-disable` escape.
25
+ class NoClientCreationOutsideServerOrClientConfig extends rules_sdk_1.BaseRuleConfig {
26
+ severity;
27
+ disableAllowed;
28
+ allowedRoles;
29
+ allowedPaths;
30
+ static SCHEMA = {
31
+ mode: new rules_sdk_1.FieldDef('string', rules_sdk_2.MODIFIED_CODE_MODES),
32
+ severity: rules_sdk_1.FieldDef.optional('string', exports.CLIENT_CREATION_SEVERITIES),
33
+ disableAllowed: rules_sdk_1.FieldDef.optional('boolean'),
34
+ allowedRoles: rules_sdk_1.FieldDef.optional('string[]'),
35
+ allowedPaths: rules_sdk_1.FieldDef.optional('string[]'),
36
+ ...rules_sdk_1.BASE_RULE_SCHEMA,
37
+ };
38
+ }
39
+ exports.NoClientCreationOutsideServerOrClientConfig = NoClientCreationOutsideServerOrClientConfig;
40
+ //# sourceMappingURL=no-client-creation-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-client-creation-config.js","sourceRoot":"","sources":["../../../../../../packages/tooling/code-rules/src/configs/no-client-creation-config.ts"],"names":[],"mappings":";;;AAAA,oDAA+F;AAC/F,oDAA6E;AAC7E,iGAAiG;AACjG,kGAAkG;AAClG,kGAAkG;AAClG,6EAA6E;AAChE,QAAA,0BAA0B,GAAG,CAAC,MAAM,EAAE,OAAO,CAAU,CAAC;AAIrE,qGAAqG;AACrG,sGAAsG;AACtG,sGAAsG;AACtG,sGAAsG;AACtG,qGAAqG;AACrG,qGAAqG;AACrG,mGAAmG;AACnG,8DAA8D;AAC9D,EAAE;AACF,sGAAsG;AACtG,qGAAqG;AACrG,qGAAqG;AACrG,gGAAgG;AAChG,2EAA2E;AAC3E,MAAa,2CAA4C,SAAQ,0BAAc;IAE3E,QAAQ,CAA0B;IAClC,cAAc,CAAW;IACzB,YAAY,CAAY;IACxB,YAAY,CAAY;IAExB,MAAM,CAAU,MAAM,GAA6D;QAC/E,IAAI,EAAE,IAAI,oBAAQ,CAAC,QAAQ,EAAE,+BAAmB,CAAC;QACjD,QAAQ,EAAE,oBAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,kCAA0B,CAAC;QACjE,cAAc,EAAE,oBAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC;QAC5C,YAAY,EAAE,oBAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC;QAC3C,YAAY,EAAE,oBAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC;QAC3C,GAAG,4BAAgB;KACtB,CAAC;;AAdN,kGAeC","sourcesContent":["import { FieldDef, SchemaShape, BaseRuleConfig, BASE_RULE_SCHEMA } from \"@webpieces/rules-sdk\";\nimport { ModifiedCodeMode, MODIFIED_CODE_MODES } from \"@webpieces/rules-sdk\";\n// no-client-creation-outside-server-or-client severity. Landed as a hard failure this rule would\n// break every existing Angular repo on upgrade (provideCoreClient-style helpers create the client\n// inside a role:lib on purpose), so it ships WARN — reports + prints the migration but passes the\n// build — and a repo flips it to `error` once it has migrated its libraries.\nexport const CLIENT_CREATION_SEVERITIES = ['warn', 'error'] as const;\n\nexport type ClientCreationSeverity = typeof CLIENT_CREATION_SEVERITIES[number];\n\n// no-client-creation-outside-server-or-client — flags a project that CONSTRUCTS an rpc/pubsub client\n// (`factory.createRpcClient(...)` / `factory.createPubSubClient(...)`) when the project's `role:` tag\n// is not one of `allowedRoles`. Only a runnable entrypoint (server / client app / app) has a declared\n// identity (`serviceName`) or target (`callsService`), so a client built there is attributable in the\n// runtime graph; a client built inside a `role:lib` reaches the fan-out fallback (one `uses` edge to\n// EVERY implementer of the api) and draws calls that cannot happen. A reusable library takes the api\n// INJECTED — the server/app module binds it to a client. Importing the api type or its DI token is\n// FINE and never flagged; only constructing the transport is.\n//\n// `severity` ships \"warn\" (report + migration, build passes) so an upgrade can't break an un-migrated\n// Angular repo; flip to \"error\" once libraries are migrated. `allowedRoles` defaults to the runnable\n// roles; `allowedPaths` exempts whole file trees (shared glob semantics). Standard rollout knobs via\n// the base: mode (OFF | NEW_AND_MODIFIED_CODE | NEW_AND_MODIFIED_FILES), turnOffRuleUntilEpoch,\n// branch, and disableAllowed for the inline `// webpieces-disable` escape.\nexport class NoClientCreationOutsideServerOrClientConfig extends BaseRuleConfig {\n declare mode?: ModifiedCodeMode;\n severity?: ClientCreationSeverity;\n disableAllowed?: boolean;\n allowedRoles?: string[];\n allowedPaths?: string[];\n\n static readonly SCHEMA: SchemaShape<NoClientCreationOutsideServerOrClientConfig> = {\n mode: new FieldDef('string', MODIFIED_CODE_MODES),\n severity: FieldDef.optional('string', CLIENT_CREATION_SEVERITIES),\n disableAllowed: FieldDef.optional('boolean'),\n allowedRoles: FieldDef.optional('string[]'),\n allowedPaths: FieldDef.optional('string[]'),\n ...BASE_RULE_SCHEMA,\n };\n}\n"]}
@@ -0,0 +1,41 @@
1
+ import { SchemaShape, BaseRuleConfig } from "@webpieces/rules-sdk";
2
+ import { ModifiedCodeMode } from "@webpieces/rules-sdk";
3
+ /**
4
+ * The template dirs `no-state-paths-in-templates` looks at when a repo has not said otherwise:
5
+ * webpieces' own instruct-ai templates, which are the generated docs the rule was written for.
6
+ *
7
+ * A consumer repo that generates AI-facing docs from its own templates points `templateDirs` at them;
8
+ * a repo that generates none matches no files and the rule is a no-op. Seeded rather than left empty
9
+ * so the rule arrives doing the job it exists for instead of waiting to be discovered.
10
+ */
11
+ export declare const DEFAULT_TEMPLATE_DIRS: readonly string[];
12
+ /**
13
+ * The path prefixes that must never be RESTATED in a generated doc, only computed.
14
+ *
15
+ * `.webpieces/` is the whole webpieces state tree, and every path under it is per-tree: a linked
16
+ * worktree's state lives at `<primary>/.webpieces/worktrees/<name>/…`, so the relative spelling names
17
+ * a file that does not exist there.
18
+ */
19
+ export declare const DEFAULT_BANNED_STATE_PATH_PREFIXES: readonly string[];
20
+ /**
21
+ * Bans a hard-coded state path inside a GENERATED-doc template.
22
+ *
23
+ * The incident: `webpieces.git-workflow.md` restated `.webpieces/logs/branch-mutations.log`. That log
24
+ * is per-worktree, so the doc — regenerated into every governed repo and handed to an agent by
25
+ * absolute path as instruction — named a file that does not exist in half the trees that read it.
26
+ * Every one of these paths already has a resolver; the template engine already substitutes. The rule
27
+ * makes "restate it" the thing that fails and "render `{{PLACEHOLDER}}` from the resolver" the thing
28
+ * that passes.
29
+ *
30
+ * Diff-scoped like every other code rule, so the docs whose SUBJECT is the layout (they explain both
31
+ * rows on purpose) are not retroactively flooded — the rule bites when a template is next edited.
32
+ * A doc that genuinely has to print the literal says so out loud:
33
+ * `<!-- webpieces-disable no-state-paths-in-templates -- this table IS the layout -->`.
34
+ */
35
+ export declare class NoStatePathsInTemplatesConfig extends BaseRuleConfig {
36
+ mode?: ModifiedCodeMode;
37
+ disableAllowed?: boolean;
38
+ templateDirs?: string[];
39
+ bannedPathPrefixes?: string[];
40
+ static readonly SCHEMA: SchemaShape<NoStatePathsInTemplatesConfig>;
41
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NoStatePathsInTemplatesConfig = exports.DEFAULT_BANNED_STATE_PATH_PREFIXES = exports.DEFAULT_TEMPLATE_DIRS = void 0;
4
+ const rules_sdk_1 = require("@webpieces/rules-sdk");
5
+ const rules_sdk_2 = require("@webpieces/rules-sdk");
6
+ /**
7
+ * The template dirs `no-state-paths-in-templates` looks at when a repo has not said otherwise:
8
+ * webpieces' own instruct-ai templates, which are the generated docs the rule was written for.
9
+ *
10
+ * A consumer repo that generates AI-facing docs from its own templates points `templateDirs` at them;
11
+ * a repo that generates none matches no files and the rule is a no-op. Seeded rather than left empty
12
+ * so the rule arrives doing the job it exists for instead of waiting to be discovered.
13
+ */
14
+ exports.DEFAULT_TEMPLATE_DIRS = ['packages/tooling/rules-config/templates'];
15
+ /**
16
+ * The path prefixes that must never be RESTATED in a generated doc, only computed.
17
+ *
18
+ * `.webpieces/` is the whole webpieces state tree, and every path under it is per-tree: a linked
19
+ * worktree's state lives at `<primary>/.webpieces/worktrees/<name>/…`, so the relative spelling names
20
+ * a file that does not exist there.
21
+ */
22
+ exports.DEFAULT_BANNED_STATE_PATH_PREFIXES = ['.webpieces/'];
23
+ /**
24
+ * Bans a hard-coded state path inside a GENERATED-doc template.
25
+ *
26
+ * The incident: `webpieces.git-workflow.md` restated `.webpieces/logs/branch-mutations.log`. That log
27
+ * is per-worktree, so the doc — regenerated into every governed repo and handed to an agent by
28
+ * absolute path as instruction — named a file that does not exist in half the trees that read it.
29
+ * Every one of these paths already has a resolver; the template engine already substitutes. The rule
30
+ * makes "restate it" the thing that fails and "render `{{PLACEHOLDER}}` from the resolver" the thing
31
+ * that passes.
32
+ *
33
+ * Diff-scoped like every other code rule, so the docs whose SUBJECT is the layout (they explain both
34
+ * rows on purpose) are not retroactively flooded — the rule bites when a template is next edited.
35
+ * A doc that genuinely has to print the literal says so out loud:
36
+ * `<!-- webpieces-disable no-state-paths-in-templates -- this table IS the layout -->`.
37
+ */
38
+ class NoStatePathsInTemplatesConfig extends rules_sdk_1.BaseRuleConfig {
39
+ disableAllowed;
40
+ templateDirs;
41
+ bannedPathPrefixes;
42
+ static SCHEMA = {
43
+ mode: new rules_sdk_1.FieldDef('string', rules_sdk_2.MODIFIED_CODE_MODES),
44
+ disableAllowed: rules_sdk_1.FieldDef.optional('boolean'),
45
+ templateDirs: rules_sdk_1.FieldDef.optional('string[]'),
46
+ bannedPathPrefixes: rules_sdk_1.FieldDef.optional('string[]'),
47
+ ...rules_sdk_1.BASE_RULE_SCHEMA,
48
+ };
49
+ }
50
+ exports.NoStatePathsInTemplatesConfig = NoStatePathsInTemplatesConfig;
51
+ //# sourceMappingURL=no-state-paths-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-state-paths-config.js","sourceRoot":"","sources":["../../../../../../packages/tooling/code-rules/src/configs/no-state-paths-config.ts"],"names":[],"mappings":";;;AAAA,oDAA+F;AAC/F,oDAA6E;AAC7E;;;;;;;GAOG;AACU,QAAA,qBAAqB,GAAsB,CAAC,yCAAyC,CAAC,CAAC;AAEpG;;;;;;GAMG;AACU,QAAA,kCAAkC,GAAsB,CAAC,aAAa,CAAC,CAAC;AAErF;;;;;;;;;;;;;;GAcG;AACH,MAAa,6BAA8B,SAAQ,0BAAc;IAE7D,cAAc,CAAW;IACzB,YAAY,CAAY;IACxB,kBAAkB,CAAY;IAE9B,MAAM,CAAU,MAAM,GAA+C;QACjE,IAAI,EAAE,IAAI,oBAAQ,CAAC,QAAQ,EAAE,+BAAmB,CAAC;QACjD,cAAc,EAAE,oBAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC;QAC5C,YAAY,EAAE,oBAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC;QAC3C,kBAAkB,EAAE,oBAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC;QACjD,GAAG,4BAAgB;KACtB,CAAC;;AAZN,sEAaC","sourcesContent":["import { FieldDef, SchemaShape, BaseRuleConfig, BASE_RULE_SCHEMA } from \"@webpieces/rules-sdk\";\nimport { ModifiedCodeMode, MODIFIED_CODE_MODES } from \"@webpieces/rules-sdk\";\n/**\n * The template dirs `no-state-paths-in-templates` looks at when a repo has not said otherwise:\n * webpieces' own instruct-ai templates, which are the generated docs the rule was written for.\n *\n * A consumer repo that generates AI-facing docs from its own templates points `templateDirs` at them;\n * a repo that generates none matches no files and the rule is a no-op. Seeded rather than left empty\n * so the rule arrives doing the job it exists for instead of waiting to be discovered.\n */\nexport const DEFAULT_TEMPLATE_DIRS: readonly string[] = ['packages/tooling/rules-config/templates'];\n\n/**\n * The path prefixes that must never be RESTATED in a generated doc, only computed.\n *\n * `.webpieces/` is the whole webpieces state tree, and every path under it is per-tree: a linked\n * worktree's state lives at `<primary>/.webpieces/worktrees/<name>/…`, so the relative spelling names\n * a file that does not exist there.\n */\nexport const DEFAULT_BANNED_STATE_PATH_PREFIXES: readonly string[] = ['.webpieces/'];\n\n/**\n * Bans a hard-coded state path inside a GENERATED-doc template.\n *\n * The incident: `webpieces.git-workflow.md` restated `.webpieces/logs/branch-mutations.log`. That log\n * is per-worktree, so the doc — regenerated into every governed repo and handed to an agent by\n * absolute path as instruction — named a file that does not exist in half the trees that read it.\n * Every one of these paths already has a resolver; the template engine already substitutes. The rule\n * makes \"restate it\" the thing that fails and \"render `{{PLACEHOLDER}}` from the resolver\" the thing\n * that passes.\n *\n * Diff-scoped like every other code rule, so the docs whose SUBJECT is the layout (they explain both\n * rows on purpose) are not retroactively flooded — the rule bites when a template is next edited.\n * A doc that genuinely has to print the literal says so out loud:\n * `<!-- webpieces-disable no-state-paths-in-templates -- this table IS the layout -->`.\n */\nexport class NoStatePathsInTemplatesConfig extends BaseRuleConfig {\n declare mode?: ModifiedCodeMode;\n disableAllowed?: boolean;\n templateDirs?: string[];\n bannedPathPrefixes?: string[];\n\n static readonly SCHEMA: SchemaShape<NoStatePathsInTemplatesConfig> = {\n mode: new FieldDef('string', MODIFIED_CODE_MODES),\n disableAllowed: FieldDef.optional('boolean'),\n templateDirs: FieldDef.optional('string[]'),\n bannedPathPrefixes: FieldDef.optional('string[]'),\n ...BASE_RULE_SCHEMA,\n };\n}\n"]}
@@ -0,0 +1,30 @@
1
+ import { SchemaShape, BaseRuleConfig } from "@webpieces/rules-sdk";
2
+ import { ModifiedCodeMode } from "@webpieces/rules-sdk";
3
+ /**
4
+ * `no-utility-types-in-api-lib` (#1026) — in every `.ts` file under `paths`, refuse the TypeScript
5
+ * utility types that turn a contract's field list (or its set of keys) into a type-level computation:
6
+ * `Omit`, `Pick`, `Partial`, `Required`, `Exclude` and `Extract`. Refused wherever a type is written
7
+ * — `interface X extends Omit<…>`, a field type, a type alias, a generic argument.
8
+ *
9
+ * Why the whole family and not `Omit` alone: every one of them makes a reader open a second file and
10
+ * compute the fields (or keys) in their head, none of them can become a DTO class (`class X extends
11
+ * Omit<…>` does not compile — a utility type has no runtime value), and banning `Omit` alone just
12
+ * moves the same computation into `Pick<T, Exclude<keyof T, K>>`. `Record`, `Readonly`, `Array` and
13
+ * friends stay allowed: they do not hide which fields a DTO carries.
14
+ *
15
+ * Every field that decides behaviour is REQUIRED with no default (`.claude/rules/no-rule-defaults.md`):
16
+ * - `mode` — OFF | NEW_AND_MODIFIED_CODE (only changed lines, so existing code is fixed as it is
17
+ * touched) | NEW_AND_MODIFIED_FILES (every occurrence in a changed file) | MODIFIED_PROJECTS /
18
+ * RUN_EVERY_TIME (every occurrence in a touched project / in the repo — #1027).
19
+ * - `paths` — the globs of the API contract libraries this rule judges, e.g. `["libraries/apis/**"]`.
20
+ * An empty list judges nothing.
21
+ *
22
+ * `allowedPaths` exempts whole trees inside `paths`. The per-site escape hatch is
23
+ * `// webpieces-disable no-utility-types-in-api-lib -- <reason>` on the line or the line above.
24
+ */
25
+ export declare class NoUtilityTypesInApiLibConfig extends BaseRuleConfig {
26
+ mode?: ModifiedCodeMode;
27
+ paths: string[];
28
+ allowedPaths?: string[];
29
+ static readonly SCHEMA: SchemaShape<NoUtilityTypesInApiLibConfig>;
30
+ }
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NoUtilityTypesInApiLibConfig = void 0;
4
+ const rules_sdk_1 = require("@webpieces/rules-sdk");
5
+ const rules_sdk_2 = require("@webpieces/rules-sdk");
6
+ /**
7
+ * `no-utility-types-in-api-lib` (#1026) — in every `.ts` file under `paths`, refuse the TypeScript
8
+ * utility types that turn a contract's field list (or its set of keys) into a type-level computation:
9
+ * `Omit`, `Pick`, `Partial`, `Required`, `Exclude` and `Extract`. Refused wherever a type is written
10
+ * — `interface X extends Omit<…>`, a field type, a type alias, a generic argument.
11
+ *
12
+ * Why the whole family and not `Omit` alone: every one of them makes a reader open a second file and
13
+ * compute the fields (or keys) in their head, none of them can become a DTO class (`class X extends
14
+ * Omit<…>` does not compile — a utility type has no runtime value), and banning `Omit` alone just
15
+ * moves the same computation into `Pick<T, Exclude<keyof T, K>>`. `Record`, `Readonly`, `Array` and
16
+ * friends stay allowed: they do not hide which fields a DTO carries.
17
+ *
18
+ * Every field that decides behaviour is REQUIRED with no default (`.claude/rules/no-rule-defaults.md`):
19
+ * - `mode` — OFF | NEW_AND_MODIFIED_CODE (only changed lines, so existing code is fixed as it is
20
+ * touched) | NEW_AND_MODIFIED_FILES (every occurrence in a changed file) | MODIFIED_PROJECTS /
21
+ * RUN_EVERY_TIME (every occurrence in a touched project / in the repo — #1027).
22
+ * - `paths` — the globs of the API contract libraries this rule judges, e.g. `["libraries/apis/**"]`.
23
+ * An empty list judges nothing.
24
+ *
25
+ * `allowedPaths` exempts whole trees inside `paths`. The per-site escape hatch is
26
+ * `// webpieces-disable no-utility-types-in-api-lib -- <reason>` on the line or the line above.
27
+ */
28
+ class NoUtilityTypesInApiLibConfig extends rules_sdk_1.BaseRuleConfig {
29
+ paths;
30
+ allowedPaths;
31
+ static SCHEMA = {
32
+ mode: new rules_sdk_1.FieldDef('string', rules_sdk_2.MODIFIED_CODE_MODES),
33
+ paths: new rules_sdk_1.FieldDef('string[]'),
34
+ allowedPaths: rules_sdk_1.FieldDef.optional('string[]'),
35
+ ...rules_sdk_1.BASE_RULE_SCHEMA,
36
+ };
37
+ }
38
+ exports.NoUtilityTypesInApiLibConfig = NoUtilityTypesInApiLibConfig;
39
+ //# sourceMappingURL=no-utility-types-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-utility-types-config.js","sourceRoot":"","sources":["../../../../../../packages/tooling/code-rules/src/configs/no-utility-types-config.ts"],"names":[],"mappings":";;;AAAA,oDAA+F;AAC/F,oDAA6E;AAC7E;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAa,4BAA6B,SAAQ,0BAAc;IAE5D,KAAK,CAAY;IACjB,YAAY,CAAY;IAExB,MAAM,CAAU,MAAM,GAA8C;QAChE,IAAI,EAAE,IAAI,oBAAQ,CAAC,QAAQ,EAAE,+BAAmB,CAAC;QACjD,KAAK,EAAE,IAAI,oBAAQ,CAAC,UAAU,CAAC;QAC/B,YAAY,EAAE,oBAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC;QAC3C,GAAG,4BAAgB;KACtB,CAAC;;AAVN,oEAWC","sourcesContent":["import { FieldDef, SchemaShape, BaseRuleConfig, BASE_RULE_SCHEMA } from \"@webpieces/rules-sdk\";\nimport { ModifiedCodeMode, MODIFIED_CODE_MODES } from \"@webpieces/rules-sdk\";\n/**\n * `no-utility-types-in-api-lib` (#1026) — in every `.ts` file under `paths`, refuse the TypeScript\n * utility types that turn a contract's field list (or its set of keys) into a type-level computation:\n * `Omit`, `Pick`, `Partial`, `Required`, `Exclude` and `Extract`. Refused wherever a type is written\n * — `interface X extends Omit<…>`, a field type, a type alias, a generic argument.\n *\n * Why the whole family and not `Omit` alone: every one of them makes a reader open a second file and\n * compute the fields (or keys) in their head, none of them can become a DTO class (`class X extends\n * Omit<…>` does not compile — a utility type has no runtime value), and banning `Omit` alone just\n * moves the same computation into `Pick<T, Exclude<keyof T, K>>`. `Record`, `Readonly`, `Array` and\n * friends stay allowed: they do not hide which fields a DTO carries.\n *\n * Every field that decides behaviour is REQUIRED with no default (`.claude/rules/no-rule-defaults.md`):\n * - `mode` — OFF | NEW_AND_MODIFIED_CODE (only changed lines, so existing code is fixed as it is\n * touched) | NEW_AND_MODIFIED_FILES (every occurrence in a changed file) | MODIFIED_PROJECTS /\n * RUN_EVERY_TIME (every occurrence in a touched project / in the repo — #1027).\n * - `paths` — the globs of the API contract libraries this rule judges, e.g. `[\"libraries/apis/**\"]`.\n * An empty list judges nothing.\n *\n * `allowedPaths` exempts whole trees inside `paths`. The per-site escape hatch is\n * `// webpieces-disable no-utility-types-in-api-lib -- <reason>` on the line or the line above.\n */\nexport class NoUtilityTypesInApiLibConfig extends BaseRuleConfig {\n declare mode?: ModifiedCodeMode;\n paths!: string[];\n allowedPaths?: string[];\n\n static readonly SCHEMA: SchemaShape<NoUtilityTypesInApiLibConfig> = {\n mode: new FieldDef('string', MODIFIED_CODE_MODES),\n paths: new FieldDef('string[]'),\n allowedPaths: FieldDef.optional('string[]'),\n ...BASE_RULE_SCHEMA,\n };\n}\n"]}
@@ -0,0 +1,49 @@
1
+ import { SchemaShape, BaseRuleConfig } from "@webpieces/rules-sdk";
2
+ import { ModifiedCodeMode } from "@webpieces/rules-sdk";
3
+ /**
4
+ * One `required-type-suffix` entry: the path globs it covers and the suffixes a type exported from a
5
+ * file under them may end in. Data-only.
6
+ */
7
+ export declare class RequiredTypeSuffixEntry {
8
+ /** Workspace-relative globs, e.g. `["libraries/apis/internal/**"]`. Non-empty. */
9
+ paths: string[];
10
+ /** Case-sensitive name suffixes, e.g. `["Request", "Response", "Event", "Dto", "Api"]`. Non-empty. */
11
+ suffixes: string[];
12
+ static readonly SCHEMA: SchemaShape<RequiredTypeSuffixEntry>;
13
+ }
14
+ /**
15
+ * `required-type-suffix` (#1037) — every EXPORTED `interface`, `class` (abstract too), `enum` and `type`
16
+ * alias in a non-test `.ts` file under an entry's `paths` must end in one of that entry's `suffixes`
17
+ * (plain, case-sensitive `endsWith`; the suffix alone is not a name). Why: the suffix tells a reader which
18
+ * LAYER a type belongs to — a `…Dto` is on the wire, a `…Fs` is a Firestore document — where an
19
+ * unsuffixed name reads the same as a server-internal or vendor type.
20
+ *
21
+ * Every field that decides behaviour is REQUIRED with no default (`.claude/rules/no-rule-defaults.md`):
22
+ * - `mode` — OFF | NEW_AND_MODIFIED_CODE (only a type whose declaration line is new or changed — a new or
23
+ * renamed type — so legacy names are grandfathered) | NEW_AND_MODIFIED_FILES (every exported type in a
24
+ * changed file) | MODIFIED_PROJECTS / RUN_EVERY_TIME (every exported type in each touched project / the
25
+ * whole repo — #1027).
26
+ * - `entries` — non-empty; each entry has non-empty `paths` and `suffixes`. For example:
27
+ *
28
+ * "entries": [
29
+ * { "paths": ["libraries/apis/internal/**"], "suffixes": ["Request", "Response", "Event", "Dto", "Api"] },
30
+ * { "paths": ["libraries/browser-node/fs-*-model/**"], "suffixes": ["Fs"] }
31
+ * ]
32
+ *
33
+ * OVERLAP — the FIRST MATCH in `entries` order wins; suffixes are never unioned. A file is governed by
34
+ * exactly one entry: the entries are read top to bottom, and the first one with a glob matching the file
35
+ * decides its suffixes. ORDER MATTERS: a narrower entry must be listed BEFORE a broader one. With
36
+ * `libraries/apis/internal/**` listed above `libraries/apis/**`, the narrower entry governs
37
+ * `libraries/apis/internal/x/src/A.ts`; listed below it, the broader entry governs that file and the
38
+ * narrower one never applies there. A failure names the governing entry's glob, so a reader can see
39
+ * which entry won.
40
+ *
41
+ * `allowedPaths` exempts whole trees inside `paths`. The per-site escape hatch is
42
+ * `// webpieces-disable required-type-suffix -- <reason>` on the declaration's line or the line above.
43
+ */
44
+ export declare class RequiredTypeSuffixConfig extends BaseRuleConfig {
45
+ mode?: ModifiedCodeMode;
46
+ entries: RequiredTypeSuffixEntry[];
47
+ allowedPaths?: string[];
48
+ static readonly SCHEMA: SchemaShape<RequiredTypeSuffixConfig>;
49
+ }
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RequiredTypeSuffixConfig = exports.RequiredTypeSuffixEntry = void 0;
4
+ const rules_sdk_1 = require("@webpieces/rules-sdk");
5
+ const rules_sdk_2 = require("@webpieces/rules-sdk");
6
+ /**
7
+ * One `required-type-suffix` entry: the path globs it covers and the suffixes a type exported from a
8
+ * file under them may end in. Data-only.
9
+ */
10
+ class RequiredTypeSuffixEntry {
11
+ /** Workspace-relative globs, e.g. `["libraries/apis/internal/**"]`. Non-empty. */
12
+ paths;
13
+ /** Case-sensitive name suffixes, e.g. `["Request", "Response", "Event", "Dto", "Api"]`. Non-empty. */
14
+ suffixes;
15
+ static SCHEMA = {
16
+ paths: rules_sdk_1.FieldDef.nonEmptyStrings(),
17
+ suffixes: rules_sdk_1.FieldDef.nonEmptyStrings(),
18
+ };
19
+ }
20
+ exports.RequiredTypeSuffixEntry = RequiredTypeSuffixEntry;
21
+ /**
22
+ * `required-type-suffix` (#1037) — every EXPORTED `interface`, `class` (abstract too), `enum` and `type`
23
+ * alias in a non-test `.ts` file under an entry's `paths` must end in one of that entry's `suffixes`
24
+ * (plain, case-sensitive `endsWith`; the suffix alone is not a name). Why: the suffix tells a reader which
25
+ * LAYER a type belongs to — a `…Dto` is on the wire, a `…Fs` is a Firestore document — where an
26
+ * unsuffixed name reads the same as a server-internal or vendor type.
27
+ *
28
+ * Every field that decides behaviour is REQUIRED with no default (`.claude/rules/no-rule-defaults.md`):
29
+ * - `mode` — OFF | NEW_AND_MODIFIED_CODE (only a type whose declaration line is new or changed — a new or
30
+ * renamed type — so legacy names are grandfathered) | NEW_AND_MODIFIED_FILES (every exported type in a
31
+ * changed file) | MODIFIED_PROJECTS / RUN_EVERY_TIME (every exported type in each touched project / the
32
+ * whole repo — #1027).
33
+ * - `entries` — non-empty; each entry has non-empty `paths` and `suffixes`. For example:
34
+ *
35
+ * "entries": [
36
+ * { "paths": ["libraries/apis/internal/**"], "suffixes": ["Request", "Response", "Event", "Dto", "Api"] },
37
+ * { "paths": ["libraries/browser-node/fs-*-model/**"], "suffixes": ["Fs"] }
38
+ * ]
39
+ *
40
+ * OVERLAP — the FIRST MATCH in `entries` order wins; suffixes are never unioned. A file is governed by
41
+ * exactly one entry: the entries are read top to bottom, and the first one with a glob matching the file
42
+ * decides its suffixes. ORDER MATTERS: a narrower entry must be listed BEFORE a broader one. With
43
+ * `libraries/apis/internal/**` listed above `libraries/apis/**`, the narrower entry governs
44
+ * `libraries/apis/internal/x/src/A.ts`; listed below it, the broader entry governs that file and the
45
+ * narrower one never applies there. A failure names the governing entry's glob, so a reader can see
46
+ * which entry won.
47
+ *
48
+ * `allowedPaths` exempts whole trees inside `paths`. The per-site escape hatch is
49
+ * `// webpieces-disable required-type-suffix -- <reason>` on the declaration's line or the line above.
50
+ */
51
+ class RequiredTypeSuffixConfig extends rules_sdk_1.BaseRuleConfig {
52
+ entries;
53
+ allowedPaths;
54
+ static SCHEMA = {
55
+ mode: new rules_sdk_1.FieldDef('string', rules_sdk_2.MODIFIED_CODE_MODES),
56
+ entries: rules_sdk_1.FieldDef.nonEmptyObjects(RequiredTypeSuffixEntry.SCHEMA),
57
+ allowedPaths: rules_sdk_1.FieldDef.optional('string[]'),
58
+ ...rules_sdk_1.BASE_RULE_SCHEMA,
59
+ };
60
+ }
61
+ exports.RequiredTypeSuffixConfig = RequiredTypeSuffixConfig;
62
+ //# sourceMappingURL=required-type-suffix-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"required-type-suffix-config.js","sourceRoot":"","sources":["../../../../../../packages/tooling/code-rules/src/configs/required-type-suffix-config.ts"],"names":[],"mappings":";;;AAAA,oDAA+F;AAC/F,oDAA6E;AAC7E;;;GAGG;AACH,MAAa,uBAAuB;IAChC,kFAAkF;IAClF,KAAK,CAAY;IACjB,sGAAsG;IACtG,QAAQ,CAAY;IAEpB,MAAM,CAAU,MAAM,GAAyC;QAC3D,KAAK,EAAE,oBAAQ,CAAC,eAAe,EAAE;QACjC,QAAQ,EAAE,oBAAQ,CAAC,eAAe,EAAE;KACvC,CAAC;;AATN,0DAUC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAa,wBAAyB,SAAQ,0BAAc;IAExD,OAAO,CAA6B;IACpC,YAAY,CAAY;IAExB,MAAM,CAAU,MAAM,GAA0C;QAC5D,IAAI,EAAE,IAAI,oBAAQ,CAAC,QAAQ,EAAE,+BAAmB,CAAC;QACjD,OAAO,EAAE,oBAAQ,CAAC,eAAe,CAAC,uBAAuB,CAAC,MAAM,CAAC;QACjE,YAAY,EAAE,oBAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC;QAC3C,GAAG,4BAAgB;KACtB,CAAC;;AAVN,4DAWC","sourcesContent":["import { FieldDef, SchemaShape, BaseRuleConfig, BASE_RULE_SCHEMA } from \"@webpieces/rules-sdk\";\nimport { ModifiedCodeMode, MODIFIED_CODE_MODES } from \"@webpieces/rules-sdk\";\n/**\n * One `required-type-suffix` entry: the path globs it covers and the suffixes a type exported from a\n * file under them may end in. Data-only.\n */\nexport class RequiredTypeSuffixEntry {\n /** Workspace-relative globs, e.g. `[\"libraries/apis/internal/**\"]`. Non-empty. */\n paths!: string[];\n /** Case-sensitive name suffixes, e.g. `[\"Request\", \"Response\", \"Event\", \"Dto\", \"Api\"]`. Non-empty. */\n suffixes!: string[];\n\n static readonly SCHEMA: SchemaShape<RequiredTypeSuffixEntry> = {\n paths: FieldDef.nonEmptyStrings(),\n suffixes: FieldDef.nonEmptyStrings(),\n };\n}\n\n/**\n * `required-type-suffix` (#1037) — every EXPORTED `interface`, `class` (abstract too), `enum` and `type`\n * alias in a non-test `.ts` file under an entry's `paths` must end in one of that entry's `suffixes`\n * (plain, case-sensitive `endsWith`; the suffix alone is not a name). Why: the suffix tells a reader which\n * LAYER a type belongs to — a `…Dto` is on the wire, a `…Fs` is a Firestore document — where an\n * unsuffixed name reads the same as a server-internal or vendor type.\n *\n * Every field that decides behaviour is REQUIRED with no default (`.claude/rules/no-rule-defaults.md`):\n * - `mode` — OFF | NEW_AND_MODIFIED_CODE (only a type whose declaration line is new or changed — a new or\n * renamed type — so legacy names are grandfathered) | NEW_AND_MODIFIED_FILES (every exported type in a\n * changed file) | MODIFIED_PROJECTS / RUN_EVERY_TIME (every exported type in each touched project / the\n * whole repo — #1027).\n * - `entries` — non-empty; each entry has non-empty `paths` and `suffixes`. For example:\n *\n * \"entries\": [\n * { \"paths\": [\"libraries/apis/internal/**\"], \"suffixes\": [\"Request\", \"Response\", \"Event\", \"Dto\", \"Api\"] },\n * { \"paths\": [\"libraries/browser-node/fs-*-model/**\"], \"suffixes\": [\"Fs\"] }\n * ]\n *\n * OVERLAP — the FIRST MATCH in `entries` order wins; suffixes are never unioned. A file is governed by\n * exactly one entry: the entries are read top to bottom, and the first one with a glob matching the file\n * decides its suffixes. ORDER MATTERS: a narrower entry must be listed BEFORE a broader one. With\n * `libraries/apis/internal/**` listed above `libraries/apis/**`, the narrower entry governs\n * `libraries/apis/internal/x/src/A.ts`; listed below it, the broader entry governs that file and the\n * narrower one never applies there. A failure names the governing entry's glob, so a reader can see\n * which entry won.\n *\n * `allowedPaths` exempts whole trees inside `paths`. The per-site escape hatch is\n * `// webpieces-disable required-type-suffix -- <reason>` on the declaration's line or the line above.\n */\nexport class RequiredTypeSuffixConfig extends BaseRuleConfig {\n declare mode?: ModifiedCodeMode;\n entries!: RequiredTypeSuffixEntry[];\n allowedPaths?: string[];\n\n static readonly SCHEMA: SchemaShape<RequiredTypeSuffixConfig> = {\n mode: new FieldDef('string', MODIFIED_CODE_MODES),\n entries: FieldDef.nonEmptyObjects(RequiredTypeSuffixEntry.SCHEMA),\n allowedPaths: FieldDef.optional('string[]'),\n ...BASE_RULE_SCHEMA,\n };\n}\n"]}
@@ -0,0 +1,131 @@
1
+ import { FileLimitMode, ModifiedCodeMode } from "@webpieces/rules-sdk";
2
+ import { BaseRuleConfig } from "@webpieces/rules-sdk";
3
+ import { SchemaShape } from "@webpieces/rules-sdk";
4
+ export declare const METHOD_LIMIT_MODES: readonly ["OFF", "NEW_METHODS", "NEW_AND_MODIFIED_METHODS", "NEW_AND_MODIFIED_FILES"];
5
+ export type MethodLimitMode = typeof METHOD_LIMIT_MODES[number];
6
+ export declare const RETURN_TYPE_MODES: readonly ["OFF", "NEW_METHODS", "NEW_AND_MODIFIED_METHODS", "NEW_AND_MODIFIED_FILES"];
7
+ export type ReturnTypeMode = typeof RETURN_TYPE_MODES[number];
8
+ export declare const INLINE_TYPE_MODES: readonly ["OFF", "NEW_METHODS", "NEW_AND_MODIFIED_METHODS", "NEW_AND_MODIFIED_FILES"];
9
+ export type InlineTypeMode = typeof INLINE_TYPE_MODES[number];
10
+ export declare const PROJECT_MODES: readonly ["OFF", "MODIFIED_PROJECTS"];
11
+ export type ProjectMode = typeof PROJECT_MODES[number];
12
+ export declare const PRISMA_DTOS_MODES: readonly ["OFF", "MODIFIED_CLASS", "NEW_AND_MODIFIED_FILES"];
13
+ export type PrismaValidateDtosMode = typeof PRISMA_DTOS_MODES[number];
14
+ export declare const PRISMA_CONVERTER_MODES: readonly ["OFF", "NEW_AND_MODIFIED_METHODS", "NEW_AND_MODIFIED_FILES"];
15
+ export type PrismaConverterMode = typeof PRISMA_CONVERTER_MODES[number];
16
+ export declare const DIRECT_API_RESOLVER_MODES: readonly ["OFF", "NEW_AND_MODIFIED_CODE", "NEW_AND_MODIFIED_METHODS", "NEW_AND_MODIFIED_FILES"];
17
+ export type DirectApiResolverMode = typeof DIRECT_API_RESOLVER_MODES[number];
18
+ export declare class MaxMethodLinesConfig extends BaseRuleConfig {
19
+ mode?: MethodLimitMode;
20
+ limit?: number;
21
+ disableAllowed?: boolean;
22
+ static readonly SCHEMA: SchemaShape<MaxMethodLinesConfig>;
23
+ }
24
+ export declare class MaxFileLinesConfig extends BaseRuleConfig {
25
+ mode?: FileLimitMode;
26
+ limit?: number;
27
+ disableAllowed?: boolean;
28
+ allowedPaths?: string[];
29
+ static readonly SCHEMA: SchemaShape<MaxFileLinesConfig>;
30
+ }
31
+ export declare class RequireReturnTypeConfig extends BaseRuleConfig {
32
+ mode?: ReturnTypeMode;
33
+ disableAllowed?: boolean;
34
+ static readonly SCHEMA: SchemaShape<RequireReturnTypeConfig>;
35
+ }
36
+ export declare class NoInlineTypeLiteralsConfig extends BaseRuleConfig {
37
+ mode?: InlineTypeMode;
38
+ disableAllowed?: boolean;
39
+ static readonly SCHEMA: SchemaShape<NoInlineTypeLiteralsConfig>;
40
+ }
41
+ export declare class NoAnyUnknownConfig extends BaseRuleConfig {
42
+ mode?: ModifiedCodeMode;
43
+ disableAllowed?: boolean;
44
+ static readonly SCHEMA: SchemaShape<NoAnyUnknownConfig>;
45
+ }
46
+ export declare class NoImplicitAnyConfig extends BaseRuleConfig {
47
+ mode?: ModifiedCodeMode;
48
+ disableAllowed?: boolean;
49
+ static readonly SCHEMA: SchemaShape<NoImplicitAnyConfig>;
50
+ }
51
+ export declare class PrismaValidateDtosConfig extends BaseRuleConfig {
52
+ mode?: PrismaValidateDtosMode;
53
+ disableAllowed?: boolean;
54
+ prismaSchemaPath?: string;
55
+ dtoSourcePaths?: string[];
56
+ static readonly SCHEMA: SchemaShape<PrismaValidateDtosConfig>;
57
+ }
58
+ export declare class PrismaConverterConfig extends BaseRuleConfig {
59
+ mode?: PrismaConverterMode;
60
+ disableAllowed?: boolean;
61
+ schemaPath?: string;
62
+ convertersPaths?: string[];
63
+ enforcePaths?: string[];
64
+ static readonly SCHEMA: SchemaShape<PrismaConverterConfig>;
65
+ }
66
+ export declare class NoDestructureConfig extends BaseRuleConfig {
67
+ mode?: ModifiedCodeMode;
68
+ allowTopLevel?: boolean;
69
+ disableAllowed?: boolean;
70
+ allowedPaths?: string[];
71
+ static readonly SCHEMA: SchemaShape<NoDestructureConfig>;
72
+ }
73
+ export declare class NoUnmanagedExceptionsConfig extends BaseRuleConfig {
74
+ mode?: ModifiedCodeMode;
75
+ disableAllowed?: boolean;
76
+ static readonly SCHEMA: SchemaShape<NoUnmanagedExceptionsConfig>;
77
+ }
78
+ export declare class CatchErrorPatternConfig extends BaseRuleConfig {
79
+ mode?: ModifiedCodeMode;
80
+ disableAllowed?: boolean;
81
+ static readonly SCHEMA: SchemaShape<CatchErrorPatternConfig>;
82
+ }
83
+ export declare class AngularNoDirectApiInResolverConfig extends BaseRuleConfig {
84
+ mode?: DirectApiResolverMode;
85
+ disableAllowed?: boolean;
86
+ enforcePaths?: string[];
87
+ static readonly SCHEMA: SchemaShape<AngularNoDirectApiInResolverConfig>;
88
+ }
89
+ export declare class NoCustomCssConfig extends BaseRuleConfig {
90
+ mode?: ModifiedCodeMode;
91
+ disableAllowed?: boolean;
92
+ allowGlobs?: string[];
93
+ static readonly SCHEMA: SchemaShape<NoCustomCssConfig>;
94
+ }
95
+ export declare class NoSymbolDiTokensConfig extends BaseRuleConfig {
96
+ mode?: ModifiedCodeMode;
97
+ disableAllowed?: boolean;
98
+ allowedPaths?: string[];
99
+ static readonly SCHEMA: SchemaShape<NoSymbolDiTokensConfig>;
100
+ }
101
+ export declare class NoProcessExitOutsideMainConfig extends BaseRuleConfig {
102
+ mode?: ModifiedCodeMode;
103
+ disableAllowed?: boolean;
104
+ static readonly SCHEMA: SchemaShape<NoProcessExitOutsideMainConfig>;
105
+ }
106
+ export declare class NoFunctionOutsideClassConfig extends BaseRuleConfig {
107
+ mode?: ModifiedCodeMode;
108
+ disableAllowed?: boolean;
109
+ allowedPaths?: string[];
110
+ static readonly SCHEMA: SchemaShape<NoFunctionOutsideClassConfig>;
111
+ }
112
+ export declare class InjectAnnotationNotNeededForConcreteClassConfig extends BaseRuleConfig {
113
+ mode?: ModifiedCodeMode;
114
+ disableAllowed?: boolean;
115
+ allowedPaths?: string[];
116
+ static readonly SCHEMA: SchemaShape<InjectAnnotationNotNeededForConcreteClassConfig>;
117
+ }
118
+ export declare class FrameworkTagConfig extends BaseRuleConfig {
119
+ mode?: ProjectMode;
120
+ knownTypes?: string[];
121
+ static readonly SCHEMA: SchemaShape<FrameworkTagConfig>;
122
+ }
123
+ export declare class RoleTagConfig extends BaseRuleConfig {
124
+ mode?: ProjectMode;
125
+ knownTypes?: string[];
126
+ static readonly SCHEMA: SchemaShape<RoleTagConfig>;
127
+ }
128
+ export declare class EnsureWeAreSecureConfig extends BaseRuleConfig {
129
+ mode?: ProjectMode;
130
+ static readonly SCHEMA: SchemaShape<EnsureWeAreSecureConfig>;
131
+ }