@webpieces/code-rules 0.4.832 → 0.4.833

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webpieces/code-rules",
3
- "version": "0.4.832",
3
+ "version": "0.4.833",
4
4
  "description": "Standalone code validation rules extracted from architecture-validators, no Nx dependency required",
5
5
  "type": "commonjs",
6
6
  "main": "./src/index.js",
@@ -16,7 +16,7 @@
16
16
  "directory": "packages/tooling/code-rules"
17
17
  },
18
18
  "dependencies": {
19
- "@webpieces/rules-config": "0.4.832",
19
+ "@webpieces/rules-config": "0.4.833",
20
20
  "@inversifyjs/binding-decorators": "1.1.5",
21
21
  "inversify": "7.10.4",
22
22
  "reflect-metadata": "0.2.2"
@@ -32,5 +32,7 @@ exports.CONFIG_BINDINGS = [
32
32
  [rules_config_1.OneEnumSpellingInApiLibConfig, 'one-enum-spelling-in-api-lib'],
33
33
  [rules_config_1.NoUtilityTypesInApiLibConfig, 'no-utility-types-in-api-lib'],
34
34
  [rules_config_1.RequiredTypeSuffixConfig, 'required-type-suffix'],
35
+ [rules_config_1.FrameworkTsconfigConfig, 'framework-tsconfig'],
36
+ [rules_config_1.FrameworkPackagesConfig, 'framework-packages'],
35
37
  ];
36
38
  //# sourceMappingURL=code-rules-config-table.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"code-rules-config-table.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/code-rules-config-table.ts"],"names":[],"mappings":";;;AAAA,0DA6BiC;AAcpB,QAAA,eAAe,GAAiC;IACzD,CAAC,mCAAoB,EAAE,kBAAkB,CAAC;IAC1C,CAAC,iCAAkB,EAAE,gBAAgB,CAAC;IACtC,CAAC,sCAAuB,EAAE,qBAAqB,CAAC;IAChD,CAAC,yCAA0B,EAAE,yBAAyB,CAAC;IACvD,CAAC,iCAAkB,EAAE,gBAAgB,CAAC;IACtC,CAAC,kCAAmB,EAAE,iBAAiB,CAAC;IACxC,CAAC,uCAAwB,EAAE,sBAAsB,CAAC;IAClD,CAAC,oCAAqB,EAAE,kBAAkB,CAAC;IAC3C,CAAC,kCAAmB,EAAE,gBAAgB,CAAC;IACvC,CAAC,sCAAuB,EAAE,qBAAqB,CAAC;IAChD,CAAC,0CAA2B,EAAE,yBAAyB,CAAC;IACxD,CAAC,iDAAkC,EAAE,mCAAmC,CAAC;IACzE,CAAC,qCAAsB,EAAE,qBAAqB,CAAC;IAC/C,CAAC,0DAA2C,EAAE,6CAA6C,CAAC;IAC5F,CAAC,gCAAiB,EAAE,eAAe,CAAC;IACpC,CAAC,4CAA6B,EAAE,6BAA6B,CAAC;IAC9D,CAAC,6CAA8B,EAAE,8BAA8B,CAAC;IAChE,CAAC,2CAA4B,EAAE,2BAA2B,CAAC;IAC3D;QACI,8DAA+C;QAC/C,iDAAiD;KACpD;IACD,CAAC,iCAAkB,EAAE,eAAe,CAAC;IACrC,CAAC,4BAAa,EAAE,UAAU,CAAC;IAC3B,CAAC,sCAAuB,EAAE,sBAAsB,CAAC;IACjD,CAAC,2CAA4B,EAAE,6BAA6B,CAAC;IAC7D,CAAC,4CAA6B,EAAE,8BAA8B,CAAC;IAC/D,CAAC,2CAA4B,EAAE,6BAA6B,CAAC;IAC7D,CAAC,uCAAwB,EAAE,sBAAsB,CAAC;CACrD,CAAC","sourcesContent":["import {\n BaseRuleConfig,\n WebpiecesRulesConfig,\n MaxMethodLinesConfig,\n MaxFileLinesConfig,\n RequireReturnTypeConfig,\n NoInlineTypeLiteralsConfig,\n NoAnyUnknownConfig,\n NoImplicitAnyConfig,\n PrismaValidateDtosConfig,\n PrismaConverterConfig,\n NoDestructureConfig,\n CatchErrorPatternConfig,\n NoUnmanagedExceptionsConfig,\n AngularNoDirectApiInResolverConfig,\n NoSymbolDiTokensConfig,\n NoClientCreationOutsideServerOrClientConfig,\n NoCustomCssConfig,\n NoStatePathsInTemplatesConfig,\n NoProcessExitOutsideMainConfig,\n NoFunctionOutsideClassConfig,\n InjectAnnotationNotNeededForConcreteClassConfig,\n FrameworkTagConfig,\n RoleTagConfig,\n EnsureWeAreSecureConfig,\n NoInlineImportInApiLibConfig,\n OneEnumSpellingInApiLibConfig,\n NoUtilityTypesInApiLibConfig,\n RequiredTypeSuffixConfig,\n} from '@webpieces/rules-config';\n\n/** A rule config class usable as an inversify inject-by-type token. */\nexport type ConfigCtor = new () => BaseRuleConfig;\n\n/**\n * The 1:1 table of `[config class, webpieces.config.json rule key]`. The composition root iterates it\n * to bind each rule's config into the container (`bind(ConfigClass).toConstantValue(config[key] ??\n * new ConfigClass())`), so every `@provideSingleton` validator injects its config by type. Data only\n * — the binding loop lives inline in the bin (an inline loop, exempt from no-function-outside-class).\n */\n/** One `[config class, rule key]` row of {@link CONFIG_BINDINGS}. */\nexport type ConfigBinding = readonly [ConfigCtor, keyof WebpiecesRulesConfig];\n\nexport const CONFIG_BINDINGS: ReadonlyArray<ConfigBinding> = [\n [MaxMethodLinesConfig, 'max-method-lines'],\n [MaxFileLinesConfig, 'max-file-lines'],\n [RequireReturnTypeConfig, 'require-return-type'],\n [NoInlineTypeLiteralsConfig, 'no-inline-type-literals'],\n [NoAnyUnknownConfig, 'no-any-unknown'],\n [NoImplicitAnyConfig, 'no-implicit-any'],\n [PrismaValidateDtosConfig, 'prisma-validate-dtos'],\n [PrismaConverterConfig, 'prisma-converter'],\n [NoDestructureConfig, 'no-destructure'],\n [CatchErrorPatternConfig, 'catch-error-pattern'],\n [NoUnmanagedExceptionsConfig, 'no-unmanaged-exceptions'],\n [AngularNoDirectApiInResolverConfig, 'angular-no-direct-api-in-resolver'],\n [NoSymbolDiTokensConfig, 'no-symbol-di-tokens'],\n [NoClientCreationOutsideServerOrClientConfig, 'no-client-creation-outside-server-or-client'],\n [NoCustomCssConfig, 'no-custom-css'],\n [NoStatePathsInTemplatesConfig, 'no-state-paths-in-templates'],\n [NoProcessExitOutsideMainConfig, 'no-process-exit-outside-main'],\n [NoFunctionOutsideClassConfig, 'no-function-outside-class'],\n [\n InjectAnnotationNotNeededForConcreteClassConfig,\n 'inject-annotation-not-needed-for-concrete-class',\n ],\n [FrameworkTagConfig, 'framework-tag'],\n [RoleTagConfig, 'role-tag'],\n [EnsureWeAreSecureConfig, 'ensure-we-are-secure'],\n [NoInlineImportInApiLibConfig, 'no-inline-import-in-api-lib'],\n [OneEnumSpellingInApiLibConfig, 'one-enum-spelling-in-api-lib'],\n [NoUtilityTypesInApiLibConfig, 'no-utility-types-in-api-lib'],\n [RequiredTypeSuffixConfig, 'required-type-suffix'],\n];\n"]}
1
+ {"version":3,"file":"code-rules-config-table.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/code-rules-config-table.ts"],"names":[],"mappings":";;;AAAA,0DA+BiC;AAcpB,QAAA,eAAe,GAAiC;IACzD,CAAC,mCAAoB,EAAE,kBAAkB,CAAC;IAC1C,CAAC,iCAAkB,EAAE,gBAAgB,CAAC;IACtC,CAAC,sCAAuB,EAAE,qBAAqB,CAAC;IAChD,CAAC,yCAA0B,EAAE,yBAAyB,CAAC;IACvD,CAAC,iCAAkB,EAAE,gBAAgB,CAAC;IACtC,CAAC,kCAAmB,EAAE,iBAAiB,CAAC;IACxC,CAAC,uCAAwB,EAAE,sBAAsB,CAAC;IAClD,CAAC,oCAAqB,EAAE,kBAAkB,CAAC;IAC3C,CAAC,kCAAmB,EAAE,gBAAgB,CAAC;IACvC,CAAC,sCAAuB,EAAE,qBAAqB,CAAC;IAChD,CAAC,0CAA2B,EAAE,yBAAyB,CAAC;IACxD,CAAC,iDAAkC,EAAE,mCAAmC,CAAC;IACzE,CAAC,qCAAsB,EAAE,qBAAqB,CAAC;IAC/C,CAAC,0DAA2C,EAAE,6CAA6C,CAAC;IAC5F,CAAC,gCAAiB,EAAE,eAAe,CAAC;IACpC,CAAC,4CAA6B,EAAE,6BAA6B,CAAC;IAC9D,CAAC,6CAA8B,EAAE,8BAA8B,CAAC;IAChE,CAAC,2CAA4B,EAAE,2BAA2B,CAAC;IAC3D;QACI,8DAA+C;QAC/C,iDAAiD;KACpD;IACD,CAAC,iCAAkB,EAAE,eAAe,CAAC;IACrC,CAAC,4BAAa,EAAE,UAAU,CAAC;IAC3B,CAAC,sCAAuB,EAAE,sBAAsB,CAAC;IACjD,CAAC,2CAA4B,EAAE,6BAA6B,CAAC;IAC7D,CAAC,4CAA6B,EAAE,8BAA8B,CAAC;IAC/D,CAAC,2CAA4B,EAAE,6BAA6B,CAAC;IAC7D,CAAC,uCAAwB,EAAE,sBAAsB,CAAC;IAClD,CAAC,sCAAuB,EAAE,oBAAoB,CAAC;IAC/C,CAAC,sCAAuB,EAAE,oBAAoB,CAAC;CAClD,CAAC","sourcesContent":["import {\n BaseRuleConfig,\n WebpiecesRulesConfig,\n MaxMethodLinesConfig,\n MaxFileLinesConfig,\n RequireReturnTypeConfig,\n NoInlineTypeLiteralsConfig,\n NoAnyUnknownConfig,\n NoImplicitAnyConfig,\n PrismaValidateDtosConfig,\n PrismaConverterConfig,\n NoDestructureConfig,\n CatchErrorPatternConfig,\n NoUnmanagedExceptionsConfig,\n AngularNoDirectApiInResolverConfig,\n NoSymbolDiTokensConfig,\n NoClientCreationOutsideServerOrClientConfig,\n NoCustomCssConfig,\n NoStatePathsInTemplatesConfig,\n NoProcessExitOutsideMainConfig,\n NoFunctionOutsideClassConfig,\n InjectAnnotationNotNeededForConcreteClassConfig,\n FrameworkTagConfig,\n RoleTagConfig,\n EnsureWeAreSecureConfig,\n NoInlineImportInApiLibConfig,\n OneEnumSpellingInApiLibConfig,\n NoUtilityTypesInApiLibConfig,\n RequiredTypeSuffixConfig,\n FrameworkTsconfigConfig,\n FrameworkPackagesConfig,\n} from '@webpieces/rules-config';\n\n/** A rule config class usable as an inversify inject-by-type token. */\nexport type ConfigCtor = new () => BaseRuleConfig;\n\n/**\n * The 1:1 table of `[config class, webpieces.config.json rule key]`. The composition root iterates it\n * to bind each rule's config into the container (`bind(ConfigClass).toConstantValue(config[key] ??\n * new ConfigClass())`), so every `@provideSingleton` validator injects its config by type. Data only\n * — the binding loop lives inline in the bin (an inline loop, exempt from no-function-outside-class).\n */\n/** One `[config class, rule key]` row of {@link CONFIG_BINDINGS}. */\nexport type ConfigBinding = readonly [ConfigCtor, keyof WebpiecesRulesConfig];\n\nexport const CONFIG_BINDINGS: ReadonlyArray<ConfigBinding> = [\n [MaxMethodLinesConfig, 'max-method-lines'],\n [MaxFileLinesConfig, 'max-file-lines'],\n [RequireReturnTypeConfig, 'require-return-type'],\n [NoInlineTypeLiteralsConfig, 'no-inline-type-literals'],\n [NoAnyUnknownConfig, 'no-any-unknown'],\n [NoImplicitAnyConfig, 'no-implicit-any'],\n [PrismaValidateDtosConfig, 'prisma-validate-dtos'],\n [PrismaConverterConfig, 'prisma-converter'],\n [NoDestructureConfig, 'no-destructure'],\n [CatchErrorPatternConfig, 'catch-error-pattern'],\n [NoUnmanagedExceptionsConfig, 'no-unmanaged-exceptions'],\n [AngularNoDirectApiInResolverConfig, 'angular-no-direct-api-in-resolver'],\n [NoSymbolDiTokensConfig, 'no-symbol-di-tokens'],\n [NoClientCreationOutsideServerOrClientConfig, 'no-client-creation-outside-server-or-client'],\n [NoCustomCssConfig, 'no-custom-css'],\n [NoStatePathsInTemplatesConfig, 'no-state-paths-in-templates'],\n [NoProcessExitOutsideMainConfig, 'no-process-exit-outside-main'],\n [NoFunctionOutsideClassConfig, 'no-function-outside-class'],\n [\n InjectAnnotationNotNeededForConcreteClassConfig,\n 'inject-annotation-not-needed-for-concrete-class',\n ],\n [FrameworkTagConfig, 'framework-tag'],\n [RoleTagConfig, 'role-tag'],\n [EnsureWeAreSecureConfig, 'ensure-we-are-secure'],\n [NoInlineImportInApiLibConfig, 'no-inline-import-in-api-lib'],\n [OneEnumSpellingInApiLibConfig, 'one-enum-spelling-in-api-lib'],\n [NoUtilityTypesInApiLibConfig, 'no-utility-types-in-api-lib'],\n [RequiredTypeSuffixConfig, 'required-type-suffix'],\n [FrameworkTsconfigConfig, 'framework-tsconfig'],\n [FrameworkPackagesConfig, 'framework-packages'],\n];\n"]}
@@ -29,6 +29,8 @@ import { NoInlineImportInApiLibValidator } from './validate-no-inline-import-in-
29
29
  import { OneEnumSpellingInApiLibValidator } from './validate-one-enum-spelling-in-api-lib';
30
30
  import { NoUtilityTypesInApiLibValidator } from './validate-no-utility-types-in-api-lib';
31
31
  import { RequiredTypeSuffixValidator } from './validate-required-type-suffix';
32
+ import { FrameworkTsconfigValidator } from './validate-framework-tsconfig';
33
+ import { FrameworkPackagesValidator } from './validate-framework-packages';
32
34
  /**
33
35
  * Owns running the code-rules suite. Every built-in validator is injected as a singleton (its config
34
36
  * is bound in the container at bootstrap), so this class IS the code-rules DI DAG the design graph
@@ -67,7 +69,9 @@ export declare class CodeRulesEngine {
67
69
  private readonly oneEnumSpellingInApiLib;
68
70
  private readonly noUtilityTypesInApiLib;
69
71
  private readonly requiredTypeSuffix;
70
- constructor(workspace: WorkspaceRoot, reporter: RuleReporter, matchRules: MatchRulesHolder, matchChecker: MatchRulesChecker, selection: RuleSelection, maxMethodLines: MaxMethodLinesValidator, maxFileLines: MaxFileLinesValidator, requireReturnType: RequireReturnTypeValidator, noInlineTypeLiterals: NoInlineTypeLiteralsValidator, noAnyUnknown: NoAnyUnknownValidator, noImplicitAny: NoImplicitAnyValidator, prismaValidateDtos: PrismaValidateDtosValidator, prismaConverter: PrismaConverterValidator, noDestructure: NoDestructureValidator, catchErrorPattern: CatchErrorPatternValidator, noUnmanagedExceptions: NoUnmanagedExceptionsValidator, noDirectApiResolver: NoDirectApiResolverValidator, noSymbolDiTokens: NoSymbolDiTokensValidator, noClientCreationOutsideServerOrClient: NoClientCreationOutsideServerOrClientValidator, noCustomCss: NoCustomCssValidator, noStatePathsInTemplates: NoStatePathsInTemplatesValidator, noProcessExitOutsideMain: NoProcessExitOutsideMainValidator, noFunctionOutsideClass: NoFunctionOutsideClassValidator, injectAnnotationNotNeeded: InjectAnnotationNotNeededForConcreteClassValidator, frameworkTag: FrameworkTagValidator, roleTag: RoleTagValidator, ensureWeAreSecure: EnsureWeAreSecureValidator, noInlineImportInApiLib: NoInlineImportInApiLibValidator, oneEnumSpellingInApiLib: OneEnumSpellingInApiLibValidator, noUtilityTypesInApiLib: NoUtilityTypesInApiLibValidator, requiredTypeSuffix: RequiredTypeSuffixValidator);
72
+ private readonly frameworkTsconfig;
73
+ private readonly frameworkPackages;
74
+ constructor(workspace: WorkspaceRoot, reporter: RuleReporter, matchRules: MatchRulesHolder, matchChecker: MatchRulesChecker, selection: RuleSelection, maxMethodLines: MaxMethodLinesValidator, maxFileLines: MaxFileLinesValidator, requireReturnType: RequireReturnTypeValidator, noInlineTypeLiterals: NoInlineTypeLiteralsValidator, noAnyUnknown: NoAnyUnknownValidator, noImplicitAny: NoImplicitAnyValidator, prismaValidateDtos: PrismaValidateDtosValidator, prismaConverter: PrismaConverterValidator, noDestructure: NoDestructureValidator, catchErrorPattern: CatchErrorPatternValidator, noUnmanagedExceptions: NoUnmanagedExceptionsValidator, noDirectApiResolver: NoDirectApiResolverValidator, noSymbolDiTokens: NoSymbolDiTokensValidator, noClientCreationOutsideServerOrClient: NoClientCreationOutsideServerOrClientValidator, noCustomCss: NoCustomCssValidator, noStatePathsInTemplates: NoStatePathsInTemplatesValidator, noProcessExitOutsideMain: NoProcessExitOutsideMainValidator, noFunctionOutsideClass: NoFunctionOutsideClassValidator, injectAnnotationNotNeeded: InjectAnnotationNotNeededForConcreteClassValidator, frameworkTag: FrameworkTagValidator, roleTag: RoleTagValidator, ensureWeAreSecure: EnsureWeAreSecureValidator, noInlineImportInApiLib: NoInlineImportInApiLibValidator, oneEnumSpellingInApiLib: OneEnumSpellingInApiLibValidator, noUtilityTypesInApiLib: NoUtilityTypesInApiLibValidator, requiredTypeSuffix: RequiredTypeSuffixValidator, frameworkTsconfig: FrameworkTsconfigValidator, frameworkPackages: FrameworkPackagesValidator);
71
75
  /** The injected built-in validators, in run order. */
72
76
  private builtIns;
73
77
  /**
@@ -34,6 +34,8 @@ const validate_no_inline_import_in_api_lib_1 = require("./validate-no-inline-imp
34
34
  const validate_one_enum_spelling_in_api_lib_1 = require("./validate-one-enum-spelling-in-api-lib");
35
35
  const validate_no_utility_types_in_api_lib_1 = require("./validate-no-utility-types-in-api-lib");
36
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");
37
39
  /**
38
40
  * Owns running the code-rules suite. Every built-in validator is injected as a singleton (its config
39
41
  * is bound in the container at bootstrap), so this class IS the code-rules DI DAG the design graph
@@ -72,8 +74,10 @@ let CodeRulesEngine = class CodeRulesEngine {
72
74
  oneEnumSpellingInApiLib;
73
75
  noUtilityTypesInApiLib;
74
76
  requiredTypeSuffix;
77
+ frameworkTsconfig;
78
+ frameworkPackages;
75
79
  // webpieces-disable max-lines-new-methods -- the built-in validator set is flat; each is one injected field
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) {
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) {
77
81
  this.workspace = workspace;
78
82
  this.reporter = reporter;
79
83
  this.matchRules = matchRules;
@@ -105,6 +109,8 @@ let CodeRulesEngine = class CodeRulesEngine {
105
109
  this.oneEnumSpellingInApiLib = oneEnumSpellingInApiLib;
106
110
  this.noUtilityTypesInApiLib = noUtilityTypesInApiLib;
107
111
  this.requiredTypeSuffix = requiredTypeSuffix;
112
+ this.frameworkTsconfig = frameworkTsconfig;
113
+ this.frameworkPackages = frameworkPackages;
108
114
  }
109
115
  /** The injected built-in validators, in run order. */
110
116
  builtIns() {
@@ -135,6 +141,8 @@ let CodeRulesEngine = class CodeRulesEngine {
135
141
  this.oneEnumSpellingInApiLib,
136
142
  this.noUtilityTypesInApiLib,
137
143
  this.requiredTypeSuffix,
144
+ this.frameworkTsconfig,
145
+ this.frameworkPackages,
138
146
  ];
139
147
  }
140
148
  /**
@@ -209,6 +217,8 @@ exports.CodeRulesEngine = CodeRulesEngine = tslib_1.__decorate([
209
217
  validate_no_inline_import_in_api_lib_1.NoInlineImportInApiLibValidator,
210
218
  validate_one_enum_spelling_in_api_lib_1.OneEnumSpellingInApiLibValidator,
211
219
  validate_no_utility_types_in_api_lib_1.NoUtilityTypesInApiLibValidator,
212
- validate_required_type_suffix_1.RequiredTypeSuffixValidator])
220
+ validate_required_type_suffix_1.RequiredTypeSuffixValidator,
221
+ validate_framework_tsconfig_1.FrameworkTsconfigValidator,
222
+ validate_framework_packages_1.FrameworkPackagesValidator])
213
223
  ], CodeRulesEngine);
214
224
  //# 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":";;;;AACA,yCAA2D;AAE3D,qDAA0E;AAC1E,mDAA+C;AAC/C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E,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
+ {"version":3,"file":"code-rules-engine.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/code-rules-engine.ts"],"names":[],"mappings":";;;;AACA,yCAA2D;AAE3D,qDAA0E;AAC1E,mDAA+C;AAC/C,6DAAuE;AACvE,qEAAyD;AACzD,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;AAC9E,+EAA2E;AAC3E,+EAA2E;AAE3E;;;;;GAKG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAe;IAGH;IACA;IACA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,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;AAlHY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAIL,kCAAa;QACd,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-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';\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"]}
package/src/index.d.ts CHANGED
@@ -26,6 +26,9 @@ export { OneEnumSpellingInApiLibValidator, EnumSpellingScanner } from './validat
26
26
  export { NoUtilityTypesInApiLibValidator, UtilityTypeScanner } from './validate-no-utility-types-in-api-lib';
27
27
  export { RequiredTypeSuffixValidator, ExportedTypeScanner, SuffixEntryPicker, SuffixRename, GoverningGlob, } from './validate-required-type-suffix';
28
28
  export { ApiLibEnumIndex } from './api-lib-enum-index';
29
+ export { ProjectScanTargets, ScannedProject } from './project-scan-targets';
30
+ export { FrameworkTsconfigValidator, FrameworkTsconfigAudit, RuntimeCompilerOptions, TsconfigRuntimeViolation, frameworkTsconfigError, } from './validate-framework-tsconfig';
31
+ export { FrameworkPackagesValidator, FrameworkPackagesAudit, FrameworkPackageViolation, frameworkPackagesError, } from './validate-framework-packages';
29
32
  export { EnumText } from './api-lib-enum-text';
30
33
  export { PrismaValidateDtosValidator } from './validate-dtos';
31
34
  export { PrismaConverterValidator } from './validate-prisma-converters';
package/src/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
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;
3
+ exports.frameworkTsconfigError = exports.TsconfigRuntimeViolation = exports.RuntimeCompilerOptions = exports.FrameworkTsconfigAudit = exports.FrameworkTsconfigValidator = exports.ScannedProject = exports.ProjectScanTargets = 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 = exports.RuleSelection = exports.CodeRulesRunRequest = exports.CodeRulesBootstrap = exports.validateCode = exports.PrismaConverterValidator = exports.PrismaValidateDtosValidator = exports.EnumText = exports.frameworkPackagesError = exports.FrameworkPackageViolation = exports.FrameworkPackagesAudit = exports.FrameworkPackagesValidator = void 0;
5
5
  const tslib_1 = require("tslib");
6
6
  var code_validator_1 = require("./code-validator");
7
7
  Object.defineProperty(exports, "CodeValidator", { enumerable: true, get: function () { return code_validator_1.CodeValidator; } });
@@ -74,6 +74,20 @@ Object.defineProperty(exports, "SuffixRename", { enumerable: true, get: function
74
74
  Object.defineProperty(exports, "GoverningGlob", { enumerable: true, get: function () { return validate_required_type_suffix_1.GoverningGlob; } });
75
75
  var api_lib_enum_index_1 = require("./api-lib-enum-index");
76
76
  Object.defineProperty(exports, "ApiLibEnumIndex", { enumerable: true, get: function () { return api_lib_enum_index_1.ApiLibEnumIndex; } });
77
+ var project_scan_targets_1 = require("./project-scan-targets");
78
+ Object.defineProperty(exports, "ProjectScanTargets", { enumerable: true, get: function () { return project_scan_targets_1.ProjectScanTargets; } });
79
+ Object.defineProperty(exports, "ScannedProject", { enumerable: true, get: function () { return project_scan_targets_1.ScannedProject; } });
80
+ var validate_framework_tsconfig_1 = require("./validate-framework-tsconfig");
81
+ Object.defineProperty(exports, "FrameworkTsconfigValidator", { enumerable: true, get: function () { return validate_framework_tsconfig_1.FrameworkTsconfigValidator; } });
82
+ Object.defineProperty(exports, "FrameworkTsconfigAudit", { enumerable: true, get: function () { return validate_framework_tsconfig_1.FrameworkTsconfigAudit; } });
83
+ Object.defineProperty(exports, "RuntimeCompilerOptions", { enumerable: true, get: function () { return validate_framework_tsconfig_1.RuntimeCompilerOptions; } });
84
+ Object.defineProperty(exports, "TsconfigRuntimeViolation", { enumerable: true, get: function () { return validate_framework_tsconfig_1.TsconfigRuntimeViolation; } });
85
+ Object.defineProperty(exports, "frameworkTsconfigError", { enumerable: true, get: function () { return validate_framework_tsconfig_1.frameworkTsconfigError; } });
86
+ var validate_framework_packages_1 = require("./validate-framework-packages");
87
+ Object.defineProperty(exports, "FrameworkPackagesValidator", { enumerable: true, get: function () { return validate_framework_packages_1.FrameworkPackagesValidator; } });
88
+ Object.defineProperty(exports, "FrameworkPackagesAudit", { enumerable: true, get: function () { return validate_framework_packages_1.FrameworkPackagesAudit; } });
89
+ Object.defineProperty(exports, "FrameworkPackageViolation", { enumerable: true, get: function () { return validate_framework_packages_1.FrameworkPackageViolation; } });
90
+ Object.defineProperty(exports, "frameworkPackagesError", { enumerable: true, get: function () { return validate_framework_packages_1.frameworkPackagesError; } });
77
91
  var api_lib_enum_text_1 = require("./api-lib-enum-text");
78
92
  Object.defineProperty(exports, "EnumText", { enumerable: true, get: function () { return api_lib_enum_text_1.EnumText; } });
79
93
  var validate_dtos_1 = require("./validate-dtos");
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":";;;;;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;AAAE,+HAAA,kBAAkB,OAAA;AACpD,+DAAuD;AAA9C,qHAAA,aAAa,OAAA;AACtB,qEAAkE;AAAzD,gIAAA,qBAAqB,OAAA;AAC9B,iEAAqE;AAA5D,mIAAA,0BAA0B,OAAA;AACnC,uEAA2E;AAAlE,yIAAA,6BAA6B,OAAA;AACtC,+EAA4E;AAAnE,0IAAA,0BAA0B,OAAA;AACnC,uFAAoF;AAA3E,kJAAA,8BAA8B,OAAA;AACvC,qEAAmE;AAA1D,iIAAA,sBAAsB,OAAA;AAC/B,qFAAiF;AAAxE,+IAAA,4BAA4B,OAAA;AACrC,+EAA2E;AAAlE,yIAAA,yBAAyB,OAAA;AAClC,+HAAwH;AAA/G,sLAAA,8CAA8C,OAAA;AACvD,+FAIgD;AAH5C,wJAAA,gCAAgC,OAAA;AAChC,oIAAA,YAAY,OAAA;AACZ,0IAAA,kBAAkB,OAAA;AAEtB,iEAA8D;AAArD,4HAAA,mBAAmB,OAAA;AAC5B,iGAA4F;AAAnF,0JAAA,iCAAiC,OAAA;AAC1C,2FAAuF;AAA9E,qJAAA,+BAA+B,OAAA;AACxC,uIAGoE;AAFhE,8LAAA,kDAAkD,OAAA;AAClD,uKAAA,2BAA2B,OAAA;AAE/B,mEAAiE;AAAxD,+HAAA,qBAAqB,OAAA;AAC9B,yDAAuD;AAA9C,qHAAA,gBAAgB,OAAA;AACzB,iFAKyC;AAJrC,2IAAA,0BAA0B,OAAA;AAC1B,0IAAA,yBAAyB,OAAA;AACzB,uIAAA,sBAAsB,OAAA;AACtB,gJAAA,+BAA+B,OAAA;AAEnC,6DAA+D;AAAtD,iHAAA,UAAU,OAAA;AAAE,iHAAA,UAAU,OAAA;AAC/B,+FAA8G;AAArG,uJAAA,+BAA+B,OAAA;AAAE,2IAAA,mBAAmB,OAAA;AAC7D,iGAAgH;AAAvG,yJAAA,gCAAgC,OAAA;AAAE,4IAAA,mBAAmB,OAAA;AAC9D,+FAA6G;AAApG,uJAAA,+BAA+B,OAAA;AAAE,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"]}
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;AAAE,+HAAA,kBAAkB,OAAA;AACpD,+DAAuD;AAA9C,qHAAA,aAAa,OAAA;AACtB,qEAAkE;AAAzD,gIAAA,qBAAqB,OAAA;AAC9B,iEAAqE;AAA5D,mIAAA,0BAA0B,OAAA;AACnC,uEAA2E;AAAlE,yIAAA,6BAA6B,OAAA;AACtC,+EAA4E;AAAnE,0IAAA,0BAA0B,OAAA;AACnC,uFAAoF;AAA3E,kJAAA,8BAA8B,OAAA;AACvC,qEAAmE;AAA1D,iIAAA,sBAAsB,OAAA;AAC/B,qFAAiF;AAAxE,+IAAA,4BAA4B,OAAA;AACrC,+EAA2E;AAAlE,yIAAA,yBAAyB,OAAA;AAClC,+HAAwH;AAA/G,sLAAA,8CAA8C,OAAA;AACvD,+FAIgD;AAH5C,wJAAA,gCAAgC,OAAA;AAChC,oIAAA,YAAY,OAAA;AACZ,0IAAA,kBAAkB,OAAA;AAEtB,iEAA8D;AAArD,4HAAA,mBAAmB,OAAA;AAC5B,iGAA4F;AAAnF,0JAAA,iCAAiC,OAAA;AAC1C,2FAAuF;AAA9E,qJAAA,+BAA+B,OA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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 { ProjectScanTargets, ScannedProject } from './project-scan-targets';\nexport {\n FrameworkTsconfigValidator,\n FrameworkTsconfigAudit,\n RuntimeCompilerOptions,\n TsconfigRuntimeViolation,\n frameworkTsconfigError,\n} from './validate-framework-tsconfig';\nexport {\n FrameworkPackagesValidator,\n FrameworkPackagesAudit,\n FrameworkPackageViolation,\n frameworkPackagesError,\n} from './validate-framework-packages';\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"]}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Which PROJECTS a project-scoped rule judges — the two tag-truth code rules (#1064),
3
+ * `framework-tsconfig` and `framework-packages` — and the `framework:` tags each carries.
4
+ *
5
+ * MODIFIED_PROJECTS — every project owning a changed file (any file, not only .ts: a project.json or
6
+ * tsconfig edit is exactly what these rules judge)
7
+ * RUN_EVERY_TIME — every project in the repo, every run (the migration sweep)
8
+ *
9
+ * The per-run `--projects` restriction of the debug run (#1027) narrows both.
10
+ */
11
+ import { DiffScope, ProjectScanMode } from '@webpieces/rules-config';
12
+ import { ProjectCatalog, ScanRestriction } from './scan-scope';
13
+ /** One project to judge and its framework env set. Data-only. */
14
+ export declare class ScannedProject {
15
+ readonly name: string;
16
+ /** Repo-relative, '/'-separated, no trailing slash. */
17
+ readonly dir: string;
18
+ /** The `framework:` tag values, in declaration order, de-duplicated. Empty when untagged. */
19
+ readonly frameworks: readonly string[];
20
+ constructor(name: string,
21
+ /** Repo-relative, '/'-separated, no trailing slash. */
22
+ dir: string,
23
+ /** The `framework:` tag values, in declaration order, de-duplicated. Empty when untagged. */
24
+ frameworks: readonly string[]);
25
+ }
26
+ export declare class ProjectScanTargets {
27
+ private readonly diffScope;
28
+ private readonly catalog;
29
+ private readonly restriction;
30
+ constructor(diffScope: DiffScope, catalog: ProjectCatalog, restriction: ScanRestriction);
31
+ /** The projects `mode` judges, root project excluded. `mode` must not be OFF. */
32
+ projects(workspaceRoot: string, mode: ProjectScanMode, ruleName: string): ScannedProject[];
33
+ private touched;
34
+ /** The `framework:` values of a project.json. Unreadable JSON is the plumbing error it is. */
35
+ private frameworksOf;
36
+ }
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ /**
3
+ * Which PROJECTS a project-scoped rule judges — the two tag-truth code rules (#1064),
4
+ * `framework-tsconfig` and `framework-packages` — and the `framework:` tags each carries.
5
+ *
6
+ * MODIFIED_PROJECTS — every project owning a changed file (any file, not only .ts: a project.json or
7
+ * tsconfig edit is exactly what these rules judge)
8
+ * RUN_EVERY_TIME — every project in the repo, every run (the migration sweep)
9
+ *
10
+ * The per-run `--projects` restriction of the debug run (#1027) narrows both.
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.ProjectScanTargets = exports.ScannedProject = void 0;
14
+ const tslib_1 = require("tslib");
15
+ const fs = tslib_1.__importStar(require("fs"));
16
+ const path = tslib_1.__importStar(require("path"));
17
+ const rules_config_1 = require("@webpieces/rules-config");
18
+ const inversify_1 = require("inversify");
19
+ const scan_scope_1 = require("./scan-scope");
20
+ const FRAMEWORK_TAG_PREFIX = 'framework:';
21
+ /** One project to judge and its framework env set. Data-only. */
22
+ class ScannedProject {
23
+ name;
24
+ dir;
25
+ frameworks;
26
+ constructor(name,
27
+ /** Repo-relative, '/'-separated, no trailing slash. */
28
+ dir,
29
+ /** The `framework:` tag values, in declaration order, de-duplicated. Empty when untagged. */
30
+ frameworks) {
31
+ this.name = name;
32
+ this.dir = dir;
33
+ this.frameworks = frameworks;
34
+ }
35
+ }
36
+ exports.ScannedProject = ScannedProject;
37
+ let ProjectScanTargets = class ProjectScanTargets {
38
+ diffScope;
39
+ catalog;
40
+ restriction;
41
+ constructor(diffScope, catalog, restriction) {
42
+ this.diffScope = diffScope;
43
+ this.catalog = catalog;
44
+ this.restriction = restriction;
45
+ }
46
+ /** The projects `mode` judges, root project excluded. `mode` must not be OFF. */
47
+ projects(workspaceRoot, mode, ruleName) {
48
+ const all = this.catalog.all(workspaceRoot).filter((p) => p.dir !== '');
49
+ const chosen = mode === 'RUN_EVERY_TIME' ? all : this.touched(workspaceRoot, all, ruleName);
50
+ const names = this.restriction.projectNames;
51
+ const restricted = names === undefined ? chosen : chosen.filter((p) => names.includes(p.name));
52
+ return restricted
53
+ .map((p) => new ScannedProject(p.name, p.dir, this.frameworksOf(workspaceRoot, p.dir)))
54
+ .sort((a, b) => a.dir.localeCompare(b.dir));
55
+ }
56
+ touched(workspaceRoot, all, ruleName) {
57
+ const range = this.diffScope.resolveBase(workspaceRoot);
58
+ if (range.base === undefined) {
59
+ throw new rules_config_1.InformAiError(`${ruleName} could not determine the comparison base for MODIFIED_PROJECTS. Set NX_BASE to the ` +
60
+ 'base branch or commit and retry.');
61
+ }
62
+ const dirs = new Set();
63
+ for (const file of this.diffScope.getChangedFiles(workspaceRoot, range.base, range.head, { tsOnly: false })) {
64
+ const owner = this.catalog.ownerOf(workspaceRoot, file);
65
+ if (owner !== undefined)
66
+ dirs.add(owner.dir);
67
+ }
68
+ return all.filter((p) => dirs.has(p.dir));
69
+ }
70
+ /** The `framework:` values of a project.json. Unreadable JSON is the plumbing error it is. */
71
+ frameworksOf(workspaceRoot, dir) {
72
+ const file = path.join(workspaceRoot, dir, 'project.json');
73
+ // webpieces-disable no-unmanaged-exceptions -- add the exact project.json path while preserving the parse/read failure as cause
74
+ // eslint-disable-next-line @webpieces/no-unmanaged-exceptions
75
+ try {
76
+ const parsed = JSON.parse(fs.readFileSync(file, 'utf-8'));
77
+ const tags = Array.isArray(parsed.tags) ? parsed.tags : [];
78
+ const values = tags
79
+ .filter((tag) => typeof tag === 'string' && tag.startsWith(FRAMEWORK_TAG_PREFIX))
80
+ .map((tag) => tag.slice(FRAMEWORK_TAG_PREFIX.length).trim())
81
+ .filter((value) => value.length > 0);
82
+ return Array.from(new Set(values));
83
+ }
84
+ catch (err) {
85
+ const error = (0, rules_config_1.toError)(err);
86
+ throw new rules_config_1.InformAiError(`Cannot read framework tags from ${file} — fix project.json and retry.`, {
87
+ cause: error,
88
+ });
89
+ }
90
+ }
91
+ };
92
+ exports.ProjectScanTargets = ProjectScanTargets;
93
+ exports.ProjectScanTargets = ProjectScanTargets = tslib_1.__decorate([
94
+ (0, inversify_1.injectable)(inversify_1.bindingScopeValues.Singleton),
95
+ tslib_1.__metadata("design:paramtypes", [rules_config_1.DiffScope,
96
+ scan_scope_1.ProjectCatalog,
97
+ scan_scope_1.ScanRestriction])
98
+ ], ProjectScanTargets);
99
+ //# sourceMappingURL=project-scan-targets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-scan-targets.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/project-scan-targets.ts"],"names":[],"mappings":";AAAA;;;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CAsD9B","sourcesContent":["/**\n * Which PROJECTS a project-scoped rule judges — the two tag-truth code rules (#1064),\n * `framework-tsconfig` and `framework-packages` — and the `framework:` tags each carries.\n *\n * MODIFIED_PROJECTS — every project owning a changed file (any file, not only .ts: a project.json or\n * tsconfig edit is exactly what these rules judge)\n * RUN_EVERY_TIME — every project in the repo, every run (the migration sweep)\n *\n * The per-run `--projects` restriction of the debug run (#1027) narrows both.\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { DiffScope, InformAiError, ProjectScanMode, toError } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { ProjectCatalog, ProjectEntry, ScanRestriction } from './scan-scope';\n\nconst FRAMEWORK_TAG_PREFIX = 'framework:';\n\n/** The only field of a project.json this reads. */\ntype RawProjectTags = { tags?: string[] };\n\n/** One project to judge and its framework env set. Data-only. */\nexport class ScannedProject {\n constructor(\n readonly name: string,\n /** Repo-relative, '/'-separated, no trailing slash. */\n readonly dir: string,\n /** The `framework:` tag values, in declaration order, de-duplicated. Empty when untagged. */\n readonly frameworks: readonly string[],\n ) {}\n}\n\n@injectable(bindingScopeValues.Singleton)\nexport class ProjectScanTargets {\n constructor(\n private readonly diffScope: DiffScope,\n private readonly catalog: ProjectCatalog,\n private readonly restriction: ScanRestriction,\n ) {}\n\n /** The projects `mode` judges, root project excluded. `mode` must not be OFF. */\n projects(workspaceRoot: string, mode: ProjectScanMode, ruleName: string): ScannedProject[] {\n const all = this.catalog.all(workspaceRoot).filter((p: ProjectEntry) => p.dir !== '');\n const chosen = mode === 'RUN_EVERY_TIME' ? all : this.touched(workspaceRoot, all, ruleName);\n const names = this.restriction.projectNames;\n const restricted = names === undefined ? chosen : chosen.filter((p: ProjectEntry) => names.includes(p.name));\n return restricted\n .map((p: ProjectEntry) => new ScannedProject(p.name, p.dir, this.frameworksOf(workspaceRoot, p.dir)))\n .sort((a: ScannedProject, b: ScannedProject) => a.dir.localeCompare(b.dir));\n }\n\n private touched(workspaceRoot: string, all: ProjectEntry[], ruleName: string): ProjectEntry[] {\n const range = this.diffScope.resolveBase(workspaceRoot);\n if (range.base === undefined) {\n throw new InformAiError(\n `${ruleName} could not determine the comparison base for MODIFIED_PROJECTS. Set NX_BASE to the ` +\n 'base branch or commit and retry.',\n );\n }\n const dirs = new Set<string>();\n for (const file of this.diffScope.getChangedFiles(workspaceRoot, range.base, range.head, { tsOnly: false })) {\n const owner = this.catalog.ownerOf(workspaceRoot, file);\n if (owner !== undefined) dirs.add(owner.dir);\n }\n return all.filter((p: ProjectEntry) => dirs.has(p.dir));\n }\n\n /** The `framework:` values of a project.json. Unreadable JSON is the plumbing error it is. */\n private frameworksOf(workspaceRoot: string, dir: string): string[] {\n const file = path.join(workspaceRoot, dir, 'project.json');\n // webpieces-disable no-unmanaged-exceptions -- add the exact project.json path while preserving the parse/read failure as cause\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const parsed = JSON.parse(fs.readFileSync(file, 'utf-8')) as RawProjectTags;\n const tags = Array.isArray(parsed.tags) ? parsed.tags : [];\n const values = tags\n .filter((tag: string) => typeof tag === 'string' && tag.startsWith(FRAMEWORK_TAG_PREFIX))\n .map((tag: string) => tag.slice(FRAMEWORK_TAG_PREFIX.length).trim())\n .filter((value: string) => value.length > 0);\n return Array.from(new Set(values));\n } catch (err: unknown) {\n const error = toError(err);\n throw new InformAiError(`Cannot read framework tags from ${file} — fix project.json and retry.`, {\n cause: error,\n });\n }\n }\n}\n"]}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * `framework-packages` (#1064, D8) — a framework package is imported only by a project whose EVERY
3
+ * `framework:` tag is one its config entry allows: `@angular/*` only in angular projects, `react` /
4
+ * `react-native` / `expo*` only in react / react-native projects, `express` and the node-only SDKs
5
+ * (`firebase-admin`, `googleapis`, `@google-cloud/*`) only in node / express projects, the browser
6
+ * `firebase` SDK only in browser projects.
7
+ *
8
+ * "Every" is the point: a `browser+node` library importing `firebase-admin` is refused, because its
9
+ * browser half cannot run it — the same reading `library-types-match-client` gives an env SET.
10
+ *
11
+ * The package list is the CONSUMER's (required, no default — `.claude/rules/no-rule-defaults.md`);
12
+ * webpieces seeds and documents the recommended one (`.claude/rules/framework-tags.md`). Only
13
+ * production source is read: a spec importing `express` to stand up a fake server is not the runtime.
14
+ * A package no entry names is not judged. The per-site hatch is
15
+ * `// webpieces-disable framework-packages -- <reason>` on the import line or the line above it.
16
+ */
17
+ import { FrameworkPackagesConfig, FrameworkPackagesEntry, RuleFailError } from '@webpieces/rules-config';
18
+ import { CodeValidator, ExecutorResult } from './code-validator';
19
+ import { ProjectScanTargets, ScannedProject } from './project-scan-targets';
20
+ /** ONE project importing a framework package its runtime cannot run. Data-only. */
21
+ export declare class FrameworkPackageViolation {
22
+ readonly project: string;
23
+ readonly frameworks: readonly string[];
24
+ readonly packageName: string;
25
+ /** `path/to/File.ts:LINE`, repo-relative — the first import found. */
26
+ readonly at: string;
27
+ /** The framework tags an entry allows for that package. */
28
+ readonly allowed: readonly string[];
29
+ constructor(project: string, frameworks: readonly string[], packageName: string,
30
+ /** `path/to/File.ts:LINE`, repo-relative — the first import found. */
31
+ at: string,
32
+ /** The framework tags an entry allows for that package. */
33
+ allowed: readonly string[]);
34
+ }
35
+ /** The audit itself — no config, no git: projects and entries in, violations out. */
36
+ export declare class FrameworkPackagesAudit {
37
+ private readonly entries;
38
+ constructor(entries: readonly FrameworkPackagesEntry[]);
39
+ audit(workspaceRoot: string, projects: readonly ScannedProject[]): FrameworkPackageViolation[];
40
+ /** Every bare-package import in a project's production source, nested projects excluded. */
41
+ private importsOf;
42
+ private isTestFile;
43
+ private sitesIn;
44
+ /** `@scope/pkg/sub` → `@scope/pkg`; `pkg/sub` → `pkg`; relative paths and `node:` builtins → null. */
45
+ private packageNameOf;
46
+ }
47
+ /** The one structured failure for every violation, shared by the validator and its spec. */
48
+ export declare function frameworkPackagesError(violations: readonly FrameworkPackageViolation[]): RuleFailError;
49
+ export declare class FrameworkPackagesValidator extends CodeValidator<FrameworkPackagesConfig> {
50
+ private readonly targets;
51
+ constructor(config: FrameworkPackagesConfig, targets: ProjectScanTargets);
52
+ run(workspaceRoot: string): Promise<ExecutorResult>;
53
+ }
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+ /**
3
+ * `framework-packages` (#1064, D8) — a framework package is imported only by a project whose EVERY
4
+ * `framework:` tag is one its config entry allows: `@angular/*` only in angular projects, `react` /
5
+ * `react-native` / `expo*` only in react / react-native projects, `express` and the node-only SDKs
6
+ * (`firebase-admin`, `googleapis`, `@google-cloud/*`) only in node / express projects, the browser
7
+ * `firebase` SDK only in browser projects.
8
+ *
9
+ * "Every" is the point: a `browser+node` library importing `firebase-admin` is refused, because its
10
+ * browser half cannot run it — the same reading `library-types-match-client` gives an env SET.
11
+ *
12
+ * The package list is the CONSUMER's (required, no default — `.claude/rules/no-rule-defaults.md`);
13
+ * webpieces seeds and documents the recommended one (`.claude/rules/framework-tags.md`). Only
14
+ * production source is read: a spec importing `express` to stand up a fake server is not the runtime.
15
+ * A package no entry names is not judged. The per-site hatch is
16
+ * `// webpieces-disable framework-packages -- <reason>` on the import line or the line above it.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.FrameworkPackagesValidator = exports.FrameworkPackagesAudit = exports.FrameworkPackageViolation = void 0;
20
+ exports.frameworkPackagesError = frameworkPackagesError;
21
+ const tslib_1 = require("tslib");
22
+ const fs = tslib_1.__importStar(require("fs"));
23
+ const path = tslib_1.__importStar(require("path"));
24
+ const rules_config_1 = require("@webpieces/rules-config");
25
+ const inversify_1 = require("inversify");
26
+ const code_validator_1 = require("./code-validator");
27
+ const project_scan_targets_1 = require("./project-scan-targets");
28
+ /** Directories never read: build output, vendored code. */
29
+ const SKIP_DIRS = new Set(['node_modules', 'dist', 'build', 'out-tsc', 'coverage', '.nx', '.git', 'tmp']);
30
+ /** `from '…'`, `import '…'`, `require('…')`, `import('…')`. */
31
+ const IMPORT_RE = /(?:\bfrom\s*|\bimport\s*|\brequire\s*\(\s*|\bimport\s*\(\s*)['"]([^'"]+)['"]/g;
32
+ /** ONE project importing a framework package its runtime cannot run. Data-only. */
33
+ class FrameworkPackageViolation {
34
+ project;
35
+ frameworks;
36
+ packageName;
37
+ at;
38
+ allowed;
39
+ constructor(project, frameworks, packageName,
40
+ /** `path/to/File.ts:LINE`, repo-relative — the first import found. */
41
+ at,
42
+ /** The framework tags an entry allows for that package. */
43
+ allowed) {
44
+ this.project = project;
45
+ this.frameworks = frameworks;
46
+ this.packageName = packageName;
47
+ this.at = at;
48
+ this.allowed = allowed;
49
+ }
50
+ }
51
+ exports.FrameworkPackageViolation = FrameworkPackageViolation;
52
+ /** The audit itself — no config, no git: projects and entries in, violations out. */
53
+ class FrameworkPackagesAudit {
54
+ entries;
55
+ constructor(entries) {
56
+ this.entries = entries;
57
+ }
58
+ audit(workspaceRoot, projects) {
59
+ const out = [];
60
+ const nestedRoots = new Set(projects.map((p) => p.dir));
61
+ for (const project of projects) {
62
+ if (project.frameworks.length === 0)
63
+ continue; // framework-tag's job
64
+ const seen = new Set();
65
+ for (const site of this.importsOf(workspaceRoot, project.dir, nestedRoots)) {
66
+ if (seen.has(site.packageName))
67
+ continue;
68
+ const matching = this.entries.filter((e) => (0, rules_config_1.matchesAnyGlob)(site.packageName, e.packages));
69
+ if (matching.length === 0)
70
+ continue;
71
+ const ok = matching.some((e) => project.frameworks.every((env) => e.frameworks.includes(env)));
72
+ if (ok)
73
+ continue;
74
+ seen.add(site.packageName);
75
+ const allowed = Array.from(new Set(matching.flatMap((e) => e.frameworks)));
76
+ out.push(new FrameworkPackageViolation(project.name, project.frameworks, site.packageName, site.at, allowed));
77
+ }
78
+ }
79
+ return out;
80
+ }
81
+ /** Every bare-package import in a project's production source, nested projects excluded. */
82
+ importsOf(workspaceRoot, dir, projectDirs) {
83
+ const sites = [];
84
+ const walk = (absDir) => {
85
+ for (const entry of fs.readdirSync(absDir, { withFileTypes: true })) {
86
+ const abs = path.join(absDir, entry.name);
87
+ const rel = path.relative(workspaceRoot, abs).split(path.sep).join('/');
88
+ if (entry.isDirectory()) {
89
+ if (SKIP_DIRS.has(entry.name) || entry.name === '__tests__' || projectDirs.has(rel))
90
+ continue;
91
+ if (fs.existsSync(path.join(abs, 'project.json')))
92
+ continue; // a nested project is judged on its own
93
+ walk(abs);
94
+ }
95
+ else if (/\.(ts|tsx|mts|cts)$/.test(entry.name) && !/\.d\.ts$/.test(entry.name) && !this.isTestFile(entry.name)) {
96
+ sites.push(...this.sitesIn(abs, rel));
97
+ }
98
+ }
99
+ };
100
+ const root = path.join(workspaceRoot, dir);
101
+ if (fs.existsSync(root))
102
+ walk(root);
103
+ return sites;
104
+ }
105
+ isTestFile(name) {
106
+ return /\.(spec|test)\.[cm]?tsx?$/.test(name) || /^test-setup\./.test(name) || /\.config\.[cm]?ts$/.test(name);
107
+ }
108
+ sitesIn(abs, rel) {
109
+ const lines = fs.readFileSync(abs, 'utf-8').split('\n');
110
+ const sites = [];
111
+ lines.forEach((line, index) => {
112
+ IMPORT_RE.lastIndex = 0;
113
+ let match = IMPORT_RE.exec(line);
114
+ while (match !== null) {
115
+ const pkg = this.packageNameOf(match[1]);
116
+ const disabled = (0, rules_config_1.hasDisable)(line, rules_config_1.RULE_NAMES.FRAMEWORK_PACKAGES) ||
117
+ (index > 0 && (0, rules_config_1.hasDisable)(lines[index - 1], rules_config_1.RULE_NAMES.FRAMEWORK_PACKAGES));
118
+ if (pkg !== null && !disabled)
119
+ sites.push(new ImportSite(pkg, `${rel}:${index + 1}`));
120
+ match = IMPORT_RE.exec(line);
121
+ }
122
+ });
123
+ return sites;
124
+ }
125
+ /** `@scope/pkg/sub` → `@scope/pkg`; `pkg/sub` → `pkg`; relative paths and `node:` builtins → null. */
126
+ packageNameOf(specifier) {
127
+ if (specifier === '' || specifier.startsWith('.') || specifier.startsWith('/') || specifier.startsWith('node:'))
128
+ return null;
129
+ const parts = specifier.split('/');
130
+ if (specifier.startsWith('@'))
131
+ return parts.length < 2 ? null : `${parts[0]}/${parts[1]}`;
132
+ return parts[0];
133
+ }
134
+ }
135
+ exports.FrameworkPackagesAudit = FrameworkPackagesAudit;
136
+ /** One import of a bare package. Data-only. */
137
+ class ImportSite {
138
+ packageName;
139
+ at;
140
+ constructor(packageName, at) {
141
+ this.packageName = packageName;
142
+ this.at = at;
143
+ }
144
+ }
145
+ /** The one structured failure for every violation, shared by the validator and its spec. */
146
+ // webpieces-disable no-function-outside-class -- one structured rule failure shared by tests and runner
147
+ function frameworkPackagesError(violations) {
148
+ const details = violations
149
+ .map((v) => ` ${v.at} — ${v.project} [${v.frameworks.join(', ')}] imports '${v.packageName}', ` +
150
+ `which only [${v.allowed.join(', ')}] projects may import`)
151
+ .join('\n');
152
+ return new rules_config_1.RuleFailError(rules_config_1.RULE_NAMES.FRAMEWORK_PACKAGES, 'A project imports a framework package that one of the runtimes its framework tags promise cannot run.\n' + details, undefined, undefined, [
153
+ new rules_config_1.Option('Move the code that needs the package into a project whose framework tags are all ones the package runs on, and depend on that project behind an api-lib contract.', true),
154
+ new rules_config_1.Option('If the project really runs only where the package does, the TAGS are wrong: narrow its framework tags (and move it to that runtime\'s folder).'),
155
+ new rules_config_1.Option('For one import that is genuinely safe, put `// webpieces-disable framework-packages -- <reason>` on the line above it.'),
156
+ ]);
157
+ }
158
+ let FrameworkPackagesValidator = class FrameworkPackagesValidator extends code_validator_1.CodeValidator {
159
+ targets;
160
+ constructor(config, targets) {
161
+ super(config, rules_config_1.RULE_NAMES.FRAMEWORK_PACKAGES, rules_config_1.RULE_NAMES.FRAMEWORK_PACKAGES);
162
+ this.targets = targets;
163
+ }
164
+ async run(workspaceRoot) {
165
+ const mode = this.config.mode ?? 'OFF';
166
+ if (mode === 'OFF')
167
+ return { success: true };
168
+ const allowed = this.config.allowedPaths ?? [];
169
+ const projects = this.targets
170
+ .projects(workspaceRoot, mode, rules_config_1.RULE_NAMES.FRAMEWORK_PACKAGES)
171
+ .filter((p) => !(0, rules_config_1.matchesAnyGlob)(p.dir, allowed));
172
+ const violations = new FrameworkPackagesAudit(this.config.entries).audit(workspaceRoot, projects);
173
+ if (violations.length === 0)
174
+ return { success: true };
175
+ throw frameworkPackagesError(violations);
176
+ }
177
+ };
178
+ exports.FrameworkPackagesValidator = FrameworkPackagesValidator;
179
+ exports.FrameworkPackagesValidator = FrameworkPackagesValidator = tslib_1.__decorate([
180
+ (0, inversify_1.injectable)(inversify_1.bindingScopeValues.Singleton),
181
+ tslib_1.__metadata("design:paramtypes", [rules_config_1.FrameworkPackagesConfig,
182
+ project_scan_targets_1.ProjectScanTargets])
183
+ ], FrameworkPackagesValidator);
184
+ //# sourceMappingURL=validate-framework-packages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-framework-packages.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/validate-framework-packages.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AA0HH,wDAiBC;;AAzID,+CAAyB;AACzB,mDAA6B;AAC7B,0DAQiC;AACjC,yCAA2D;AAC3D,qDAAiE;AACjE,iEAA4E;AAE5E,2DAA2D;AAC3D,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;AAC1G,+DAA+D;AAC/D,MAAM,SAAS,GAAG,+EAA+E,CAAC;AAElG,mFAAmF;AACnF,MAAa,yBAAyB;IAErB;IACA;IACA;IAEA;IAEA;IAPb,YACa,OAAe,EACf,UAA6B,EAC7B,WAAmB;IAC5B,sEAAsE;IAC7D,EAAU;IACnB,2DAA2D;IAClD,OAA0B;QAN1B,YAAO,GAAP,OAAO,CAAQ;QACf,eAAU,GAAV,UAAU,CAAmB;QAC7B,gBAAW,GAAX,WAAW,CAAQ;QAEnB,OAAE,GAAF,EAAE,CAAQ;QAEV,YAAO,GAAP,OAAO,CAAmB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AAQ,GAAG,IAAI,CAAC,OAAO;aACxB,QAAQ,CAAC,aAAa,EAAE,IAAI,EAAE,yBAAU,CAAC,kBAAkB,CAAC;aAC5D,MAAM,CAAC,CAAC,CAAiB,EAAE,EAAE,CAAC,CAAC,IAAA,6BAAc,EAAC,CAAC,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;QACpE,MAAM,UAAU,GAAG,IAAI,sBAAsB,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;QAClG,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QACtD,MAAM,sBAAsB,CAAC,UAAU,CAAC,CAAC;IAC7C,CAAC;CACJ,CAAA;AAnBY,gEAA0B;qCAA1B,0BAA0B;IADtC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGzB,sCAAuB;QACL,yCAAkB;GAHvC,0BAA0B,CAmBtC","sourcesContent":["/**\n * `framework-packages` (#1064, D8) — a framework package is imported only by a project whose EVERY\n * `framework:` tag is one its config entry allows: `@angular/*` only in angular projects, `react` /\n * `react-native` / `expo*` only in react / react-native projects, `express` and the node-only SDKs\n * (`firebase-admin`, `googleapis`, `@google-cloud/*`) only in node / express projects, the browser\n * `firebase` SDK only in browser projects.\n *\n * \"Every\" is the point: a `browser+node` library importing `firebase-admin` is refused, because its\n * browser half cannot run it — the same reading `library-types-match-client` gives an env SET.\n *\n * The package list is the CONSUMER's (required, no default — `.claude/rules/no-rule-defaults.md`);\n * webpieces seeds and documents the recommended one (`.claude/rules/framework-tags.md`). Only\n * production source is read: a spec importing `express` to stand up a fake server is not the runtime.\n * A package no entry names is not judged. The per-site hatch is\n * `// webpieces-disable framework-packages -- <reason>` on the import line or the line above it.\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport {\n FrameworkPackagesConfig,\n FrameworkPackagesEntry,\n hasDisable,\n matchesAnyGlob,\n Option,\n RuleFailError,\n RULE_NAMES,\n} from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { CodeValidator, ExecutorResult } from './code-validator';\nimport { ProjectScanTargets, ScannedProject } from './project-scan-targets';\n\n/** Directories never read: build output, vendored code. */\nconst SKIP_DIRS = new Set(['node_modules', 'dist', 'build', 'out-tsc', 'coverage', '.nx', '.git', 'tmp']);\n/** `from '…'`, `import '…'`, `require('…')`, `import('…')`. */\nconst IMPORT_RE = /(?:\\bfrom\\s*|\\bimport\\s*|\\brequire\\s*\\(\\s*|\\bimport\\s*\\(\\s*)['\"]([^'\"]+)['\"]/g;\n\n/** ONE project importing a framework package its runtime cannot run. Data-only. */\nexport class FrameworkPackageViolation {\n constructor(\n readonly project: string,\n readonly frameworks: readonly string[],\n readonly packageName: string,\n /** `path/to/File.ts:LINE`, repo-relative — the first import found. */\n readonly at: string,\n /** The framework tags an entry allows for that package. */\n readonly allowed: readonly string[],\n ) {}\n}\n\n/** The audit itself — no config, no git: projects and entries in, violations out. */\nexport class FrameworkPackagesAudit {\n constructor(private readonly entries: readonly FrameworkPackagesEntry[]) {}\n\n audit(workspaceRoot: string, projects: readonly ScannedProject[]): FrameworkPackageViolation[] {\n const out: FrameworkPackageViolation[] = [];\n const nestedRoots = new Set(projects.map((p: ScannedProject) => p.dir));\n for (const project of projects) {\n if (project.frameworks.length === 0) continue; // framework-tag's job\n const seen = new Set<string>();\n for (const site of this.importsOf(workspaceRoot, project.dir, nestedRoots)) {\n if (seen.has(site.packageName)) continue;\n const matching = this.entries.filter((e: FrameworkPackagesEntry) => matchesAnyGlob(site.packageName, e.packages));\n if (matching.length === 0) continue;\n const ok = matching.some((e: FrameworkPackagesEntry) =>\n project.frameworks.every((env: string) => e.frameworks.includes(env)));\n if (ok) continue;\n seen.add(site.packageName);\n const allowed = Array.from(new Set(matching.flatMap((e: FrameworkPackagesEntry) => e.frameworks)));\n out.push(new FrameworkPackageViolation(project.name, project.frameworks, site.packageName, site.at, allowed));\n }\n }\n return out;\n }\n\n /** Every bare-package import in a project's production source, nested projects excluded. */\n private importsOf(workspaceRoot: string, dir: string, projectDirs: ReadonlySet<string>): ImportSite[] {\n const sites: ImportSite[] = [];\n const walk = (absDir: string): void => {\n for (const entry of fs.readdirSync(absDir, { withFileTypes: true })) {\n const abs = path.join(absDir, entry.name);\n const rel = path.relative(workspaceRoot, abs).split(path.sep).join('/');\n if (entry.isDirectory()) {\n if (SKIP_DIRS.has(entry.name) || entry.name === '__tests__' || projectDirs.has(rel)) continue;\n if (fs.existsSync(path.join(abs, 'project.json'))) continue; // a nested project is judged on its own\n walk(abs);\n } else if (/\\.(ts|tsx|mts|cts)$/.test(entry.name) && !/\\.d\\.ts$/.test(entry.name) && !this.isTestFile(entry.name)) {\n sites.push(...this.sitesIn(abs, rel));\n }\n }\n };\n const root = path.join(workspaceRoot, dir);\n if (fs.existsSync(root)) walk(root);\n return sites;\n }\n\n private isTestFile(name: string): boolean {\n return /\\.(spec|test)\\.[cm]?tsx?$/.test(name) || /^test-setup\\./.test(name) || /\\.config\\.[cm]?ts$/.test(name);\n }\n\n private sitesIn(abs: string, rel: string): ImportSite[] {\n const lines = fs.readFileSync(abs, 'utf-8').split('\\n');\n const sites: ImportSite[] = [];\n lines.forEach((line: string, index: number) => {\n IMPORT_RE.lastIndex = 0;\n let match = IMPORT_RE.exec(line);\n while (match !== null) {\n const pkg = this.packageNameOf(match[1]);\n const disabled =\n hasDisable(line, RULE_NAMES.FRAMEWORK_PACKAGES) ||\n (index > 0 && hasDisable(lines[index - 1], RULE_NAMES.FRAMEWORK_PACKAGES));\n if (pkg !== null && !disabled) sites.push(new ImportSite(pkg, `${rel}:${index + 1}`));\n match = IMPORT_RE.exec(line);\n }\n });\n return sites;\n }\n\n /** `@scope/pkg/sub` → `@scope/pkg`; `pkg/sub` → `pkg`; relative paths and `node:` builtins → null. */\n private packageNameOf(specifier: string): string | null {\n if (specifier === '' || specifier.startsWith('.') || specifier.startsWith('/') || specifier.startsWith('node:')) return null;\n const parts = specifier.split('/');\n if (specifier.startsWith('@')) return parts.length < 2 ? null : `${parts[0]}/${parts[1]}`;\n return parts[0];\n }\n}\n\n/** One import of a bare package. Data-only. */\nclass ImportSite {\n constructor(\n readonly packageName: string,\n readonly at: string,\n ) {}\n}\n\n/** The one structured failure for every violation, shared by the validator and its spec. */\n// webpieces-disable no-function-outside-class -- one structured rule failure shared by tests and runner\nexport function frameworkPackagesError(violations: readonly FrameworkPackageViolation[]): RuleFailError {\n const details = violations\n .map((v: FrameworkPackageViolation) =>\n ` ${v.at} — ${v.project} [${v.frameworks.join(', ')}] imports '${v.packageName}', ` +\n `which only [${v.allowed.join(', ')}] projects may import`)\n .join('\\n');\n return new RuleFailError(\n RULE_NAMES.FRAMEWORK_PACKAGES,\n 'A project imports a framework package that one of the runtimes its framework tags promise cannot run.\\n' + details,\n undefined,\n undefined,\n [\n new Option('Move the code that needs the package into a project whose framework tags are all ones the package runs on, and depend on that project behind an api-lib contract.', true),\n new Option('If the project really runs only where the package does, the TAGS are wrong: narrow its framework tags (and move it to that runtime\\'s folder).'),\n new Option('For one import that is genuinely safe, put `// webpieces-disable framework-packages -- <reason>` on the line above it.'),\n ],\n );\n}\n\n@injectable(bindingScopeValues.Singleton)\nexport class FrameworkPackagesValidator extends CodeValidator<FrameworkPackagesConfig> {\n constructor(\n config: FrameworkPackagesConfig,\n private readonly targets: ProjectScanTargets,\n ) {\n super(config, RULE_NAMES.FRAMEWORK_PACKAGES, RULE_NAMES.FRAMEWORK_PACKAGES);\n }\n\n async run(workspaceRoot: string): Promise<ExecutorResult> {\n const mode = this.config.mode ?? 'OFF';\n if (mode === 'OFF') return { success: true };\n const allowed = this.config.allowedPaths ?? [];\n const projects = this.targets\n .projects(workspaceRoot, mode, RULE_NAMES.FRAMEWORK_PACKAGES)\n .filter((p: ScannedProject) => !matchesAnyGlob(p.dir, allowed));\n const violations = new FrameworkPackagesAudit(this.config.entries).audit(workspaceRoot, projects);\n if (violations.length === 0) return { success: true };\n throw frameworkPackagesError(violations);\n }\n}\n"]}
@@ -7,14 +7,17 @@
7
7
  * from the atomic values:
8
8
  *
9
9
  * framework:browser | framework:react | framework:angular
10
- * framework:node | framework:express
10
+ * framework:node | framework:express | framework:react-native
11
11
  *
12
12
  * A project lists EVERY environment it promises to run in (e.g.
13
13
  * `framework:browser` + `framework:node`). This env set is the source of truth
14
14
  * for the `framework` field written into architecture/dependencies.json and for
15
15
  * the `library-types-match-client` rule, which uses the compatibility lattice
16
16
  * (react/angular→browser, express→node) to keep an express project from
17
- * depending on a browser-only library (and vice-versa).
17
+ * depending on a browser-only library (and vice-versa). `react-native` is its own
18
+ * runtime, NOT a browser (#1064): it has no DOM, IndexedDB or OPFS, so a
19
+ * react-native project consumes only libraries that are themselves tagged
20
+ * `framework:react-native`.
18
21
  *
19
22
  * The legacy single-value `framework:all` "usable by any side" bucket is
20
23
  * REMOVED — it is a hard error, and the author must declare the actual env set.
@@ -8,14 +8,17 @@
8
8
  * from the atomic values:
9
9
  *
10
10
  * framework:browser | framework:react | framework:angular
11
- * framework:node | framework:express
11
+ * framework:node | framework:express | framework:react-native
12
12
  *
13
13
  * A project lists EVERY environment it promises to run in (e.g.
14
14
  * `framework:browser` + `framework:node`). This env set is the source of truth
15
15
  * for the `framework` field written into architecture/dependencies.json and for
16
16
  * the `library-types-match-client` rule, which uses the compatibility lattice
17
17
  * (react/angular→browser, express→node) to keep an express project from
18
- * depending on a browser-only library (and vice-versa).
18
+ * depending on a browser-only library (and vice-versa). `react-native` is its own
19
+ * runtime, NOT a browser (#1064): it has no DOM, IndexedDB or OPFS, so a
20
+ * react-native project consumes only libraries that are themselves tagged
21
+ * `framework:react-native`.
19
22
  *
20
23
  * The legacy single-value `framework:all` "usable by any side" bucket is
21
24
  * REMOVED — it is a hard error, and the author must declare the actual env set.
@@ -57,8 +60,9 @@ function reportViolations(untagged, knownTypes, mode) {
57
60
  console.error('❌ Every modified project must declare the env set it runs in (>=1 framework tag)!');
58
61
  console.error('');
59
62
  console.error(` Add ONE OR MORE of these to the project's project.json "tags" array: ${suggestion}`);
60
- console.error(' (react/angular specialize browser; express specializes node. A project that runs in');
61
- console.error(' both the browser and node declares BOTH, e.g. framework:browser + framework:node.)');
63
+ console.error(' (react/angular specialize browser; express specializes node; react-native is its own runtime,');
64
+ console.error(' NOT a browser — no DOM, IndexedDB or OPFS. A project that runs in several declares EVERY one,');
65
+ console.error(' e.g. framework:browser + framework:node + framework:react-native for a universal library.)');
62
66
  console.error(' This libType drives architecture/dependencies.json and the library-types-match-client rule.');
63
67
  console.error('');
64
68
  for (const project of untagged) {
@@ -1 +1 @@
1
- {"version":3,"file":"validate-framework-tag.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/validate-framework-tag.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;;;AAuBH,oDAEC;;AAvBD,0DAA0E;AAC1E,qDAAiE;AACjE,yCAA2D;AAC3D,yCAMoB;AAEpB,MAAM,oBAAoB,GAAG,YAAY,CAAC;AAC1C,MAAM,mBAAmB,GAAG,CAAC,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC;AAE/F,kFAAkF;AAClF,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAEhC;;;GAGG;AACH,SAAgB,oBAAoB,CAAC,aAAqB,EAAE,YAAsB;IAC9E,OAAO,IAAA,iCAAsB,EAAC,aAAa,EAAE,YAAY,EAAE,oBAAoB,CAAC,CAAC;AACrF,CAAC;AAED,SAAS,gBAAgB,CAAC,QAA6B,EAAE,UAAoB,EAAE,IAAiB;IAC5F,MAAM,UAAU,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,GAAG,oBAAoB,GAAG,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;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,iCAAkB;GAD7B,qBAAqB,CAQjC","sourcesContent":["/**\n * Validate Framework Tag Executor\n *\n * Every project that a changed source file belongs to must carry at least one\n * `framework:<value>` nx tag in its project.json. Those tags are the project's\n * \"libType\" — the SET of runtime environments it is validated to run in, drawn\n * from the atomic values:\n *\n * framework:browser | framework:react | framework:angular\n * framework:node | framework:express\n *\n * A project lists EVERY environment it promises to run in (e.g.\n * `framework:browser` + `framework:node`). This env set is the source of truth\n * for the `framework` field written into architecture/dependencies.json and for\n * the `library-types-match-client` rule, which uses the compatibility lattice\n * (react/angular→browser, express→node) to keep an express project from\n * depending on a browser-only library (and vice-versa).\n *\n * The legacy single-value `framework:all` \"usable by any side\" bucket is\n * REMOVED — it is a hard error, and the author must declare the actual env set.\n *\n * The project-walking + diff-scoping + mode logic is shared with the `role-tag`\n * rule in `tag-rule.ts`; this file supplies only the framework-specific prefix,\n * known values, and violation messages. Unlike role-tag, framework-tag ALSO\n * validates tag VALUES (allowing multiple) via {@link TagRuleSpec.validateValues}.\n *\n * ============================================================================\n * MODES (PROJECT-LEVEL)\n * ============================================================================\n * - OFF: Skip validation entirely.\n * - MODIFIED_PROJECTS: Require >=1 valid framework tag on every project that\n * owns ANY changed file (not just .ts, and not line-scoped).\n */\n\nimport { ProjectMode, FrameworkTagConfig } from '@webpieces/rules-config';\nimport { CodeValidator, ExecutorResult } from './code-validator';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport {\n InvalidTagProject,\n MissingTagProject,\n TagRuleSpec,\n findProjectsMissingTag,\n runTagValidator,\n} from './tag-rule';\n\nconst FRAMEWORK_TAG_PREFIX = 'framework:';\nconst DEFAULT_KNOWN_TYPES = ['browser', 'react', 'angular', 'node', 'express', 'react-native'];\n\n/** The removed legacy libType, kept only to emit a targeted migration message. */\nconst REMOVED_ALL_VALUE = 'all';\n\n/**\n * Back-compat export used by tests: the framework-tag flavor of the shared\n * missing-tag scan.\n */\nexport function findUntaggedProjects(workspaceRoot: string, changedFiles: string[]): MissingTagProject[] {\n return findProjectsMissingTag(workspaceRoot, changedFiles, FRAMEWORK_TAG_PREFIX);\n}\n\nfunction reportViolations(untagged: MissingTagProject[], knownTypes: string[], mode: ProjectMode): void {\n const suggestion = knownTypes.map((t: string) => `${FRAMEWORK_TAG_PREFIX}${t}`).join(' | ');\n console.error('');\n console.error('❌ Every modified project must declare the env set it runs in (>=1 framework tag)!');\n console.error('');\n console.error(` Add ONE OR MORE of these to the project's project.json \"tags\" array: ${suggestion}`);\n console.error(' (react/angular specialize browser; express specializes node. A project that runs in');\n console.error(' both the browser and node declares BOTH, e.g. framework:browser + framework:node.)');\n console.error(' This libType drives architecture/dependencies.json and the library-types-match-client rule.');\n console.error('');\n\n for (const project of untagged) {\n console.error(` ❌ ${project.name} — ${project.projectJsonPath}`);\n console.error(` add e.g. \"tags\": [\"${FRAMEWORK_TAG_PREFIX}browser\", \"${FRAMEWORK_TAG_PREFIX}node\"]`);\n }\n console.error('');\n console.error(` Current mode: ${mode}`);\n console.error('');\n}\n\nfunction reportInvalidValues(invalid: InvalidTagProject[], knownTypes: string[], mode: ProjectMode): void {\n const known = knownTypes.map((t: string) => `${FRAMEWORK_TAG_PREFIX}${t}`).join(' | ');\n console.error('');\n console.error('❌ Some modified projects carry an unknown framework tag value!');\n console.error('');\n console.error(` Allowed values: ${known}`);\n console.error('');\n\n for (const project of invalid) {\n console.error(` ❌ ${project.name} — ${project.projectJsonPath}`);\n for (const bad of project.badValues) {\n if (bad === REMOVED_ALL_VALUE) {\n console.error(\n ` framework:all is removed — declare the actual env set, ` +\n `e.g. framework:browser + framework:node`\n );\n } else {\n console.error(` unknown value \"${FRAMEWORK_TAG_PREFIX}${bad}\" — use one of: ${known}`);\n }\n }\n }\n console.error('');\n console.error(` Current mode: ${mode}`);\n console.error('');\n}\n\nconst FRAMEWORK_TAG_SPEC = new TagRuleSpec(\n FRAMEWORK_TAG_PREFIX,\n 'framework-tag',\n 'Framework Tag',\n DEFAULT_KNOWN_TYPES,\n reportViolations,\n true,\n reportInvalidValues\n);\n\n@injectable(bindingScopeValues.Singleton)\nexport class FrameworkTagValidator extends CodeValidator<FrameworkTagConfig> {\n constructor(config: FrameworkTagConfig) {\n super(config, 'framework-tag', 'framework-tag');\n }\n\n async run(workspaceRoot: string): Promise<ExecutorResult> {\n return runTagValidator(this.config, workspaceRoot, FRAMEWORK_TAG_SPEC);\n }\n}\n"]}
1
+ {"version":3,"file":"validate-framework-tag.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/validate-framework-tag.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;;;AAuBH,oDAEC;;AAvBD,0DAA0E;AAC1E,qDAAiE;AACjE,yCAA2D;AAC3D,yCAMoB;AAEpB,MAAM,oBAAoB,GAAG,YAAY,CAAC;AAC1C,MAAM,mBAAmB,GAAG,CAAC,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC;AAE/F,kFAAkF;AAClF,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAEhC;;;GAGG;AACH,SAAgB,oBAAoB,CAAC,aAAqB,EAAE,YAAsB;IAC9E,OAAO,IAAA,iCAAsB,EAAC,aAAa,EAAE,YAAY,EAAE,oBAAoB,CAAC,CAAC;AACrF,CAAC;AAED,SAAS,gBAAgB,CAAC,QAA6B,EAAE,UAAoB,EAAE,IAAiB;IAC5F,MAAM,UAAU,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,GAAG,oBAAoB,GAAG,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5F,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAClB,OAAO,CAAC,KAAK,CAAC,mFAAmF,CAAC,CAAC;IACnG,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAClB,OAAO,CAAC,KAAK,CAAC,2EAA2E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CAAC,OAAO,OAAO,CAAC,IAAI,MAAM,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;QAClE,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;YAClC,IAAI,GAAG,KAAK,iBAAiB,EAAE,CAAC;gBAC5B,OAAO,CAAC,KAAK,CACT,8DAA8D;oBAC1D,yCAAyC,CAChD,CAAC;YACN,CAAC;iBAAM,CAAC;gBACJ,OAAO,CAAC,KAAK,CAAC,uBAAuB,oBAAoB,GAAG,GAAG,mBAAmB,KAAK,EAAE,CAAC,CAAC;YAC/F,CAAC;QACL,CAAC;IACL,CAAC;IACD,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAClB,OAAO,CAAC,KAAK,CAAC,oBAAoB,IAAI,EAAE,CAAC,CAAC;IAC1C,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AACtB,CAAC;AAED,MAAM,kBAAkB,GAAG,IAAI,sBAAW,CACtC,oBAAoB,EACpB,eAAe,EACf,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,IAAI,EACJ,mBAAmB,CACtB,CAAC;AAGK,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,8BAAiC;IACxE,YAAY,MAA0B;QAClC,KAAK,CAAC,MAAM,EAAE,eAAe,EAAE,eAAe,CAAC,CAAC;IACpD,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,aAAqB;QAC3B,OAAO,IAAA,0BAAe,EAAC,IAAI,CAAC,MAAM,EAAE,aAAa,EAAE,kBAAkB,CAAC,CAAC;IAC3E,CAAC;CACJ,CAAA;AARY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEjB,iCAAkB;GAD7B,qBAAqB,CAQjC","sourcesContent":["/**\n * Validate Framework Tag Executor\n *\n * Every project that a changed source file belongs to must carry at least one\n * `framework:<value>` nx tag in its project.json. Those tags are the project's\n * \"libType\" — the SET of runtime environments it is validated to run in, drawn\n * from the atomic values:\n *\n * framework:browser | framework:react | framework:angular\n * framework:node | framework:express | framework:react-native\n *\n * A project lists EVERY environment it promises to run in (e.g.\n * `framework:browser` + `framework:node`). This env set is the source of truth\n * for the `framework` field written into architecture/dependencies.json and for\n * the `library-types-match-client` rule, which uses the compatibility lattice\n * (react/angular→browser, express→node) to keep an express project from\n * depending on a browser-only library (and vice-versa). `react-native` is its own\n * runtime, NOT a browser (#1064): it has no DOM, IndexedDB or OPFS, so a\n * react-native project consumes only libraries that are themselves tagged\n * `framework:react-native`.\n *\n * The legacy single-value `framework:all` \"usable by any side\" bucket is\n * REMOVED — it is a hard error, and the author must declare the actual env set.\n *\n * The project-walking + diff-scoping + mode logic is shared with the `role-tag`\n * rule in `tag-rule.ts`; this file supplies only the framework-specific prefix,\n * known values, and violation messages. Unlike role-tag, framework-tag ALSO\n * validates tag VALUES (allowing multiple) via {@link TagRuleSpec.validateValues}.\n *\n * ============================================================================\n * MODES (PROJECT-LEVEL)\n * ============================================================================\n * - OFF: Skip validation entirely.\n * - MODIFIED_PROJECTS: Require >=1 valid framework tag on every project that\n * owns ANY changed file (not just .ts, and not line-scoped).\n */\n\nimport { ProjectMode, FrameworkTagConfig } from '@webpieces/rules-config';\nimport { CodeValidator, ExecutorResult } from './code-validator';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport {\n InvalidTagProject,\n MissingTagProject,\n TagRuleSpec,\n findProjectsMissingTag,\n runTagValidator,\n} from './tag-rule';\n\nconst FRAMEWORK_TAG_PREFIX = 'framework:';\nconst DEFAULT_KNOWN_TYPES = ['browser', 'react', 'angular', 'node', 'express', 'react-native'];\n\n/** The removed legacy libType, kept only to emit a targeted migration message. */\nconst REMOVED_ALL_VALUE = 'all';\n\n/**\n * Back-compat export used by tests: the framework-tag flavor of the shared\n * missing-tag scan.\n */\nexport function findUntaggedProjects(workspaceRoot: string, changedFiles: string[]): MissingTagProject[] {\n return findProjectsMissingTag(workspaceRoot, changedFiles, FRAMEWORK_TAG_PREFIX);\n}\n\nfunction reportViolations(untagged: MissingTagProject[], knownTypes: string[], mode: ProjectMode): void {\n const suggestion = knownTypes.map((t: string) => `${FRAMEWORK_TAG_PREFIX}${t}`).join(' | ');\n console.error('');\n console.error('❌ Every modified project must declare the env set it runs in (>=1 framework tag)!');\n console.error('');\n console.error(` Add ONE OR MORE of these to the project's project.json \"tags\" array: ${suggestion}`);\n console.error(' (react/angular specialize browser; express specializes node; react-native is its own runtime,');\n console.error(' NOT a browser — no DOM, IndexedDB or OPFS. A project that runs in several declares EVERY one,');\n console.error(' e.g. framework:browser + framework:node + framework:react-native for a universal library.)');\n console.error(' This libType drives architecture/dependencies.json and the library-types-match-client rule.');\n console.error('');\n\n for (const project of untagged) {\n console.error(` ❌ ${project.name} — ${project.projectJsonPath}`);\n console.error(` add e.g. \"tags\": [\"${FRAMEWORK_TAG_PREFIX}browser\", \"${FRAMEWORK_TAG_PREFIX}node\"]`);\n }\n console.error('');\n console.error(` Current mode: ${mode}`);\n console.error('');\n}\n\nfunction reportInvalidValues(invalid: InvalidTagProject[], knownTypes: string[], mode: ProjectMode): void {\n const known = knownTypes.map((t: string) => `${FRAMEWORK_TAG_PREFIX}${t}`).join(' | ');\n console.error('');\n console.error('❌ Some modified projects carry an unknown framework tag value!');\n console.error('');\n console.error(` Allowed values: ${known}`);\n console.error('');\n\n for (const project of invalid) {\n console.error(` ❌ ${project.name} — ${project.projectJsonPath}`);\n for (const bad of project.badValues) {\n if (bad === REMOVED_ALL_VALUE) {\n console.error(\n ` framework:all is removed — declare the actual env set, ` +\n `e.g. framework:browser + framework:node`\n );\n } else {\n console.error(` unknown value \"${FRAMEWORK_TAG_PREFIX}${bad}\" — use one of: ${known}`);\n }\n }\n }\n console.error('');\n console.error(` Current mode: ${mode}`);\n console.error('');\n}\n\nconst FRAMEWORK_TAG_SPEC = new TagRuleSpec(\n FRAMEWORK_TAG_PREFIX,\n 'framework-tag',\n 'Framework Tag',\n DEFAULT_KNOWN_TYPES,\n reportViolations,\n true,\n reportInvalidValues\n);\n\n@injectable(bindingScopeValues.Singleton)\nexport class FrameworkTagValidator extends CodeValidator<FrameworkTagConfig> {\n constructor(config: FrameworkTagConfig) {\n super(config, 'framework-tag', 'framework-tag');\n }\n\n async run(workspaceRoot: string): Promise<ExecutorResult> {\n return runTagValidator(this.config, workspaceRoot, FRAMEWORK_TAG_SPEC);\n }\n}\n"]}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * `framework-tsconfig` (#1064, D7) — the COMPILER enforces the runtime a library's `framework:` tags
3
+ * promise.
4
+ *
5
+ * A tag used to be a promise only the dependency graph checked: nothing stopped a `browser+node`
6
+ * library from importing `fs` or reading `window`. The cure is not a lint rule that greps for `window`;
7
+ * it is the compiler, which already refuses a global its `lib` / `types` do not declare. So this rule
8
+ * checks the one file that decides what compiles — the library's `tsconfig.lib.json`, with everything
9
+ * it `extends` — against its tags:
10
+ *
11
+ * | tags | `lib` | `types` | effect |
12
+ * |-----------------------------------------|---------------------|----------------|----------------------------------------------|
13
+ * | browser only (browser / angular / react) | includes `dom` | no `node` | `fs`, `process`, `__dirname`, `Buffer` fail |
14
+ * | node only (node / express) | no `dom` | includes `node`| `window`, `document`, `localStorage` fail |
15
+ * | anything else — universal (browser + node + react-native), browser + react-native, react-native | no `dom` | no `node` | pure TypeScript |
16
+ *
17
+ * An unset `lib` resolves to TypeScript's default for the target, which INCLUDES `dom`; an unset
18
+ * `types` loads every installed `@types/*`, which includes `node`. So a library whose runtime excludes
19
+ * either must STATE both. Only `tsconfig.lib.json` is read — an app's own tsconfig (react-native types,
20
+ * a server's) is the app's business.
21
+ */
22
+ import { FrameworkTsconfigConfig, RuleFailError } from '@webpieces/rules-config';
23
+ import { CodeValidator, ExecutorResult } from './code-validator';
24
+ import { ProjectScanTargets, ScannedProject } from './project-scan-targets';
25
+ /** What a library's tsconfig must resolve to, given its framework set. Data-only. */
26
+ export declare class RuntimeCompilerOptions {
27
+ /** `browser-only` | `node-only` | `pure` — which row of the table governs. */
28
+ readonly row: string;
29
+ readonly wantsDom: boolean;
30
+ readonly wantsNodeTypes: boolean;
31
+ /** The `compilerOptions` to paste. */
32
+ readonly snippet: string;
33
+ constructor(
34
+ /** `browser-only` | `node-only` | `pure` — which row of the table governs. */
35
+ row: string, wantsDom: boolean, wantsNodeTypes: boolean,
36
+ /** The `compilerOptions` to paste. */
37
+ snippet: string);
38
+ static forFrameworks(frameworks: readonly string[]): RuntimeCompilerOptions;
39
+ }
40
+ /** ONE library whose tsconfig lets code compile that its runtime cannot run. Data-only. */
41
+ export declare class TsconfigRuntimeViolation {
42
+ readonly project: string;
43
+ /** Repo-relative path of the tsconfig.lib.json. */
44
+ readonly tsconfig: string;
45
+ readonly frameworks: readonly string[];
46
+ readonly problems: readonly string[];
47
+ readonly snippet: string;
48
+ constructor(project: string,
49
+ /** Repo-relative path of the tsconfig.lib.json. */
50
+ tsconfig: string, frameworks: readonly string[], problems: readonly string[], snippet: string);
51
+ }
52
+ /** The audit itself — no config, no git: a list of projects in, violations out. */
53
+ export declare class FrameworkTsconfigAudit {
54
+ audit(workspaceRoot: string, projects: readonly ScannedProject[]): TsconfigRuntimeViolation[];
55
+ /** The compilerOptions the file resolves to, `extends` chain included. */
56
+ private resolvedOptions;
57
+ }
58
+ /** The one structured failure for every violation, shared by the validator and its spec. */
59
+ export declare function frameworkTsconfigError(violations: readonly TsconfigRuntimeViolation[]): RuleFailError;
60
+ export declare class FrameworkTsconfigValidator extends CodeValidator<FrameworkTsconfigConfig> {
61
+ private readonly targets;
62
+ constructor(config: FrameworkTsconfigConfig, targets: ProjectScanTargets);
63
+ run(workspaceRoot: string): Promise<ExecutorResult>;
64
+ }
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+ /**
3
+ * `framework-tsconfig` (#1064, D7) — the COMPILER enforces the runtime a library's `framework:` tags
4
+ * promise.
5
+ *
6
+ * A tag used to be a promise only the dependency graph checked: nothing stopped a `browser+node`
7
+ * library from importing `fs` or reading `window`. The cure is not a lint rule that greps for `window`;
8
+ * it is the compiler, which already refuses a global its `lib` / `types` do not declare. So this rule
9
+ * checks the one file that decides what compiles — the library's `tsconfig.lib.json`, with everything
10
+ * it `extends` — against its tags:
11
+ *
12
+ * | tags | `lib` | `types` | effect |
13
+ * |-----------------------------------------|---------------------|----------------|----------------------------------------------|
14
+ * | browser only (browser / angular / react) | includes `dom` | no `node` | `fs`, `process`, `__dirname`, `Buffer` fail |
15
+ * | node only (node / express) | no `dom` | includes `node`| `window`, `document`, `localStorage` fail |
16
+ * | anything else — universal (browser + node + react-native), browser + react-native, react-native | no `dom` | no `node` | pure TypeScript |
17
+ *
18
+ * An unset `lib` resolves to TypeScript's default for the target, which INCLUDES `dom`; an unset
19
+ * `types` loads every installed `@types/*`, which includes `node`. So a library whose runtime excludes
20
+ * either must STATE both. Only `tsconfig.lib.json` is read — an app's own tsconfig (react-native types,
21
+ * a server's) is the app's business.
22
+ */
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.FrameworkTsconfigValidator = exports.FrameworkTsconfigAudit = exports.TsconfigRuntimeViolation = exports.RuntimeCompilerOptions = void 0;
25
+ exports.frameworkTsconfigError = frameworkTsconfigError;
26
+ const tslib_1 = require("tslib");
27
+ const fs = tslib_1.__importStar(require("fs"));
28
+ const path = tslib_1.__importStar(require("path"));
29
+ const ts = tslib_1.__importStar(require("typescript"));
30
+ const rules_config_1 = require("@webpieces/rules-config");
31
+ const inversify_1 = require("inversify");
32
+ const code_validator_1 = require("./code-validator");
33
+ const project_scan_targets_1 = require("./project-scan-targets");
34
+ const LIB_TSCONFIG = 'tsconfig.lib.json';
35
+ /** Envs whose every global is a browser's. */
36
+ const DOM_ENVS = ['browser', 'angular', 'react'];
37
+ /** Envs whose every global is node's. */
38
+ const NODE_ENVS = ['node', 'express'];
39
+ /** What a library's tsconfig must resolve to, given its framework set. Data-only. */
40
+ class RuntimeCompilerOptions {
41
+ row;
42
+ wantsDom;
43
+ wantsNodeTypes;
44
+ snippet;
45
+ constructor(
46
+ /** `browser-only` | `node-only` | `pure` — which row of the table governs. */
47
+ row, wantsDom, wantsNodeTypes,
48
+ /** The `compilerOptions` to paste. */
49
+ snippet) {
50
+ this.row = row;
51
+ this.wantsDom = wantsDom;
52
+ this.wantsNodeTypes = wantsNodeTypes;
53
+ this.snippet = snippet;
54
+ }
55
+ // webpieces-disable no-function-outside-class -- static factory of this class
56
+ static forFrameworks(frameworks) {
57
+ if (frameworks.every((env) => DOM_ENVS.includes(env))) {
58
+ return new RuntimeCompilerOptions('browser-only', true, false, '"lib": ["es2022", "dom"], "types": []');
59
+ }
60
+ if (frameworks.every((env) => NODE_ENVS.includes(env))) {
61
+ return new RuntimeCompilerOptions('node-only', false, true, '"lib": ["es2022"], "types": ["node"]');
62
+ }
63
+ return new RuntimeCompilerOptions('pure', false, false, '"lib": ["es2022"], "types": []');
64
+ }
65
+ }
66
+ exports.RuntimeCompilerOptions = RuntimeCompilerOptions;
67
+ /** ONE library whose tsconfig lets code compile that its runtime cannot run. Data-only. */
68
+ class TsconfigRuntimeViolation {
69
+ project;
70
+ tsconfig;
71
+ frameworks;
72
+ problems;
73
+ snippet;
74
+ constructor(project,
75
+ /** Repo-relative path of the tsconfig.lib.json. */
76
+ tsconfig, frameworks, problems, snippet) {
77
+ this.project = project;
78
+ this.tsconfig = tsconfig;
79
+ this.frameworks = frameworks;
80
+ this.problems = problems;
81
+ this.snippet = snippet;
82
+ }
83
+ }
84
+ exports.TsconfigRuntimeViolation = TsconfigRuntimeViolation;
85
+ /** The audit itself — no config, no git: a list of projects in, violations out. */
86
+ class FrameworkTsconfigAudit {
87
+ audit(workspaceRoot, projects) {
88
+ const out = [];
89
+ for (const project of projects) {
90
+ if (project.frameworks.length === 0)
91
+ continue; // framework-tag's job
92
+ const rel = `${project.dir}/${LIB_TSCONFIG}`;
93
+ const abs = path.join(workspaceRoot, rel);
94
+ if (!fs.existsSync(abs))
95
+ continue; // not a library
96
+ const want = RuntimeCompilerOptions.forFrameworks(project.frameworks);
97
+ const options = this.resolvedOptions(abs);
98
+ const libs = options.lib?.map((each) => each.replace(/^lib\./, '').replace(/\.d\.ts$/, '').toLowerCase());
99
+ const hasDom = libs === undefined || libs.some((lib) => lib === 'dom' || lib.startsWith('dom.'));
100
+ const hasNode = options.types === undefined || options.types.includes('node');
101
+ const problems = [];
102
+ if (want.wantsDom && !hasDom)
103
+ problems.push('`lib` does not include "dom", so the browser globals its runtime has do not compile');
104
+ if (!want.wantsDom && hasDom) {
105
+ problems.push(libs === undefined
106
+ ? '`lib` is unset, so TypeScript\'s default — which includes "dom" — lets `window`/`document` compile'
107
+ : '`lib` includes "dom", so `window`/`document`/`localStorage` compile where the runtime has none');
108
+ }
109
+ if (want.wantsNodeTypes && !hasNode)
110
+ problems.push('`types` does not include "node", so node\'s globals do not compile');
111
+ if (!want.wantsNodeTypes && hasNode) {
112
+ problems.push(options.types === undefined
113
+ ? '`types` is unset, so every installed @types/* — @types/node included — lets `fs`/`process`/`Buffer` compile'
114
+ : '`types` includes "node", so `fs`/`process`/`__dirname`/`Buffer` compile where the runtime has none');
115
+ }
116
+ if (problems.length > 0)
117
+ out.push(new TsconfigRuntimeViolation(project.name, rel, project.frameworks, problems, want.snippet));
118
+ }
119
+ return out;
120
+ }
121
+ /** The compilerOptions the file resolves to, `extends` chain included. */
122
+ resolvedOptions(abs) {
123
+ const host = Object.assign({}, ts.sys, { onUnRecoverableConfigFileDiagnostic: () => undefined });
124
+ return ts.getParsedCommandLineOfConfigFile(abs, {}, host)?.options ?? {};
125
+ }
126
+ }
127
+ exports.FrameworkTsconfigAudit = FrameworkTsconfigAudit;
128
+ /** The one structured failure for every violation, shared by the validator and its spec. */
129
+ // webpieces-disable no-function-outside-class -- one structured rule failure shared by tests and runner
130
+ function frameworkTsconfigError(violations) {
131
+ const details = violations
132
+ .map((v) => ` ${v.tsconfig} — ${v.project} [${v.frameworks.join(', ')}]\n` +
133
+ v.problems.map((p) => ` ${p}`).join('\n') +
134
+ `\n set compilerOptions: { ${v.snippet} }`)
135
+ .join('\n');
136
+ return new rules_config_1.RuleFailError(rules_config_1.RULE_NAMES.FRAMEWORK_TSCONFIG, 'A library\'s tsconfig.lib.json lets code compile that the runtime its framework tags promise cannot run.\n' + details, undefined, undefined, [
137
+ new rules_config_1.Option('Set each listed tsconfig.lib.json\'s compilerOptions.lib and compilerOptions.types to the values printed beside it, then fix whatever stops compiling — that code was never runnable everywhere the tags promised.', true),
138
+ new rules_config_1.Option('If the code genuinely needs the other runtime, the TAGS are wrong: narrow the framework tags (and move the library to the folder for that runtime).'),
139
+ ]);
140
+ }
141
+ let FrameworkTsconfigValidator = class FrameworkTsconfigValidator extends code_validator_1.CodeValidator {
142
+ targets;
143
+ constructor(config, targets) {
144
+ super(config, rules_config_1.RULE_NAMES.FRAMEWORK_TSCONFIG, rules_config_1.RULE_NAMES.FRAMEWORK_TSCONFIG);
145
+ this.targets = targets;
146
+ }
147
+ async run(workspaceRoot) {
148
+ const mode = this.config.mode ?? 'OFF';
149
+ if (mode === 'OFF')
150
+ return { success: true };
151
+ const allowed = this.config.allowedPaths ?? [];
152
+ const projects = this.targets
153
+ .projects(workspaceRoot, mode, rules_config_1.RULE_NAMES.FRAMEWORK_TSCONFIG)
154
+ .filter((p) => !(0, rules_config_1.matchesAnyGlob)(p.dir, allowed));
155
+ const violations = new FrameworkTsconfigAudit().audit(workspaceRoot, projects);
156
+ if (violations.length === 0)
157
+ return { success: true };
158
+ throw frameworkTsconfigError(violations);
159
+ }
160
+ };
161
+ exports.FrameworkTsconfigValidator = FrameworkTsconfigValidator;
162
+ exports.FrameworkTsconfigValidator = FrameworkTsconfigValidator = tslib_1.__decorate([
163
+ (0, inversify_1.injectable)(inversify_1.bindingScopeValues.Singleton),
164
+ tslib_1.__metadata("design:paramtypes", [rules_config_1.FrameworkTsconfigConfig,
165
+ project_scan_targets_1.ProjectScanTargets])
166
+ ], FrameworkTsconfigValidator);
167
+ //# sourceMappingURL=validate-framework-tsconfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-framework-tsconfig.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/validate-framework-tsconfig.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAiGH,wDAiBC;;AAhHD,+CAAyB;AACzB,mDAA6B;AAC7B,uDAAiC;AACjC,0DAAqH;AACrH,yCAA2D;AAC3D,qDAAiE;AACjE,iEAA4E;AAE5E,MAAM,YAAY,GAAG,mBAAmB,CAAC;AAEzC,8CAA8C;AAC9C,MAAM,QAAQ,GAAsB,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;AACpE,yCAAyC;AACzC,MAAM,SAAS,GAAsB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAEzD,qFAAqF;AACrF,MAAa,sBAAsB;IAGlB;IACA;IACA;IAEA;IANb;IACI,8EAA8E;IACrE,GAAW,EACX,QAAiB,EACjB,cAAuB;IAChC,sCAAsC;IAC7B,OAAe;QAJf,QAAG,GAAH,GAAG,CAAQ;QACX,aAAQ,GAAR,QAAQ,CAAS;QACjB,mBAAc,GAAd,cAAc,CAAS;QAEvB,YAAO,GAAP,OAAO,CAAQ;IACzB,CAAC;IAEJ,8EAA8E;IAC9E,MAAM,CAAC,aAAa,CAAC,UAA6B;QAC9C,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC,GAAW,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YAC5D,OAAO,IAAI,sBAAsB,CAAC,cAAc,EAAE,IAAI,EAAE,KAAK,EAAE,uCAAuC,CAAC,CAAC;QAC5G,CAAC;QACD,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC,GAAW,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YAC7D,OAAO,IAAI,sBAAsB,CAAC,WAAW,EAAE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AAE,yBAAU,CAAC,kBAAkB,CAAC,CAAC;QAF3D,YAAO,GAAP,OAAO,CAAoB;IAGhD,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,aAAqB;QAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,KAAK,CAAC;QACvC,IAAI,IAAI,KAAK,KAAK;YAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAC7C,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,IAAI,EAAE,CAAC;QAC/C,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO;aACxB,QAAQ,CAAC,aAAa,EAAE,IAAI,EAAE,yBAAU,CAAC,kBAAkB,CAAC;aAC5D,MAAM,CAAC,CAAC,CAAiB,EAAE,EAAE,CAAC,CAAC,IAAA,6BAAc,EAAC,CAAC,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;QACpE,MAAM,UAAU,GAAG,IAAI,sBAAsB,EAAE,CAAC,KAAK,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;QAC/E,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QACtD,MAAM,sBAAsB,CAAC,UAAU,CAAC,CAAC;IAC7C,CAAC;CACJ,CAAA;AAnBY,gEAA0B;qCAA1B,0BAA0B;IADtC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGzB,sCAAuB;QACL,yCAAkB;GAHvC,0BAA0B,CAmBtC","sourcesContent":["/**\n * `framework-tsconfig` (#1064, D7) — the COMPILER enforces the runtime a library's `framework:` tags\n * promise.\n *\n * A tag used to be a promise only the dependency graph checked: nothing stopped a `browser+node`\n * library from importing `fs` or reading `window`. The cure is not a lint rule that greps for `window`;\n * it is the compiler, which already refuses a global its `lib` / `types` do not declare. So this rule\n * checks the one file that decides what compiles — the library's `tsconfig.lib.json`, with everything\n * it `extends` — against its tags:\n *\n * | tags | `lib` | `types` | effect |\n * |-----------------------------------------|---------------------|----------------|----------------------------------------------|\n * | browser only (browser / angular / react) | includes `dom` | no `node` | `fs`, `process`, `__dirname`, `Buffer` fail |\n * | node only (node / express) | no `dom` | includes `node`| `window`, `document`, `localStorage` fail |\n * | anything else — universal (browser + node + react-native), browser + react-native, react-native | no `dom` | no `node` | pure TypeScript |\n *\n * An unset `lib` resolves to TypeScript's default for the target, which INCLUDES `dom`; an unset\n * `types` loads every installed `@types/*`, which includes `node`. So a library whose runtime excludes\n * either must STATE both. Only `tsconfig.lib.json` is read — an app's own tsconfig (react-native types,\n * a server's) is the app's business.\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as ts from 'typescript';\nimport { FrameworkTsconfigConfig, matchesAnyGlob, Option, RuleFailError, RULE_NAMES } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { CodeValidator, ExecutorResult } from './code-validator';\nimport { ProjectScanTargets, ScannedProject } from './project-scan-targets';\n\nconst LIB_TSCONFIG = 'tsconfig.lib.json';\n\n/** Envs whose every global is a browser's. */\nconst DOM_ENVS: readonly string[] = ['browser', 'angular', 'react'];\n/** Envs whose every global is node's. */\nconst NODE_ENVS: readonly string[] = ['node', 'express'];\n\n/** What a library's tsconfig must resolve to, given its framework set. Data-only. */\nexport class RuntimeCompilerOptions {\n constructor(\n /** `browser-only` | `node-only` | `pure` — which row of the table governs. */\n readonly row: string,\n readonly wantsDom: boolean,\n readonly wantsNodeTypes: boolean,\n /** The `compilerOptions` to paste. */\n readonly snippet: string,\n ) {}\n\n // webpieces-disable no-function-outside-class -- static factory of this class\n static forFrameworks(frameworks: readonly string[]): RuntimeCompilerOptions {\n if (frameworks.every((env: string) => DOM_ENVS.includes(env))) {\n return new RuntimeCompilerOptions('browser-only', true, false, '\"lib\": [\"es2022\", \"dom\"], \"types\": []');\n }\n if (frameworks.every((env: string) => NODE_ENVS.includes(env))) {\n return new RuntimeCompilerOptions('node-only', false, true, '\"lib\": [\"es2022\"], \"types\": [\"node\"]');\n }\n return new RuntimeCompilerOptions('pure', false, false, '\"lib\": [\"es2022\"], \"types\": []');\n }\n}\n\n/** ONE library whose tsconfig lets code compile that its runtime cannot run. Data-only. */\nexport class TsconfigRuntimeViolation {\n constructor(\n readonly project: string,\n /** Repo-relative path of the tsconfig.lib.json. */\n readonly tsconfig: string,\n readonly frameworks: readonly string[],\n readonly problems: readonly string[],\n readonly snippet: string,\n ) {}\n}\n\n/** The audit itself — no config, no git: a list of projects in, violations out. */\nexport class FrameworkTsconfigAudit {\n audit(workspaceRoot: string, projects: readonly ScannedProject[]): TsconfigRuntimeViolation[] {\n const out: TsconfigRuntimeViolation[] = [];\n for (const project of projects) {\n if (project.frameworks.length === 0) continue; // framework-tag's job\n const rel = `${project.dir}/${LIB_TSCONFIG}`;\n const abs = path.join(workspaceRoot, rel);\n if (!fs.existsSync(abs)) continue; // not a library\n const want = RuntimeCompilerOptions.forFrameworks(project.frameworks);\n const options = this.resolvedOptions(abs);\n const libs = options.lib?.map((each: string) => each.replace(/^lib\\./, '').replace(/\\.d\\.ts$/, '').toLowerCase());\n const hasDom = libs === undefined || libs.some((lib: string) => lib === 'dom' || lib.startsWith('dom.'));\n const hasNode = options.types === undefined || options.types.includes('node');\n const problems: string[] = [];\n if (want.wantsDom && !hasDom) problems.push('`lib` does not include \"dom\", so the browser globals its runtime has do not compile');\n if (!want.wantsDom && hasDom) {\n problems.push(\n libs === undefined\n ? '`lib` is unset, so TypeScript\\'s default — which includes \"dom\" — lets `window`/`document` compile'\n : '`lib` includes \"dom\", so `window`/`document`/`localStorage` compile where the runtime has none',\n );\n }\n if (want.wantsNodeTypes && !hasNode) problems.push('`types` does not include \"node\", so node\\'s globals do not compile');\n if (!want.wantsNodeTypes && hasNode) {\n problems.push(\n options.types === undefined\n ? '`types` is unset, so every installed @types/* — @types/node included — lets `fs`/`process`/`Buffer` compile'\n : '`types` includes \"node\", so `fs`/`process`/`__dirname`/`Buffer` compile where the runtime has none',\n );\n }\n if (problems.length > 0) out.push(new TsconfigRuntimeViolation(project.name, rel, project.frameworks, problems, want.snippet));\n }\n return out;\n }\n\n /** The compilerOptions the file resolves to, `extends` chain included. */\n private resolvedOptions(abs: string): ts.CompilerOptions {\n const host = Object.assign({}, ts.sys, { onUnRecoverableConfigFileDiagnostic: (): void => undefined }) as ts.ParseConfigFileHost;\n return ts.getParsedCommandLineOfConfigFile(abs, {}, host)?.options ?? {};\n }\n}\n\n/** The one structured failure for every violation, shared by the validator and its spec. */\n// webpieces-disable no-function-outside-class -- one structured rule failure shared by tests and runner\nexport function frameworkTsconfigError(violations: readonly TsconfigRuntimeViolation[]): RuleFailError {\n const details = violations\n .map((v: TsconfigRuntimeViolation) =>\n ` ${v.tsconfig} — ${v.project} [${v.frameworks.join(', ')}]\\n` +\n v.problems.map((p: string) => ` ${p}`).join('\\n') +\n `\\n set compilerOptions: { ${v.snippet} }`)\n .join('\\n');\n return new RuleFailError(\n RULE_NAMES.FRAMEWORK_TSCONFIG,\n 'A library\\'s tsconfig.lib.json lets code compile that the runtime its framework tags promise cannot run.\\n' + details,\n undefined,\n undefined,\n [\n new Option('Set each listed tsconfig.lib.json\\'s compilerOptions.lib and compilerOptions.types to the values printed beside it, then fix whatever stops compiling — that code was never runnable everywhere the tags promised.', true),\n new Option('If the code genuinely needs the other runtime, the TAGS are wrong: narrow the framework tags (and move the library to the folder for that runtime).'),\n ],\n );\n}\n\n@injectable(bindingScopeValues.Singleton)\nexport class FrameworkTsconfigValidator extends CodeValidator<FrameworkTsconfigConfig> {\n constructor(\n config: FrameworkTsconfigConfig,\n private readonly targets: ProjectScanTargets,\n ) {\n super(config, RULE_NAMES.FRAMEWORK_TSCONFIG, RULE_NAMES.FRAMEWORK_TSCONFIG);\n }\n\n async run(workspaceRoot: string): Promise<ExecutorResult> {\n const mode = this.config.mode ?? 'OFF';\n if (mode === 'OFF') return { success: true };\n const allowed = this.config.allowedPaths ?? [];\n const projects = this.targets\n .projects(workspaceRoot, mode, RULE_NAMES.FRAMEWORK_TSCONFIG)\n .filter((p: ScannedProject) => !matchesAnyGlob(p.dir, allowed));\n const violations = new FrameworkTsconfigAudit().audit(workspaceRoot, projects);\n if (violations.length === 0) return { success: true };\n throw frameworkTsconfigError(violations);\n }\n}\n"]}
@@ -5,7 +5,8 @@
5
5
  * `role:<value>` nx tag in its project.json. That tag is the project's ROLE
6
6
  * (orthogonal to its `framework` libType):
7
7
  *
8
- * role:server | role:designed-lib | role:lib | role:client
8
+ * role:server | role:app | role:bundle | role:designed-lib | role:lib | role:client
9
+ * role:api-lib | role:api-client
9
10
  *
10
11
  * It is the source of truth for the `role` field written into
11
12
  * architecture/dependencies.json, for the `role-dependency` edge rule (apps are
@@ -6,7 +6,8 @@
6
6
  * `role:<value>` nx tag in its project.json. That tag is the project's ROLE
7
7
  * (orthogonal to its `framework` libType):
8
8
  *
9
- * role:server | role:designed-lib | role:lib | role:client
9
+ * role:server | role:app | role:bundle | role:designed-lib | role:lib | role:client
10
+ * role:api-lib | role:api-client
10
11
  *
11
12
  * It is the source of truth for the `role` field written into
12
13
  * architecture/dependencies.json, for the `role-dependency` edge rule (apps are
@@ -26,7 +27,7 @@ const code_validator_1 = require("./code-validator");
26
27
  const inversify_1 = require("inversify");
27
28
  const tag_rule_1 = require("./tag-rule");
28
29
  const ROLE_TAG_PREFIX = 'role:';
29
- const DEFAULT_KNOWN_TYPES = ['server', 'app', 'bundle', 'designed-lib', 'lib', 'client', 'api-lib'];
30
+ const DEFAULT_KNOWN_TYPES = ['server', 'app', 'bundle', 'designed-lib', 'lib', 'client', 'api-lib', 'api-client'];
30
31
  /** The role-tag flavor of the shared missing-tag scan (exported for tests). */
31
32
  function findRoleUntaggedProjects(workspaceRoot, changedFiles) {
32
33
  return (0, tag_rule_1.findProjectsMissingTag)(workspaceRoot, changedFiles, ROLE_TAG_PREFIX);
@@ -39,7 +40,9 @@ function reportViolations(untagged, knownTypes, mode) {
39
40
  console.error(` Add ONE of these to the project's project.json "tags" array: ${suggestion}`);
40
41
  console.error(' (server = runnable HTTP app · app = runnable non-HTTP app via container.get(XxxApp) ·');
41
42
  console.error(' designed-lib = library with a @DocumentDesign DI design ·');
42
- console.error(' lib = plain library, no design · client = client app e.g. angular.)');
43
+ console.error(' lib = plain library, no design · client = client app e.g. angular ·');
44
+ console.error(' api-lib = a boundary contract and/or its DTOs, implementation elsewhere ·');
45
+ console.error(' api-client = a contract PLUS its default implementation talking to an outside system via its SDK.)');
43
46
  console.error(' This role drives DI-design generation, the arch graph, and the role-dependency rule.');
44
47
  console.error('');
45
48
  for (const project of untagged) {
@@ -1 +1 @@
1
- {"version":3,"file":"validate-role-tag.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/validate-role-tag.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAWH,4DAEC;;AAXD,0DAAqE;AACrE,qDAAiE;AACjE,yCAA2D;AAC3D,yCAAqG;AAErG,MAAM,eAAe,GAAG,OAAO,CAAC;AAChC,MAAM,mBAAmB,GAAG,CAAC,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AAEpG,+EAA+E;AAC/E,SAAgB,wBAAwB,CAAC,aAAqB,EAAE,YAAsB;IAClF,OAAO,IAAA,iCAAsB,EAAC,aAAa,EAAE,YAAY,EAAE,eAAe,CAAC,CAAC;AAChF,CAAC;AAED,SAAS,gBAAgB,CAAC,QAA6B,EAAE,UAAoB,EAAE,IAAiB;IAC5F,MAAM,UAAU,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,GAAG,eAAe,GAAG,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACvF,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAClB,OAAO,CAAC,KAAK,CAAC,8DAA8D,CAA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AAC,8BAAkB,CAAC,SAAS,CAAC;6CAEjB,4BAAa;GADxB,gBAAgB,CAQ5B","sourcesContent":["/**\n * Validate Role Tag Executor\n *\n * Every project that a changed source file belongs to must carry a\n * `role:<value>` nx tag in its project.json. That tag is the project's ROLE\n * (orthogonal to its `framework` libType):\n *\n * role:server | role:designed-lib | role:lib | role:client\n *\n * It is the source of truth for the `role` field written into\n * architecture/dependencies.json, for the `role-dependency` edge rule (apps are\n * never depended upon), and for DI-design generation (server → @DocumentDesign,\n * designed-lib → @DocumentDesign, lib → none, client → angular design).\n *\n * The project-walking + diff-scoping + mode logic is shared with the\n * `framework-tag` rule in `tag-rule.ts`; this file supplies only the\n * role-specific prefix, known values, and violation message.\n */\n\nimport { ProjectMode, RoleTagConfig } from '@webpieces/rules-config';\nimport { CodeValidator, ExecutorResult } from './code-validator';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { MissingTagProject, TagRuleSpec, findProjectsMissingTag, runTagValidator } from './tag-rule';\n\nconst ROLE_TAG_PREFIX = 'role:';\nconst DEFAULT_KNOWN_TYPES = ['server', 'app', 'bundle', 'designed-lib', 'lib', 'client', 'api-lib'];\n\n/** The role-tag flavor of the shared missing-tag scan (exported for tests). */\nexport function findRoleUntaggedProjects(workspaceRoot: string, changedFiles: string[]): MissingTagProject[] {\n return findProjectsMissingTag(workspaceRoot, changedFiles, ROLE_TAG_PREFIX);\n}\n\nfunction reportViolations(untagged: MissingTagProject[], knownTypes: string[], mode: ProjectMode): void {\n const suggestion = knownTypes.map((t: string) => `${ROLE_TAG_PREFIX}${t}`).join(' | ');\n console.error('');\n console.error('❌ Every modified project must declare its role (a role tag)!');\n console.error('');\n console.error(` Add ONE of these to the project's project.json \"tags\" array: ${suggestion}`);\n console.error(' (server = runnable HTTP app · app = runnable non-HTTP app via container.get(XxxApp) ·');\n console.error(' designed-lib = library with a @DocumentDesign DI design ·');\n console.error(' lib = plain library, no design · client = client app e.g. angular.)');\n console.error(' This role drives DI-design generation, the arch graph, and the role-dependency rule.');\n console.error('');\n\n for (const project of untagged) {\n console.error(` ❌ ${project.name} — ${project.projectJsonPath}`);\n console.error(` add e.g. \"tags\": [\"${ROLE_TAG_PREFIX}lib\"]`);\n }\n console.error('');\n console.error(` Current mode: ${mode}`);\n console.error('');\n}\n\nconst ROLE_TAG_SPEC = new TagRuleSpec(ROLE_TAG_PREFIX, 'role-tag', 'Role Tag', DEFAULT_KNOWN_TYPES, reportViolations);\n\n@injectable(bindingScopeValues.Singleton)\nexport class RoleTagValidator extends CodeValidator<RoleTagConfig> {\n constructor(config: RoleTagConfig) {\n super(config, 'role-tag', 'role-tag');\n }\n\n async run(workspaceRoot: string): Promise<ExecutorResult> {\n return runTagValidator(this.config, workspaceRoot, ROLE_TAG_SPEC);\n }\n}\n"]}
1
+ {"version":3,"file":"validate-role-tag.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/validate-role-tag.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;AAWH,4DAEC;;AAXD,0DAAqE;AACrE,qDAAiE;AACjE,yCAA2D;AAC3D,yCAAqG;AAErG,MAAM,eAAe,GAAG,OAAO,CAAC;AAChC,MAAM,mBAAmB,GAAG,CAAC,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;AAElH,+EAA+E;AAC/E,SAAgB,wBAAwB,CAAC,aAAqB,EAAE,YAAsB;IAClF,OAAO,IAAA,iCAAsB,EAAC,aAAa,EAAE,YAAY,EAAE,eAAe,CAAC,CAAC;AAChF,CAAC;AAED,SAAS,gBAAgB,CAAC,QAA6B,EAAE,UAAoB,EAAE,IAAiB;IAC5F,MAAM,UAAU,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,GAAG,eAAe,GAAG,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACv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,CAAC,GAAG,CAAC,aAAqB;QAC3B,OAAO,IAAA,0BAAe,EAAC,IAAI,CAAC,MAAM,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC;IACtE,CAAC;CACJ,CAAA;AARY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEjB,4BAAa;GADxB,gBAAgB,CAQ5B","sourcesContent":["/**\n * Validate Role Tag Executor\n *\n * Every project that a changed source file belongs to must carry a\n * `role:<value>` nx tag in its project.json. That tag is the project's ROLE\n * (orthogonal to its `framework` libType):\n *\n * role:server | role:app | role:bundle | role:designed-lib | role:lib | role:client\n * role:api-lib | role:api-client\n *\n * It is the source of truth for the `role` field written into\n * architecture/dependencies.json, for the `role-dependency` edge rule (apps are\n * never depended upon), and for DI-design generation (server → @DocumentDesign,\n * designed-lib → @DocumentDesign, lib → none, client → angular design).\n *\n * The project-walking + diff-scoping + mode logic is shared with the\n * `framework-tag` rule in `tag-rule.ts`; this file supplies only the\n * role-specific prefix, known values, and violation message.\n */\n\nimport { ProjectMode, RoleTagConfig } from '@webpieces/rules-config';\nimport { CodeValidator, ExecutorResult } from './code-validator';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { MissingTagProject, TagRuleSpec, findProjectsMissingTag, runTagValidator } from './tag-rule';\n\nconst ROLE_TAG_PREFIX = 'role:';\nconst DEFAULT_KNOWN_TYPES = ['server', 'app', 'bundle', 'designed-lib', 'lib', 'client', 'api-lib', 'api-client'];\n\n/** The role-tag flavor of the shared missing-tag scan (exported for tests). */\nexport function findRoleUntaggedProjects(workspaceRoot: string, changedFiles: string[]): MissingTagProject[] {\n return findProjectsMissingTag(workspaceRoot, changedFiles, ROLE_TAG_PREFIX);\n}\n\nfunction reportViolations(untagged: MissingTagProject[], knownTypes: string[], mode: ProjectMode): void {\n const suggestion = knownTypes.map((t: string) => `${ROLE_TAG_PREFIX}${t}`).join(' | ');\n console.error('');\n console.error('❌ Every modified project must declare its role (a role tag)!');\n console.error('');\n console.error(` Add ONE of these to the project's project.json \"tags\" array: ${suggestion}`);\n console.error(' (server = runnable HTTP app · app = runnable non-HTTP app via container.get(XxxApp) ·');\n console.error(' designed-lib = library with a @DocumentDesign DI design ·');\n console.error(' lib = plain library, no design · client = client app e.g. angular ·');\n console.error(' api-lib = a boundary contract and/or its DTOs, implementation elsewhere ·');\n console.error(' api-client = a contract PLUS its default implementation talking to an outside system via its SDK.)');\n console.error(' This role drives DI-design generation, the arch graph, and the role-dependency rule.');\n console.error('');\n\n for (const project of untagged) {\n console.error(` ❌ ${project.name} — ${project.projectJsonPath}`);\n console.error(` add e.g. \"tags\": [\"${ROLE_TAG_PREFIX}lib\"]`);\n }\n console.error('');\n console.error(` Current mode: ${mode}`);\n console.error('');\n}\n\nconst ROLE_TAG_SPEC = new TagRuleSpec(ROLE_TAG_PREFIX, 'role-tag', 'Role Tag', DEFAULT_KNOWN_TYPES, reportViolations);\n\n@injectable(bindingScopeValues.Singleton)\nexport class RoleTagValidator extends CodeValidator<RoleTagConfig> {\n constructor(config: RoleTagConfig) {\n super(config, 'role-tag', 'role-tag');\n }\n\n async run(workspaceRoot: string): Promise<ExecutorResult> {\n return runTagValidator(this.config, workspaceRoot, ROLE_TAG_SPEC);\n }\n}\n"]}