@angular-modernizer/plugin-system 0.3.0 → 1.0.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/dist/plugin-interface.d.ts +5 -0
- package/package.json +7 -6
- package/dist/contexts.d.ts.map +0 -1
- package/dist/contexts.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/plugin-interface.d.ts.map +0 -1
- package/dist/plugin-interface.js.map +0 -1
- package/src/contexts.ts +0 -223
- package/src/index.ts +0 -33
- package/src/plugin-interface.ts +0 -359
|
@@ -143,6 +143,11 @@ export interface AnalysisResult {
|
|
|
143
143
|
* Suggested fix (if applicable).
|
|
144
144
|
*/
|
|
145
145
|
suggestedFix?: string;
|
|
146
|
+
/**
|
|
147
|
+
* Severity of this finding when it differs from the rule severity
|
|
148
|
+
* (e.g. an informational hint from a rule whose findings are errors).
|
|
149
|
+
*/
|
|
150
|
+
severity?: 'error' | 'warning' | 'info';
|
|
146
151
|
/**
|
|
147
152
|
* Additional metadata.
|
|
148
153
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-modernizer/plugin-system",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Plugin infrastructure for the Angular Modernization Platform",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"plugin-system"
|
|
12
12
|
],
|
|
13
13
|
"license": "MIT",
|
|
14
|
+
"author": "Christian Weiss",
|
|
14
15
|
"repository": {
|
|
15
16
|
"type": "git",
|
|
16
17
|
"url": "git+https://github.com/eiweiss/tsanalyzer.git",
|
|
@@ -30,17 +31,14 @@
|
|
|
30
31
|
},
|
|
31
32
|
"files": [
|
|
32
33
|
"dist",
|
|
33
|
-
"src",
|
|
34
34
|
"!dist/**/__tests__/**",
|
|
35
|
-
"!
|
|
36
|
-
"!src/**/*.test.ts",
|
|
37
|
-
"!src/**/*.spec.ts"
|
|
35
|
+
"!dist/**/*.map"
|
|
38
36
|
],
|
|
39
37
|
"dependencies": {
|
|
40
38
|
"ts-morph": "^27.0.2"
|
|
41
39
|
},
|
|
42
40
|
"devDependencies": {
|
|
43
|
-
"@types/node": "^
|
|
41
|
+
"@types/node": "^20.19.0",
|
|
44
42
|
"rimraf": "^6.1.0",
|
|
45
43
|
"typescript": "^5.9.3"
|
|
46
44
|
},
|
|
@@ -53,6 +51,9 @@
|
|
|
53
51
|
],
|
|
54
52
|
"tsconfig": "./tsconfig.json"
|
|
55
53
|
},
|
|
54
|
+
"engines": {
|
|
55
|
+
"node": "^20.19.0 || ^22.12.0 || >=24.0.0"
|
|
56
|
+
},
|
|
56
57
|
"scripts": {
|
|
57
58
|
"build": "tsc --build",
|
|
58
59
|
"test": "jest --passWithNoTests",
|
package/dist/contexts.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contexts.d.ts","sourceRoot":"","sources":["../src/contexts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEpD;;;;GAIG;AAEH,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC;AAEhC;;;GAGG;AACH,MAAM,WAAW,WAAW,CAAC,IAAI,GAAG,aAAa;IAC/C;;;OAGG;IACH,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAEhC;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B;;;;;;OAMG;IACH,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC;IAEnB;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEzC;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;C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e,CAAC;AAEvB,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAuBH,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-interface.d.ts","sourceRoot":"","sources":["../src/plugin-interface.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,eAAe,CAAC;AAEvB;;;;;;;GAOG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC;IAC5B,cAAc,IAAI,MAAM,CAAC;CAC1B;AAED;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAE9B;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEzB;;;;;;OAMG;IACH,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3C;;;;;OAKG;IACH,gBAAgB,IAAI,YAAY,EAAE,CAAC;IAEnC;;;;;OAKG;IACH,iBAAiB,IAAI,aAAa,EAAE,CAAC;IAErC;;;;;OAKG;IACH,kBAAkB,IAAI,cAAc,EAAE,CAAC;CACxC;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB;;OA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CAAC,CAAC;IAElC;;OAEG;IACH,iBAAiB,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpC;;OAEG;IACH,gBAAgB,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnC;;OAEG;IACH,UAAU,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-interface.js","sourceRoot":"","sources":["../src/plugin-interface.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG"}
|
package/src/contexts.ts
DELETED
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @angular-modernizer/plugin-system - Context Objects
|
|
3
|
-
*
|
|
4
|
-
* Context objects are the mechanism by which we pass capabilities to plugins.
|
|
5
|
-
* They contain the PublicApi and provide scoped access to the codebase.
|
|
6
|
-
*
|
|
7
|
-
* Design Philosophy: "Context is the API Gateway"
|
|
8
|
-
* - Plugins receive a context object, not raw infrastructure
|
|
9
|
-
* - Context contains the PublicApi with battle-tested helpers
|
|
10
|
-
* - Context is immutable and scoped to a single operation
|
|
11
|
-
* - This enforces plugins to use standardized, high-quality tools
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import type { Project, SourceFile } from 'ts-morph';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Generic type for the Public API.
|
|
18
|
-
* The actual PublicApi interface is defined in `@angular-modernizer/api`.
|
|
19
|
-
* Uses `any` here to avoid circular dependencies between packages.
|
|
20
|
-
*/
|
|
21
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
-
export type PublicApiType = any;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Base context shared by all plugin operations.
|
|
26
|
-
* Contains common elements needed across analysis, transformation, and validation.
|
|
27
|
-
*/
|
|
28
|
-
export interface BaseContext<TApi = PublicApiType> {
|
|
29
|
-
/**
|
|
30
|
-
* The source file being operated on.
|
|
31
|
-
* This is the primary entry point for all plugin operations.
|
|
32
|
-
*/
|
|
33
|
-
readonly sourceFile: SourceFile;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* The ts-morph Project instance.
|
|
37
|
-
* Provides access to the entire codebase for cross-file analysis.
|
|
38
|
-
*/
|
|
39
|
-
readonly project: Project;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* The Public API - the plugin's toolbox.
|
|
43
|
-
* Contains all high-level helpers for analysis and transformation.
|
|
44
|
-
*
|
|
45
|
-
* This is THE critical design decision:
|
|
46
|
-
* Plugins don't implement low-level logic. They consume the API.
|
|
47
|
-
*/
|
|
48
|
-
readonly api: TApi;
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Plugin-specific configuration.
|
|
52
|
-
* Allows users to customize plugin behavior.
|
|
53
|
-
*/
|
|
54
|
-
readonly config: Record<string, unknown>;
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* File path for convenience (derived from sourceFile).
|
|
58
|
-
*/
|
|
59
|
-
readonly filePath: string;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Context for analysis operations.
|
|
64
|
-
* Passed to AnalysisRule.analyze() methods.
|
|
65
|
-
*
|
|
66
|
-
* Analysis contexts are READ-ONLY. They must not modify code.
|
|
67
|
-
*/
|
|
68
|
-
export interface AnalysisContext<TApi = PublicApiType>
|
|
69
|
-
extends BaseContext<TApi> {
|
|
70
|
-
/**
|
|
71
|
-
* Type discriminator for type safety.
|
|
72
|
-
*/
|
|
73
|
-
readonly type: 'analysis';
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Analysis-specific options.
|
|
77
|
-
*/
|
|
78
|
-
readonly options?: {
|
|
79
|
-
/**
|
|
80
|
-
* Whether to perform deep analysis (cross-file).
|
|
81
|
-
* Default: false (single-file analysis only)
|
|
82
|
-
*/
|
|
83
|
-
deep?: boolean;
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Maximum depth for cross-file analysis.
|
|
87
|
-
* Only relevant if deep=true.
|
|
88
|
-
*/
|
|
89
|
-
maxDepth?: number;
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Context for transformation operations.
|
|
95
|
-
* Passed to TransformRule.transform() methods.
|
|
96
|
-
*
|
|
97
|
-
* Transform contexts allow WRITE operations.
|
|
98
|
-
* Plugins can modify the sourceFile through ts-morph APIs.
|
|
99
|
-
*/
|
|
100
|
-
export interface TransformContext<TApi = PublicApiType>
|
|
101
|
-
extends BaseContext<TApi> {
|
|
102
|
-
/**
|
|
103
|
-
* Type discriminator for type safety.
|
|
104
|
-
*/
|
|
105
|
-
readonly type: 'transform';
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Transform-specific options.
|
|
109
|
-
*/
|
|
110
|
-
readonly options?: {
|
|
111
|
-
/**
|
|
112
|
-
* Whether to perform a dry-run (no actual changes).
|
|
113
|
-
* Default: false
|
|
114
|
-
*/
|
|
115
|
-
dryRun?: boolean;
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Whether to auto-save changes after transformation.
|
|
119
|
-
* Default: true
|
|
120
|
-
*/
|
|
121
|
-
autoSave?: boolean;
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Whether to format code after transformation.
|
|
125
|
-
* Default: true
|
|
126
|
-
*/
|
|
127
|
-
format?: boolean;
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Context for validation operations.
|
|
133
|
-
* Passed to ValidationRule.validate() methods.
|
|
134
|
-
*
|
|
135
|
-
* Validation contexts are READ-ONLY post-transformation checks.
|
|
136
|
-
*/
|
|
137
|
-
export interface ValidationContext<TApi = PublicApiType>
|
|
138
|
-
extends BaseContext<TApi> {
|
|
139
|
-
/**
|
|
140
|
-
* Type discriminator for type safety.
|
|
141
|
-
*/
|
|
142
|
-
readonly type: 'validation';
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Validation-specific options.
|
|
146
|
-
*/
|
|
147
|
-
readonly options?: {
|
|
148
|
-
/**
|
|
149
|
-
* Whether to fail fast on first validation error.
|
|
150
|
-
* Default: false (collect all validation errors)
|
|
151
|
-
*/
|
|
152
|
-
failFast?: boolean;
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Factory for creating context objects.
|
|
158
|
-
* This is used internally by the orchestration layer.
|
|
159
|
-
*/
|
|
160
|
-
export class ContextFactory {
|
|
161
|
-
/**
|
|
162
|
-
* Create an analysis context.
|
|
163
|
-
*/
|
|
164
|
-
static createAnalysisContext<TApi = PublicApiType>(params: {
|
|
165
|
-
sourceFile: SourceFile;
|
|
166
|
-
project: Project;
|
|
167
|
-
api: TApi;
|
|
168
|
-
config?: Record<string, unknown>;
|
|
169
|
-
options?: AnalysisContext<TApi>['options'];
|
|
170
|
-
}): AnalysisContext<TApi> {
|
|
171
|
-
return {
|
|
172
|
-
type: 'analysis',
|
|
173
|
-
sourceFile: params.sourceFile,
|
|
174
|
-
project: params.project,
|
|
175
|
-
api: params.api,
|
|
176
|
-
config: params.config ?? {},
|
|
177
|
-
filePath: params.sourceFile.getFilePath(),
|
|
178
|
-
options: params.options,
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Create a transform context.
|
|
184
|
-
*/
|
|
185
|
-
static createTransformContext<TApi = PublicApiType>(params: {
|
|
186
|
-
sourceFile: SourceFile;
|
|
187
|
-
project: Project;
|
|
188
|
-
api: TApi;
|
|
189
|
-
config?: Record<string, unknown>;
|
|
190
|
-
options?: TransformContext<TApi>['options'];
|
|
191
|
-
}): TransformContext<TApi> {
|
|
192
|
-
return {
|
|
193
|
-
type: 'transform',
|
|
194
|
-
sourceFile: params.sourceFile,
|
|
195
|
-
project: params.project,
|
|
196
|
-
api: params.api,
|
|
197
|
-
config: params.config ?? {},
|
|
198
|
-
filePath: params.sourceFile.getFilePath(),
|
|
199
|
-
options: params.options,
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Create a validation context.
|
|
205
|
-
*/
|
|
206
|
-
static createValidationContext<TApi = PublicApiType>(params: {
|
|
207
|
-
sourceFile: SourceFile;
|
|
208
|
-
project: Project;
|
|
209
|
-
api: TApi;
|
|
210
|
-
config?: Record<string, unknown>;
|
|
211
|
-
options?: ValidationContext<TApi>['options'];
|
|
212
|
-
}): ValidationContext<TApi> {
|
|
213
|
-
return {
|
|
214
|
-
type: 'validation',
|
|
215
|
-
sourceFile: params.sourceFile,
|
|
216
|
-
project: params.project,
|
|
217
|
-
api: params.api,
|
|
218
|
-
config: params.config ?? {},
|
|
219
|
-
filePath: params.sourceFile.getFilePath(),
|
|
220
|
-
options: params.options,
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @angular-modernizer/plugin-system
|
|
3
|
-
*
|
|
4
|
-
* Plugin infrastructure for the Angular Modernization Platform.
|
|
5
|
-
* This package defines the contracts and interfaces for the plugin ecosystem.
|
|
6
|
-
*
|
|
7
|
-
* Export Strategy: "Export Everything"
|
|
8
|
-
* - All public interfaces are exported through this index
|
|
9
|
-
* - Plugin authors should only import from '@angular-modernizer/plugin-system'
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
// Plugin interfaces
|
|
13
|
-
export type {
|
|
14
|
-
Plugin,
|
|
15
|
-
AnalysisRule,
|
|
16
|
-
AnalysisResult,
|
|
17
|
-
TransformRule,
|
|
18
|
-
TransformResult,
|
|
19
|
-
ValidationRule,
|
|
20
|
-
ValidationResult,
|
|
21
|
-
PluginLifecycle,
|
|
22
|
-
IKernel,
|
|
23
|
-
} from './plugin-interface.js';
|
|
24
|
-
|
|
25
|
-
// Context objects
|
|
26
|
-
export type {
|
|
27
|
-
BaseContext,
|
|
28
|
-
AnalysisContext,
|
|
29
|
-
TransformContext,
|
|
30
|
-
ValidationContext,
|
|
31
|
-
} from './contexts.js';
|
|
32
|
-
|
|
33
|
-
export { ContextFactory } from './contexts.js';
|
package/src/plugin-interface.ts
DELETED
|
@@ -1,359 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @angular-modernizer/plugin-system - Plugin Interface
|
|
3
|
-
*
|
|
4
|
-
* Core contracts for the plugin ecosystem. This defines how plugins
|
|
5
|
-
* integrate with the Angular Modernization Platform.
|
|
6
|
-
*
|
|
7
|
-
* Design Philosophy: "API-Driven Plugins"
|
|
8
|
-
* - Plugins are powerless on their own
|
|
9
|
-
* - They receive capabilities through Context objects
|
|
10
|
-
* - The Context contains the PublicApi with all tools
|
|
11
|
-
* - This ensures plugins use battle-tested, reusable logic
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import type {
|
|
15
|
-
AnalysisContext,
|
|
16
|
-
TransformContext,
|
|
17
|
-
ValidationContext,
|
|
18
|
-
} from './contexts.ts';
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Minimal Kernel interface to avoid circular dependency.
|
|
22
|
-
* The actual Kernel implementation is in @angular-modernizer/core.
|
|
23
|
-
*
|
|
24
|
-
* Exposes a single accessor method for the project root, derived from
|
|
25
|
-
* tsConfigPath (if set) via path.dirname, or process.cwd() as a fallback.
|
|
26
|
-
* Safe to call during plugin.initialize() before Kernel.initialize() completes.
|
|
27
|
-
*/
|
|
28
|
-
export interface IKernel {
|
|
29
|
-
readonly __brand?: 'Kernel';
|
|
30
|
-
getProjectRoot(): string;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Core plugin interface.
|
|
35
|
-
* Every plugin must implement this interface to integrate with the platform.
|
|
36
|
-
*/
|
|
37
|
-
export interface Plugin {
|
|
38
|
-
/**
|
|
39
|
-
* Unique plugin identifier.
|
|
40
|
-
* Must be unique across all plugins in the system.
|
|
41
|
-
*/
|
|
42
|
-
readonly name: string;
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Plugin version (semantic versioning recommended).
|
|
46
|
-
*/
|
|
47
|
-
readonly version: string;
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Plugin description for documentation and tooling.
|
|
51
|
-
*/
|
|
52
|
-
readonly description?: string;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Plugin author information.
|
|
56
|
-
*/
|
|
57
|
-
readonly author?: string;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Initialize the plugin.
|
|
61
|
-
* Called once during Kernel initialization.
|
|
62
|
-
*
|
|
63
|
-
* @param kernel - The Kernel instance for accessing infrastructure
|
|
64
|
-
* @throws Error if initialization fails
|
|
65
|
-
*/
|
|
66
|
-
initialize(kernel: IKernel): Promise<void>;
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Get all analysis rules provided by this plugin.
|
|
70
|
-
* Analysis rules examine code and report violations/insights.
|
|
71
|
-
*
|
|
72
|
-
* @returns Array of analysis rules
|
|
73
|
-
*/
|
|
74
|
-
getAnalysisRules(): AnalysisRule[];
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Get all transformation rules provided by this plugin.
|
|
78
|
-
* Transformation rules modify code to fix violations or modernize patterns.
|
|
79
|
-
*
|
|
80
|
-
* @returns Array of transformation rules
|
|
81
|
-
*/
|
|
82
|
-
getTransformRules(): TransformRule[];
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Get all validation rules provided by this plugin.
|
|
86
|
-
* Validation rules verify that transformations were successful.
|
|
87
|
-
*
|
|
88
|
-
* @returns Array of validation rules
|
|
89
|
-
*/
|
|
90
|
-
getValidationRules(): ValidationRule[];
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Analysis Rule - examines code and reports findings.
|
|
95
|
-
*
|
|
96
|
-
* Analysis rules are READ-ONLY. They must never modify code.
|
|
97
|
-
* Their purpose is to identify patterns, violations, and opportunities.
|
|
98
|
-
*/
|
|
99
|
-
export interface AnalysisRule {
|
|
100
|
-
/**
|
|
101
|
-
* Unique rule identifier (scoped to plugin).
|
|
102
|
-
* Format: "plugin-name:rule-name" (e.g., "angular-standalone:component-not-standalone")
|
|
103
|
-
*/
|
|
104
|
-
readonly id: string;
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Human-readable rule name.
|
|
108
|
-
*/
|
|
109
|
-
readonly name: string;
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Rule description explaining what it checks.
|
|
113
|
-
*/
|
|
114
|
-
readonly description: string;
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Rule severity level.
|
|
118
|
-
*/
|
|
119
|
-
readonly severity: 'error' | 'warning' | 'info';
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Rule category for grouping.
|
|
123
|
-
*/
|
|
124
|
-
readonly category: string;
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Tags for filtering and search.
|
|
128
|
-
*/
|
|
129
|
-
readonly tags?: string[];
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Analyze a source file and return findings.
|
|
133
|
-
*
|
|
134
|
-
* @param context - Analysis context with file, project, and API access
|
|
135
|
-
* @returns Promise resolving to array of analysis results
|
|
136
|
-
*/
|
|
137
|
-
analyze(context: AnalysisContext): Promise<AnalysisResult[]>;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Result from an analysis rule execution.
|
|
142
|
-
*/
|
|
143
|
-
export interface AnalysisResult {
|
|
144
|
-
/**
|
|
145
|
-
* Rule that produced this result.
|
|
146
|
-
*/
|
|
147
|
-
ruleId: string;
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Result message for display.
|
|
151
|
-
*/
|
|
152
|
-
message: string;
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* File path where the issue was found.
|
|
156
|
-
*/
|
|
157
|
-
filePath: string;
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Line number (1-indexed) where the issue starts.
|
|
161
|
-
*/
|
|
162
|
-
line?: number;
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Column number (0-indexed) where the issue starts.
|
|
166
|
-
*/
|
|
167
|
-
column?: number;
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Suggested fix (if applicable).
|
|
171
|
-
*/
|
|
172
|
-
suggestedFix?: string;
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Additional metadata.
|
|
176
|
-
*/
|
|
177
|
-
metadata?: Record<string, unknown>;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Transform Rule - modifies code to fix issues or modernize patterns.
|
|
182
|
-
*
|
|
183
|
-
* Transform rules are WRITE operations. They must be:
|
|
184
|
-
* - Idempotent: Running twice should be safe
|
|
185
|
-
* - Atomic: Either fully succeed or fully fail
|
|
186
|
-
* - Reversible: Should not cause data loss
|
|
187
|
-
*/
|
|
188
|
-
export interface TransformRule {
|
|
189
|
-
/**
|
|
190
|
-
* Unique rule identifier (scoped to plugin).
|
|
191
|
-
*/
|
|
192
|
-
readonly id: string;
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Human-readable rule name.
|
|
196
|
-
*/
|
|
197
|
-
readonly name: string;
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Rule description explaining what it does.
|
|
201
|
-
*/
|
|
202
|
-
readonly description: string;
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Rule category for grouping.
|
|
206
|
-
*/
|
|
207
|
-
readonly category: string;
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Tags for filtering and search.
|
|
211
|
-
*/
|
|
212
|
-
readonly tags?: string[];
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Transform a source file.
|
|
216
|
-
*
|
|
217
|
-
* @param context - Transform context with file, project, and API access
|
|
218
|
-
* @returns Promise resolving to transform result
|
|
219
|
-
*/
|
|
220
|
-
transform(context: TransformContext): Promise<TransformResult>;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* Result from a transform rule execution.
|
|
225
|
-
*/
|
|
226
|
-
export interface TransformResult {
|
|
227
|
-
/**
|
|
228
|
-
* Rule that produced this result.
|
|
229
|
-
*/
|
|
230
|
-
ruleId: string;
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* Whether the file was modified.
|
|
234
|
-
*/
|
|
235
|
-
modified: boolean;
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* Human-readable message describing what was done.
|
|
239
|
-
*/
|
|
240
|
-
message: string;
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* File path that was transformed.
|
|
244
|
-
*/
|
|
245
|
-
filePath: string;
|
|
246
|
-
|
|
247
|
-
/**
|
|
248
|
-
* Number of changes made.
|
|
249
|
-
*/
|
|
250
|
-
changeCount?: number;
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* Additional metadata.
|
|
254
|
-
*/
|
|
255
|
-
metadata?: Record<string, unknown>;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* Validation Rule - verifies that code meets requirements.
|
|
260
|
-
*
|
|
261
|
-
* Validation rules are READ-ONLY checks that run after transformations
|
|
262
|
-
* to ensure correctness. They're like analysis rules, but focused on
|
|
263
|
-
* post-transformation verification.
|
|
264
|
-
*/
|
|
265
|
-
export interface ValidationRule {
|
|
266
|
-
/**
|
|
267
|
-
* Unique rule identifier (scoped to plugin).
|
|
268
|
-
*/
|
|
269
|
-
readonly id: string;
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* Human-readable rule name.
|
|
273
|
-
*/
|
|
274
|
-
readonly name: string;
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* Rule description explaining what it validates.
|
|
278
|
-
*/
|
|
279
|
-
readonly description: string;
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Rule category for grouping.
|
|
283
|
-
*/
|
|
284
|
-
readonly category: string;
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* Validate a source file.
|
|
288
|
-
*
|
|
289
|
-
* @param context - Validation context with file, project, and API access
|
|
290
|
-
* @returns Promise resolving to validation result
|
|
291
|
-
*/
|
|
292
|
-
validate(context: ValidationContext): Promise<ValidationResult>;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* Result from a validation rule execution.
|
|
297
|
-
*/
|
|
298
|
-
export interface ValidationResult {
|
|
299
|
-
/**
|
|
300
|
-
* Rule that produced this result.
|
|
301
|
-
*/
|
|
302
|
-
ruleId: string;
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* Whether validation passed.
|
|
306
|
-
*/
|
|
307
|
-
passed: boolean;
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* Validation message.
|
|
311
|
-
*/
|
|
312
|
-
message: string;
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* File path that was validated.
|
|
316
|
-
*/
|
|
317
|
-
filePath: string;
|
|
318
|
-
|
|
319
|
-
/**
|
|
320
|
-
* Additional details if validation failed.
|
|
321
|
-
*/
|
|
322
|
-
details?: string;
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* Additional metadata.
|
|
326
|
-
*/
|
|
327
|
-
metadata?: Record<string, unknown>;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* Plugin lifecycle events.
|
|
332
|
-
* Plugins can optionally implement these hooks for advanced scenarios.
|
|
333
|
-
*/
|
|
334
|
-
export interface PluginLifecycle {
|
|
335
|
-
/**
|
|
336
|
-
* Called before analysis begins.
|
|
337
|
-
*/
|
|
338
|
-
onBeforeAnalysis?(): Promise<void>;
|
|
339
|
-
|
|
340
|
-
/**
|
|
341
|
-
* Called after analysis completes.
|
|
342
|
-
*/
|
|
343
|
-
onAfterAnalysis?(): Promise<void>;
|
|
344
|
-
|
|
345
|
-
/**
|
|
346
|
-
* Called before transformations begin.
|
|
347
|
-
*/
|
|
348
|
-
onBeforeTransform?(): Promise<void>;
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* Called after transformations complete.
|
|
352
|
-
*/
|
|
353
|
-
onAfterTransform?(): Promise<void>;
|
|
354
|
-
|
|
355
|
-
/**
|
|
356
|
-
* Called when the plugin is being shut down.
|
|
357
|
-
*/
|
|
358
|
-
onShutdown?(): Promise<void>;
|
|
359
|
-
}
|