@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.
- package/README.md +11 -19
- package/dist/adapters/angular/angular-lifecycle-usage-adapter.d.ts +15 -0
- package/dist/adapters/angular/angular-lifecycle-usage-adapter.d.ts.map +1 -0
- package/dist/adapters/angular/angular-lifecycle-usage-adapter.js +87 -0
- package/dist/adapters/angular/angular-template-expression-utilities.js +2 -2
- package/dist/adapters/angular/angular-template-usage-context.d.ts +1 -1
- package/dist/adapters/angular/angular-template-usage-context.d.ts.map +1 -1
- package/dist/adapters/angular/angular-template-usage-context.js +2 -2
- package/dist/adapters/angular/no-unused-public-members-template-adapter.js +2 -2
- package/dist/adapters/angular/plugin.d.ts.map +1 -1
- package/dist/adapters/angular/plugin.js +7 -3
- package/dist/codeperfect-eslint-plugin-1.0.0.tgz +0 -0
- package/dist/domain/architecture/consistent-barrel-files/exports-only-rule-utilities.d.ts +39 -0
- package/dist/domain/architecture/consistent-barrel-files/exports-only-rule-utilities.d.ts.map +1 -0
- package/dist/domain/architecture/consistent-barrel-files/exports-only-rule-utilities.js +131 -0
- package/dist/domain/architecture/consistent-barrel-files/exports-only-rule.d.ts.map +1 -1
- package/dist/domain/architecture/consistent-barrel-files/exports-only-rule.js +12 -1
- package/dist/domain/architecture/index.d.ts +2 -0
- package/dist/domain/architecture/index.d.ts.map +1 -1
- package/dist/domain/architecture/index.js +3 -1
- package/dist/domain/architecture/no-directory-only-imports/index.d.ts +2 -0
- package/dist/domain/architecture/no-directory-only-imports/index.d.ts.map +1 -0
- package/dist/domain/architecture/no-directory-only-imports/index.js +2 -0
- package/dist/domain/architecture/no-directory-only-imports/no-directory-only-imports-rule.d.ts +5 -0
- package/dist/domain/architecture/no-directory-only-imports/no-directory-only-imports-rule.d.ts.map +1 -0
- package/dist/domain/architecture/no-directory-only-imports/no-directory-only-imports-rule.js +83 -0
- package/dist/domain/architecture/no-unused-exports/no-unused-exports-identifier-utilities.d.ts +1 -1
- package/dist/domain/architecture/no-unused-exports/no-unused-exports-identifier-utilities.d.ts.map +1 -1
- package/dist/domain/architecture/no-unused-exports/no-unused-exports-identifier-utilities.js +2 -2
- package/dist/domain/architecture/no-unused-exports/no-unused-exports-symbol-utilities.d.ts +1 -1
- package/dist/domain/architecture/no-unused-exports/no-unused-exports-symbol-utilities.d.ts.map +1 -1
- package/dist/domain/architecture/no-unused-exports/no-unused-exports-symbol-utilities.js +2 -2
- package/dist/domain/architecture/no-unused-exports/no-unused-exports-usage-index-builder.d.ts +1 -1
- package/dist/domain/architecture/no-unused-exports/no-unused-exports-usage-index-builder.d.ts.map +1 -1
- package/dist/domain/architecture/no-unused-exports/no-unused-exports-usage-index-builder.js +2 -2
- package/dist/domain/architecture/no-unused-exports/no-unused-exports-usage-index.d.ts +1 -1
- package/dist/domain/architecture/no-unused-exports/no-unused-exports-usage-index.d.ts.map +1 -1
- package/dist/domain/architecture/no-unused-exports/no-unused-exports-usage-index.js +2 -2
- package/dist/domain/architecture/no-unused-exports/rule.d.ts +14 -1
- package/dist/domain/architecture/no-unused-exports/rule.d.ts.map +1 -1
- package/dist/domain/architecture/no-unused-exports/rule.js +17 -4
- package/dist/domain/architecture/no-unused-public-members/member-api-reachability-utilities.d.ts +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-api-reachability-utilities.d.ts.map +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-api-reachability-utilities.js +2 -2
- package/dist/domain/architecture/no-unused-public-members/member-api-relevance-utilities.d.ts +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-api-relevance-utilities.d.ts.map +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-api-relevance-utilities.js +2 -2
- package/dist/domain/architecture/no-unused-public-members/member-api-type-utilities.d.ts +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-api-type-utilities.d.ts.map +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-api-type-utilities.js +2 -2
- package/dist/domain/architecture/no-unused-public-members/member-contract-utilities.d.ts +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-contract-utilities.d.ts.map +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-contract-utilities.js +13 -2
- package/dist/domain/architecture/no-unused-public-members/member-declaration-utilities.d.ts +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-declaration-utilities.d.ts.map +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-declaration-utilities.js +9 -4
- package/dist/domain/architecture/no-unused-public-members/member-factory-utilities.d.ts +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-factory-utilities.d.ts.map +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-factory-utilities.js +2 -2
- package/dist/domain/architecture/no-unused-public-members/member-function-utilities.d.ts +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-function-utilities.d.ts.map +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-function-utilities.js +2 -2
- package/dist/domain/architecture/no-unused-public-members/member-host-utilities.d.ts +3 -3
- package/dist/domain/architecture/no-unused-public-members/member-host-utilities.d.ts.map +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-host-utilities.js +40 -25
- package/dist/domain/architecture/no-unused-public-members/member-operation-utilities.d.ts +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-operation-utilities.d.ts.map +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-operation-utilities.js +2 -2
- package/dist/domain/architecture/no-unused-public-members/member-parameter-flow-utilities.d.ts +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-parameter-flow-utilities.d.ts.map +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-parameter-flow-utilities.js +2 -2
- package/dist/domain/architecture/no-unused-public-members/member-public-api-utilities.d.ts +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-public-api-utilities.d.ts.map +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-public-api-utilities.js +2 -2
- package/dist/domain/architecture/no-unused-public-members/member-request-body-utilities.d.ts +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-request-body-utilities.d.ts.map +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-request-body-utilities.js +2 -2
- package/dist/domain/architecture/no-unused-public-members/member-scope-utilities.d.ts +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-scope-utilities.d.ts.map +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-scope-utilities.js +39 -15
- package/dist/domain/architecture/no-unused-public-members/member-usage-call-utilities.d.ts +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-usage-call-utilities.d.ts.map +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-usage-call-utilities.js +2 -2
- package/dist/domain/architecture/no-unused-public-members/member-usage-expression-reference-utilities.d.ts +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-usage-expression-reference-utilities.d.ts.map +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-usage-expression-reference-utilities.js +2 -2
- package/dist/domain/architecture/no-unused-public-members/member-usage-handoff-utilities.d.ts +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-usage-handoff-utilities.d.ts.map +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-usage-handoff-utilities.js +2 -2
- package/dist/domain/architecture/no-unused-public-members/member-usage-index-utilities.d.ts +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-usage-index-utilities.d.ts.map +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-usage-index-utilities.js +2 -2
- package/dist/domain/architecture/no-unused-public-members/member-usage-local-flow-utilities.d.ts +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-usage-local-flow-utilities.d.ts.map +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-usage-local-flow-utilities.js +2 -2
- package/dist/domain/architecture/no-unused-public-members/member-usage-reference-utilities.d.ts +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-usage-reference-utilities.d.ts.map +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-usage-reference-utilities.js +2 -2
- package/dist/domain/architecture/no-unused-public-members/member-usage-serialization-utilities.d.ts +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-usage-serialization-utilities.d.ts.map +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-usage-serialization-utilities.js +2 -2
- package/dist/domain/architecture/no-unused-public-members/member-usage-type-utilities.d.ts +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-usage-type-utilities.d.ts.map +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-usage-type-utilities.js +2 -2
- package/dist/domain/architecture/no-unused-public-members/member-usage-utilities.d.ts +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-usage-utilities.d.ts.map +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-usage-utilities.js +13 -2
- package/dist/domain/architecture/no-unused-public-members/member-usage-value-utilities.d.ts +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-usage-value-utilities.d.ts.map +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-usage-value-utilities.js +2 -2
- package/dist/domain/architecture/no-unused-public-members/member-usage-whole-object-utilities.d.ts +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-usage-whole-object-utilities.d.ts.map +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-usage-whole-object-utilities.js +2 -2
- package/dist/domain/architecture/no-unused-public-members/member-utilities.d.ts +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-utilities.d.ts.map +1 -1
- package/dist/domain/architecture/no-unused-public-members/member-utilities.js +2 -2
- package/dist/domain/architecture/no-unused-public-members/rule.d.ts +14 -1
- package/dist/domain/architecture/no-unused-public-members/rule.d.ts.map +1 -1
- package/dist/domain/architecture/no-unused-public-members/rule.js +16 -3
- package/dist/domain/architecture/package-subpath-imports/index.d.ts +2 -0
- package/dist/domain/architecture/package-subpath-imports/index.d.ts.map +1 -0
- package/dist/domain/architecture/package-subpath-imports/index.js +2 -0
- package/dist/domain/architecture/package-subpath-imports/package-subpath-import-alias-utilities.d.ts +12 -0
- package/dist/domain/architecture/package-subpath-imports/package-subpath-import-alias-utilities.d.ts.map +1 -0
- package/dist/domain/architecture/package-subpath-imports/package-subpath-import-alias-utilities.js +215 -0
- package/dist/domain/architecture/package-subpath-imports/package-subpath-import-matching-utilities.d.ts +24 -0
- package/dist/domain/architecture/package-subpath-imports/package-subpath-import-matching-utilities.d.ts.map +1 -0
- package/dist/domain/architecture/package-subpath-imports/package-subpath-import-matching-utilities.js +46 -0
- package/dist/domain/architecture/package-subpath-imports/package-subpath-import-path-utilities.d.ts +36 -0
- package/dist/domain/architecture/package-subpath-imports/package-subpath-import-path-utilities.d.ts.map +1 -0
- package/dist/domain/architecture/package-subpath-imports/package-subpath-import-path-utilities.js +103 -0
- package/dist/domain/architecture/package-subpath-imports/package-subpath-import-types.d.ts +44 -0
- package/dist/domain/architecture/package-subpath-imports/package-subpath-import-types.d.ts.map +1 -0
- package/dist/domain/architecture/package-subpath-imports/package-subpath-import-types.js +1 -0
- package/dist/domain/architecture/package-subpath-imports/package-subpath-import-utilities.d.ts +13 -0
- package/dist/domain/architecture/package-subpath-imports/package-subpath-import-utilities.d.ts.map +1 -0
- package/dist/domain/architecture/package-subpath-imports/package-subpath-import-utilities.js +194 -0
- package/dist/domain/architecture/package-subpath-imports/prefer-package-subpath-imports-rule.d.ts +5 -0
- package/dist/domain/architecture/package-subpath-imports/prefer-package-subpath-imports-rule.d.ts.map +1 -0
- package/dist/domain/architecture/package-subpath-imports/prefer-package-subpath-imports-rule.js +106 -0
- package/dist/domain/architecture/program-analysis/source-dependency-utilities.d.ts +1 -1
- package/dist/domain/architecture/program-analysis/source-dependency-utilities.d.ts.map +1 -1
- package/dist/domain/architecture/program-analysis/source-dependency-utilities.js +2 -2
- package/dist/domain/architecture/program-analysis/source-file-facts.d.ts +1 -1
- package/dist/domain/architecture/program-analysis/source-file-facts.d.ts.map +1 -1
- package/dist/domain/architecture/program-analysis/source-file-facts.js +2 -2
- package/dist/domain/docs/single-line-jsdoc/rule.js +2 -2
- package/dist/domain/index.d.ts +1 -1
- package/dist/domain/index.d.ts.map +1 -1
- package/dist/domain/index.js +2 -2
- package/dist/domain/testing/require-act-result-capture/rule.js +2 -2
- package/dist/index.d.ts +1 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -3
- package/dist/infrastructure/codeperfect-plugin.d.ts +4 -0
- package/dist/infrastructure/codeperfect-plugin.d.ts.map +1 -1
- package/dist/infrastructure/codeperfect-plugin.js +4 -2
- package/dist/infrastructure/index.d.ts +0 -1
- package/dist/infrastructure/index.d.ts.map +1 -1
- package/dist/infrastructure/index.js +1 -2
- package/dist/infrastructure/presets.d.ts.map +1 -1
- package/dist/infrastructure/presets.js +5 -1
- package/docs/README.md +20 -0
- package/docs/api/index.md +19 -0
- package/docs/api/type-aliases/CodeperfectPreset.md +13 -0
- package/docs/api/variables/aaa.md +13 -0
- package/docs/api/variables/all.md +13 -0
- package/docs/api/variables/architecture.md +13 -0
- package/docs/api/variables/codeperfectPlugin.md +111 -0
- package/docs/api/variables/core.md +13 -0
- package/docs/api/variables/documentation.md +13 -0
- package/docs/api/variables/testing.md +13 -0
- package/docs/design/README.md +6 -0
- package/docs/design/architecture.md +218 -0
- package/docs/design/release.md +30 -0
- package/docs/rules/assert-actual-expected-names.md +163 -0
- package/docs/rules/barrel-files-exports-only.md +88 -0
- package/docs/rules/consistent-barrel-files.md +107 -0
- package/docs/rules/enforce-aaa-structure.md +220 -0
- package/docs/rules/no-directory-only-imports.md +72 -0
- package/docs/rules/no-import-export-aliases.md +54 -0
- package/docs/rules/no-import-export-extensions.md +63 -0
- package/docs/rules/no-interface-member-docs.md +101 -0
- package/docs/rules/no-multiple-declarators.md +105 -0
- package/docs/rules/no-reexports-outside-barrels.md +106 -0
- package/docs/rules/no-unused-exports.md +283 -0
- package/docs/rules/no-unused-public-members.md +389 -0
- package/docs/rules/no-useless-delegation.md +56 -0
- package/docs/rules/prefer-interface-types.md +138 -0
- package/docs/rules/prefer-package-subpath-imports.md +82 -0
- package/docs/rules/prefer-vi-mocked-import.md +129 -0
- package/docs/rules/require-act-result-capture.md +183 -0
- package/docs/rules/require-example-language.md +172 -0
- package/docs/rules/require-test-companion.md +125 -0
- package/docs/rules/single-act-statement.md +133 -0
- package/docs/rules/single-line-jsdoc.md +140 -0
- package/package.json +27 -26
- package/dist/application/custom-rules.d.ts +0 -70
- package/dist/application/custom-rules.d.ts.map +0 -1
- package/dist/application/custom-rules.js +0 -37
- package/dist/application/index.d.ts +0 -4
- package/dist/application/index.d.ts.map +0 -1
- package/dist/application/index.js +0 -3
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# `codeperfect/require-example-language`
|
|
2
|
+
|
|
3
|
+
## Summary
|
|
4
|
+
|
|
5
|
+
Require `@example` JSDoc tags to use fenced code blocks with an explicit language.
|
|
6
|
+
|
|
7
|
+
## Enabled by
|
|
8
|
+
|
|
9
|
+
- `jsdoc`
|
|
10
|
+
- internal `codeperfect` plugin registry
|
|
11
|
+
|
|
12
|
+
## Why this rule exists
|
|
13
|
+
|
|
14
|
+
Language-tagged code fences:
|
|
15
|
+
|
|
16
|
+
- improve syntax highlighting in editors and documentation tools
|
|
17
|
+
- remove ambiguity about the example’s intent
|
|
18
|
+
- enforce consistent documentation structure across codebases
|
|
19
|
+
|
|
20
|
+
## Rule Details
|
|
21
|
+
|
|
22
|
+
### What the rule targets
|
|
23
|
+
|
|
24
|
+
The rule inspects all `@example` JSDoc tags.
|
|
25
|
+
|
|
26
|
+
### Required format
|
|
27
|
+
|
|
28
|
+
Each `@example` must:
|
|
29
|
+
|
|
30
|
+
- use a fenced code block (triple backticks)
|
|
31
|
+
- include a language identifier (e.g. `typescript`, `ts`, `js`)
|
|
32
|
+
- place all example code inside the fence
|
|
33
|
+
|
|
34
|
+
### Disallowed patterns
|
|
35
|
+
|
|
36
|
+
- code fences without a language
|
|
37
|
+
- inline `@example` code (non-fenced)
|
|
38
|
+
- partially fenced examples (code both inside and outside fences)
|
|
39
|
+
|
|
40
|
+
### Allowed variations
|
|
41
|
+
|
|
42
|
+
- any valid language identifier is accepted (`ts`, `typescript`, `js`, etc.)
|
|
43
|
+
- empty lines inside fences are allowed
|
|
44
|
+
- multiple `@example` tags per block are allowed (each must comply)
|
|
45
|
+
|
|
46
|
+
## Invalid
|
|
47
|
+
|
|
48
|
+
### Missing language in fence
|
|
49
|
+
|
|
50
|
+
````typescript
|
|
51
|
+
/**
|
|
52
|
+
* @example
|
|
53
|
+
* ```
|
|
54
|
+
* value();
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
````
|
|
58
|
+
|
|
59
|
+
### Inline example (not fenced)
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
/**
|
|
63
|
+
* @example const value = 1;
|
|
64
|
+
*/
|
|
65
|
+
export function demo(): void {}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Mixed fenced and inline content
|
|
69
|
+
|
|
70
|
+
````typescript
|
|
71
|
+
/**
|
|
72
|
+
* @example
|
|
73
|
+
* const value = 1;
|
|
74
|
+
* ```typescript
|
|
75
|
+
* value();
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
````
|
|
79
|
+
|
|
80
|
+
## Autofix
|
|
81
|
+
|
|
82
|
+
The autofix:
|
|
83
|
+
|
|
84
|
+
- wraps inline examples in a fenced block
|
|
85
|
+
- adds a default language (`typescript`) when missing
|
|
86
|
+
- preserves existing code content and indentation where possible
|
|
87
|
+
|
|
88
|
+
### Before
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
/**
|
|
92
|
+
* @example const value = 1;
|
|
93
|
+
*/
|
|
94
|
+
export function demo(): void {}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### After
|
|
98
|
+
|
|
99
|
+
````typescript
|
|
100
|
+
/**
|
|
101
|
+
* @example
|
|
102
|
+
* ```typescript
|
|
103
|
+
* const value = 1;
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
export function demo(): void {}
|
|
107
|
+
````
|
|
108
|
+
|
|
109
|
+
### Before
|
|
110
|
+
|
|
111
|
+
````typescript
|
|
112
|
+
/**
|
|
113
|
+
* @example
|
|
114
|
+
* ```
|
|
115
|
+
* const value = 1;
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
export function demo(): void {}
|
|
119
|
+
````
|
|
120
|
+
|
|
121
|
+
### After
|
|
122
|
+
|
|
123
|
+
````typescript
|
|
124
|
+
/**
|
|
125
|
+
* @example
|
|
126
|
+
* ```typescript
|
|
127
|
+
* const value = 1;
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
export function demo(): void {}
|
|
131
|
+
````
|
|
132
|
+
|
|
133
|
+
## Valid
|
|
134
|
+
|
|
135
|
+
### Proper fenced example with language
|
|
136
|
+
|
|
137
|
+
````typescript
|
|
138
|
+
/**
|
|
139
|
+
* @example
|
|
140
|
+
* ```typescript
|
|
141
|
+
* value();
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
````
|
|
145
|
+
|
|
146
|
+
### Export with valid example
|
|
147
|
+
|
|
148
|
+
````typescript
|
|
149
|
+
/**
|
|
150
|
+
* @example
|
|
151
|
+
* ```typescript
|
|
152
|
+
* const value = 1;
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
export function demo(): void {}
|
|
156
|
+
````
|
|
157
|
+
|
|
158
|
+
### Multiple examples
|
|
159
|
+
|
|
160
|
+
````typescript
|
|
161
|
+
/**
|
|
162
|
+
* @example
|
|
163
|
+
* ```typescript
|
|
164
|
+
* value();
|
|
165
|
+
* ```
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```typescript
|
|
169
|
+
* otherValue();
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
````
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# `codeperfect/require-test-companion`
|
|
2
|
+
|
|
3
|
+
## Summary
|
|
4
|
+
|
|
5
|
+
Require each test file to have a matching TypeScript source file.
|
|
6
|
+
|
|
7
|
+
## Enabled by
|
|
8
|
+
|
|
9
|
+
- `test-companion`
|
|
10
|
+
- internal `codeperfect` plugin registry
|
|
11
|
+
|
|
12
|
+
## Why this rule exists
|
|
13
|
+
|
|
14
|
+
Keeping test files tied to concrete source files:
|
|
15
|
+
|
|
16
|
+
- prevents orphaned or outdated test files
|
|
17
|
+
|
|
18
|
+
## Rule Details
|
|
19
|
+
|
|
20
|
+
### What the rule targets
|
|
21
|
+
|
|
22
|
+
- Test files matching configured patterns (e.g. `.test.ts`, `.spec.ts`)
|
|
23
|
+
|
|
24
|
+
### What counts as a companion
|
|
25
|
+
|
|
26
|
+
A matching source file:
|
|
27
|
+
|
|
28
|
+
- shares the same base filename
|
|
29
|
+
- uses the TypeScript `.ts` extension
|
|
30
|
+
|
|
31
|
+
Example:
|
|
32
|
+
|
|
33
|
+
| Test file | Required source |
|
|
34
|
+
| ----------------- | --------------- |
|
|
35
|
+
| `feature.test.ts` | `feature.ts` |
|
|
36
|
+
| `feature.spec.ts` | `feature.ts` |
|
|
37
|
+
|
|
38
|
+
### Supported patterns
|
|
39
|
+
|
|
40
|
+
- `.test.ts`
|
|
41
|
+
- `.spec.ts`
|
|
42
|
+
|
|
43
|
+
The active pattern depends on project configuration.
|
|
44
|
+
|
|
45
|
+
### Required behavior
|
|
46
|
+
|
|
47
|
+
- Every test file must have a corresponding source file
|
|
48
|
+
|
|
49
|
+
### Disallowed patterns
|
|
50
|
+
|
|
51
|
+
- test files without a source file
|
|
52
|
+
- mismatched naming (different base names)
|
|
53
|
+
|
|
54
|
+
## Invalid
|
|
55
|
+
|
|
56
|
+
### Test file without source
|
|
57
|
+
|
|
58
|
+
```tree
|
|
59
|
+
feature.test.ts
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
// feature.test.ts
|
|
64
|
+
export {};
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Mismatched names
|
|
68
|
+
|
|
69
|
+
```tree
|
|
70
|
+
feature.ts
|
|
71
|
+
feature-utils.test.ts // ❌ expects feature-utils.ts
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Valid
|
|
75
|
+
|
|
76
|
+
### `.spec.ts` with matching source
|
|
77
|
+
|
|
78
|
+
```tree
|
|
79
|
+
feature.ts
|
|
80
|
+
feature.spec.ts
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
// feature.ts
|
|
85
|
+
export const feature = 1;
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
// feature.spec.ts
|
|
90
|
+
export {};
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### `.test.ts` with matching source
|
|
94
|
+
|
|
95
|
+
```tree
|
|
96
|
+
feature.ts
|
|
97
|
+
feature.test.ts
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
// feature.ts
|
|
102
|
+
export const feature = 1;
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
// feature.test.ts
|
|
107
|
+
export {};
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Configured pattern flexibility
|
|
111
|
+
|
|
112
|
+
If the project is configured to use `.test.ts`, then:
|
|
113
|
+
|
|
114
|
+
```tree
|
|
115
|
+
feature.ts
|
|
116
|
+
feature.test.ts
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
is valid, and `.spec.ts` companions are not expected.
|
|
120
|
+
|
|
121
|
+
## Notes
|
|
122
|
+
|
|
123
|
+
- This rule does not require every source file to have tests.
|
|
124
|
+
- This rule does not enforce test content quality or coverage depth.
|
|
125
|
+
- This rule operates purely on file presence and naming conventions.
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# `codeperfect/single-act-statement`
|
|
2
|
+
|
|
3
|
+
## Summary
|
|
4
|
+
|
|
5
|
+
Require the `// Act` phase to contain exactly one top-level statement.
|
|
6
|
+
|
|
7
|
+
## Enabled by
|
|
8
|
+
|
|
9
|
+
- `testing`
|
|
10
|
+
- internal `codeperfect` plugin registry
|
|
11
|
+
|
|
12
|
+
## Why this rule exists
|
|
13
|
+
|
|
14
|
+
The Act phase should represent a single interaction with the system under test. Multiple top-level statements often indicate:
|
|
15
|
+
|
|
16
|
+
- hidden setup leaking from Arrange
|
|
17
|
+
- follow-up work that belongs after the Act
|
|
18
|
+
- multiple behaviors being tested at once
|
|
19
|
+
|
|
20
|
+
Keeping Act to one statement enforces clarity and intent.
|
|
21
|
+
|
|
22
|
+
## Rule Details
|
|
23
|
+
|
|
24
|
+
### What counts as a statement
|
|
25
|
+
|
|
26
|
+
Within the `// Act` section, the rule considers **top-level statements only**, including:
|
|
27
|
+
|
|
28
|
+
- expression statements (e.g. `run(input)`)
|
|
29
|
+
- variable declarations (e.g. `const result = run(input)`)
|
|
30
|
+
|
|
31
|
+
### Required behavior
|
|
32
|
+
|
|
33
|
+
- The Act phase must contain **exactly one top-level statement**
|
|
34
|
+
- That statement represents the primary interaction under test
|
|
35
|
+
|
|
36
|
+
### Allowed patterns
|
|
37
|
+
|
|
38
|
+
- nested logic inside the single statement (e.g. inline function calls)
|
|
39
|
+
- a single variable declaration capturing the result
|
|
40
|
+
- a single expression statement for side-effect interactions
|
|
41
|
+
|
|
42
|
+
### Disallowed patterns
|
|
43
|
+
|
|
44
|
+
- multiple top-level statements in Act
|
|
45
|
+
- splitting a single interaction across multiple statements
|
|
46
|
+
- performing follow-up work after the main Act statement
|
|
47
|
+
|
|
48
|
+
### Non-goals
|
|
49
|
+
|
|
50
|
+
- This rule does not enforce:
|
|
51
|
+
- result capture (handled by `require-act-result-capture`)
|
|
52
|
+
- AAA structure, section presence, or phase purity (handled by `enforce-aaa-structure`)
|
|
53
|
+
|
|
54
|
+
## Invalid
|
|
55
|
+
|
|
56
|
+
### Multiple top-level statements
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
it("keeps one act statement", () => {
|
|
60
|
+
// Arrange
|
|
61
|
+
const input = 1;
|
|
62
|
+
|
|
63
|
+
// Act
|
|
64
|
+
const actualResult = run(input);
|
|
65
|
+
cleanup(actualResult); // ❌ second statement
|
|
66
|
+
|
|
67
|
+
// Assert
|
|
68
|
+
expect(actualResult).toBe(1);
|
|
69
|
+
});
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Split interaction
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
it("splits the act across steps", () => {
|
|
76
|
+
// Arrange
|
|
77
|
+
const input = 1;
|
|
78
|
+
|
|
79
|
+
// Act
|
|
80
|
+
const intermediate = prepare(input);
|
|
81
|
+
const actualResult = run(intermediate); // ❌ multiple steps in Act
|
|
82
|
+
|
|
83
|
+
// Assert
|
|
84
|
+
expect(actualResult).toBe(1);
|
|
85
|
+
});
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Valid
|
|
89
|
+
|
|
90
|
+
### Single declaration
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
it("allows one act declaration", () => {
|
|
94
|
+
// Arrange
|
|
95
|
+
const input = 1;
|
|
96
|
+
|
|
97
|
+
// Act
|
|
98
|
+
const actualResult = run(input);
|
|
99
|
+
|
|
100
|
+
// Assert
|
|
101
|
+
expect(actualResult).toBe(1);
|
|
102
|
+
});
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Single expression
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
it("allows one act expression", () => {
|
|
109
|
+
// Arrange
|
|
110
|
+
const input = 1;
|
|
111
|
+
|
|
112
|
+
// Act
|
|
113
|
+
run(input);
|
|
114
|
+
|
|
115
|
+
// Assert
|
|
116
|
+
expect(input).toBe(1);
|
|
117
|
+
});
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Nested interaction within one statement
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
it("allows nested calls in a single statement", () => {
|
|
124
|
+
// Arrange
|
|
125
|
+
const input = 1;
|
|
126
|
+
|
|
127
|
+
// Act
|
|
128
|
+
const actualResult = run(prepare(input));
|
|
129
|
+
|
|
130
|
+
// Assert
|
|
131
|
+
expect(actualResult).toBe(1);
|
|
132
|
+
});
|
|
133
|
+
```
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# `codeperfect/single-line-jsdoc`
|
|
2
|
+
|
|
3
|
+
## Summary
|
|
4
|
+
|
|
5
|
+
Require JSDoc comments to use a single-line format when their content fits on one line.
|
|
6
|
+
|
|
7
|
+
## Enabled by
|
|
8
|
+
|
|
9
|
+
- `jsdoc`
|
|
10
|
+
- internal `codeperfect` plugin registry
|
|
11
|
+
|
|
12
|
+
## Why this rule exists
|
|
13
|
+
|
|
14
|
+
Short documentation should remain compact and easy to scan. Single-line JSDoc:
|
|
15
|
+
|
|
16
|
+
- reduces vertical noise
|
|
17
|
+
- improves readability for simple descriptions
|
|
18
|
+
- keeps formatting consistent across codebases
|
|
19
|
+
|
|
20
|
+
## Rule Details
|
|
21
|
+
|
|
22
|
+
### What the rule targets
|
|
23
|
+
|
|
24
|
+
- JSDoc block comments (`/** ... */`)
|
|
25
|
+
|
|
26
|
+
### When a single-line format is required
|
|
27
|
+
|
|
28
|
+
A JSDoc comment must be converted to a single line when:
|
|
29
|
+
|
|
30
|
+
- it contains only plain text (no tags)
|
|
31
|
+
- it fits within the configured maximum line length
|
|
32
|
+
- it does not contain line breaks that are semantically meaningful
|
|
33
|
+
|
|
34
|
+
### Disallowed patterns
|
|
35
|
+
|
|
36
|
+
- multi-line JSDoc with a single short description
|
|
37
|
+
- unnecessary line breaks in simple comments
|
|
38
|
+
|
|
39
|
+
### Allowed patterns
|
|
40
|
+
|
|
41
|
+
The rule does **not** enforce single-line format when:
|
|
42
|
+
|
|
43
|
+
- the comment contains JSDoc tags (`@param`, `@returns`, `@example`, etc.)
|
|
44
|
+
- the content exceeds the configured line length
|
|
45
|
+
- the comment includes multiple logical lines or paragraphs
|
|
46
|
+
- formatting would reduce clarity
|
|
47
|
+
- the comment documents a function-like target (function declaration/expression, method, function signature, function-valued property, or function-valued variable declaration)
|
|
48
|
+
|
|
49
|
+
### Autofix behavior
|
|
50
|
+
|
|
51
|
+
The autofix:
|
|
52
|
+
|
|
53
|
+
- collapses eligible multi-line JSDoc into a single line
|
|
54
|
+
- preserves the original text content
|
|
55
|
+
- trims leading `*` and indentation
|
|
56
|
+
- respects line length limits
|
|
57
|
+
|
|
58
|
+
The autofix does **not** apply when:
|
|
59
|
+
|
|
60
|
+
- tags are present
|
|
61
|
+
- content would exceed the maximum line length
|
|
62
|
+
- formatting ambiguity exists
|
|
63
|
+
|
|
64
|
+
## Invalid
|
|
65
|
+
|
|
66
|
+
### Simple multi-line description
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
/**
|
|
70
|
+
* Returns the value.
|
|
71
|
+
*/
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Unnecessary multi-line comment
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
/**
|
|
78
|
+
* doc
|
|
79
|
+
*/
|
|
80
|
+
const value = 1;
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Autofix
|
|
84
|
+
|
|
85
|
+
### Before
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
/**
|
|
89
|
+
* doc
|
|
90
|
+
*/
|
|
91
|
+
const value = 1;
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### After
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
/** doc */
|
|
98
|
+
const value = 1;
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Valid
|
|
102
|
+
|
|
103
|
+
### Proper single-line JSDoc
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
/** Returns the value. */
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
/** doc */
|
|
111
|
+
const value = 1;
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Multi-line with tags
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
/**
|
|
118
|
+
* @param value Input value.
|
|
119
|
+
*/
|
|
120
|
+
function demo(value: string): string {
|
|
121
|
+
return value;
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Function-target JSDoc
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
/**
|
|
129
|
+
* doc
|
|
130
|
+
*/
|
|
131
|
+
function demo(): void {}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Multi-line due to length
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
/**
|
|
138
|
+
* Returns a very long description that would exceed the configured maximum line length if written on a single line.
|
|
139
|
+
*/
|
|
140
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codeperfect/eslint-plugin",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.0",
|
|
4
4
|
"description": "Custom ESLint rules for TypeScript repositories",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "github:parloti/eslint-plugin",
|
|
@@ -20,9 +20,12 @@
|
|
|
20
20
|
"default": "./dist/adapters/angular/plugin.js"
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
|
+
"imports": {
|
|
24
|
+
"#root": "./src/index.ts"
|
|
25
|
+
},
|
|
23
26
|
"sideEffects": false,
|
|
24
27
|
"engines": {
|
|
25
|
-
"node": ">=
|
|
28
|
+
"node": ">=26.13.1"
|
|
26
29
|
},
|
|
27
30
|
"publishConfig": {
|
|
28
31
|
"access": "public"
|
|
@@ -69,7 +72,8 @@
|
|
|
69
72
|
"docs:clean": "npx --yes rimraf docs/api"
|
|
70
73
|
},
|
|
71
74
|
"files": [
|
|
72
|
-
"dist"
|
|
75
|
+
"dist",
|
|
76
|
+
"docs"
|
|
73
77
|
],
|
|
74
78
|
"keywords": [
|
|
75
79
|
"eslint",
|
|
@@ -81,14 +85,14 @@
|
|
|
81
85
|
"nodejs"
|
|
82
86
|
],
|
|
83
87
|
"dependencies": {
|
|
84
|
-
"@typescript-eslint/utils": "^8.
|
|
85
|
-
"minimatch": "^11.0.
|
|
88
|
+
"@typescript-eslint/utils": "^8.73.0",
|
|
89
|
+
"minimatch": "^11.0.9"
|
|
86
90
|
},
|
|
87
91
|
"devDependencies": {
|
|
88
|
-
"@angular/compiler": "^22.
|
|
92
|
+
"@angular/compiler": "^22.3.0",
|
|
89
93
|
"@codeperfect/commitlint-config-emoji": "^1.1.0",
|
|
90
|
-
"@codeperfect/eslint-config": "^2.
|
|
91
|
-
"@codeperfect/task-runner": "^1.
|
|
94
|
+
"@codeperfect/eslint-config": "^2.8.0",
|
|
95
|
+
"@codeperfect/task-runner": "^1.10.0",
|
|
92
96
|
"@commitlint/cz-commitlint": "^21.2.4",
|
|
93
97
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.8.1",
|
|
94
98
|
"@eslint/js": "^10.0.1",
|
|
@@ -100,45 +104,42 @@
|
|
|
100
104
|
"@stylistic/eslint-plugin": "^5.10.0",
|
|
101
105
|
"@types/lodash-es": "^4.17.12",
|
|
102
106
|
"@types/node": "^26.6.6",
|
|
103
|
-
"@typescript-eslint/rule-tester": "^8.
|
|
104
|
-
"@vitest/coverage-v8": "^5.1.
|
|
107
|
+
"@typescript-eslint/rule-tester": "^8.73.0",
|
|
108
|
+
"@vitest/coverage-v8": "^5.1.1",
|
|
105
109
|
"@vitest/eslint-plugin": "^1.6.28",
|
|
106
110
|
"chalk": "^6.0.1",
|
|
107
|
-
"
|
|
108
|
-
"eslint": "^10.14.0",
|
|
111
|
+
"eslint": "^10.15.0",
|
|
109
112
|
"eslint-config-prettier": "^10.1.8",
|
|
110
113
|
"eslint-import-resolver-typescript": "^4.4.5",
|
|
111
|
-
"eslint-plugin-boundaries": "^7.4.
|
|
114
|
+
"eslint-plugin-boundaries": "^7.4.4",
|
|
112
115
|
"eslint-plugin-eslint-plugin": "^7.6.2",
|
|
113
|
-
"eslint-plugin-import-x": "^4.18.
|
|
114
|
-
"eslint-plugin-
|
|
115
|
-
"eslint-plugin-jest": "^29.17.0",
|
|
116
|
-
"eslint-plugin-jsdoc": "^65.4.5",
|
|
116
|
+
"eslint-plugin-import-x": "^4.18.1",
|
|
117
|
+
"eslint-plugin-jsdoc": "^65.5.1",
|
|
117
118
|
"eslint-plugin-package-json": "^1.14.0",
|
|
118
|
-
"eslint-plugin-perfectionist": "^5.
|
|
119
|
+
"eslint-plugin-perfectionist": "^5.14.0",
|
|
119
120
|
"eslint-plugin-prettier": "^5.5.7",
|
|
120
121
|
"eslint-plugin-rxjs-x": "^1.0.6",
|
|
121
122
|
"eslint-plugin-unicorn": "^79.0.0",
|
|
122
123
|
"globals": "^17.14.0",
|
|
123
124
|
"husky": "^9.1.7",
|
|
124
125
|
"jiti": "^2.7.0",
|
|
125
|
-
"lint-staged": "^17.6.
|
|
126
|
-
"listr2": "^11.4.0",
|
|
126
|
+
"lint-staged": "^17.6.1",
|
|
127
127
|
"lodash-es": "^4.18.1",
|
|
128
128
|
"patch-package": "^8.0.1",
|
|
129
|
-
"prettier": "^3.
|
|
129
|
+
"prettier": "^3.10.1",
|
|
130
130
|
"rimraf": "^6.1.4",
|
|
131
|
-
"semantic-release": "^
|
|
131
|
+
"semantic-release": "^26.0.1",
|
|
132
132
|
"tsc-alias": "^1.9.10",
|
|
133
133
|
"typedoc": "^0.28.20",
|
|
134
134
|
"typedoc-plugin-markdown": "^4.14.1",
|
|
135
135
|
"typescript": "^6.0.3",
|
|
136
|
-
"typescript-eslint": "^8.
|
|
137
|
-
"vitest": "^5.1.
|
|
136
|
+
"typescript-eslint": "^8.73.0",
|
|
137
|
+
"vitest": "^5.1.1"
|
|
138
138
|
},
|
|
139
139
|
"peerDependencies": {
|
|
140
|
-
"@angular/compiler": ">=22.
|
|
141
|
-
"eslint": ">=10.
|
|
140
|
+
"@angular/compiler": ">=22.3.0",
|
|
141
|
+
"eslint": ">=10.15.0",
|
|
142
|
+
"typescript": ">=6.0.3"
|
|
142
143
|
},
|
|
143
144
|
"peerDependenciesMeta": {
|
|
144
145
|
"@angular/compiler": {
|