@codeperfect/eslint-plugin 3.7.0 → 3.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/README.md +11 -19
  2. package/dist/adapters/angular/angular-lifecycle-usage-adapter.d.ts +15 -0
  3. package/dist/adapters/angular/angular-lifecycle-usage-adapter.d.ts.map +1 -0
  4. package/dist/adapters/angular/angular-lifecycle-usage-adapter.js +87 -0
  5. package/dist/adapters/angular/angular-template-expression-utilities.js +2 -2
  6. package/dist/adapters/angular/angular-template-usage-context.d.ts +1 -1
  7. package/dist/adapters/angular/angular-template-usage-context.d.ts.map +1 -1
  8. package/dist/adapters/angular/angular-template-usage-context.js +2 -2
  9. package/dist/adapters/angular/no-unused-public-members-template-adapter.js +2 -2
  10. package/dist/adapters/angular/plugin.d.ts.map +1 -1
  11. package/dist/adapters/angular/plugin.js +7 -3
  12. package/dist/codeperfect-eslint-plugin-1.0.0.tgz +0 -0
  13. package/dist/domain/architecture/consistent-barrel-files/exports-only-rule-utilities.d.ts +39 -0
  14. package/dist/domain/architecture/consistent-barrel-files/exports-only-rule-utilities.d.ts.map +1 -0
  15. package/dist/domain/architecture/consistent-barrel-files/exports-only-rule-utilities.js +131 -0
  16. package/dist/domain/architecture/consistent-barrel-files/exports-only-rule.d.ts.map +1 -1
  17. package/dist/domain/architecture/consistent-barrel-files/exports-only-rule.js +12 -1
  18. package/dist/domain/architecture/index.d.ts +2 -0
  19. package/dist/domain/architecture/index.d.ts.map +1 -1
  20. package/dist/domain/architecture/index.js +3 -1
  21. package/dist/domain/architecture/no-directory-only-imports/index.d.ts +2 -0
  22. package/dist/domain/architecture/no-directory-only-imports/index.d.ts.map +1 -0
  23. package/dist/domain/architecture/no-directory-only-imports/index.js +2 -0
  24. package/dist/domain/architecture/no-directory-only-imports/no-directory-only-imports-rule.d.ts +5 -0
  25. package/dist/domain/architecture/no-directory-only-imports/no-directory-only-imports-rule.d.ts.map +1 -0
  26. package/dist/domain/architecture/no-directory-only-imports/no-directory-only-imports-rule.js +83 -0
  27. package/dist/domain/architecture/no-unused-exports/no-unused-exports-identifier-utilities.d.ts +1 -1
  28. package/dist/domain/architecture/no-unused-exports/no-unused-exports-identifier-utilities.d.ts.map +1 -1
  29. package/dist/domain/architecture/no-unused-exports/no-unused-exports-identifier-utilities.js +2 -2
  30. package/dist/domain/architecture/no-unused-exports/no-unused-exports-symbol-utilities.d.ts +1 -1
  31. package/dist/domain/architecture/no-unused-exports/no-unused-exports-symbol-utilities.d.ts.map +1 -1
  32. package/dist/domain/architecture/no-unused-exports/no-unused-exports-symbol-utilities.js +2 -2
  33. package/dist/domain/architecture/no-unused-exports/no-unused-exports-usage-index-builder.d.ts +1 -1
  34. package/dist/domain/architecture/no-unused-exports/no-unused-exports-usage-index-builder.d.ts.map +1 -1
  35. package/dist/domain/architecture/no-unused-exports/no-unused-exports-usage-index-builder.js +2 -2
  36. package/dist/domain/architecture/no-unused-exports/no-unused-exports-usage-index.d.ts +1 -1
  37. package/dist/domain/architecture/no-unused-exports/no-unused-exports-usage-index.d.ts.map +1 -1
  38. package/dist/domain/architecture/no-unused-exports/no-unused-exports-usage-index.js +2 -2
  39. package/dist/domain/architecture/no-unused-exports/rule.d.ts +14 -1
  40. package/dist/domain/architecture/no-unused-exports/rule.d.ts.map +1 -1
  41. package/dist/domain/architecture/no-unused-exports/rule.js +17 -4
  42. package/dist/domain/architecture/no-unused-public-members/member-api-reachability-utilities.d.ts +1 -1
  43. package/dist/domain/architecture/no-unused-public-members/member-api-reachability-utilities.d.ts.map +1 -1
  44. package/dist/domain/architecture/no-unused-public-members/member-api-reachability-utilities.js +2 -2
  45. package/dist/domain/architecture/no-unused-public-members/member-api-relevance-utilities.d.ts +1 -1
  46. package/dist/domain/architecture/no-unused-public-members/member-api-relevance-utilities.d.ts.map +1 -1
  47. package/dist/domain/architecture/no-unused-public-members/member-api-relevance-utilities.js +2 -2
  48. package/dist/domain/architecture/no-unused-public-members/member-api-type-utilities.d.ts +1 -1
  49. package/dist/domain/architecture/no-unused-public-members/member-api-type-utilities.d.ts.map +1 -1
  50. package/dist/domain/architecture/no-unused-public-members/member-api-type-utilities.js +2 -2
  51. package/dist/domain/architecture/no-unused-public-members/member-contract-utilities.d.ts +1 -1
  52. package/dist/domain/architecture/no-unused-public-members/member-contract-utilities.d.ts.map +1 -1
  53. package/dist/domain/architecture/no-unused-public-members/member-contract-utilities.js +13 -2
  54. package/dist/domain/architecture/no-unused-public-members/member-declaration-utilities.d.ts +1 -1
  55. package/dist/domain/architecture/no-unused-public-members/member-declaration-utilities.d.ts.map +1 -1
  56. package/dist/domain/architecture/no-unused-public-members/member-declaration-utilities.js +9 -4
  57. package/dist/domain/architecture/no-unused-public-members/member-factory-utilities.d.ts +1 -1
  58. package/dist/domain/architecture/no-unused-public-members/member-factory-utilities.d.ts.map +1 -1
  59. package/dist/domain/architecture/no-unused-public-members/member-factory-utilities.js +2 -2
  60. package/dist/domain/architecture/no-unused-public-members/member-function-utilities.d.ts +1 -1
  61. package/dist/domain/architecture/no-unused-public-members/member-function-utilities.d.ts.map +1 -1
  62. package/dist/domain/architecture/no-unused-public-members/member-function-utilities.js +2 -2
  63. package/dist/domain/architecture/no-unused-public-members/member-host-utilities.d.ts +3 -3
  64. package/dist/domain/architecture/no-unused-public-members/member-host-utilities.d.ts.map +1 -1
  65. package/dist/domain/architecture/no-unused-public-members/member-host-utilities.js +40 -25
  66. package/dist/domain/architecture/no-unused-public-members/member-operation-utilities.d.ts +1 -1
  67. package/dist/domain/architecture/no-unused-public-members/member-operation-utilities.d.ts.map +1 -1
  68. package/dist/domain/architecture/no-unused-public-members/member-operation-utilities.js +2 -2
  69. package/dist/domain/architecture/no-unused-public-members/member-parameter-flow-utilities.d.ts +1 -1
  70. package/dist/domain/architecture/no-unused-public-members/member-parameter-flow-utilities.d.ts.map +1 -1
  71. package/dist/domain/architecture/no-unused-public-members/member-parameter-flow-utilities.js +2 -2
  72. package/dist/domain/architecture/no-unused-public-members/member-public-api-utilities.d.ts +1 -1
  73. package/dist/domain/architecture/no-unused-public-members/member-public-api-utilities.d.ts.map +1 -1
  74. package/dist/domain/architecture/no-unused-public-members/member-public-api-utilities.js +2 -2
  75. package/dist/domain/architecture/no-unused-public-members/member-request-body-utilities.d.ts +1 -1
  76. package/dist/domain/architecture/no-unused-public-members/member-request-body-utilities.d.ts.map +1 -1
  77. package/dist/domain/architecture/no-unused-public-members/member-request-body-utilities.js +2 -2
  78. package/dist/domain/architecture/no-unused-public-members/member-scope-utilities.d.ts +1 -1
  79. package/dist/domain/architecture/no-unused-public-members/member-scope-utilities.d.ts.map +1 -1
  80. package/dist/domain/architecture/no-unused-public-members/member-scope-utilities.js +39 -15
  81. package/dist/domain/architecture/no-unused-public-members/member-usage-call-utilities.d.ts +1 -1
  82. package/dist/domain/architecture/no-unused-public-members/member-usage-call-utilities.d.ts.map +1 -1
  83. package/dist/domain/architecture/no-unused-public-members/member-usage-call-utilities.js +2 -2
  84. package/dist/domain/architecture/no-unused-public-members/member-usage-expression-reference-utilities.d.ts +1 -1
  85. package/dist/domain/architecture/no-unused-public-members/member-usage-expression-reference-utilities.d.ts.map +1 -1
  86. package/dist/domain/architecture/no-unused-public-members/member-usage-expression-reference-utilities.js +2 -2
  87. package/dist/domain/architecture/no-unused-public-members/member-usage-handoff-utilities.d.ts +1 -1
  88. package/dist/domain/architecture/no-unused-public-members/member-usage-handoff-utilities.d.ts.map +1 -1
  89. package/dist/domain/architecture/no-unused-public-members/member-usage-handoff-utilities.js +2 -2
  90. package/dist/domain/architecture/no-unused-public-members/member-usage-index-utilities.d.ts +1 -1
  91. package/dist/domain/architecture/no-unused-public-members/member-usage-index-utilities.d.ts.map +1 -1
  92. package/dist/domain/architecture/no-unused-public-members/member-usage-index-utilities.js +2 -2
  93. package/dist/domain/architecture/no-unused-public-members/member-usage-local-flow-utilities.d.ts +1 -1
  94. package/dist/domain/architecture/no-unused-public-members/member-usage-local-flow-utilities.d.ts.map +1 -1
  95. package/dist/domain/architecture/no-unused-public-members/member-usage-local-flow-utilities.js +2 -2
  96. package/dist/domain/architecture/no-unused-public-members/member-usage-reference-utilities.d.ts +1 -1
  97. package/dist/domain/architecture/no-unused-public-members/member-usage-reference-utilities.d.ts.map +1 -1
  98. package/dist/domain/architecture/no-unused-public-members/member-usage-reference-utilities.js +2 -2
  99. package/dist/domain/architecture/no-unused-public-members/member-usage-serialization-utilities.d.ts +1 -1
  100. package/dist/domain/architecture/no-unused-public-members/member-usage-serialization-utilities.d.ts.map +1 -1
  101. package/dist/domain/architecture/no-unused-public-members/member-usage-serialization-utilities.js +2 -2
  102. package/dist/domain/architecture/no-unused-public-members/member-usage-type-utilities.d.ts +1 -1
  103. package/dist/domain/architecture/no-unused-public-members/member-usage-type-utilities.d.ts.map +1 -1
  104. package/dist/domain/architecture/no-unused-public-members/member-usage-type-utilities.js +2 -2
  105. package/dist/domain/architecture/no-unused-public-members/member-usage-utilities.d.ts +1 -1
  106. package/dist/domain/architecture/no-unused-public-members/member-usage-utilities.d.ts.map +1 -1
  107. package/dist/domain/architecture/no-unused-public-members/member-usage-utilities.js +13 -2
  108. package/dist/domain/architecture/no-unused-public-members/member-usage-value-utilities.d.ts +1 -1
  109. package/dist/domain/architecture/no-unused-public-members/member-usage-value-utilities.d.ts.map +1 -1
  110. package/dist/domain/architecture/no-unused-public-members/member-usage-value-utilities.js +2 -2
  111. package/dist/domain/architecture/no-unused-public-members/member-usage-whole-object-utilities.d.ts +1 -1
  112. package/dist/domain/architecture/no-unused-public-members/member-usage-whole-object-utilities.d.ts.map +1 -1
  113. package/dist/domain/architecture/no-unused-public-members/member-usage-whole-object-utilities.js +2 -2
  114. package/dist/domain/architecture/no-unused-public-members/member-utilities.d.ts +1 -1
  115. package/dist/domain/architecture/no-unused-public-members/member-utilities.d.ts.map +1 -1
  116. package/dist/domain/architecture/no-unused-public-members/member-utilities.js +2 -2
  117. package/dist/domain/architecture/no-unused-public-members/rule.d.ts +14 -1
  118. package/dist/domain/architecture/no-unused-public-members/rule.d.ts.map +1 -1
  119. package/dist/domain/architecture/no-unused-public-members/rule.js +16 -3
  120. package/dist/domain/architecture/package-subpath-imports/index.d.ts +2 -0
  121. package/dist/domain/architecture/package-subpath-imports/index.d.ts.map +1 -0
  122. package/dist/domain/architecture/package-subpath-imports/index.js +2 -0
  123. package/dist/domain/architecture/package-subpath-imports/package-subpath-import-alias-utilities.d.ts +12 -0
  124. package/dist/domain/architecture/package-subpath-imports/package-subpath-import-alias-utilities.d.ts.map +1 -0
  125. package/dist/domain/architecture/package-subpath-imports/package-subpath-import-alias-utilities.js +215 -0
  126. package/dist/domain/architecture/package-subpath-imports/package-subpath-import-matching-utilities.d.ts +24 -0
  127. package/dist/domain/architecture/package-subpath-imports/package-subpath-import-matching-utilities.d.ts.map +1 -0
  128. package/dist/domain/architecture/package-subpath-imports/package-subpath-import-matching-utilities.js +46 -0
  129. package/dist/domain/architecture/package-subpath-imports/package-subpath-import-path-utilities.d.ts +36 -0
  130. package/dist/domain/architecture/package-subpath-imports/package-subpath-import-path-utilities.d.ts.map +1 -0
  131. package/dist/domain/architecture/package-subpath-imports/package-subpath-import-path-utilities.js +103 -0
  132. package/dist/domain/architecture/package-subpath-imports/package-subpath-import-types.d.ts +44 -0
  133. package/dist/domain/architecture/package-subpath-imports/package-subpath-import-types.d.ts.map +1 -0
  134. package/dist/domain/architecture/package-subpath-imports/package-subpath-import-types.js +1 -0
  135. package/dist/domain/architecture/package-subpath-imports/package-subpath-import-utilities.d.ts +13 -0
  136. package/dist/domain/architecture/package-subpath-imports/package-subpath-import-utilities.d.ts.map +1 -0
  137. package/dist/domain/architecture/package-subpath-imports/package-subpath-import-utilities.js +194 -0
  138. package/dist/domain/architecture/package-subpath-imports/prefer-package-subpath-imports-rule.d.ts +5 -0
  139. package/dist/domain/architecture/package-subpath-imports/prefer-package-subpath-imports-rule.d.ts.map +1 -0
  140. package/dist/domain/architecture/package-subpath-imports/prefer-package-subpath-imports-rule.js +106 -0
  141. package/dist/domain/architecture/program-analysis/source-dependency-utilities.d.ts +1 -1
  142. package/dist/domain/architecture/program-analysis/source-dependency-utilities.d.ts.map +1 -1
  143. package/dist/domain/architecture/program-analysis/source-dependency-utilities.js +2 -2
  144. package/dist/domain/architecture/program-analysis/source-file-facts.d.ts +1 -1
  145. package/dist/domain/architecture/program-analysis/source-file-facts.d.ts.map +1 -1
  146. package/dist/domain/architecture/program-analysis/source-file-facts.js +2 -2
  147. package/dist/domain/docs/single-line-jsdoc/rule.js +2 -2
  148. package/dist/domain/index.d.ts +1 -1
  149. package/dist/domain/index.d.ts.map +1 -1
  150. package/dist/domain/index.js +2 -2
  151. package/dist/domain/testing/require-act-result-capture/rule.js +2 -2
  152. package/dist/index.d.ts +1 -3
  153. package/dist/index.d.ts.map +1 -1
  154. package/dist/index.js +2 -3
  155. package/dist/infrastructure/codeperfect-plugin.d.ts +4 -0
  156. package/dist/infrastructure/codeperfect-plugin.d.ts.map +1 -1
  157. package/dist/infrastructure/codeperfect-plugin.js +4 -2
  158. package/dist/infrastructure/index.d.ts +0 -1
  159. package/dist/infrastructure/index.d.ts.map +1 -1
  160. package/dist/infrastructure/index.js +1 -2
  161. package/dist/infrastructure/presets.d.ts.map +1 -1
  162. package/dist/infrastructure/presets.js +5 -1
  163. package/docs/README.md +20 -0
  164. package/docs/api/index.md +19 -0
  165. package/docs/api/type-aliases/CodeperfectPreset.md +13 -0
  166. package/docs/api/variables/aaa.md +13 -0
  167. package/docs/api/variables/all.md +13 -0
  168. package/docs/api/variables/architecture.md +13 -0
  169. package/docs/api/variables/codeperfectPlugin.md +111 -0
  170. package/docs/api/variables/core.md +13 -0
  171. package/docs/api/variables/documentation.md +13 -0
  172. package/docs/api/variables/testing.md +13 -0
  173. package/docs/design/README.md +6 -0
  174. package/docs/design/architecture.md +218 -0
  175. package/docs/design/release.md +30 -0
  176. package/docs/rules/assert-actual-expected-names.md +163 -0
  177. package/docs/rules/barrel-files-exports-only.md +88 -0
  178. package/docs/rules/consistent-barrel-files.md +107 -0
  179. package/docs/rules/enforce-aaa-structure.md +220 -0
  180. package/docs/rules/no-directory-only-imports.md +72 -0
  181. package/docs/rules/no-import-export-aliases.md +54 -0
  182. package/docs/rules/no-import-export-extensions.md +63 -0
  183. package/docs/rules/no-interface-member-docs.md +101 -0
  184. package/docs/rules/no-multiple-declarators.md +105 -0
  185. package/docs/rules/no-reexports-outside-barrels.md +106 -0
  186. package/docs/rules/no-unused-exports.md +283 -0
  187. package/docs/rules/no-unused-public-members.md +389 -0
  188. package/docs/rules/no-useless-delegation.md +56 -0
  189. package/docs/rules/prefer-interface-types.md +138 -0
  190. package/docs/rules/prefer-package-subpath-imports.md +82 -0
  191. package/docs/rules/prefer-vi-mocked-import.md +129 -0
  192. package/docs/rules/require-act-result-capture.md +183 -0
  193. package/docs/rules/require-example-language.md +172 -0
  194. package/docs/rules/require-test-companion.md +125 -0
  195. package/docs/rules/single-act-statement.md +133 -0
  196. package/docs/rules/single-line-jsdoc.md +140 -0
  197. package/package.json +27 -26
  198. package/dist/application/custom-rules.d.ts +0 -70
  199. package/dist/application/custom-rules.d.ts.map +0 -1
  200. package/dist/application/custom-rules.js +0 -37
  201. package/dist/application/index.d.ts +0 -4
  202. package/dist/application/index.d.ts.map +0 -1
  203. package/dist/application/index.js +0 -3
@@ -0,0 +1,220 @@
1
+ # `codeperfect/enforce-aaa-structure`
2
+
3
+ ## Summary
4
+
5
+ Require explicit AAA section comments, enforce section order and uniqueness, and keep setup, action, and assertions in their intended phases.
6
+
7
+ ## Enabled by
8
+
9
+ - `testing`
10
+ - internal `codeperfect` plugin registry
11
+
12
+ ## Why this rule exists
13
+
14
+ AAA tests are easier to follow when each phase appears once and in a predictable order. Reordered, duplicated, or partially overlapping phase markers make test flow ambiguous and harder to reason about.
15
+
16
+ The rule also protects section quality by requiring meaningful section content, preserving section boundaries with blank-line separators, and reporting phase-purity violations when setup, action, and assertion behavior leaks across sections.
17
+
18
+ The analyzer recognizes conventional setup factories by name, including suffixes such as `Context`, `Fixture`, `Mock`, and `Options`. Constructor-created fixtures and filesystem setup calls such as `fs.mkdirSync` are treated as Arrange operations. Collection queries used to derive assertion-local values are not treated as additional SUT actions.
19
+
20
+ ## Rule Details
21
+
22
+ The rule applies to tests that use AAA comments:
23
+
24
+ - `// Arrange`
25
+ - `// Act`
26
+ - `// Assert`
27
+ - `// Arrange & Act`
28
+ - `// Act & Assert`
29
+ - `// Arrange & Act & Assert`
30
+
31
+ ### Phase Model
32
+
33
+ Each comment represents one or more phases:
34
+
35
+ | Comment | Phases Covered |
36
+ | --------------------------- | ---------------------- |
37
+ | `// Arrange` | Arrange |
38
+ | `// Act` | Act |
39
+ | `// Assert` | Assert |
40
+ | `// Arrange & Act` | Arrange + Act |
41
+ | `// Act & Assert` | Act + Assert |
42
+ | `// Arrange & Act & Assert` | Arrange + Act + Assert |
43
+
44
+ ### Ordering
45
+
46
+ - Phases must appear in logical order: Arrange → Act → Assert
47
+ - Combined comments must respect this ordering
48
+ - Invalid examples:
49
+ - introducing an earlier phase after a later one
50
+ - splitting a combined phase incorrectly
51
+
52
+ Examples:
53
+
54
+ - `Arrange → Act → Assert` ✅
55
+ - `Arrange & Act → Assert` ✅
56
+ - `Arrange → Act & Assert` ✅
57
+ - `Arrange & Act & Assert` ✅
58
+ - `Act → Arrange` ❌
59
+ - `Act & Assert → Arrange` ❌
60
+
61
+ ### Uniqueness
62
+
63
+ - Each phase (Arrange, Act, Assert) must be covered **at most once**
64
+ - A phase cannot be reintroduced after it has already appeared
65
+
66
+ Invalid:
67
+
68
+ - `Arrange → Arrange`
69
+ - `Act → Act`
70
+ - `Arrange → Act → Arrange`
71
+ - `Arrange & Act → Act` (Act duplicated)
72
+ - `Act & Assert → Assert` (Assert duplicated)
73
+
74
+ ### Presence
75
+
76
+ - Act and Assert markers must exist in supported test blocks
77
+ - Arrange is required when statements appear before the first section marker
78
+ - Valid structures include:
79
+ - Full separation: `Arrange → Act → Assert`
80
+ - Partial combinations:
81
+ - `Arrange & Act → Assert`
82
+ - `Arrange → Act & Assert`
83
+ - Fully combined:
84
+ - `Arrange & Act & Assert`
85
+ - Missing phases are allowed only if they are not implied elsewhere
86
+
87
+ ### Section Quality
88
+
89
+ - Each section must contain executable statements; comment-only sections are invalid
90
+ - Statements before the first Arrange marker are invalid
91
+ - A blank line is required before boundary section comments after the first section
92
+
93
+ ### Phase Purity
94
+
95
+ - Setup must remain in Arrange
96
+ - The primary interaction belongs in Act
97
+ - Assertions belong in Assert
98
+ - Read-only assertion-local declarations may narrow, alias, or project values produced by Act
99
+ - Assertion-local declarations must not call functions, construct values, await work, or mutate state
100
+ - Mutations and setup work after Act are reported
101
+ - Await usage outside Act is reported
102
+
103
+ ### Invalid
104
+
105
+ ```typescript
106
+ it("rejects incorrect ordering", () => {
107
+ // Act
108
+ const actual = run();
109
+
110
+ // Arrange
111
+ const input = 1;
112
+
113
+ // Assert
114
+ expect(actual).toBe(input);
115
+ });
116
+ ```
117
+
118
+ ```typescript
119
+ it("rejects duplicate phases via split comments", () => {
120
+ // Arrange & Act
121
+ const actual = run(1);
122
+
123
+ // Act
124
+ const next = rerun(actual); // ❌ Act duplicated
125
+
126
+ // Assert
127
+ expect(next).toBe(2);
128
+ });
129
+ ```
130
+
131
+ ```typescript
132
+ it("rejects reintroducing earlier phases", () => {
133
+ // Arrange
134
+ const input = 1;
135
+
136
+ // Act & Assert
137
+ expect(run(input)).toBe(1);
138
+
139
+ // Arrange
140
+ const other = 2; // ❌ Arrange after Assert
141
+ });
142
+ ```
143
+
144
+ ```typescript
145
+ it("rejects overlapping full coverage", () => {
146
+ // Arrange & Act & Assert
147
+ expect(run(1)).toBe(1);
148
+
149
+ // Assert
150
+ expect(1).toBe(1); // ❌ Assert duplicated
151
+ });
152
+ ```
153
+
154
+ ### Valid
155
+
156
+ ```typescript
157
+ it("keeps a standard AAA flow", () => {
158
+ // Arrange
159
+ const input = 1;
160
+
161
+ // Act
162
+ const actual = run(input);
163
+
164
+ // Assert
165
+ expect(actual).toBe(1);
166
+ });
167
+ ```
168
+
169
+ ```typescript
170
+ it("allows assertion-local projections", () => {
171
+ // Act
172
+ const reportDescriptor = run();
173
+
174
+ // Assert
175
+ const actualSuggestions = reportDescriptor?.suggest as
176
+ Rule.SuggestionReportDescriptor[] | undefined;
177
+
178
+ expect(reportDescriptor).toMatchObject({ messageId: "emptyExample" });
179
+ expect(actualSuggestions).toHaveLength(1);
180
+ expect(actualSuggestions).toMatchObject([
181
+ { messageId: "removeEmptyExample" },
182
+ ]);
183
+ });
184
+ ```
185
+
186
+ ```typescript
187
+ it("allows arrange and act combination", () => {
188
+ // Arrange & Act
189
+ const actual = run(1);
190
+
191
+ // Assert
192
+ expect(actual).toBe(1);
193
+ });
194
+ ```
195
+
196
+ ```typescript
197
+ it("allows act and assert combination", () => {
198
+ // Arrange
199
+ const input = 1;
200
+
201
+ // Act & Assert
202
+ expect(run(input)).toBe(1);
203
+ });
204
+ ```
205
+
206
+ ```typescript
207
+ it("allows fully combined AAA", () => {
208
+ // Arrange & Act & Assert
209
+ expect(run(1)).toBe(1);
210
+ });
211
+ ```
212
+
213
+ ```typescript
214
+ it("allows tests without AAA comments", () => {
215
+ const result = run(1);
216
+ expect(result).toBe(1);
217
+ });
218
+ ```
219
+
220
+ When an unmarked test is autofixed, the rule adds one `// Arrange & Act & Assert` marker at the start of the test. Tests with existing markers are not rearranged automatically because their phase boundaries require local judgment.
@@ -0,0 +1,72 @@
1
+ # `codeperfect/no-directory-only-imports`
2
+
3
+ ## Summary
4
+
5
+ Disallow relative module specifiers made only from `.` and `..` path segments.
6
+
7
+ ## Enabled by
8
+
9
+ - `architecture`
10
+ - `all`
11
+ - internal `codeperfect` plugin registry
12
+
13
+ ## Why this rule exists
14
+
15
+ Importing a directory through its index file can create hidden dependencies on a barrel and introduce cycles. Naming the target module directly makes the dependency explicit.
16
+
17
+ ## Rule Details
18
+
19
+ The rule checks static imports, re-exports, TypeScript import types, and literal dynamic imports. It reports relative specifiers whose path consists only of `.` and `..` segments, allowing an optional query or fragment suffix.
20
+
21
+ ## Invalid
22
+
23
+ ```typescript
24
+ import { value } from ".";
25
+ ```
26
+
27
+ ```typescript
28
+ import { value } from "..";
29
+ ```
30
+
31
+ ```typescript
32
+ import { value } from "./..";
33
+ ```
34
+
35
+ ```typescript
36
+ const module = await import(".././..");
37
+ ```
38
+
39
+ ```typescript
40
+ const module = await import(`..`);
41
+ ```
42
+
43
+ ```typescript
44
+ type Shape = import(".").Shape;
45
+ ```
46
+
47
+ ```typescript
48
+ import { value } from ".\\..";
49
+ ```
50
+
51
+ ## Valid
52
+
53
+ ```typescript
54
+ import { value } from "./value";
55
+ ```
56
+
57
+ ```typescript
58
+ import { value } from "../domain/value";
59
+ ```
60
+
61
+ ```typescript
62
+ import { value } from "./.../value";
63
+ ```
64
+
65
+ The last example names a directory literally called `...`; it is not a `.` or `..` path segment.
66
+
67
+ ## Notes
68
+
69
+ - The rule does not resolve paths or infer whether a named module itself re-exports from a barrel.
70
+ - Computed dynamic imports are not analyzed.
71
+ - Backslashes are treated as path separators.
72
+ - CommonJS `require()` calls and TypeScript `import = require(...)` declarations are outside the rule's scope.
@@ -0,0 +1,54 @@
1
+ # `codeperfect/no-import-export-aliases`
2
+
3
+ ## Summary
4
+
5
+ Disallow aliased named imports and exports such as `A as B`, except when the original name is already bound in the same file.
6
+
7
+ ## Enabled by
8
+
9
+ - `architecture`
10
+ - `all`
11
+ - internal `codeperfect` plugin registry
12
+
13
+ ## Why this rule exists
14
+
15
+ Avoiding unnecessary aliases keeps module boundaries readable and prevents avoidable naming indirection.
16
+
17
+ ## Rule Details
18
+
19
+ ### What this rule checks
20
+
21
+ - named import specifiers with aliasing
22
+ - named export specifiers with aliasing
23
+
24
+ ### Allowed exception
25
+
26
+ Aliasing is allowed when the original name is already bound in the same file. This covers collision-avoidance scenarios.
27
+
28
+ ## Invalid
29
+
30
+ ```typescript
31
+ import { A as B } from "./feature";
32
+ ```
33
+
34
+ ## Valid
35
+
36
+ ```typescript
37
+ import { A } from "./one";
38
+ import { A as B } from "./two";
39
+ ```
40
+
41
+ ```typescript
42
+ import { A } from "./feature";
43
+ export { A as B };
44
+ ```
45
+
46
+ ```typescript
47
+ import { A } from "./feature";
48
+ export { A };
49
+ ```
50
+
51
+ ## Notes
52
+
53
+ - This rule does not rewrite identifiers automatically.
54
+ - This rule does not enforce naming style beyond alias usage.
@@ -0,0 +1,63 @@
1
+ # `codeperfect/no-import-export-extensions`
2
+
3
+ ## Summary
4
+
5
+ Disallow explicit file extensions in import and export module specifiers.
6
+
7
+ ## Enabled by
8
+
9
+ - `architecture`
10
+ - `all`
11
+ - internal `codeperfect` plugin registry
12
+
13
+ ## Why this rule exists
14
+
15
+ Extensionless module specifiers improve consistency across TypeScript and JavaScript outputs and reduce extension-specific churn.
16
+
17
+ ## Rule Details
18
+
19
+ ### What this rule checks
20
+
21
+ - `import ... from "..."`
22
+ - `export { ... } from "..."`
23
+ - `export * from "..."`
24
+
25
+ The rule reports module specifiers that end with one of:
26
+
27
+ - `.ts`
28
+ - `.tsx`
29
+ - `.js`
30
+ - `.jsx`
31
+ - `.mts`
32
+ - `.cts`
33
+ - `.mjs`
34
+ - `.cjs`
35
+
36
+ ## Invalid
37
+
38
+ ```typescript
39
+ import { A } from "./feature.js";
40
+ ```
41
+
42
+ ```typescript
43
+ export { A } from "./feature.ts";
44
+ ```
45
+
46
+ ## Valid
47
+
48
+ ```typescript
49
+ import { A } from "./feature";
50
+ ```
51
+
52
+ ```typescript
53
+ export { A } from "./feature";
54
+ ```
55
+
56
+ ```typescript
57
+ import { readFileSync } from "node:fs";
58
+ ```
59
+
60
+ ## Notes
61
+
62
+ - This rule applies to all module specifiers.
63
+ - This rule does not enforce any specific path alias strategy.
@@ -0,0 +1,101 @@
1
+ # `codeperfect/no-interface-member-docs`
2
+
3
+ ## Summary
4
+
5
+ Disallow documenting members of parameters typed with named interfaces or type aliases using nested `@param` tags.
6
+
7
+ ## Enabled by
8
+
9
+ - `jsdoc`
10
+ - internal `codeperfect` plugin registry
11
+
12
+ ## Why this rule exists
13
+
14
+ When a parameter uses a named interface or type alias, documenting its members with nested `@param` tags (e.g. `@param context.value`) duplicates structure that should live on the type definition itself. This creates drift and splits documentation across multiple locations.
15
+
16
+ Inline object types are the exception, since their structure is defined at the function boundary.
17
+
18
+ ## Rule Details
19
+
20
+ - Disallowed:
21
+ - Nested `@param` tags for parameters typed with:
22
+ - interfaces
23
+ - type aliases
24
+ - Allowed:
25
+ - A single top-level `@param` for the parameter itself
26
+ - Nested `@param` tags when the parameter uses an inline object type
27
+ - The rule applies only to dot-notation param tags:
28
+ - e.g. `@param context.value`
29
+
30
+ ## Invalid
31
+
32
+ ```typescript
33
+ /**
34
+ * @param context The metadata context.
35
+ * @param context.commentValue The full comment value. // ❌ nested param on typed object
36
+ */
37
+ function getLineMeta(context: LineMetaContext): void {}
38
+ ```
39
+
40
+ ```typescript
41
+ /**
42
+ * @param options Configuration.
43
+ * @param options.retryCount Number of retries. // ❌ duplicate structure
44
+ */
45
+ function run(options: RunOptions): void {}
46
+ ```
47
+
48
+ ## Autofix
49
+
50
+ Removes nested `@param` entries for typed object members.
51
+
52
+ ### Before
53
+
54
+ ```typescript
55
+ /**
56
+ * @param context The metadata context.
57
+ * @param context.commentValue The full comment value.
58
+ */
59
+ function getLineMeta(context: LineMetaContext): void {}
60
+ ```
61
+
62
+ ### After
63
+
64
+ ```typescript
65
+ /**
66
+ * @param context The metadata context.
67
+ */
68
+ function getLineMeta(context: LineMetaContext): void {}
69
+ ```
70
+
71
+ ## Valid
72
+
73
+ ### Named type without nested docs
74
+
75
+ ```typescript
76
+ /**
77
+ * @param context The metadata context.
78
+ */
79
+ function getLineMeta(context: LineMetaContext): void {}
80
+ ```
81
+
82
+ ### Inline object type (nested docs allowed)
83
+
84
+ ```typescript
85
+ /**
86
+ * @param context The metadata context.
87
+ * @param context.commentValue The full comment value.
88
+ */
89
+ function getLineMeta(context: { commentValue: string }): void {}
90
+ ```
91
+
92
+ ### Multiple parameters with correct usage
93
+
94
+ ```typescript
95
+ /**
96
+ * @param context The metadata context.
97
+ * @param options Inline options.
98
+ * @param options.retryCount Number of retries.
99
+ */
100
+ function run(context: LineMetaContext, options: { retryCount: number }): void {}
101
+ ```
@@ -0,0 +1,105 @@
1
+ # `codeperfect/no-multiple-declarators`
2
+
3
+ ## Summary
4
+
5
+ Require exactly one variable declarator per declaration statement.
6
+
7
+ ## Enabled by
8
+
9
+ - `core`
10
+ - internal `codeperfect` plugin registry
11
+
12
+ ## Why this rule exists
13
+
14
+ Splitting declarations improves readability, produces cleaner diffs, and avoids coupling unrelated variables in a single statement.
15
+
16
+ ## Rule Details
17
+
18
+ - Each `const`, `let`, or `var` declaration must declare exactly one variable
19
+ - Multiple declarators in a single statement are disallowed, regardless of formatting
20
+ - The rule reports any declaration with multiple declarators, including standalone, exported, and loop initializer declarations.
21
+
22
+ ### Examples of disallowed patterns
23
+
24
+ - comma-separated declarators
25
+ - multi-line declarator lists
26
+ - declarators separated by comments
27
+
28
+ ## Invalid
29
+
30
+ ```typescript
31
+ const availableRules = new Set(Object.keys(rules ?? {})),
32
+ customError = buildCustomErrorRules(availableRules);
33
+ ```
34
+
35
+ ```typescript
36
+ export const availableRules = new Set(Object.keys(rules ?? {})),
37
+ customError = buildCustomErrorRules(availableRules);
38
+ ```
39
+
40
+ ```typescript
41
+ const availableRules = new Set(Object.keys(rules ?? {})),
42
+ /* keep */ customError = buildCustomErrorRules(availableRules);
43
+ ```
44
+
45
+ ## Valid
46
+
47
+ ```typescript
48
+ const availableRules = new Set(Object.keys(rules ?? {}));
49
+ const customError = buildCustomErrorRules(availableRules);
50
+ ```
51
+
52
+ ```typescript
53
+ let count = 0;
54
+ ```
55
+
56
+ ```typescript
57
+ var value = compute();
58
+ ```
59
+
60
+ ```typescript
61
+ const { availableRules } = source;
62
+ const customError = buildError(availableRules);
63
+ ```
64
+
65
+ ```typescript
66
+ export const availableRules = new Set(Object.keys(rules ?? {}));
67
+ export const customError = buildCustomErrorRules(availableRules);
68
+ ```
69
+
70
+ ## Autofix
71
+
72
+ Splits multi-declarator statements into multiple single-declarator statements.
73
+
74
+ ### Before
75
+
76
+ ```typescript
77
+ const availableRules = new Set(Object.keys(rules ?? {})),
78
+ customError = buildCustomErrorRules(availableRules);
79
+ ```
80
+
81
+ ### After
82
+
83
+ ```typescript
84
+ const availableRules = new Set(Object.keys(rules ?? {}));
85
+ const customError = buildCustomErrorRules(availableRules);
86
+ ```
87
+
88
+ ## Autofix Behavior
89
+
90
+ The rule auto-fixes only safe, standalone declarations.
91
+
92
+ The following cases are reported but not auto-fixed:
93
+
94
+ - declarations inside loop initializers
95
+
96
+ ```typescript
97
+ for (let i = 0, j = 0; i < 10; i++) {}
98
+ ```
99
+
100
+ - declarations with inline comments between declarators
101
+ - exported declarations
102
+ - TypeScript ambient declarations using the `declare` modifier
103
+ - declaration kinds outside `const`, `let`, and `var`
104
+
105
+ Manual refactoring is required in these cases to preserve intent and formatting.
@@ -0,0 +1,106 @@
1
+ # `codeperfect/no-reexports-outside-barrels`
2
+
3
+ ## Summary
4
+
5
+ Disallow re-exporting values from other modules outside configured barrel files.
6
+
7
+ ## Enabled by
8
+
9
+ - `barrel-files`
10
+ - internal `codeperfect` plugin registry
11
+
12
+ ## Why this rule exists
13
+
14
+ Re-exports should be centralized in designated barrel files. Allowing them in regular modules makes module boundaries harder to follow and weakens the intended architecture.
15
+
16
+ Non-barrel modules should only export values they define locally.
17
+
18
+ ## Options
19
+
20
+ ```typescript
21
+ type Options = {
22
+ allowedBarrelNames?: string[]; // default: ["index"]
23
+ };
24
+ ```
25
+
26
+ - `allowedBarrelNames`
27
+ - Defines which filenames are treated as barrel files
28
+
29
+ ## Rule Details
30
+
31
+ - A **re-export** is any export that forwards values from another module:
32
+ - `export * from "./x"`
33
+ - `export { foo } from "./x"`
34
+ - `export { foo as bar } from "./x"`
35
+
36
+ - Re-exports are only allowed in files whose name matches `allowedBarrelNames`
37
+ - Non-barrel files must not:
38
+ - re-export from another module
39
+ - import a value and immediately export it
40
+
41
+ ### Allowed in non-barrel files
42
+
43
+ - exporting locally defined values
44
+ - exporting locally declared functions, classes, or constants
45
+
46
+ ### Allowed in barrel files
47
+
48
+ - all forms of re-export
49
+
50
+ ## Invalid
51
+
52
+ ### Re-export in non-barrel file
53
+
54
+ ```typescript
55
+ export * from "./dependency";
56
+ ```
57
+
58
+ ```typescript
59
+ export { feature } from "./dependency";
60
+ ```
61
+
62
+ ### Import + export (re-export pattern)
63
+
64
+ ```typescript
65
+ import { feature } from "./dependency";
66
+ export { feature };
67
+ ```
68
+
69
+ ```typescript
70
+ import { feature as baseFeature } from "./dependency";
71
+ export { baseFeature as feature };
72
+ ```
73
+
74
+ ## Valid
75
+
76
+ ### Barrel file (e.g. index.ts)
77
+
78
+ ```typescript
79
+ // index.ts
80
+ export * from "./feature";
81
+ ```
82
+
83
+ ```typescript
84
+ // index.ts
85
+ export { feature } from "./feature";
86
+ ```
87
+
88
+ ### Local exports
89
+
90
+ ```typescript
91
+ export const feature = 1;
92
+ ```
93
+
94
+ ```typescript
95
+ function createFeature() {
96
+ return 1;
97
+ }
98
+
99
+ export { createFeature };
100
+ ```
101
+
102
+ ```typescript
103
+ export function run() {
104
+ return 1;
105
+ }
106
+ ```