@webpieces/code-rules 0.4.846 → 0.4.848
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 +8 -7
- package/src/code-policy-composition.d.ts +9 -0
- package/src/code-policy-composition.js +39 -0
- package/src/code-policy-composition.js.map +1 -0
- package/src/code-policy-registry.d.ts +12 -0
- package/src/code-policy-registry.js +95 -0
- package/src/code-policy-registry.js.map +1 -0
- package/src/code-rules-bootstrap.js +30 -22
- package/src/code-rules-bootstrap.js.map +1 -1
- package/src/code-rules-engine.d.ts +8 -65
- package/src/code-rules-engine.js +15 -155
- package/src/code-rules-engine.js.map +1 -1
- package/src/code-validator.d.ts +1 -1
- package/src/code-validator.js +1 -1
- package/src/code-validator.js.map +1 -1
- package/src/prune-unknown-config.js +5 -15
- package/src/prune-unknown-config.js.map +1 -1
- package/src/rule-help.d.ts +3 -0
- package/src/rule-help.js +36 -0
- package/src/rule-help.js.map +1 -0
- package/src/rule-pack.js +3 -2
- package/src/rule-pack.js.map +1 -1
- package/src/rule-runtime.d.ts +10 -0
- package/src/rule-runtime.js +50 -0
- package/src/rule-runtime.js.map +1 -0
- package/src/validate-required-type-suffix.d.ts +2 -2
- package/src/validate-required-type-suffix.js +45 -22
- package/src/validate-required-type-suffix.js.map +1 -1
- package/src/wp-ci.d.ts +20 -1
- package/src/wp-ci.js +7 -19
- package/src/wp-ci.js.map +1 -1
- package/src/code-rules-config-table.d.ts +0 -11
- package/src/code-rules-config-table.js +0 -53
- package/src/code-rules-config-table.js.map +0 -1
package/src/code-rules-engine.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CodeRulesEngine = void 0;
|
|
3
|
+
exports.CodeRulesEngine = exports.BuildPolicySet = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const inversify_1 = require("inversify");
|
|
6
6
|
const code_validator_1 = require("./code-validator");
|
|
@@ -8,142 +8,29 @@ const rule_reporter_1 = require("./rule-reporter");
|
|
|
8
8
|
const code_rules_context_1 = require("./code-rules-context");
|
|
9
9
|
const code_rules_run_request_1 = require("./code-rules-run-request");
|
|
10
10
|
const validate_match_rules_1 = require("./validate-match-rules");
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const validate_no_destructure_1 = require("./validate-no-destructure");
|
|
20
|
-
const validate_catch_error_pattern_1 = require("./validate-catch-error-pattern");
|
|
21
|
-
const validate_no_unmanaged_exceptions_1 = require("./validate-no-unmanaged-exceptions");
|
|
22
|
-
const validate_no_direct_api_resolver_1 = require("./validate-no-direct-api-resolver");
|
|
23
|
-
const validate_no_symbol_di_tokens_1 = require("./validate-no-symbol-di-tokens");
|
|
24
|
-
const validate_no_client_creation_outside_server_or_client_1 = require("./validate-no-client-creation-outside-server-or-client");
|
|
25
|
-
const validate_no_custom_css_1 = require("./validate-no-custom-css");
|
|
26
|
-
const validate_no_state_paths_in_templates_1 = require("./validate-no-state-paths-in-templates");
|
|
27
|
-
const validate_no_process_exit_outside_main_1 = require("./validate-no-process-exit-outside-main");
|
|
28
|
-
const validate_no_function_outside_class_1 = require("./validate-no-function-outside-class");
|
|
29
|
-
const validate_inject_annotation_not_needed_for_concrete_class_1 = require("./validate-inject-annotation-not-needed-for-concrete-class");
|
|
30
|
-
const validate_framework_tag_1 = require("./validate-framework-tag");
|
|
31
|
-
const validate_role_tag_1 = require("./validate-role-tag");
|
|
32
|
-
const validate_ensure_we_are_secure_1 = require("./validate-ensure-we-are-secure");
|
|
33
|
-
const validate_no_inline_import_in_api_lib_1 = require("./validate-no-inline-import-in-api-lib");
|
|
34
|
-
const validate_one_enum_spelling_in_api_lib_1 = require("./validate-one-enum-spelling-in-api-lib");
|
|
35
|
-
const validate_no_utility_types_in_api_lib_1 = require("./validate-no-utility-types-in-api-lib");
|
|
36
|
-
const validate_required_type_suffix_1 = require("./validate-required-type-suffix");
|
|
37
|
-
const validate_framework_tsconfig_1 = require("./validate-framework-tsconfig");
|
|
38
|
-
const validate_framework_packages_1 = require("./validate-framework-packages");
|
|
39
|
-
/**
|
|
40
|
-
* Owns running the code-rules suite. Every built-in validator is injected as a singleton (its config
|
|
41
|
-
* is bound in the container at bootstrap), so this class IS the code-rules DI DAG the design graph
|
|
42
|
-
* draws. The per-entry match-rules validators are the one exception — they are config-per-instance,
|
|
43
|
-
* so they are built from the injected {@link MatchRulesHolder}.
|
|
44
|
-
*/
|
|
11
|
+
/** Runtime checks are composed from the owner's policy entries, rather than injected individually. */
|
|
12
|
+
class BuildPolicySet {
|
|
13
|
+
policies;
|
|
14
|
+
constructor(policies) {
|
|
15
|
+
this.policies = policies;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.BuildPolicySet = BuildPolicySet;
|
|
45
19
|
let CodeRulesEngine = class CodeRulesEngine {
|
|
46
20
|
workspace;
|
|
47
21
|
reporter;
|
|
48
22
|
matchRules;
|
|
49
23
|
matchChecker;
|
|
50
24
|
selection;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
noInlineTypeLiterals;
|
|
55
|
-
noAnyUnknown;
|
|
56
|
-
noImplicitAny;
|
|
57
|
-
prismaValidateDtos;
|
|
58
|
-
prismaConverter;
|
|
59
|
-
noDestructure;
|
|
60
|
-
catchErrorPattern;
|
|
61
|
-
noUnmanagedExceptions;
|
|
62
|
-
noDirectApiResolver;
|
|
63
|
-
noSymbolDiTokens;
|
|
64
|
-
noClientCreationOutsideServerOrClient;
|
|
65
|
-
noCustomCss;
|
|
66
|
-
noStatePathsInTemplates;
|
|
67
|
-
noProcessExitOutsideMain;
|
|
68
|
-
noFunctionOutsideClass;
|
|
69
|
-
injectAnnotationNotNeeded;
|
|
70
|
-
frameworkTag;
|
|
71
|
-
roleTag;
|
|
72
|
-
ensureWeAreSecure;
|
|
73
|
-
noInlineImportInApiLib;
|
|
74
|
-
oneEnumSpellingInApiLib;
|
|
75
|
-
noUtilityTypesInApiLib;
|
|
76
|
-
requiredTypeSuffix;
|
|
77
|
-
frameworkTsconfig;
|
|
78
|
-
frameworkPackages;
|
|
79
|
-
// webpieces-disable max-lines-new-methods -- the built-in validator set is flat; each is one injected field
|
|
80
|
-
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, frameworkTsconfig, frameworkPackages) {
|
|
25
|
+
checks;
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
27
|
+
constructor(workspace, reporter, matchRules, matchChecker, selection, checks) {
|
|
81
28
|
this.workspace = workspace;
|
|
82
29
|
this.reporter = reporter;
|
|
83
30
|
this.matchRules = matchRules;
|
|
84
31
|
this.matchChecker = matchChecker;
|
|
85
32
|
this.selection = selection;
|
|
86
|
-
this.
|
|
87
|
-
this.maxFileLines = maxFileLines;
|
|
88
|
-
this.requireReturnType = requireReturnType;
|
|
89
|
-
this.noInlineTypeLiterals = noInlineTypeLiterals;
|
|
90
|
-
this.noAnyUnknown = noAnyUnknown;
|
|
91
|
-
this.noImplicitAny = noImplicitAny;
|
|
92
|
-
this.prismaValidateDtos = prismaValidateDtos;
|
|
93
|
-
this.prismaConverter = prismaConverter;
|
|
94
|
-
this.noDestructure = noDestructure;
|
|
95
|
-
this.catchErrorPattern = catchErrorPattern;
|
|
96
|
-
this.noUnmanagedExceptions = noUnmanagedExceptions;
|
|
97
|
-
this.noDirectApiResolver = noDirectApiResolver;
|
|
98
|
-
this.noSymbolDiTokens = noSymbolDiTokens;
|
|
99
|
-
this.noClientCreationOutsideServerOrClient = noClientCreationOutsideServerOrClient;
|
|
100
|
-
this.noCustomCss = noCustomCss;
|
|
101
|
-
this.noStatePathsInTemplates = noStatePathsInTemplates;
|
|
102
|
-
this.noProcessExitOutsideMain = noProcessExitOutsideMain;
|
|
103
|
-
this.noFunctionOutsideClass = noFunctionOutsideClass;
|
|
104
|
-
this.injectAnnotationNotNeeded = injectAnnotationNotNeeded;
|
|
105
|
-
this.frameworkTag = frameworkTag;
|
|
106
|
-
this.roleTag = roleTag;
|
|
107
|
-
this.ensureWeAreSecure = ensureWeAreSecure;
|
|
108
|
-
this.noInlineImportInApiLib = noInlineImportInApiLib;
|
|
109
|
-
this.oneEnumSpellingInApiLib = oneEnumSpellingInApiLib;
|
|
110
|
-
this.noUtilityTypesInApiLib = noUtilityTypesInApiLib;
|
|
111
|
-
this.requiredTypeSuffix = requiredTypeSuffix;
|
|
112
|
-
this.frameworkTsconfig = frameworkTsconfig;
|
|
113
|
-
this.frameworkPackages = frameworkPackages;
|
|
114
|
-
}
|
|
115
|
-
/** The injected built-in validators, in run order. */
|
|
116
|
-
builtIns() {
|
|
117
|
-
return [
|
|
118
|
-
this.maxMethodLines,
|
|
119
|
-
this.maxFileLines,
|
|
120
|
-
this.requireReturnType,
|
|
121
|
-
this.noInlineTypeLiterals,
|
|
122
|
-
this.noAnyUnknown,
|
|
123
|
-
this.noImplicitAny,
|
|
124
|
-
this.prismaValidateDtos,
|
|
125
|
-
this.prismaConverter,
|
|
126
|
-
this.noDestructure,
|
|
127
|
-
this.catchErrorPattern,
|
|
128
|
-
this.noUnmanagedExceptions,
|
|
129
|
-
this.noDirectApiResolver,
|
|
130
|
-
this.noSymbolDiTokens,
|
|
131
|
-
this.noClientCreationOutsideServerOrClient,
|
|
132
|
-
this.noCustomCss,
|
|
133
|
-
this.noStatePathsInTemplates,
|
|
134
|
-
this.noProcessExitOutsideMain,
|
|
135
|
-
this.noFunctionOutsideClass,
|
|
136
|
-
this.injectAnnotationNotNeeded,
|
|
137
|
-
this.frameworkTag,
|
|
138
|
-
this.roleTag,
|
|
139
|
-
this.ensureWeAreSecure,
|
|
140
|
-
this.noInlineImportInApiLib,
|
|
141
|
-
this.oneEnumSpellingInApiLib,
|
|
142
|
-
this.noUtilityTypesInApiLib,
|
|
143
|
-
this.requiredTypeSuffix,
|
|
144
|
-
this.frameworkTsconfig,
|
|
145
|
-
this.frameworkPackages,
|
|
146
|
-
];
|
|
33
|
+
this.checks = checks;
|
|
147
34
|
}
|
|
148
35
|
/**
|
|
149
36
|
* Every ACTIVE run: an injected built-in validator whose `shouldRun()` is true, or an injected
|
|
@@ -153,7 +40,7 @@ let CodeRulesEngine = class CodeRulesEngine {
|
|
|
153
40
|
*/
|
|
154
41
|
activeRuns(root) {
|
|
155
42
|
const runs = [];
|
|
156
|
-
for (const v of this.
|
|
43
|
+
for (const v of this.checks.policies) {
|
|
157
44
|
if (this.selection.includes(v.name) && v.shouldRun())
|
|
158
45
|
runs.push(new code_validator_1.RuleRun(v.name, () => v.run(root)));
|
|
159
46
|
}
|
|
@@ -192,33 +79,6 @@ exports.CodeRulesEngine = CodeRulesEngine = tslib_1.__decorate([
|
|
|
192
79
|
code_rules_context_1.MatchRulesHolder,
|
|
193
80
|
validate_match_rules_1.MatchRulesChecker,
|
|
194
81
|
code_rules_run_request_1.RuleSelection,
|
|
195
|
-
|
|
196
|
-
validate_modified_files_1.MaxFileLinesValidator,
|
|
197
|
-
validate_return_types_1.RequireReturnTypeValidator,
|
|
198
|
-
validate_no_inline_types_1.NoInlineTypeLiteralsValidator,
|
|
199
|
-
validate_no_any_unknown_1.NoAnyUnknownValidator,
|
|
200
|
-
validate_no_implicit_any_1.NoImplicitAnyValidator,
|
|
201
|
-
validate_dtos_1.PrismaValidateDtosValidator,
|
|
202
|
-
validate_prisma_converters_1.PrismaConverterValidator,
|
|
203
|
-
validate_no_destructure_1.NoDestructureValidator,
|
|
204
|
-
validate_catch_error_pattern_1.CatchErrorPatternValidator,
|
|
205
|
-
validate_no_unmanaged_exceptions_1.NoUnmanagedExceptionsValidator,
|
|
206
|
-
validate_no_direct_api_resolver_1.NoDirectApiResolverValidator,
|
|
207
|
-
validate_no_symbol_di_tokens_1.NoSymbolDiTokensValidator,
|
|
208
|
-
validate_no_client_creation_outside_server_or_client_1.NoClientCreationOutsideServerOrClientValidator,
|
|
209
|
-
validate_no_custom_css_1.NoCustomCssValidator,
|
|
210
|
-
validate_no_state_paths_in_templates_1.NoStatePathsInTemplatesValidator,
|
|
211
|
-
validate_no_process_exit_outside_main_1.NoProcessExitOutsideMainValidator,
|
|
212
|
-
validate_no_function_outside_class_1.NoFunctionOutsideClassValidator,
|
|
213
|
-
validate_inject_annotation_not_needed_for_concrete_class_1.InjectAnnotationNotNeededForConcreteClassValidator,
|
|
214
|
-
validate_framework_tag_1.FrameworkTagValidator,
|
|
215
|
-
validate_role_tag_1.RoleTagValidator,
|
|
216
|
-
validate_ensure_we_are_secure_1.EnsureWeAreSecureValidator,
|
|
217
|
-
validate_no_inline_import_in_api_lib_1.NoInlineImportInApiLibValidator,
|
|
218
|
-
validate_one_enum_spelling_in_api_lib_1.OneEnumSpellingInApiLibValidator,
|
|
219
|
-
validate_no_utility_types_in_api_lib_1.NoUtilityTypesInApiLibValidator,
|
|
220
|
-
validate_required_type_suffix_1.RequiredTypeSuffixValidator,
|
|
221
|
-
validate_framework_tsconfig_1.FrameworkTsconfigValidator,
|
|
222
|
-
validate_framework_packages_1.FrameworkPackagesValidator])
|
|
82
|
+
BuildPolicySet])
|
|
223
83
|
], CodeRulesEngine);
|
|
224
84
|
//# sourceMappingURL=code-rules-engine.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-rules-engine.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/code-rules-engine.ts"],"names":[],"mappings":";;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,4BAAY;QACV,qCAAgB;QACd,wCAAiB;QACpB,sCAAa;QACR,mDAAuB;QACzB,+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;QAC5B,wDAA0B;QAC1B,wDAA0B;GAnCzD,eAAe,CAkH3B","sourcesContent":["import { BaseRuleConfig } from '@webpieces/rules-sdk';\n\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';\nimport { FrameworkTsconfigValidator } from './validate-framework-tsconfig';\nimport { FrameworkPackagesValidator } from './validate-framework-packages';\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 private readonly frameworkTsconfig: FrameworkTsconfigValidator,\n private readonly frameworkPackages: FrameworkPackagesValidator,\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 this.frameworkTsconfig,\n this.frameworkPackages,\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
|
+
{"version":3,"file":"code-rules-engine.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/code-rules-engine.ts"],"names":[],"mappings":";;;;AAEA,yCAA2D;AAE3D,qDAA2D;AAC3D,mDAA+C;AAC/C,6DAAuE;AACvE,qEAAyD;AACzD,iEAA2D;AAE3D,sGA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EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;QACxF,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,GAAG;QACL,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAClD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACpB,OAAO,CAAC,GAAG,CAAC,wDAAwD,CAAC,CAAC;YACtE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAC7B,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;QAC/C,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,CAAC,GAAG,CAAC,CAAC,CAAU,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC/E,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAEhB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QACvD,OAAO,CAAC,GAAG,CACP,MAAM,CAAC,OAAO;YACV,CAAC,CAAC,mCAAmC;YACrC,CAAC,CAAC,oCAAoC,CAC7C,CAAC;QACF,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ,CAAA;AAtDY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAIL,kCAAa;QACd,4BAAY;QACV,qCAAgB;QACd,wCAAiB;QACpB,sCAAa;QAChB,cAAc;GARlC,eAAe,CAsD3B","sourcesContent":["import { BuildPolicy } from '@webpieces/rules-sdk';\n\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { 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';\n\n/** Runtime checks are composed from the owner's policy entries, rather than injected individually. */\nexport class BuildPolicySet {\n constructor(readonly policies: readonly BuildPolicy[]) {}\n}\n\n@injectable(bindingScopeValues.Singleton)\nexport class CodeRulesEngine {\n // eslint-disable-next-line @typescript-eslint/max-params\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 checks: BuildPolicySet,\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.checks.policies) {\n if (this.selection.includes(v.name) && v.shouldRun())\n 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"]}
|
package/src/code-validator.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export declare class RuleRun {
|
|
|
21
21
|
*
|
|
22
22
|
* Extends the shared {@link AbstractRule} (which owns `name` + the on/off + escape-hatch
|
|
23
23
|
* decision in `shouldRun()`) and adds the code-rules execution surface: `run(workspaceRoot)`.
|
|
24
|
-
* Each validator is constructed with its typed `*Config` from
|
|
24
|
+
* Each validator is constructed with its typed `*Config` from this policy owner, so
|
|
25
25
|
* the config classes are genuinely consumed (find-usages / rename work across packages).
|
|
26
26
|
*/
|
|
27
27
|
export declare abstract class CodeValidator<C extends BaseRuleConfig> extends AbstractRule<C> {
|
package/src/code-validator.js
CHANGED
|
@@ -21,7 +21,7 @@ exports.RuleRun = RuleRun;
|
|
|
21
21
|
*
|
|
22
22
|
* Extends the shared {@link AbstractRule} (which owns `name` + the on/off + escape-hatch
|
|
23
23
|
* decision in `shouldRun()`) and adds the code-rules execution surface: `run(workspaceRoot)`.
|
|
24
|
-
* Each validator is constructed with its typed `*Config` from
|
|
24
|
+
* Each validator is constructed with its typed `*Config` from this policy owner, so
|
|
25
25
|
* the config classes are genuinely consumed (find-usages / rename work across packages).
|
|
26
26
|
*/
|
|
27
27
|
class CodeValidator extends rules_config_1.AbstractRule {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-validator.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/code-validator.ts"],"names":[],"mappings":";;;AACA,0DAAuD;AASvD;;;;GAIG;AACH,MAAa,OAAO;IAEH;IACA;IAFb,YACa,IAAY,EACZ,GAAkC;QADlC,SAAI,GAAJ,IAAI,CAAQ;QACZ,QAAG,GAAH,GAAG,CAA+B;IAC5C,CAAC;CACP;AALD,0BAKC;AAED;;;;;;;GAOG;AACH,MAAsB,aAAwC,SAAQ,2BAAe;CAEpF;AAFD,sCAEC","sourcesContent":["import { BaseRuleConfig } from '@webpieces/rules-sdk';\nimport { AbstractRule } from '@webpieces/rules-config';\n\n/**\n * Result of running a single code validator.\n */\nexport interface ExecutorResult {\n success: boolean;\n}\n\n/**\n * One named unit of work for {@link RuleReporter} — a validator (or a per-entry match-rule) paired\n * with a thunk that runs it. A value object (not a DAG service), so the engine can build the run list\n * from its injected validators + checker WITHOUT `new`-ing any DAG member.\n */\nexport class RuleRun {\n constructor(\n readonly name: string,\n readonly run: () => Promise<ExecutorResult>,\n ) {}\n}\n\n/**\n * Base class for every code-rules validator.\n *\n * Extends the shared {@link AbstractRule} (which owns `name` + the on/off + escape-hatch\n * decision in `shouldRun()`) and adds the code-rules execution surface: `run(workspaceRoot)`.\n * Each validator is constructed with its typed `*Config` from
|
|
1
|
+
{"version":3,"file":"code-validator.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/code-validator.ts"],"names":[],"mappings":";;;AACA,0DAAuD;AASvD;;;;GAIG;AACH,MAAa,OAAO;IAEH;IACA;IAFb,YACa,IAAY,EACZ,GAAkC;QADlC,SAAI,GAAJ,IAAI,CAAQ;QACZ,QAAG,GAAH,GAAG,CAA+B;IAC5C,CAAC;CACP;AALD,0BAKC;AAED;;;;;;;GAOG;AACH,MAAsB,aAAwC,SAAQ,2BAAe;CAEpF;AAFD,sCAEC","sourcesContent":["import { BaseRuleConfig } from '@webpieces/rules-sdk';\nimport { AbstractRule } from '@webpieces/rules-config';\n\n/**\n * Result of running a single code validator.\n */\nexport interface ExecutorResult {\n success: boolean;\n}\n\n/**\n * One named unit of work for {@link RuleReporter} — a validator (or a per-entry match-rule) paired\n * with a thunk that runs it. A value object (not a DAG service), so the engine can build the run list\n * from its injected validators + checker WITHOUT `new`-ing any DAG member.\n */\nexport class RuleRun {\n constructor(\n readonly name: string,\n readonly run: () => Promise<ExecutorResult>,\n ) {}\n}\n\n/**\n * Base class for every code-rules validator.\n *\n * Extends the shared {@link AbstractRule} (which owns `name` + the on/off + escape-hatch\n * decision in `shouldRun()`) and adds the code-rules execution surface: `run(workspaceRoot)`.\n * Each validator is constructed with its typed `*Config` from this policy owner, so\n * the config classes are genuinely consumed (find-usages / rename work across packages).\n */\nexport abstract class CodeValidator<C extends BaseRuleConfig> extends AbstractRule<C> {\n abstract run(workspaceRoot: string): Promise<ExecutorResult>;\n}\n"]}
|
|
@@ -4,24 +4,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
require("reflect-metadata");
|
|
5
5
|
const inversify_1 = require("inversify");
|
|
6
6
|
const rules_config_1 = require("@webpieces/rules-config");
|
|
7
|
-
/**
|
|
8
|
-
* `wp-prune-unknown-config` — strip every key from webpieces.config.json that no running validator has a
|
|
9
|
-
* schema for, and say which ones went.
|
|
10
|
-
*
|
|
11
|
-
* This is the command the unknown-rule error and the validation banner both name. It exists because the
|
|
12
|
-
* moment that advice is read is the worst moment to act on it by hand: the hook guard denies every Bash
|
|
13
|
-
* call while the config is invalid, so the reader is editing JSON blind. One command makes cleanliness
|
|
14
|
-
* the default path instead of a judgement call taken under a total block.
|
|
15
|
-
*
|
|
16
|
-
* It lives in code-rules rather than rules-config because rules-config is a library with no bins, and
|
|
17
|
-
* code-rules already ships `wp-validate-code` — the command whose failure sends a reader here. All the
|
|
18
|
-
* logic is `ConfigPruner`; this file is the composition root and nothing else.
|
|
19
|
-
*/
|
|
7
|
+
/** CLI composition for pruning unknown keys from explicitly declared owner config files. */
|
|
20
8
|
(0, rules_config_1.runMain)(async () => {
|
|
21
9
|
const container = new inversify_1.Container({ autobind: true });
|
|
22
10
|
// Reject `--help`/bogus flags BEFORE anything rewrites a file — an ignored flag must never mutate config.
|
|
23
|
-
container
|
|
24
|
-
|
|
11
|
+
container
|
|
12
|
+
.get(rules_config_1.CliArgs)
|
|
13
|
+
.assertNoArgs(new rules_config_1.CliUsage('wp-prune-unknown-config', 'Delete unknown policy keys from declared owner config files, naming each file and key. ' +
|
|
14
|
+
'Keep owner-declared migrations for explicit upgrade; reject retired root policy sections.'));
|
|
25
15
|
const result = container.get(rules_config_1.ConfigPruner).pruneFrom(process.cwd());
|
|
26
16
|
process.stdout.write(result.describeSelf() + '\n');
|
|
27
17
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prune-unknown-config.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/prune-unknown-config.ts"],"names":[],"mappings":";;;AACA,4BAA0B;AAC1B,yCAAsC;AACtC,0DAAgG;AAEhG
|
|
1
|
+
{"version":3,"file":"prune-unknown-config.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/prune-unknown-config.ts"],"names":[],"mappings":";;;AACA,4BAA0B;AAC1B,yCAAsC;AACtC,0DAAgG;AAEhG,4FAA4F;AAC5F,IAAA,sBAAO,EAAC,KAAK,IAAmB,EAAE;IAC9B,MAAM,SAAS,GAAG,IAAI,qBAAS,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IACpD,0GAA0G;IAC1G,SAAS;SACJ,GAAG,CAAC,sBAAO,CAAC;SACZ,YAAY,CACT,IAAI,uBAAQ,CACR,yBAAyB,EACzB,yFAAyF;QACrF,2FAA2F,CAClG,CACJ,CAAC;IACN,MAAM,MAAM,GAAgB,SAAS,CAAC,GAAG,CAAC,2BAAY,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACjF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,YAAY,EAAE,GAAG,IAAI,CAAC,CAAC;AACvD,CAAC,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\nimport 'reflect-metadata';\nimport { Container } from 'inversify';\nimport { runMain, CliArgs, CliUsage, ConfigPruner, PruneResult } from '@webpieces/rules-config';\n\n/** CLI composition for pruning unknown keys from explicitly declared owner config files. */\nrunMain(async (): Promise<void> => {\n const container = new Container({ autobind: true });\n // Reject `--help`/bogus flags BEFORE anything rewrites a file — an ignored flag must never mutate config.\n container\n .get(CliArgs)\n .assertNoArgs(\n new CliUsage(\n 'wp-prune-unknown-config',\n 'Delete unknown policy keys from declared owner config files, naming each file and key. ' +\n 'Keep owner-declared migrations for explicit upgrade; reject retired root policy sections.',\n ),\n );\n const result: PruneResult = container.get(ConfigPruner).pruneFrom(process.cwd());\n process.stdout.write(result.describeSelf() + '\\n');\n});\n"]}
|
package/src/rule-help.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ruleHelp = void 0;
|
|
4
|
+
const rules_sdk_1 = require("@webpieces/rules-sdk");
|
|
5
|
+
/** Owner-authored guidance consumed by the registry catalog. */
|
|
6
|
+
exports.ruleHelp = {
|
|
7
|
+
'max-method-lines': new rules_sdk_1.RuleHelp('Limit method length in the configured scan scope.', 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.'),
|
|
8
|
+
'max-file-lines': new rules_sdk_1.RuleHelp('Limit source file length in the configured scan scope.', 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.'),
|
|
9
|
+
'require-return-type': new rules_sdk_1.RuleHelp('Require explicit function and method return types.', 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.'),
|
|
10
|
+
'no-inline-type-literals': new rules_sdk_1.RuleHelp('Use named data classes instead of inline object type declarations.', 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.'),
|
|
11
|
+
'no-any-unknown': new rules_sdk_1.RuleHelp('Require concrete types outside explicitly permitted opaque boundaries.', 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.'),
|
|
12
|
+
'no-implicit-any': new rules_sdk_1.RuleHelp('Require explicit parameter types when inference does not establish them.', 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.'),
|
|
13
|
+
'prisma-validate-dtos': new rules_sdk_1.RuleHelp('Validate Prisma-facing DTO declarations against the generated model.', 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.'),
|
|
14
|
+
'prisma-converter': new rules_sdk_1.RuleHelp('Validate the converters between Prisma models and application DTOs.', 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.'),
|
|
15
|
+
'no-destructure': new rules_sdk_1.RuleHelp('Use whole values or explicit property access instead of destructuring.', 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.'),
|
|
16
|
+
'catch-error-pattern': new rules_sdk_1.RuleHelp('Narrow caught errors through the shared error conversion pattern.', 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.'),
|
|
17
|
+
'no-unmanaged-exceptions': new rules_sdk_1.RuleHelp('Handle or explicitly document exceptions at the responsible boundary.', 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.'),
|
|
18
|
+
'angular-no-direct-api-in-resolver': new rules_sdk_1.RuleHelp('Keep direct API client construction out of Angular resolvers.', 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.'),
|
|
19
|
+
'no-symbol-di-tokens': new rules_sdk_1.RuleHelp('Use class tokens for dependency injection instead of symbol tokens.', 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.'),
|
|
20
|
+
'no-client-creation-outside-server-or-client': new rules_sdk_1.RuleHelp('Construct API clients only in their designated server or client layer.', 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.'),
|
|
21
|
+
'no-custom-css': new rules_sdk_1.RuleHelp('Use the configured styling system instead of custom CSS in governed files.', 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.'),
|
|
22
|
+
'no-state-paths-in-templates': new rules_sdk_1.RuleHelp('Use the declared state binding pattern in application templates.', 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.'),
|
|
23
|
+
'no-process-exit-outside-main': new rules_sdk_1.RuleHelp('Restrict process termination to executable application boundaries.', 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.'),
|
|
24
|
+
'no-function-outside-class': new rules_sdk_1.RuleHelp('Put business operations in instance methods on classes.', 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.'),
|
|
25
|
+
'inject-annotation-not-needed-for-concrete-class': new rules_sdk_1.RuleHelp('Inject concrete classes by their class token without redundant annotations.', 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.'),
|
|
26
|
+
'framework-tag': new rules_sdk_1.RuleHelp('Match project framework tags to their actual code and package usage.', 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.'),
|
|
27
|
+
'role-tag': new rules_sdk_1.RuleHelp('Match project role tags to their actual API and implementation responsibilities.', 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.'),
|
|
28
|
+
'ensure-we-are-secure': new rules_sdk_1.RuleHelp('Check configured API security requirements at the implementation boundary.', 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.'),
|
|
29
|
+
'no-inline-import-in-api-lib': new rules_sdk_1.RuleHelp('Keep API library type imports explicit and named.', 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.'),
|
|
30
|
+
'one-enum-spelling-in-api-lib': new rules_sdk_1.RuleHelp('Use one enum declaration spelling in API libraries.', 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.'),
|
|
31
|
+
'no-utility-types-in-api-lib': new rules_sdk_1.RuleHelp('Use explicit named API data contracts instead of utility types.', 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.'),
|
|
32
|
+
'required-type-suffix': new rules_sdk_1.RuleHelp('Require configured suffixes on API contract types.', 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.'),
|
|
33
|
+
'framework-tsconfig': new rules_sdk_1.RuleHelp('Align framework-specific TypeScript settings with project declarations.', 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.'),
|
|
34
|
+
'framework-packages': new rules_sdk_1.RuleHelp('Align framework packages with the configured project requirements.', 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.'),
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=rule-help.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-help.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/rule-help.ts"],"names":[],"mappings":";;;AAAA,oDAAgD;AAEhD,gEAAgE;AACnD,QAAA,QAAQ,GAAuC;IACxD,kBAAkB,EAAE,IAAI,oBAAQ,CAC5B,mDAAmD,EACnD,sIAAsI,CACzI;IACD,gBAAgB,EAAE,IAAI,oBAAQ,CAC1B,wDAAwD,EACxD,sIAAsI,CACzI;IACD,qBAAqB,EAAE,IAAI,oBAAQ,CAC/B,oDAAoD,EACpD,sIAAsI,CACzI;IACD,yBAAyB,EAAE,IAAI,oBAAQ,CACnC,oEAAoE,EACpE,sIAAsI,CACzI;IACD,gBAAgB,EAAE,IAAI,oBAAQ,CAC1B,wEAAwE,EACxE,sIAAsI,CACzI;IACD,iBAAiB,EAAE,IAAI,oBAAQ,CAC3B,0EAA0E,EAC1E,sIAAsI,CACzI;IACD,sBAAsB,EAAE,IAAI,oBAAQ,CAChC,sEAAsE,EACtE,sIAAsI,CACzI;IACD,kBAAkB,EAAE,IAAI,oBAAQ,CAC5B,qEAAqE,EACrE,sIAAsI,CACzI;IACD,gBAAgB,EAAE,IAAI,oBAAQ,CAC1B,wEAAwE,EACxE,sIAAsI,CACzI;IACD,qBAAqB,EAAE,IAAI,oBAAQ,CAC/B,mEAAmE,EACnE,sIAAsI,CACzI;IACD,yBAAyB,EAAE,IAAI,oBAAQ,CACnC,uEAAuE,EACvE,sIAAsI,C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Owner-authored guidance consumed by the registry catalog. */\nexport const ruleHelp: Readonly<Record<string, RuleHelp>> = {\n 'max-method-lines': new RuleHelp(\n 'Limit method length in the configured scan scope.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'max-file-lines': new RuleHelp(\n 'Limit source file length in the configured scan scope.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'require-return-type': new RuleHelp(\n 'Require explicit function and method return types.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-inline-type-literals': new RuleHelp(\n 'Use named data classes instead of inline object type declarations.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-any-unknown': new RuleHelp(\n 'Require concrete types outside explicitly permitted opaque boundaries.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-implicit-any': new RuleHelp(\n 'Require explicit parameter types when inference does not establish them.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'prisma-validate-dtos': new RuleHelp(\n 'Validate Prisma-facing DTO declarations against the generated model.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'prisma-converter': new RuleHelp(\n 'Validate the converters between Prisma models and application DTOs.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-destructure': new RuleHelp(\n 'Use whole values or explicit property access instead of destructuring.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'catch-error-pattern': new RuleHelp(\n 'Narrow caught errors through the shared error conversion pattern.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-unmanaged-exceptions': new RuleHelp(\n 'Handle or explicitly document exceptions at the responsible boundary.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'angular-no-direct-api-in-resolver': new RuleHelp(\n 'Keep direct API client construction out of Angular resolvers.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-symbol-di-tokens': new RuleHelp(\n 'Use class tokens for dependency injection instead of symbol tokens.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-client-creation-outside-server-or-client': new RuleHelp(\n 'Construct API clients only in their designated server or client layer.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-custom-css': new RuleHelp(\n 'Use the configured styling system instead of custom CSS in governed files.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-state-paths-in-templates': new RuleHelp(\n 'Use the declared state binding pattern in application templates.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-process-exit-outside-main': new RuleHelp(\n 'Restrict process termination to executable application boundaries.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-function-outside-class': new RuleHelp(\n 'Put business operations in instance methods on classes.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'inject-annotation-not-needed-for-concrete-class': new RuleHelp(\n 'Inject concrete classes by their class token without redundant annotations.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'framework-tag': new RuleHelp(\n 'Match project framework tags to their actual code and package usage.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'role-tag': new RuleHelp(\n 'Match project role tags to their actual API and implementation responsibilities.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'ensure-we-are-secure': new RuleHelp(\n 'Check configured API security requirements at the implementation boundary.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-inline-import-in-api-lib': new RuleHelp(\n 'Keep API library type imports explicit and named.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'one-enum-spelling-in-api-lib': new RuleHelp(\n 'Use one enum declaration spelling in API libraries.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-utility-types-in-api-lib': new RuleHelp(\n 'Use explicit named API data contracts instead of utility types.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'required-type-suffix': new RuleHelp(\n 'Require configured suffixes on API contract types.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'framework-tsconfig': new RuleHelp(\n 'Align framework-specific TypeScript settings with project declarations.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'framework-packages': new RuleHelp(\n 'Align framework packages with the configured project requirements.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n};\n"]}
|
package/src/rule-pack.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.rulePackManifest = void 0;
|
|
4
|
+
const rule_help_1 = require("./rule-help");
|
|
4
5
|
const rule_settings_1 = require("./rule-settings");
|
|
5
6
|
const rules_sdk_1 = require("@webpieces/rules-sdk");
|
|
6
|
-
const
|
|
7
|
+
const code_policy_registry_1 = require("./code-policy-registry");
|
|
7
8
|
const package_json_1 = require("../package.json");
|
|
8
9
|
/** The code owner publishes the same definitions its composition root binds. */
|
|
9
|
-
exports.rulePackManifest = new rules_sdk_1.RulePackManifest('@webpieces/code-rules', package_json_1.version, rules_sdk_1.RULE_PACK_API_VERSION,
|
|
10
|
+
exports.rulePackManifest = new rules_sdk_1.RulePackManifest('@webpieces/code-rules', package_json_1.version, rules_sdk_1.RULE_PACK_API_VERSION, code_policy_registry_1.CODE_POLICIES.map((binding) => new rules_sdk_1.OwnedRuleDefinition(binding.ruleId, binding.schema, rules_sdk_1.RULE_SCHEMA_API_VERSION, rule_settings_1.optionalTuning[binding.ruleId], rule_settings_1.recommendedSeeds[binding.ruleId], 'rules', rule_help_1.ruleHelp[binding.ruleId])), code_policy_registry_1.CODE_POLICIES.map((binding) => new rules_sdk_1.RuleContribution(binding.ruleId, '@webpieces/code-rules', 'build', '@webpieces/code-rules/rule-runtime')), [], []);
|
|
10
11
|
//# sourceMappingURL=rule-pack.js.map
|
package/src/rule-pack.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule-pack.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/rule-pack.ts"],"names":[],"mappings":";;;AAAA,mDAAmE;AACnE,
|
|
1
|
+
{"version":3,"file":"rule-pack.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/rule-pack.ts"],"names":[],"mappings":";;;AAAA,2CAAuC;AACvC,mDAAmE;AACnE,oDAM8B;AAC9B,iEAAmE;AACnE,kDAA0C;AAE1C,gFAAgF;AACnE,QAAA,gBAAgB,GAAG,IAAI,4BAAgB,CAChD,uBAAuB,EACvB,sBAAO,EACP,iCAAqB,EACrB,oCAAa,CAAC,GAAG,CACb,CAAC,OAAmB,EAAE,EAAE,CACpB,IAAI,+BAAmB,CACnB,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,MAAM,EACd,mCAAuB,EACvB,8BAAc,CAAC,OAAO,CAAC,MAAM,CAAC,EAC9B,gCAAgB,CAAC,OAAO,CAAC,MAAM,CAAC,EAChC,OAAO,EACP,oBAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAC3B,CACR,EACD,oCAAa,CAAC,GAAG,CACb,CAAC,OAAmB,EAAE,EAAE,CACpB,IAAI,4BAAgB,CAChB,OAAO,CAAC,MAAM,EACd,uBAAuB,EACvB,OAAO,EACP,oCAAoC,CACvC,CACR,EACD,EAAE,EACF,EAAE,CACL,CAAC","sourcesContent":["import { ruleHelp } from './rule-help';\nimport { optionalTuning, recommendedSeeds } from './rule-settings';\nimport {\n OwnedRuleDefinition,\n RuleContribution,\n RulePackManifest,\n RULE_PACK_API_VERSION,\n RULE_SCHEMA_API_VERSION,\n} from '@webpieces/rules-sdk';\nimport { CODE_POLICIES, CodePolicy } from './code-policy-registry';\nimport { version } from '../package.json';\n\n/** The code owner publishes the same definitions its composition root binds. */\nexport const rulePackManifest = new RulePackManifest(\n '@webpieces/code-rules',\n version,\n RULE_PACK_API_VERSION,\n CODE_POLICIES.map(\n (binding: CodePolicy) =>\n new OwnedRuleDefinition(\n binding.ruleId,\n binding.schema,\n RULE_SCHEMA_API_VERSION,\n optionalTuning[binding.ruleId],\n recommendedSeeds[binding.ruleId],\n 'rules',\n ruleHelp[binding.ruleId],\n ),\n ),\n CODE_POLICIES.map(\n (binding: CodePolicy) =>\n new RuleContribution(\n binding.ruleId,\n '@webpieces/code-rules',\n 'build',\n '@webpieces/code-rules/rule-runtime',\n ),\n ),\n [],\n [],\n);\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { BuildDebugRequest, BuildDebugRuntime, BuildPolicyResult } from '@webpieces/rules-sdk';
|
|
3
|
+
import { CodeRuleRuntime } from './code-policy-composition';
|
|
4
|
+
export declare const buildRuleRuntime: CodeRuleRuntime;
|
|
5
|
+
/** Debug behavior remains owner-defined, including project restrictions and warning site counts. */
|
|
6
|
+
declare class CodeDebugRuntime implements BuildDebugRuntime {
|
|
7
|
+
run(request: BuildDebugRequest): Promise<BuildPolicyResult>;
|
|
8
|
+
}
|
|
9
|
+
export declare const buildDebugRuntime: CodeDebugRuntime;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.buildDebugRuntime = exports.buildRuleRuntime = void 0;
|
|
37
|
+
require("reflect-metadata");
|
|
38
|
+
const code_policy_composition_1 = require("./code-policy-composition");
|
|
39
|
+
exports.buildRuleRuntime = new code_policy_composition_1.CodeRuleRuntime();
|
|
40
|
+
/** Debug behavior remains owner-defined, including project restrictions and warning site counts. */
|
|
41
|
+
class CodeDebugRuntime {
|
|
42
|
+
async run(request) {
|
|
43
|
+
const bootstrap = await Promise.resolve().then(() => __importStar(require('./code-rules-bootstrap')));
|
|
44
|
+
const parser = await Promise.resolve().then(() => __importStar(require('./code-rules-run-request')));
|
|
45
|
+
const selection = request.selection;
|
|
46
|
+
return new bootstrap.CodeRulesBootstrap().run(request.workspaceRoot, new parser.RunRequestParser().parse(selection.rule, selection.mode, selection.projects));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.buildDebugRuntime = new CodeDebugRuntime();
|
|
50
|
+
//# sourceMappingURL=rule-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-runtime.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/rule-runtime.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4BAA0B;AAgB1B,uEAA4D;AAE/C,QAAA,gBAAgB,GAAG,IAAI,yCAAe,EAAE,CAAC;AAEtD,oGAAoG;AACpG,MAAM,gBAAgB;IAClB,KAAK,CAAC,GAAG,CAAC,OAA0B;QAChC,MAAM,SAAS,GAAG,wDAAa,wBAAwB,GAAC,CAAC;QACzD,MAAM,MAAM,GAAG,wDAAa,0BAA0B,GAAC,CAAC;QACxD,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACpC,OAAO,IAAI,SAAS,CAAC,kBAAkB,EAAE,CAAC,GAAG,CACzC,OAAO,CAAC,aAAa,EACrB,IAAI,MAAM,CAAC,gBAAgB,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,QAAQ,CAAC,CAC1F,CAAC;IACN,CAAC;CACJ;AAEY,QAAA,iBAAiB,GAAG,IAAI,gBAAgB,EAAE,CAAC","sourcesContent":["import 'reflect-metadata';\nimport { Container } from 'inversify';\nimport {\n BuildPolicy,\n BuildRuleRuntime,\n PolicyRuntimeRequest,\n BuildDebugRequest,\n BuildDebugRuntime,\n BuildPolicyResult,\n} from '@webpieces/rules-sdk';\nimport { InformAiError } from '@webpieces/tooling-common';\nimport { CODE_POLICIES, CodePolicy } from './code-policy-registry';\nimport { WorkspaceRoot } from './code-rules-context';\nimport { ScanRestriction } from './scan-scope';\nimport { BuildPolicySet } from './code-rules-engine';\n\nimport { CodeRuleRuntime } from './code-policy-composition';\n\nexport const buildRuleRuntime = new CodeRuleRuntime();\n\n/** Debug behavior remains owner-defined, including project restrictions and warning site counts. */\nclass CodeDebugRuntime implements BuildDebugRuntime {\n async run(request: BuildDebugRequest): Promise<BuildPolicyResult> {\n const bootstrap = await import('./code-rules-bootstrap');\n const parser = await import('./code-rules-run-request');\n const selection = request.selection;\n return new bootstrap.CodeRulesBootstrap().run(\n request.workspaceRoot,\n new parser.RunRequestParser().parse(selection.rule, selection.mode, selection.projects),\n );\n }\n}\n\nexport const buildDebugRuntime = new CodeDebugRuntime();\n"]}
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
* Under NEW_AND_MODIFIED_CODE only a declaration whose NAME line is new or changed is judged — a new type
|
|
23
23
|
* or a renamed one — so legacy names are grandfathered and a repo with hundreds of them can convert slowly.
|
|
24
24
|
*/
|
|
25
|
-
import { DiffScope } from
|
|
26
|
-
import { RequiredTypeSuffixConfig, RequiredTypeSuffixEntry } from
|
|
25
|
+
import { DiffScope } from '@webpieces/rules-config';
|
|
26
|
+
import { RequiredTypeSuffixConfig, RequiredTypeSuffixEntry } from './configs/required-type-suffix-config';
|
|
27
27
|
import { ApiLibFile, ApiLibSite, ApiLibSourceRule } from './api-lib-source-rule';
|
|
28
28
|
import { ProjectRoleResolver } from './project-role-resolver';
|
|
29
29
|
import { ScanScope } from './scan-scope';
|