@webpieces/code-rules 0.4.819 → 0.4.821
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/package.json +2 -2
- package/src/api-lib-source-rule.d.ts +5 -2
- package/src/api-lib-source-rule.js +8 -4
- package/src/api-lib-source-rule.js.map +1 -1
- package/src/cli.js +13 -14
- package/src/cli.js.map +1 -1
- package/src/code-rules-bootstrap.d.ts +31 -8
- package/src/code-rules-bootstrap.js +136 -18
- package/src/code-rules-bootstrap.js.map +1 -1
- package/src/code-rules-config-table.d.ts +3 -1
- package/src/code-rules-config-table.js +0 -6
- package/src/code-rules-config-table.js.map +1 -1
- package/src/code-rules-engine.d.ts +4 -13
- package/src/code-rules-engine.js +9 -31
- package/src/code-rules-engine.js.map +1 -1
- package/src/code-rules-run-request.d.ts +30 -34
- package/src/code-rules-run-request.js +43 -80
- package/src/code-rules-run-request.js.map +1 -1
- package/src/index.d.ts +3 -1
- package/src/index.js +13 -2
- package/src/index.js.map +1 -1
- package/src/resolve-mode.d.ts +1 -1
- package/src/resolve-mode.js +2 -3
- package/src/resolve-mode.js.map +1 -1
- package/src/scan-scope.d.ts +82 -0
- package/src/scan-scope.js +200 -0
- package/src/scan-scope.js.map +1 -0
- package/src/validate-catch-error-pattern.d.ts +3 -1
- package/src/validate-catch-error-pattern.js +11 -6
- package/src/validate-catch-error-pattern.js.map +1 -1
- package/src/validate-code.d.ts +4 -5
- package/src/validate-code.js +6 -17
- package/src/validate-code.js.map +1 -1
- package/src/validate-inject-annotation-not-needed-for-concrete-class.d.ts +3 -1
- package/src/validate-inject-annotation-not-needed-for-concrete-class.js +11 -6
- package/src/validate-inject-annotation-not-needed-for-concrete-class.js.map +1 -1
- package/src/validate-match-rules.d.ts +3 -0
- package/src/validate-match-rules.js +10 -3
- package/src/validate-match-rules.js.map +1 -1
- package/src/validate-no-any-unknown.d.ts +3 -1
- package/src/validate-no-any-unknown.js +11 -6
- package/src/validate-no-any-unknown.js.map +1 -1
- package/src/validate-no-client-creation-outside-server-or-client.d.ts +4 -2
- package/src/validate-no-client-creation-outside-server-or-client.js +10 -5
- package/src/validate-no-client-creation-outside-server-or-client.js.map +1 -1
- package/src/validate-no-custom-css.d.ts +4 -2
- package/src/validate-no-custom-css.js +9 -5
- package/src/validate-no-custom-css.js.map +1 -1
- package/src/validate-no-destructure.d.ts +3 -1
- package/src/validate-no-destructure.js +11 -6
- package/src/validate-no-destructure.js.map +1 -1
- package/src/validate-no-function-outside-class.d.ts +3 -1
- package/src/validate-no-function-outside-class.js +12 -6
- package/src/validate-no-function-outside-class.js.map +1 -1
- package/src/validate-no-implicit-any.d.ts +3 -1
- package/src/validate-no-implicit-any.js +13 -8
- package/src/validate-no-implicit-any.js.map +1 -1
- package/src/validate-no-inline-import-in-api-lib.d.ts +2 -1
- package/src/validate-no-inline-import-in-api-lib.js +4 -3
- package/src/validate-no-inline-import-in-api-lib.js.map +1 -1
- package/src/validate-no-process-exit-outside-main.d.ts +3 -1
- package/src/validate-no-process-exit-outside-main.js +12 -6
- package/src/validate-no-process-exit-outside-main.js.map +1 -1
- package/src/validate-no-state-paths-in-templates.d.ts +4 -2
- package/src/validate-no-state-paths-in-templates.js +9 -5
- package/src/validate-no-state-paths-in-templates.js.map +1 -1
- package/src/validate-no-symbol-di-tokens.d.ts +3 -1
- package/src/validate-no-symbol-di-tokens.js +11 -6
- package/src/validate-no-symbol-di-tokens.js.map +1 -1
- package/src/validate-no-unmanaged-exceptions.d.ts +3 -1
- package/src/validate-no-unmanaged-exceptions.js +11 -6
- package/src/validate-no-unmanaged-exceptions.js.map +1 -1
- package/src/validate-no-utility-types-in-api-lib.d.ts +2 -1
- package/src/validate-no-utility-types-in-api-lib.js +4 -3
- package/src/validate-no-utility-types-in-api-lib.js.map +1 -1
- package/src/validate-one-enum-spelling-in-api-lib.d.ts +2 -1
- package/src/validate-one-enum-spelling-in-api-lib.js +4 -3
- package/src/validate-one-enum-spelling-in-api-lib.js.map +1 -1
- package/src/validate-required-type-suffix.d.ts +2 -1
- package/src/validate-required-type-suffix.js +7 -3
- package/src/validate-required-type-suffix.js.map +1 -1
- package/src/wp-ci.d.ts +2 -2
- package/src/wp-ci.js +11 -5
- package/src/wp-ci.js.map +1 -1
- package/src/debug-run-report.d.ts +0 -22
- package/src/debug-run-report.js +0 -127
- package/src/debug-run-report.js.map +0 -1
- package/src/rule-scope-plan.d.ts +0 -72
- package/src/rule-scope-plan.js +0 -132
- package/src/rule-scope-plan.js.map +0 -1
package/src/code-rules-engine.js
CHANGED
|
@@ -2,14 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CodeRulesEngine = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const rules_config_1 = require("@webpieces/rules-config");
|
|
6
5
|
const inversify_1 = require("inversify");
|
|
7
6
|
const code_validator_1 = require("./code-validator");
|
|
8
7
|
const rule_reporter_1 = require("./rule-reporter");
|
|
9
8
|
const code_rules_context_1 = require("./code-rules-context");
|
|
10
9
|
const code_rules_run_request_1 = require("./code-rules-run-request");
|
|
11
|
-
const debug_run_report_1 = require("./debug-run-report");
|
|
12
|
-
const rule_scope_plan_1 = require("./rule-scope-plan");
|
|
13
10
|
const validate_match_rules_1 = require("./validate-match-rules");
|
|
14
11
|
const validate_modified_methods_1 = require("./validate-modified-methods");
|
|
15
12
|
const validate_modified_files_1 = require("./validate-modified-files");
|
|
@@ -48,10 +45,7 @@ let CodeRulesEngine = class CodeRulesEngine {
|
|
|
48
45
|
reporter;
|
|
49
46
|
matchRules;
|
|
50
47
|
matchChecker;
|
|
51
|
-
|
|
52
|
-
scopes;
|
|
53
|
-
debugReport;
|
|
54
|
-
diffScope;
|
|
48
|
+
selection;
|
|
55
49
|
maxMethodLines;
|
|
56
50
|
maxFileLines;
|
|
57
51
|
requireReturnType;
|
|
@@ -79,15 +73,12 @@ let CodeRulesEngine = class CodeRulesEngine {
|
|
|
79
73
|
noUtilityTypesInApiLib;
|
|
80
74
|
requiredTypeSuffix;
|
|
81
75
|
// webpieces-disable max-lines-new-methods -- the built-in validator set is flat; each is one injected field
|
|
82
|
-
constructor(workspace, reporter, matchRules, matchChecker,
|
|
76
|
+
constructor(workspace, reporter, matchRules, matchChecker, selection, maxMethodLines, maxFileLines, requireReturnType, noInlineTypeLiterals, noAnyUnknown, noImplicitAny, prismaValidateDtos, prismaConverter, noDestructure, catchErrorPattern, noUnmanagedExceptions, noDirectApiResolver, noSymbolDiTokens, noClientCreationOutsideServerOrClient, noCustomCss, noStatePathsInTemplates, noProcessExitOutsideMain, noFunctionOutsideClass, injectAnnotationNotNeeded, frameworkTag, roleTag, ensureWeAreSecure, noInlineImportInApiLib, oneEnumSpellingInApiLib, noUtilityTypesInApiLib, requiredTypeSuffix) {
|
|
83
77
|
this.workspace = workspace;
|
|
84
78
|
this.reporter = reporter;
|
|
85
79
|
this.matchRules = matchRules;
|
|
86
80
|
this.matchChecker = matchChecker;
|
|
87
|
-
this.
|
|
88
|
-
this.scopes = scopes;
|
|
89
|
-
this.debugReport = debugReport;
|
|
90
|
-
this.diffScope = diffScope;
|
|
81
|
+
this.selection = selection;
|
|
91
82
|
this.maxMethodLines = maxMethodLines;
|
|
92
83
|
this.maxFileLines = maxFileLines;
|
|
93
84
|
this.requireReturnType = requireReturnType;
|
|
@@ -150,27 +141,20 @@ let CodeRulesEngine = class CodeRulesEngine {
|
|
|
150
141
|
* Every ACTIVE run: an injected built-in validator whose `shouldRun()` is true, or an injected
|
|
151
142
|
* match-rule check per configured entry that is active. Built as {@link RuleRun} value objects
|
|
152
143
|
* (name + thunk) so NO DAG member is `new`-ed — the validators and the checker are injected.
|
|
144
|
+
* A debug run (#1027) narrows the set to the one rule its {@link RuleSelection} names.
|
|
153
145
|
*/
|
|
154
146
|
activeRuns(root) {
|
|
155
147
|
const runs = [];
|
|
156
148
|
for (const v of this.builtIns()) {
|
|
157
|
-
if (this.
|
|
158
|
-
runs.push(new code_validator_1.RuleRun(v.name, () =>
|
|
149
|
+
if (this.selection.includes(v.name) && v.shouldRun())
|
|
150
|
+
runs.push(new code_validator_1.RuleRun(v.name, () => v.run(root)));
|
|
159
151
|
}
|
|
160
152
|
for (const mr of this.matchRules.rules) {
|
|
161
|
-
if (this.
|
|
162
|
-
runs.push(new code_validator_1.RuleRun(mr.name, () => this.
|
|
153
|
+
if (this.selection.includes(mr.name) && this.matchChecker.shouldRun(mr))
|
|
154
|
+
runs.push(new code_validator_1.RuleRun(mr.name, () => this.matchChecker.runForConfig(mr, root)));
|
|
163
155
|
}
|
|
164
156
|
return runs;
|
|
165
157
|
}
|
|
166
|
-
/** The gate runs every rule; a debug run only the one it names. */
|
|
167
|
-
selected(key) {
|
|
168
|
-
return this.request.rule === null || this.request.rule === key;
|
|
169
|
-
}
|
|
170
|
-
/** Run one rule inside its planned {@link FileScope} (whole-scope modes, `--projects`). */
|
|
171
|
-
scoped(scope, work) {
|
|
172
|
-
return this.diffScope.within(scope, work);
|
|
173
|
-
}
|
|
174
158
|
/**
|
|
175
159
|
* Run all configured code validators against the workspace. A validator runs only when
|
|
176
160
|
* `shouldRun()` is true (mode not OFF and no branch/epoch escape hatch). Per-run isolation lives
|
|
@@ -178,9 +162,6 @@ let CodeRulesEngine = class CodeRulesEngine {
|
|
|
178
162
|
*/
|
|
179
163
|
async run() {
|
|
180
164
|
const runs = this.activeRuns(this.workspace.path);
|
|
181
|
-
const target = this.scopes.debugTarget;
|
|
182
|
-
if (target !== null)
|
|
183
|
-
return this.debugReport.run(this.workspace.path, runs, target);
|
|
184
165
|
if (runs.length === 0) {
|
|
185
166
|
console.log('\n⏭️ Skipping all code validations (all modes: OFF)\n');
|
|
186
167
|
return { success: true };
|
|
@@ -202,10 +183,7 @@ exports.CodeRulesEngine = CodeRulesEngine = tslib_1.__decorate([
|
|
|
202
183
|
rule_reporter_1.RuleReporter,
|
|
203
184
|
code_rules_context_1.MatchRulesHolder,
|
|
204
185
|
validate_match_rules_1.MatchRulesChecker,
|
|
205
|
-
code_rules_run_request_1.
|
|
206
|
-
rule_scope_plan_1.RuleScopes,
|
|
207
|
-
debug_run_report_1.DebugRunReport,
|
|
208
|
-
rules_config_1.DiffScope,
|
|
186
|
+
code_rules_run_request_1.RuleSelection,
|
|
209
187
|
validate_modified_methods_1.MaxMethodLinesValidator,
|
|
210
188
|
validate_modified_files_1.MaxFileLinesValidator,
|
|
211
189
|
validate_return_types_1.RequireReturnTypeValidator,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-rules-engine.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/code-rules-engine.ts"],"names":[],"mappings":";;;;AAAA,0DAA+E;AAC/E,yCAA2D;AAE3D,qDAA0E;AAC1E,mDAA+C;AAC/C,6DAAuE;AACvE,qEAA+D;AAC/D,yDAAoD;AACpD,uDAA+C;AAC/C,iEAA2D;AAC3D,2EAAsE;AACtE,uEAAkE;AAClE,mEAAqE;AACrE,yEAA2E;AAC3E,uEAAkE;AAClE,yEAAoE;AACpE,mDAA8D;AAC9D,6EAAwE;AACxE,uEAAmE;AACnE,iFAA4E;AAC5E,yFAAoF;AACpF,uFAAiF;AACjF,iFAA2E;AAC3E,iIAAwH;AACxH,qEAAgE;AAChE,iGAA0F;AAC1F,mGAA4F;AAC5F,6FAAuF;AACvF,yIAAgI;AAChI,qEAAiE;AACjE,2DAAuD;AACvD,mFAA6E;AAC7E,iGAAyF;AACzF,mGAA2F;AAC3F,iGAAyF;AACzF,mFAA8E;AAE9E;;;;;GAKG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAe;IAGH;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAnCrB,4GAA4G;IAC5G,YACqB,SAAwB,EACxB,QAAsB,EACtB,UAA4B,EAC5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ACzB,+CAAqB;QAChB,kDAA0B;QACvB,wDAA6B;QACrC,+CAAqB;QACpB,iDAAsB;QACjB,2CAA2B;QAC9B,qDAAwB;QAC1B,gDAAsB;QAClB,yDAA0B;QACtB,iEAA8B;QAChC,8DAA4B;QAC/B,wDAAyB;QACJ,qGAA8C;QACxE,6CAAoB;QACR,uEAAgC;QAC/B,yEAAiC;QACnC,oEAA+B;QAC5B,6GAAkD;QAC/D,8CAAqB;QAC1B,oCAAgB;QACN,0DAA0B;QACrB,sEAA+B;QAC9B,wEAAgC;QACjC,sEAA+B;QACnC,2DAA2B;GApC3D,eAAe,CA6H3B","sourcesContent":["import { BaseRuleConfig, DiffScope, FileScope } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { CodeValidator, ExecutorResult, RuleRun } from './code-validator';\nimport { RuleReporter } from './rule-reporter';\nimport { WorkspaceRoot, MatchRulesHolder } from './code-rules-context';\nimport { CodeRulesRunRequest } from './code-rules-run-request';\nimport { DebugRunReport } from './debug-run-report';\nimport { RuleScopes } from './rule-scope-plan';\nimport { MatchRulesChecker } from './validate-match-rules';\nimport { MaxMethodLinesValidator } from './validate-modified-methods';\nimport { MaxFileLinesValidator } from './validate-modified-files';\nimport { RequireReturnTypeValidator } from './validate-return-types';\nimport { NoInlineTypeLiteralsValidator } from './validate-no-inline-types';\nimport { NoAnyUnknownValidator } from './validate-no-any-unknown';\nimport { NoImplicitAnyValidator } from './validate-no-implicit-any';\nimport { PrismaValidateDtosValidator } from './validate-dtos';\nimport { PrismaConverterValidator } from './validate-prisma-converters';\nimport { NoDestructureValidator } from './validate-no-destructure';\nimport { CatchErrorPatternValidator } from './validate-catch-error-pattern';\nimport { NoUnmanagedExceptionsValidator } from './validate-no-unmanaged-exceptions';\nimport { NoDirectApiResolverValidator } from './validate-no-direct-api-resolver';\nimport { NoSymbolDiTokensValidator } from './validate-no-symbol-di-tokens';\nimport { NoClientCreationOutsideServerOrClientValidator } from './validate-no-client-creation-outside-server-or-client';\nimport { NoCustomCssValidator } from './validate-no-custom-css';\nimport { NoStatePathsInTemplatesValidator } from './validate-no-state-paths-in-templates';\nimport { NoProcessExitOutsideMainValidator } from './validate-no-process-exit-outside-main';\nimport { NoFunctionOutsideClassValidator } from './validate-no-function-outside-class';\nimport { InjectAnnotationNotNeededForConcreteClassValidator } from './validate-inject-annotation-not-needed-for-concrete-class';\nimport { FrameworkTagValidator } from './validate-framework-tag';\nimport { RoleTagValidator } from './validate-role-tag';\nimport { EnsureWeAreSecureValidator } from './validate-ensure-we-are-secure';\nimport { NoInlineImportInApiLibValidator } from './validate-no-inline-import-in-api-lib';\nimport { OneEnumSpellingInApiLibValidator } from './validate-one-enum-spelling-in-api-lib';\nimport { NoUtilityTypesInApiLibValidator } from './validate-no-utility-types-in-api-lib';\nimport { RequiredTypeSuffixValidator } from './validate-required-type-suffix';\n\n/**\n * Owns running the code-rules suite. Every built-in validator is injected as a singleton (its config\n * is bound in the container at bootstrap), so this class IS the code-rules DI DAG the design graph\n * draws. The per-entry match-rules validators are the one exception — they are config-per-instance,\n * so they are built from the injected {@link MatchRulesHolder}.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class CodeRulesEngine {\n // webpieces-disable max-lines-new-methods -- the built-in validator set is flat; each is one injected field\n constructor(\n private readonly workspace: WorkspaceRoot,\n private readonly reporter: RuleReporter,\n private readonly matchRules: MatchRulesHolder,\n private readonly matchChecker: MatchRulesChecker,\n private readonly request: CodeRulesRunRequest,\n private readonly scopes: RuleScopes,\n private readonly debugReport: DebugRunReport,\n private readonly diffScope: DiffScope,\n private readonly maxMethodLines: MaxMethodLinesValidator,\n private readonly maxFileLines: MaxFileLinesValidator,\n private readonly requireReturnType: RequireReturnTypeValidator,\n private readonly noInlineTypeLiterals: NoInlineTypeLiteralsValidator,\n private readonly noAnyUnknown: NoAnyUnknownValidator,\n private readonly noImplicitAny: NoImplicitAnyValidator,\n private readonly prismaValidateDtos: PrismaValidateDtosValidator,\n private readonly prismaConverter: PrismaConverterValidator,\n private readonly noDestructure: NoDestructureValidator,\n private readonly catchErrorPattern: CatchErrorPatternValidator,\n private readonly noUnmanagedExceptions: NoUnmanagedExceptionsValidator,\n private readonly noDirectApiResolver: NoDirectApiResolverValidator,\n private readonly noSymbolDiTokens: NoSymbolDiTokensValidator,\n private readonly noClientCreationOutsideServerOrClient: NoClientCreationOutsideServerOrClientValidator,\n private readonly noCustomCss: NoCustomCssValidator,\n private readonly noStatePathsInTemplates: NoStatePathsInTemplatesValidator,\n private readonly noProcessExitOutsideMain: NoProcessExitOutsideMainValidator,\n private readonly noFunctionOutsideClass: NoFunctionOutsideClassValidator,\n private readonly injectAnnotationNotNeeded: InjectAnnotationNotNeededForConcreteClassValidator,\n private readonly frameworkTag: FrameworkTagValidator,\n private readonly roleTag: RoleTagValidator,\n private readonly ensureWeAreSecure: EnsureWeAreSecureValidator,\n private readonly noInlineImportInApiLib: NoInlineImportInApiLibValidator,\n private readonly oneEnumSpellingInApiLib: OneEnumSpellingInApiLibValidator,\n private readonly noUtilityTypesInApiLib: NoUtilityTypesInApiLibValidator,\n private readonly requiredTypeSuffix: RequiredTypeSuffixValidator,\n ) {}\n\n /** The injected built-in validators, in run order. */\n private builtIns(): CodeValidator<BaseRuleConfig>[] {\n return [\n this.maxMethodLines,\n this.maxFileLines,\n this.requireReturnType,\n this.noInlineTypeLiterals,\n this.noAnyUnknown,\n this.noImplicitAny,\n this.prismaValidateDtos,\n this.prismaConverter,\n this.noDestructure,\n this.catchErrorPattern,\n this.noUnmanagedExceptions,\n this.noDirectApiResolver,\n this.noSymbolDiTokens,\n this.noClientCreationOutsideServerOrClient,\n this.noCustomCss,\n this.noStatePathsInTemplates,\n this.noProcessExitOutsideMain,\n this.noFunctionOutsideClass,\n this.injectAnnotationNotNeeded,\n this.frameworkTag,\n this.roleTag,\n this.ensureWeAreSecure,\n this.noInlineImportInApiLib,\n this.oneEnumSpellingInApiLib,\n this.noUtilityTypesInApiLib,\n this.requiredTypeSuffix,\n ];\n }\n\n /**\n * Every ACTIVE run: an injected built-in validator whose `shouldRun()` is true, or an injected\n * match-rule check per configured entry that is active. Built as {@link RuleRun} value objects\n * (name + thunk) so NO DAG member is `new`-ed — the validators and the checker are injected.\n */\n private activeRuns(root: string): RuleRun[] {\n const runs: RuleRun[] = [];\n for (const v of this.builtIns()) {\n if (this.selected(v.configKey) && v.shouldRun())\n runs.push(new RuleRun(v.name, () => this.scoped(this.scopes.of(v.configKey), () => v.run(root))));\n }\n for (const mr of this.matchRules.rules) {\n if (this.selected(mr.name) && this.matchChecker.shouldRun(mr))\n runs.push(new RuleRun(mr.name, () => this.scoped(this.scopes.of(mr.name), () => this.matchChecker.runForConfig(mr, root))));\n }\n return runs;\n }\n\n /** The gate runs every rule; a debug run only the one it names. */\n private selected(key: string): boolean {\n return this.request.rule === null || this.request.rule === key;\n }\n\n /** Run one rule inside its planned {@link FileScope} (whole-scope modes, `--projects`). */\n private scoped(scope: FileScope, work: () => Promise<ExecutorResult>): Promise<ExecutorResult> {\n return this.diffScope.within(scope, work);\n }\n\n /**\n * Run all configured code validators against the workspace. A validator runs only when\n * `shouldRun()` is true (mode not OFF and no branch/epoch escape hatch). Per-run isolation lives\n * in {@link RuleReporter} so one validator can never abort the rest.\n */\n async run(): Promise<ExecutorResult> {\n const runs = this.activeRuns(this.workspace.path);\n const target = this.scopes.debugTarget;\n if (target !== null) return this.debugReport.run(this.workspace.path, runs, target);\n if (runs.length === 0) {\n console.log('\\n⏭️ Skipping all code validations (all modes: OFF)\\n');\n return { success: true };\n }\n\n console.log('\\n📏 Running Code Validations\\n');\n console.log(` Active rules: ${runs.map((r: RuleRun) => r.name).join(', ')}`);\n console.log('');\n\n const result = await this.reporter.runValidators(runs);\n console.log(\n result.success\n ? '\\n✅ All code validations passed\\n'\n : '\\n❌ Some code validations failed\\n',\n );\n return result;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"code-rules-engine.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules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gDAAsB;QAClB,yDAA0B;QACtB,iEAA8B;QAChC,8DAA4B;QAC/B,wDAAyB;QACJ,qGAA8C;QACxE,6CAAoB;QACR,uEAAgC;QAC/B,yEAAiC;QACnC,oEAA+B;QAC5B,6GAAkD;QAC/D,8CAAqB;QAC1B,oCAAgB;QACN,0DAA0B;QACrB,sEAA+B;QAC9B,wEAAgC;QACjC,sEAA+B;QACnC,2DAA2B;GAjC3D,eAAe,CA8G3B","sourcesContent":["import { BaseRuleConfig } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { CodeValidator, ExecutorResult, RuleRun } from './code-validator';\nimport { RuleReporter } from './rule-reporter';\nimport { WorkspaceRoot, MatchRulesHolder } from './code-rules-context';\nimport { RuleSelection } from './code-rules-run-request';\nimport { MatchRulesChecker } from './validate-match-rules';\nimport { MaxMethodLinesValidator } from './validate-modified-methods';\nimport { MaxFileLinesValidator } from './validate-modified-files';\nimport { RequireReturnTypeValidator } from './validate-return-types';\nimport { NoInlineTypeLiteralsValidator } from './validate-no-inline-types';\nimport { NoAnyUnknownValidator } from './validate-no-any-unknown';\nimport { NoImplicitAnyValidator } from './validate-no-implicit-any';\nimport { PrismaValidateDtosValidator } from './validate-dtos';\nimport { PrismaConverterValidator } from './validate-prisma-converters';\nimport { NoDestructureValidator } from './validate-no-destructure';\nimport { CatchErrorPatternValidator } from './validate-catch-error-pattern';\nimport { NoUnmanagedExceptionsValidator } from './validate-no-unmanaged-exceptions';\nimport { NoDirectApiResolverValidator } from './validate-no-direct-api-resolver';\nimport { NoSymbolDiTokensValidator } from './validate-no-symbol-di-tokens';\nimport { NoClientCreationOutsideServerOrClientValidator } from './validate-no-client-creation-outside-server-or-client';\nimport { NoCustomCssValidator } from './validate-no-custom-css';\nimport { NoStatePathsInTemplatesValidator } from './validate-no-state-paths-in-templates';\nimport { NoProcessExitOutsideMainValidator } from './validate-no-process-exit-outside-main';\nimport { NoFunctionOutsideClassValidator } from './validate-no-function-outside-class';\nimport { InjectAnnotationNotNeededForConcreteClassValidator } from './validate-inject-annotation-not-needed-for-concrete-class';\nimport { FrameworkTagValidator } from './validate-framework-tag';\nimport { RoleTagValidator } from './validate-role-tag';\nimport { EnsureWeAreSecureValidator } from './validate-ensure-we-are-secure';\nimport { NoInlineImportInApiLibValidator } from './validate-no-inline-import-in-api-lib';\nimport { OneEnumSpellingInApiLibValidator } from './validate-one-enum-spelling-in-api-lib';\nimport { NoUtilityTypesInApiLibValidator } from './validate-no-utility-types-in-api-lib';\nimport { RequiredTypeSuffixValidator } from './validate-required-type-suffix';\n\n/**\n * Owns running the code-rules suite. Every built-in validator is injected as a singleton (its config\n * is bound in the container at bootstrap), so this class IS the code-rules DI DAG the design graph\n * draws. The per-entry match-rules validators are the one exception — they are config-per-instance,\n * so they are built from the injected {@link MatchRulesHolder}.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class CodeRulesEngine {\n // webpieces-disable max-lines-new-methods -- the built-in validator set is flat; each is one injected field\n constructor(\n private readonly workspace: WorkspaceRoot,\n private readonly reporter: RuleReporter,\n private readonly matchRules: MatchRulesHolder,\n private readonly matchChecker: MatchRulesChecker,\n private readonly selection: RuleSelection,\n private readonly maxMethodLines: MaxMethodLinesValidator,\n private readonly maxFileLines: MaxFileLinesValidator,\n private readonly requireReturnType: RequireReturnTypeValidator,\n private readonly noInlineTypeLiterals: NoInlineTypeLiteralsValidator,\n private readonly noAnyUnknown: NoAnyUnknownValidator,\n private readonly noImplicitAny: NoImplicitAnyValidator,\n private readonly prismaValidateDtos: PrismaValidateDtosValidator,\n private readonly prismaConverter: PrismaConverterValidator,\n private readonly noDestructure: NoDestructureValidator,\n private readonly catchErrorPattern: CatchErrorPatternValidator,\n private readonly noUnmanagedExceptions: NoUnmanagedExceptionsValidator,\n private readonly noDirectApiResolver: NoDirectApiResolverValidator,\n private readonly noSymbolDiTokens: NoSymbolDiTokensValidator,\n private readonly noClientCreationOutsideServerOrClient: NoClientCreationOutsideServerOrClientValidator,\n private readonly noCustomCss: NoCustomCssValidator,\n private readonly noStatePathsInTemplates: NoStatePathsInTemplatesValidator,\n private readonly noProcessExitOutsideMain: NoProcessExitOutsideMainValidator,\n private readonly noFunctionOutsideClass: NoFunctionOutsideClassValidator,\n private readonly injectAnnotationNotNeeded: InjectAnnotationNotNeededForConcreteClassValidator,\n private readonly frameworkTag: FrameworkTagValidator,\n private readonly roleTag: RoleTagValidator,\n private readonly ensureWeAreSecure: EnsureWeAreSecureValidator,\n private readonly noInlineImportInApiLib: NoInlineImportInApiLibValidator,\n private readonly oneEnumSpellingInApiLib: OneEnumSpellingInApiLibValidator,\n private readonly noUtilityTypesInApiLib: NoUtilityTypesInApiLibValidator,\n private readonly requiredTypeSuffix: RequiredTypeSuffixValidator,\n ) {}\n\n /** The injected built-in validators, in run order. */\n private builtIns(): CodeValidator<BaseRuleConfig>[] {\n return [\n this.maxMethodLines,\n this.maxFileLines,\n this.requireReturnType,\n this.noInlineTypeLiterals,\n this.noAnyUnknown,\n this.noImplicitAny,\n this.prismaValidateDtos,\n this.prismaConverter,\n this.noDestructure,\n this.catchErrorPattern,\n this.noUnmanagedExceptions,\n this.noDirectApiResolver,\n this.noSymbolDiTokens,\n this.noClientCreationOutsideServerOrClient,\n this.noCustomCss,\n this.noStatePathsInTemplates,\n this.noProcessExitOutsideMain,\n this.noFunctionOutsideClass,\n this.injectAnnotationNotNeeded,\n this.frameworkTag,\n this.roleTag,\n this.ensureWeAreSecure,\n this.noInlineImportInApiLib,\n this.oneEnumSpellingInApiLib,\n this.noUtilityTypesInApiLib,\n this.requiredTypeSuffix,\n ];\n }\n\n /**\n * Every ACTIVE run: an injected built-in validator whose `shouldRun()` is true, or an injected\n * match-rule check per configured entry that is active. Built as {@link RuleRun} value objects\n * (name + thunk) so NO DAG member is `new`-ed — the validators and the checker are injected.\n * A debug run (#1027) narrows the set to the one rule its {@link RuleSelection} names.\n */\n private activeRuns(root: string): RuleRun[] {\n const runs: RuleRun[] = [];\n for (const v of this.builtIns()) {\n if (this.selection.includes(v.name) && v.shouldRun()) runs.push(new RuleRun(v.name, () => v.run(root)));\n }\n for (const mr of this.matchRules.rules) {\n if (this.selection.includes(mr.name) && this.matchChecker.shouldRun(mr))\n runs.push(new RuleRun(mr.name, () => this.matchChecker.runForConfig(mr, root)));\n }\n return runs;\n }\n\n /**\n * Run all configured code validators against the workspace. A validator runs only when\n * `shouldRun()` is true (mode not OFF and no branch/epoch escape hatch). Per-run isolation lives\n * in {@link RuleReporter} so one validator can never abort the rest.\n */\n async run(): Promise<ExecutorResult> {\n const runs = this.activeRuns(this.workspace.path);\n if (runs.length === 0) {\n console.log('\\n⏭️ Skipping all code validations (all modes: OFF)\\n');\n return { success: true };\n }\n\n console.log('\\n📏 Running Code Validations\\n');\n console.log(` Active rules: ${runs.map((r: RuleRun) => r.name).join(', ')}`);\n console.log('');\n\n const result = await this.reporter.runValidators(runs);\n console.log(\n result.success\n ? '\\n✅ All code validations passed\\n'\n : '\\n❌ Some code validations failed\\n',\n );\n return result;\n }\n}\n"]}
|
|
@@ -1,41 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* What
|
|
2
|
+
* What ONE code-rules run was asked to do (#1027). Data-only.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* restricted to named projects (`projects`)
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* a `mode` or `projects` without a `rule`.
|
|
4
|
+
* Every field undefined is the gate: every configured rule, at its committed mode, over the diff. Any
|
|
5
|
+
* field set makes it a DEBUG run — exactly one rule (`rule`, required then), optionally at another mode
|
|
6
|
+
* (`mode`, e.g. RUN_EVERY_TIME) and/or restricted to named nx projects (`projects`) — with NOTHING
|
|
7
|
+
* written to disk. `wp-validate-code --rule=… --mode=… --projects=a,b` and
|
|
8
|
+
* `nx run architecture:validate-code --rule=… --mode=… --projects=a,b` both build one of these.
|
|
10
9
|
*/
|
|
11
10
|
export declare class CodeRulesRunRequest {
|
|
12
|
-
|
|
13
|
-
readonly
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
readonly projects: readonly string[] | null;
|
|
18
|
-
static readonly GATE: CodeRulesRunRequest;
|
|
19
|
-
constructor(
|
|
20
|
-
/** The one rule a debug run judges; null = the gate (every rule, `mode`/`projects` unused). */
|
|
21
|
-
rule: string | null,
|
|
22
|
-
/** A mode to judge `rule` at INSTEAD of its committed one; null = the committed mode. */
|
|
23
|
-
mode: string | null,
|
|
24
|
-
/** nx project names to restrict the run to; null = every project. */
|
|
25
|
-
projects: readonly string[] | null);
|
|
11
|
+
readonly rule: string | undefined;
|
|
12
|
+
readonly mode: string | undefined;
|
|
13
|
+
readonly projects: readonly string[] | undefined;
|
|
14
|
+
constructor(rule: string | undefined, mode: string | undefined, projects: readonly string[] | undefined);
|
|
15
|
+
/** True when any debug field was passed. */
|
|
26
16
|
isDebug(): boolean;
|
|
27
17
|
}
|
|
28
|
-
/**
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Which rules the engine runs, bound at the composition root: `undefined` for the gate (every active
|
|
20
|
+
* rule), one rule name for a debug run. Data-only.
|
|
21
|
+
*/
|
|
22
|
+
export declare class RuleSelection {
|
|
23
|
+
readonly onlyRule: string | undefined;
|
|
24
|
+
constructor(onlyRule: string | undefined);
|
|
25
|
+
includes(ruleName: string): boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Builds a {@link CodeRulesRunRequest} from raw flag values. nx hands `--projects=a,b` over as a string
|
|
29
|
+
* or an array depending on how it was typed, and the bin hands over strings, so the normalisation lives
|
|
30
|
+
* here once: `a,b` / `a, b` / `['a','b']` / `['a,b']` all become `['a','b']`, and a blank value is "not
|
|
31
|
+
* passed".
|
|
32
|
+
*/
|
|
33
|
+
export declare class RunRequestParser {
|
|
34
|
+
parse(rule: string | undefined, mode: string | undefined, projects: string | readonly string[] | undefined): CodeRulesRunRequest;
|
|
35
|
+
private splitProjects;
|
|
36
|
+
private blankToUndefined;
|
|
41
37
|
}
|
|
@@ -1,103 +1,66 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const rules_config_1 = require("@webpieces/rules-config");
|
|
6
|
-
const inversify_1 = require("inversify");
|
|
7
|
-
/** The three debug flags, spelled once for the parser and the usage text. */
|
|
8
|
-
const RULE_FLAG = '--rule=';
|
|
9
|
-
const MODE_FLAG = '--mode=';
|
|
10
|
-
const PROJECTS_FLAG = '--projects=';
|
|
11
|
-
const USAGE = `${RULE_FLAG}<rule> [${MODE_FLAG}<MODE>] [${PROJECTS_FLAG}<project>,<project>]`;
|
|
3
|
+
exports.RunRequestParser = exports.RuleSelection = exports.CodeRulesRunRequest = void 0;
|
|
12
4
|
/**
|
|
13
|
-
* What
|
|
5
|
+
* What ONE code-rules run was asked to do (#1027). Data-only.
|
|
14
6
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* restricted to named projects (`projects`)
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* a `mode` or `projects` without a `rule`.
|
|
7
|
+
* Every field undefined is the gate: every configured rule, at its committed mode, over the diff. Any
|
|
8
|
+
* field set makes it a DEBUG run — exactly one rule (`rule`, required then), optionally at another mode
|
|
9
|
+
* (`mode`, e.g. RUN_EVERY_TIME) and/or restricted to named nx projects (`projects`) — with NOTHING
|
|
10
|
+
* written to disk. `wp-validate-code --rule=… --mode=… --projects=a,b` and
|
|
11
|
+
* `nx run architecture:validate-code --rule=… --mode=… --projects=a,b` both build one of these.
|
|
21
12
|
*/
|
|
22
13
|
class CodeRulesRunRequest {
|
|
23
14
|
rule;
|
|
24
15
|
mode;
|
|
25
16
|
projects;
|
|
26
|
-
|
|
27
|
-
constructor(
|
|
28
|
-
/** The one rule a debug run judges; null = the gate (every rule, `mode`/`projects` unused). */
|
|
29
|
-
rule,
|
|
30
|
-
/** A mode to judge `rule` at INSTEAD of its committed one; null = the committed mode. */
|
|
31
|
-
mode,
|
|
32
|
-
/** nx project names to restrict the run to; null = every project. */
|
|
33
|
-
projects) {
|
|
17
|
+
constructor(rule, mode, projects) {
|
|
34
18
|
this.rule = rule;
|
|
35
19
|
this.mode = mode;
|
|
36
20
|
this.projects = projects;
|
|
37
21
|
}
|
|
22
|
+
/** True when any debug field was passed. */
|
|
38
23
|
isDebug() {
|
|
39
|
-
return this.rule !==
|
|
24
|
+
return this.rule !== undefined || this.mode !== undefined || this.projects !== undefined;
|
|
40
25
|
}
|
|
41
26
|
}
|
|
42
27
|
exports.CodeRulesRunRequest = CodeRulesRunRequest;
|
|
43
|
-
/**
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (arg.startsWith(RULE_FLAG))
|
|
52
|
-
rule = this.value(arg, RULE_FLAG);
|
|
53
|
-
else if (arg.startsWith(MODE_FLAG))
|
|
54
|
-
mode = this.value(arg, MODE_FLAG);
|
|
55
|
-
else if (arg.startsWith(PROJECTS_FLAG))
|
|
56
|
-
projects = this.split(this.value(arg, PROJECTS_FLAG));
|
|
57
|
-
else
|
|
58
|
-
throw new rules_config_1.InformAiError(`Unknown argument '${arg}'. Usage: wp-validate-code ${USAGE}`);
|
|
59
|
-
}
|
|
60
|
-
return this.request(rule, mode, projects);
|
|
28
|
+
/**
|
|
29
|
+
* Which rules the engine runs, bound at the composition root: `undefined` for the gate (every active
|
|
30
|
+
* rule), one rule name for a debug run. Data-only.
|
|
31
|
+
*/
|
|
32
|
+
class RuleSelection {
|
|
33
|
+
onlyRule;
|
|
34
|
+
constructor(onlyRule) {
|
|
35
|
+
this.onlyRule = onlyRule;
|
|
61
36
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
* `nx run architecture:validate-code --rule=… --mode=… --projects=…` lands. nx hands `projects` over
|
|
65
|
-
* as a string or, when it split the commas itself, as an array.
|
|
66
|
-
*/
|
|
67
|
-
// webpieces-disable no-any-unknown -- nx executor options arrive as an untyped record
|
|
68
|
-
fromExecutorOptions(options) {
|
|
69
|
-
const rule = typeof options['rule'] === 'string' ? options['rule'] : null;
|
|
70
|
-
const mode = typeof options['mode'] === 'string' ? options['mode'] : null;
|
|
71
|
-
const raw = options['projects'];
|
|
72
|
-
let projects = null;
|
|
73
|
-
if (typeof raw === 'string')
|
|
74
|
-
projects = this.split(raw);
|
|
75
|
-
else if (Array.isArray(raw))
|
|
76
|
-
projects = this.split(raw.map(String).join(','));
|
|
77
|
-
return this.request(rule, mode, projects);
|
|
37
|
+
includes(ruleName) {
|
|
38
|
+
return this.onlyRule === undefined || this.onlyRule === ruleName;
|
|
78
39
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
40
|
+
}
|
|
41
|
+
exports.RuleSelection = RuleSelection;
|
|
42
|
+
/**
|
|
43
|
+
* Builds a {@link CodeRulesRunRequest} from raw flag values. nx hands `--projects=a,b` over as a string
|
|
44
|
+
* or an array depending on how it was typed, and the bin hands over strings, so the normalisation lives
|
|
45
|
+
* here once: `a,b` / `a, b` / `['a','b']` / `['a,b']` all become `['a','b']`, and a blank value is "not
|
|
46
|
+
* passed".
|
|
47
|
+
*/
|
|
48
|
+
class RunRequestParser {
|
|
49
|
+
parse(rule, mode, projects) {
|
|
50
|
+
return new CodeRulesRunRequest(this.blankToUndefined(rule), this.blankToUndefined(mode), this.splitProjects(projects));
|
|
85
51
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
52
|
+
splitProjects(raw) {
|
|
53
|
+
if (raw === undefined)
|
|
54
|
+
return undefined;
|
|
55
|
+
const parts = (typeof raw === 'string' ? [raw] : [...raw])
|
|
56
|
+
.flatMap((each) => each.split(','))
|
|
57
|
+
.map((each) => each.trim())
|
|
58
|
+
.filter((each) => each.length > 0);
|
|
59
|
+
return parts.length === 0 ? undefined : parts;
|
|
91
60
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if (names.length === 0)
|
|
95
|
-
throw new rules_config_1.InformAiError(`${PROJECTS_FLAG} names no project. Usage: ${USAGE}`);
|
|
96
|
-
return names;
|
|
61
|
+
blankToUndefined(raw) {
|
|
62
|
+
return raw === undefined || raw.trim() === '' ? undefined : raw.trim();
|
|
97
63
|
}
|
|
98
|
-
}
|
|
99
|
-
exports.
|
|
100
|
-
exports.CodeRulesRunRequestParser = CodeRulesRunRequestParser = tslib_1.__decorate([
|
|
101
|
-
(0, inversify_1.injectable)(inversify_1.bindingScopeValues.Singleton)
|
|
102
|
-
], CodeRulesRunRequestParser);
|
|
64
|
+
}
|
|
65
|
+
exports.RunRequestParser = RunRequestParser;
|
|
103
66
|
//# sourceMappingURL=code-rules-run-request.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-rules-run-request.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/code-rules-run-request.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"code-rules-run-request.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/code-rules-run-request.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;GAQG;AACH,MAAa,mBAAmB;IAEf;IACA;IACA;IAHb,YACa,IAAwB,EACxB,IAAwB,EACxB,QAAuC;QAFvC,SAAI,GAAJ,IAAI,CAAoB;QACxB,SAAI,GAAJ,IAAI,CAAoB;QACxB,aAAQ,GAAR,QAAQ,CAA+B;IACjD,CAAC;IAEJ,4CAA4C;IAC5C,OAAO;QACH,OAAO,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,KAAK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AAG,KAAK,SAAS,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;IAC3E,CAAC;CACJ;AAjBD,4CAiBC","sourcesContent":["/**\n * What ONE code-rules run was asked to do (#1027). Data-only.\n *\n * Every field undefined is the gate: every configured rule, at its committed mode, over the diff. Any\n * field set makes it a DEBUG run — exactly one rule (`rule`, required then), optionally at another mode\n * (`mode`, e.g. RUN_EVERY_TIME) and/or restricted to named nx projects (`projects`) — with NOTHING\n * written to disk. `wp-validate-code --rule=… --mode=… --projects=a,b` and\n * `nx run architecture:validate-code --rule=… --mode=… --projects=a,b` both build one of these.\n */\nexport class CodeRulesRunRequest {\n constructor(\n readonly rule: string | undefined,\n readonly mode: string | undefined,\n readonly projects: readonly string[] | undefined,\n ) {}\n\n /** True when any debug field was passed. */\n isDebug(): boolean {\n return this.rule !== undefined || this.mode !== undefined || this.projects !== undefined;\n }\n}\n\n/**\n * Which rules the engine runs, bound at the composition root: `undefined` for the gate (every active\n * rule), one rule name for a debug run. Data-only.\n */\nexport class RuleSelection {\n constructor(readonly onlyRule: string | undefined) {}\n\n includes(ruleName: string): boolean {\n return this.onlyRule === undefined || this.onlyRule === ruleName;\n }\n}\n\n/**\n * Builds a {@link CodeRulesRunRequest} from raw flag values. nx hands `--projects=a,b` over as a string\n * or an array depending on how it was typed, and the bin hands over strings, so the normalisation lives\n * here once: `a,b` / `a, b` / `['a','b']` / `['a,b']` all become `['a','b']`, and a blank value is \"not\n * passed\".\n */\nexport class RunRequestParser {\n parse(rule: string | undefined, mode: string | undefined, projects: string | readonly string[] | undefined): CodeRulesRunRequest {\n return new CodeRulesRunRequest(this.blankToUndefined(rule), this.blankToUndefined(mode), this.splitProjects(projects));\n }\n\n private splitProjects(raw: string | readonly string[] | undefined): string[] | undefined {\n if (raw === undefined) return undefined;\n const parts = (typeof raw === 'string' ? [raw] : [...raw])\n .flatMap((each: string) => each.split(','))\n .map((each: string) => each.trim())\n .filter((each: string) => each.length > 0);\n return parts.length === 0 ? undefined : parts;\n }\n\n private blankToUndefined(raw: string | undefined): string | undefined {\n return raw === undefined || raw.trim() === '' ? undefined : raw.trim();\n }\n}\n"]}
|
package/src/index.d.ts
CHANGED
|
@@ -30,5 +30,7 @@ export { EnumText } from './api-lib-enum-text';
|
|
|
30
30
|
export { PrismaValidateDtosValidator } from './validate-dtos';
|
|
31
31
|
export { PrismaConverterValidator } from './validate-prisma-converters';
|
|
32
32
|
export { default as validateCode } from './validate-code';
|
|
33
|
-
export {
|
|
33
|
+
export { CodeRulesBootstrap } from './code-rules-bootstrap';
|
|
34
|
+
export { CodeRulesRunRequest, RuleSelection, RunRequestParser } from './code-rules-run-request';
|
|
35
|
+
export { ScanScope, GateScanScope, ScanRestriction, ProjectCatalog, ProjectEntry, RecordedSite } from './scan-scope';
|
|
34
36
|
export { ReactNativeCompatibility } from './react-native-compatibility';
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.RuleSelection = exports.CodeRulesRunRequest = exports.CodeRulesBootstrap = exports.validateCode = exports.PrismaConverterValidator = exports.PrismaValidateDtosValidator = exports.EnumText = exports.ApiLibEnumIndex = exports.GoverningGlob = exports.SuffixRename = exports.SuffixEntryPicker = exports.ExportedTypeScanner = exports.RequiredTypeSuffixValidator = exports.UtilityTypeScanner = exports.NoUtilityTypesInApiLibValidator = exports.EnumSpellingScanner = exports.OneEnumSpellingInApiLibValidator = exports.InlineImportScanner = exports.NoInlineImportInApiLibValidator = exports.ApiLibSite = exports.ApiLibFile = exports.findDirectlyChangedProjectRoots = exports.auditSecurityContracts = exports.SecurityContractViolation = exports.EnsureWeAreSecureValidator = exports.RoleTagValidator = exports.FrameworkTagValidator = exports.findRedundantInjectInSource = exports.InjectAnnotationNotNeededForConcreteClassValidator = exports.NoFunctionOutsideClassValidator = exports.NoProcessExitOutsideMainValidator = exports.ProjectRoleResolver = exports.StatePathViolation = exports.StatePathHit = exports.NoStatePathsInTemplatesValidator = exports.NoClientCreationOutsideServerOrClientValidator = exports.NoSymbolDiTokensValidator = exports.NoDirectApiResolverValidator = exports.NoDestructureValidator = exports.NoUnmanagedExceptionsValidator = exports.CatchErrorPatternValidator = exports.NoInlineTypeLiteralsValidator = exports.RequireReturnTypeValidator = exports.MaxFileLinesValidator = exports.runNewMethods = exports.runModifiedMethods = exports.MaxMethodLinesValidator = exports.NoImplicitAnyValidator = exports.NoAnyUnknownValidator = exports.CodeValidator = void 0;
|
|
4
|
+
exports.ReactNativeCompatibility = exports.RecordedSite = exports.ProjectEntry = exports.ProjectCatalog = exports.ScanRestriction = exports.GateScanScope = exports.ScanScope = exports.RunRequestParser = void 0;
|
|
4
5
|
const tslib_1 = require("tslib");
|
|
5
6
|
var code_validator_1 = require("./code-validator");
|
|
6
7
|
Object.defineProperty(exports, "CodeValidator", { enumerable: true, get: function () { return code_validator_1.CodeValidator; } });
|
|
@@ -81,9 +82,19 @@ var validate_prisma_converters_1 = require("./validate-prisma-converters");
|
|
|
81
82
|
Object.defineProperty(exports, "PrismaConverterValidator", { enumerable: true, get: function () { return validate_prisma_converters_1.PrismaConverterValidator; } });
|
|
82
83
|
var validate_code_1 = require("./validate-code");
|
|
83
84
|
Object.defineProperty(exports, "validateCode", { enumerable: true, get: function () { return tslib_1.__importDefault(validate_code_1).default; } });
|
|
85
|
+
var code_rules_bootstrap_1 = require("./code-rules-bootstrap");
|
|
86
|
+
Object.defineProperty(exports, "CodeRulesBootstrap", { enumerable: true, get: function () { return code_rules_bootstrap_1.CodeRulesBootstrap; } });
|
|
84
87
|
var code_rules_run_request_1 = require("./code-rules-run-request");
|
|
85
88
|
Object.defineProperty(exports, "CodeRulesRunRequest", { enumerable: true, get: function () { return code_rules_run_request_1.CodeRulesRunRequest; } });
|
|
86
|
-
Object.defineProperty(exports, "
|
|
89
|
+
Object.defineProperty(exports, "RuleSelection", { enumerable: true, get: function () { return code_rules_run_request_1.RuleSelection; } });
|
|
90
|
+
Object.defineProperty(exports, "RunRequestParser", { enumerable: true, get: function () { return code_rules_run_request_1.RunRequestParser; } });
|
|
91
|
+
var scan_scope_1 = require("./scan-scope");
|
|
92
|
+
Object.defineProperty(exports, "ScanScope", { enumerable: true, get: function () { return scan_scope_1.ScanScope; } });
|
|
93
|
+
Object.defineProperty(exports, "GateScanScope", { enumerable: true, get: function () { return scan_scope_1.GateScanScope; } });
|
|
94
|
+
Object.defineProperty(exports, "ScanRestriction", { enumerable: true, get: function () { return scan_scope_1.ScanRestriction; } });
|
|
95
|
+
Object.defineProperty(exports, "ProjectCatalog", { enumerable: true, get: function () { return scan_scope_1.ProjectCatalog; } });
|
|
96
|
+
Object.defineProperty(exports, "ProjectEntry", { enumerable: true, get: function () { return scan_scope_1.ProjectEntry; } });
|
|
97
|
+
Object.defineProperty(exports, "RecordedSite", { enumerable: true, get: function () { return scan_scope_1.RecordedSite; } });
|
|
87
98
|
var react_native_compatibility_1 = require("./react-native-compatibility");
|
|
88
99
|
Object.defineProperty(exports, "ReactNativeCompatibility", { enumerable: true, get: function () { return react_native_compatibility_1.ReactNativeCompatibility; } });
|
|
89
100
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/index.ts"],"names":[],"mappings":";;;;;AAAA,mDAAiE;AAAxD,+GAAA,aAAa,OAAA;AAEtB,qEAAkE;AAAzD,gIAAA,qBAAqB,OAAA;AAC9B,uEAAoE;AAA3D,kIAAA,sBAAsB,OAAA;AAC/B,yEAA0F;AAAjF,oIAAA,uBAAuB,OAAA;AA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E,0IAAA,kBAAkB,OAAA;AAC5D,iFAMyC;AALrC,4IAAA,2BAA2B,OAAA;AAC3B,oIAAA,mBAAmB,OAAA;AACnB,kIAAA,iBAAiB,OAAA;AACjB,6HAAA,YAAY,OAAA;AACZ,8HAAA,aAAa,OAAA;AAEjB,2DAAuD;AAA9C,qHAAA,eAAe,OAAA;AACxB,yDAA+C;AAAtC,6GAAA,QAAQ,OAAA;AACjB,iDAA8D;AAArD,4HAAA,2BAA2B,OAAA;AACpC,2EAAwE;AAA/D,sIAAA,wBAAwB,OAAA;AACjC,iDAA0D;AAAjD,sIAAA,OAAO,OAAgB;AAChC,+DAA4D;AAAnD,0HAAA,kBAAkB,OAAA;AAC3B,mEAAgG;AAAvF,6HAAA,mBAAmB,OAAA;AAAE,uHAAA,aAAa,OAAA;AAAE,0HAAA,gBAAgB,OAAA;AAC7D,2CAAqH;AAA5G,uGAAA,SAAS,OAAA;AAAE,2GAAA,aAAa,OAAA;AAAE,6GAAA,eAAe,OAAA;AAAE,4GAAA,cAAc,OAAA;AAAE,0GAAA,YAAY,OAAA;AAAE,0GAAA,YAAY,OAAA;AAE9F,2EAAwE;AAA/D,sIAAA,wBAAwB,OAAA","sourcesContent":["export { CodeValidator, ExecutorResult } from './code-validator';\n\nexport { NoAnyUnknownValidator } from './validate-no-any-unknown';\nexport { NoImplicitAnyValidator } from './validate-no-implicit-any';\nexport { MaxMethodLinesValidator, runModifiedMethods } from './validate-modified-methods';\nexport { runNewMethods } from './validate-new-methods';\nexport { MaxFileLinesValidator } from './validate-modified-files';\nexport { RequireReturnTypeValidator } from './validate-return-types';\nexport { NoInlineTypeLiteralsValidator } from './validate-no-inline-types';\nexport { CatchErrorPatternValidator } from './validate-catch-error-pattern';\nexport { NoUnmanagedExceptionsValidator } from './validate-no-unmanaged-exceptions';\nexport { NoDestructureValidator } from './validate-no-destructure';\nexport { NoDirectApiResolverValidator } from './validate-no-direct-api-resolver';\nexport { NoSymbolDiTokensValidator } from './validate-no-symbol-di-tokens';\nexport { NoClientCreationOutsideServerOrClientValidator } from './validate-no-client-creation-outside-server-or-client';\nexport {\n NoStatePathsInTemplatesValidator,\n StatePathHit,\n StatePathViolation,\n} from './validate-no-state-paths-in-templates';\nexport { ProjectRoleResolver } from './project-role-resolver';\nexport { NoProcessExitOutsideMainValidator } from './validate-no-process-exit-outside-main';\nexport { NoFunctionOutsideClassValidator } from './validate-no-function-outside-class';\nexport {\n InjectAnnotationNotNeededForConcreteClassValidator,\n findRedundantInjectInSource,\n} from './validate-inject-annotation-not-needed-for-concrete-class';\nexport { FrameworkTagValidator } from './validate-framework-tag';\nexport { RoleTagValidator } from './validate-role-tag';\nexport {\n EnsureWeAreSecureValidator,\n SecurityContractViolation,\n auditSecurityContracts,\n findDirectlyChangedProjectRoots,\n} from './validate-ensure-we-are-secure';\nexport { ApiLibFile, ApiLibSite } from './api-lib-source-rule';\nexport { NoInlineImportInApiLibValidator, InlineImportScanner } from './validate-no-inline-import-in-api-lib';\nexport { OneEnumSpellingInApiLibValidator, EnumSpellingScanner } from './validate-one-enum-spelling-in-api-lib';\nexport { NoUtilityTypesInApiLibValidator, UtilityTypeScanner } from './validate-no-utility-types-in-api-lib';\nexport {\n RequiredTypeSuffixValidator,\n ExportedTypeScanner,\n SuffixEntryPicker,\n SuffixRename,\n GoverningGlob,\n} from './validate-required-type-suffix';\nexport { ApiLibEnumIndex } from './api-lib-enum-index';\nexport { EnumText } from './api-lib-enum-text';\nexport { PrismaValidateDtosValidator } from './validate-dtos';\nexport { PrismaConverterValidator } from './validate-prisma-converters';\nexport { default as validateCode } from './validate-code';\nexport { CodeRulesBootstrap } from './code-rules-bootstrap';\nexport { CodeRulesRunRequest, RuleSelection, RunRequestParser } from './code-rules-run-request';\nexport { ScanScope, GateScanScope, ScanRestriction, ProjectCatalog, ProjectEntry, RecordedSite } from './scan-scope';\n\nexport { ReactNativeCompatibility } from './react-native-compatibility';\n"]}
|
package/src/resolve-mode.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { shouldSkipRule
|
|
1
|
+
export { shouldSkipRule } from '@webpieces/rules-config';
|
|
2
2
|
export { SkipRuleResult } from '@webpieces/rules-config';
|
package/src/resolve-mode.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SkipRuleResult = exports.
|
|
4
|
-
// shouldSkipRule /
|
|
3
|
+
exports.SkipRuleResult = exports.shouldSkipRule = void 0;
|
|
4
|
+
// shouldSkipRule / SkipRuleResult moved to @webpieces/rules-config
|
|
5
5
|
// so ai-hook-rules and the Nx executors share one implementation. Re-exported here
|
|
6
6
|
// for back-compat with the many code-rules validators that import from './resolve-mode'.
|
|
7
7
|
var rules_config_1 = require("@webpieces/rules-config");
|
|
8
8
|
Object.defineProperty(exports, "shouldSkipRule", { enumerable: true, get: function () { return rules_config_1.shouldSkipRule; } });
|
|
9
|
-
Object.defineProperty(exports, "getCurrentBranch", { enumerable: true, get: function () { return rules_config_1.getCurrentBranch; } });
|
|
10
9
|
var rules_config_2 = require("@webpieces/rules-config");
|
|
11
10
|
Object.defineProperty(exports, "SkipRuleResult", { enumerable: true, get: function () { return rules_config_2.SkipRuleResult; } });
|
|
12
11
|
//# sourceMappingURL=resolve-mode.js.map
|
package/src/resolve-mode.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-mode.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/resolve-mode.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"resolve-mode.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/resolve-mode.ts"],"names":[],"mappings":";;;AAAA,mEAAmE;AACnE,mFAAmF;AACnF,yFAAyF;AACzF,wDAAyD;AAAhD,8GAAA,cAAc,OAAA;AACvB,wDAAyD;AAAhD,8GAAA,cAAc,OAAA","sourcesContent":["// shouldSkipRule / SkipRuleResult moved to @webpieces/rules-config\n// so ai-hook-rules and the Nx executors share one implementation. Re-exported here\n// for back-compat with the many code-rules validators that import from './resolve-mode'.\nexport { shouldSkipRule } from '@webpieces/rules-config';\nexport { SkipRuleResult } from '@webpieces/rules-config';\n"]}
|