@webpieces/dev-config 0.2.94 → 0.2.97

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.
Files changed (183) hide show
  1. package/config/eslint/base.mjs +1 -1
  2. package/executors.json +6 -91
  3. package/package.json +6 -19
  4. package/{executors → src/executors}/help/executor.d.ts +4 -2
  5. package/src/executors/help/executor.js.map +1 -0
  6. package/{executors → src/executors}/validate-eslint-sync/executor.d.ts +3 -2
  7. package/src/executors/validate-eslint-sync/executor.js.map +1 -0
  8. package/{executors → src/executors}/validate-versions-locked/executor.js +5 -3
  9. package/src/executors/validate-versions-locked/executor.js.map +1 -0
  10. package/src/generators/init/generator.js.map +1 -1
  11. package/src/index.d.ts +1 -1
  12. package/src/index.js +1 -1
  13. package/src/index.js.map +1 -1
  14. package/src/plugin.d.ts +86 -0
  15. package/{plugin.js → src/plugin.js} +31 -15
  16. package/src/plugin.js.map +1 -0
  17. package/src/toError.d.ts +5 -0
  18. package/src/toError.js +37 -0
  19. package/src/toError.js.map +1 -0
  20. package/templates/eslint.webpieces.config.mjs +1 -1
  21. package/templates/webpieces.exceptions.md +15 -15
  22. package/architecture/executors/diff-utils.d.ts +0 -24
  23. package/architecture/executors/diff-utils.js +0 -119
  24. package/architecture/executors/diff-utils.js.map +0 -1
  25. package/architecture/executors/diff-utils.ts +0 -127
  26. package/architecture/executors/generate/executor.d.ts +0 -16
  27. package/architecture/executors/generate/executor.js +0 -44
  28. package/architecture/executors/generate/executor.js.map +0 -1
  29. package/architecture/executors/generate/executor.ts +0 -59
  30. package/architecture/executors/generate/schema.json +0 -14
  31. package/architecture/executors/validate-architecture-unchanged/executor.d.ts +0 -17
  32. package/architecture/executors/validate-architecture-unchanged/executor.js +0 -229
  33. package/architecture/executors/validate-architecture-unchanged/executor.js.map +0 -1
  34. package/architecture/executors/validate-architecture-unchanged/executor.ts +0 -251
  35. package/architecture/executors/validate-architecture-unchanged/schema.json +0 -14
  36. package/architecture/executors/validate-code/executor.d.ts +0 -78
  37. package/architecture/executors/validate-code/executor.js +0 -243
  38. package/architecture/executors/validate-code/executor.js.map +0 -1
  39. package/architecture/executors/validate-code/executor.ts +0 -406
  40. package/architecture/executors/validate-code/schema.json +0 -227
  41. package/architecture/executors/validate-dtos/executor.d.ts +0 -42
  42. package/architecture/executors/validate-dtos/executor.js +0 -561
  43. package/architecture/executors/validate-dtos/executor.js.map +0 -1
  44. package/architecture/executors/validate-dtos/executor.ts +0 -689
  45. package/architecture/executors/validate-dtos/schema.json +0 -33
  46. package/architecture/executors/validate-modified-files/executor.d.ts +0 -25
  47. package/architecture/executors/validate-modified-files/executor.js +0 -501
  48. package/architecture/executors/validate-modified-files/executor.js.map +0 -1
  49. package/architecture/executors/validate-modified-files/executor.ts +0 -571
  50. package/architecture/executors/validate-modified-files/schema.json +0 -25
  51. package/architecture/executors/validate-modified-methods/executor.d.ts +0 -31
  52. package/architecture/executors/validate-modified-methods/executor.js +0 -694
  53. package/architecture/executors/validate-modified-methods/executor.js.map +0 -1
  54. package/architecture/executors/validate-modified-methods/executor.ts +0 -797
  55. package/architecture/executors/validate-modified-methods/schema.json +0 -25
  56. package/architecture/executors/validate-new-methods/executor.d.ts +0 -28
  57. package/architecture/executors/validate-new-methods/executor.js +0 -513
  58. package/architecture/executors/validate-new-methods/executor.js.map +0 -1
  59. package/architecture/executors/validate-new-methods/executor.ts +0 -584
  60. package/architecture/executors/validate-new-methods/schema.json +0 -25
  61. package/architecture/executors/validate-no-any-unknown/executor.d.ts +0 -42
  62. package/architecture/executors/validate-no-any-unknown/executor.js +0 -462
  63. package/architecture/executors/validate-no-any-unknown/executor.js.map +0 -1
  64. package/architecture/executors/validate-no-any-unknown/executor.ts +0 -540
  65. package/architecture/executors/validate-no-any-unknown/schema.json +0 -24
  66. package/architecture/executors/validate-no-architecture-cycles/executor.d.ts +0 -16
  67. package/architecture/executors/validate-no-architecture-cycles/executor.js +0 -48
  68. package/architecture/executors/validate-no-architecture-cycles/executor.js.map +0 -1
  69. package/architecture/executors/validate-no-architecture-cycles/executor.ts +0 -60
  70. package/architecture/executors/validate-no-architecture-cycles/schema.json +0 -8
  71. package/architecture/executors/validate-no-destructure/executor.d.ts +0 -52
  72. package/architecture/executors/validate-no-destructure/executor.js +0 -491
  73. package/architecture/executors/validate-no-destructure/executor.js.map +0 -1
  74. package/architecture/executors/validate-no-destructure/executor.ts +0 -578
  75. package/architecture/executors/validate-no-destructure/schema.json +0 -24
  76. package/architecture/executors/validate-no-direct-api-resolver/executor.d.ts +0 -47
  77. package/architecture/executors/validate-no-direct-api-resolver/executor.js +0 -566
  78. package/architecture/executors/validate-no-direct-api-resolver/executor.js.map +0 -1
  79. package/architecture/executors/validate-no-direct-api-resolver/executor.ts +0 -666
  80. package/architecture/executors/validate-no-direct-api-resolver/schema.json +0 -29
  81. package/architecture/executors/validate-no-inline-types/executor.d.ts +0 -91
  82. package/architecture/executors/validate-no-inline-types/executor.js +0 -669
  83. package/architecture/executors/validate-no-inline-types/executor.js.map +0 -1
  84. package/architecture/executors/validate-no-inline-types/executor.ts +0 -775
  85. package/architecture/executors/validate-no-inline-types/schema.json +0 -24
  86. package/architecture/executors/validate-no-skiplevel-deps/executor.d.ts +0 -19
  87. package/architecture/executors/validate-no-skiplevel-deps/executor.js +0 -227
  88. package/architecture/executors/validate-no-skiplevel-deps/executor.js.map +0 -1
  89. package/architecture/executors/validate-no-skiplevel-deps/executor.ts +0 -267
  90. package/architecture/executors/validate-no-skiplevel-deps/schema.json +0 -8
  91. package/architecture/executors/validate-packagejson/executor.d.ts +0 -16
  92. package/architecture/executors/validate-packagejson/executor.js +0 -57
  93. package/architecture/executors/validate-packagejson/executor.js.map +0 -1
  94. package/architecture/executors/validate-packagejson/executor.ts +0 -74
  95. package/architecture/executors/validate-packagejson/schema.json +0 -8
  96. package/architecture/executors/validate-prisma-converters/executor.d.ts +0 -60
  97. package/architecture/executors/validate-prisma-converters/executor.js +0 -634
  98. package/architecture/executors/validate-prisma-converters/executor.js.map +0 -1
  99. package/architecture/executors/validate-prisma-converters/executor.ts +0 -822
  100. package/architecture/executors/validate-prisma-converters/schema.json +0 -38
  101. package/architecture/executors/validate-return-types/executor.d.ts +0 -29
  102. package/architecture/executors/validate-return-types/executor.js +0 -439
  103. package/architecture/executors/validate-return-types/executor.js.map +0 -1
  104. package/architecture/executors/validate-return-types/executor.ts +0 -524
  105. package/architecture/executors/validate-return-types/schema.json +0 -24
  106. package/architecture/executors/visualize/executor.d.ts +0 -17
  107. package/architecture/executors/visualize/executor.js +0 -49
  108. package/architecture/executors/visualize/executor.js.map +0 -1
  109. package/architecture/executors/visualize/executor.ts +0 -63
  110. package/architecture/executors/visualize/schema.json +0 -14
  111. package/architecture/index.d.ts +0 -19
  112. package/architecture/index.js +0 -23
  113. package/architecture/index.js.map +0 -1
  114. package/architecture/index.ts +0 -20
  115. package/architecture/lib/graph-comparator.d.ts +0 -39
  116. package/architecture/lib/graph-comparator.js +0 -100
  117. package/architecture/lib/graph-comparator.js.map +0 -1
  118. package/architecture/lib/graph-comparator.ts +0 -141
  119. package/architecture/lib/graph-generator.d.ts +0 -19
  120. package/architecture/lib/graph-generator.js +0 -84
  121. package/architecture/lib/graph-generator.js.map +0 -1
  122. package/architecture/lib/graph-generator.ts +0 -97
  123. package/architecture/lib/graph-loader.d.ts +0 -31
  124. package/architecture/lib/graph-loader.js +0 -98
  125. package/architecture/lib/graph-loader.js.map +0 -1
  126. package/architecture/lib/graph-loader.ts +0 -116
  127. package/architecture/lib/graph-sorter.d.ts +0 -37
  128. package/architecture/lib/graph-sorter.js +0 -110
  129. package/architecture/lib/graph-sorter.js.map +0 -1
  130. package/architecture/lib/graph-sorter.ts +0 -137
  131. package/architecture/lib/graph-visualizer.d.ts +0 -29
  132. package/architecture/lib/graph-visualizer.js +0 -217
  133. package/architecture/lib/graph-visualizer.js.map +0 -1
  134. package/architecture/lib/graph-visualizer.ts +0 -231
  135. package/architecture/lib/package-validator.d.ts +0 -38
  136. package/architecture/lib/package-validator.js +0 -126
  137. package/architecture/lib/package-validator.js.map +0 -1
  138. package/architecture/lib/package-validator.ts +0 -170
  139. package/eslint-plugin/__tests__/catch-error-pattern.test.ts +0 -359
  140. package/eslint-plugin/__tests__/max-file-lines.test.ts +0 -207
  141. package/eslint-plugin/__tests__/max-method-lines.test.ts +0 -258
  142. package/eslint-plugin/__tests__/no-unmanaged-exceptions.test.ts +0 -359
  143. package/eslint-plugin/index.d.ts +0 -23
  144. package/eslint-plugin/index.js +0 -30
  145. package/eslint-plugin/index.js.map +0 -1
  146. package/eslint-plugin/index.ts +0 -29
  147. package/eslint-plugin/rules/catch-error-pattern.d.ts +0 -11
  148. package/eslint-plugin/rules/catch-error-pattern.js +0 -196
  149. package/eslint-plugin/rules/catch-error-pattern.js.map +0 -1
  150. package/eslint-plugin/rules/catch-error-pattern.ts +0 -281
  151. package/eslint-plugin/rules/enforce-architecture.d.ts +0 -15
  152. package/eslint-plugin/rules/enforce-architecture.js +0 -476
  153. package/eslint-plugin/rules/enforce-architecture.js.map +0 -1
  154. package/eslint-plugin/rules/enforce-architecture.ts +0 -543
  155. package/eslint-plugin/rules/max-file-lines.d.ts +0 -12
  156. package/eslint-plugin/rules/max-file-lines.js +0 -257
  157. package/eslint-plugin/rules/max-file-lines.js.map +0 -1
  158. package/eslint-plugin/rules/max-file-lines.ts +0 -272
  159. package/eslint-plugin/rules/max-method-lines.d.ts +0 -12
  160. package/eslint-plugin/rules/max-method-lines.js +0 -240
  161. package/eslint-plugin/rules/max-method-lines.js.map +0 -1
  162. package/eslint-plugin/rules/max-method-lines.ts +0 -287
  163. package/eslint-plugin/rules/no-unmanaged-exceptions.d.ts +0 -22
  164. package/eslint-plugin/rules/no-unmanaged-exceptions.js +0 -160
  165. package/eslint-plugin/rules/no-unmanaged-exceptions.js.map +0 -1
  166. package/eslint-plugin/rules/no-unmanaged-exceptions.ts +0 -179
  167. package/executors/help/executor.js.map +0 -1
  168. package/executors/help/executor.ts +0 -61
  169. package/executors/validate-eslint-sync/executor.js.map +0 -1
  170. package/executors/validate-eslint-sync/executor.ts +0 -83
  171. package/executors/validate-versions-locked/executor.js.map +0 -1
  172. package/executors/validate-versions-locked/executor.ts +0 -367
  173. package/plugin/README.md +0 -243
  174. package/plugin/index.d.ts +0 -4
  175. package/plugin/index.js +0 -8
  176. package/plugin/index.js.map +0 -1
  177. package/plugin/index.ts +0 -4
  178. /package/{executors → src/executors}/help/executor.js +0 -0
  179. /package/{executors → src/executors}/help/schema.json +0 -0
  180. /package/{executors → src/executors}/validate-eslint-sync/executor.js +0 -0
  181. /package/{executors → src/executors}/validate-eslint-sync/schema.json +0 -0
  182. /package/{executors → src/executors}/validate-versions-locked/executor.d.ts +0 -0
  183. /package/{executors → src/executors}/validate-versions-locked/schema.json +0 -0
@@ -1,406 +0,0 @@
1
- import { ExecutorContext } from '@nx/devkit';
2
- import runNewMethodsExecutor from '../validate-new-methods/executor';
3
- import runModifiedMethodsExecutor from '../validate-modified-methods/executor';
4
- import runModifiedFilesExecutor from '../validate-modified-files/executor';
5
- import runReturnTypesExecutor, { ReturnTypeMode } from '../validate-return-types/executor';
6
- import runNoInlineTypesExecutor, { NoInlineTypesMode } from '../validate-no-inline-types/executor';
7
- import runNoAnyUnknownExecutor, { NoAnyUnknownMode } from '../validate-no-any-unknown/executor';
8
- import runValidateDtosExecutor, { ValidateDtosMode } from '../validate-dtos/executor';
9
- import runPrismaConvertersExecutor, { PrismaConverterMode } from '../validate-prisma-converters/executor';
10
- import runNoDestructureExecutor, { NoDestructureMode } from '../validate-no-destructure/executor';
11
- import runNoDirectApiResolverExecutor, { NoDirectApiResolverMode } from '../validate-no-direct-api-resolver/executor';
12
-
13
- export type MethodMaxLimitMode = 'OFF' | 'NEW_METHODS' | 'NEW_AND_MODIFIED_METHODS' | 'MODIFIED_FILES';
14
- export type FileMaxLimitMode = 'OFF' | 'MODIFIED_FILES';
15
-
16
- export interface MethodMaxLimitConfig {
17
- limit?: number;
18
- mode?: MethodMaxLimitMode;
19
- disableAllowed?: boolean;
20
- ignoreModifiedUntilEpoch?: number;
21
- }
22
-
23
- export interface FileMaxLimitConfig {
24
- limit?: number;
25
- mode?: FileMaxLimitMode;
26
- disableAllowed?: boolean;
27
- ignoreModifiedUntilEpoch?: number;
28
- }
29
-
30
- export interface RequireReturnTypeConfig {
31
- mode?: ReturnTypeMode;
32
- disableAllowed?: boolean;
33
- ignoreModifiedUntilEpoch?: number;
34
- }
35
-
36
- export interface NoInlineTypeLiteralsConfig {
37
- mode?: NoInlineTypesMode;
38
- disableAllowed?: boolean;
39
- ignoreModifiedUntilEpoch?: number;
40
- }
41
-
42
- export interface NoAnyUnknownConfig {
43
- mode?: NoAnyUnknownMode;
44
- disableAllowed?: boolean;
45
- ignoreModifiedUntilEpoch?: number;
46
- }
47
-
48
- export interface ValidateDtosConfig {
49
- mode?: ValidateDtosMode;
50
- disableAllowed?: boolean;
51
- prismaSchemaPath?: string;
52
- dtoSourcePaths?: string[];
53
- ignoreModifiedUntilEpoch?: number;
54
- }
55
-
56
- export interface PrismaConverterConfig {
57
- mode?: PrismaConverterMode;
58
- disableAllowed?: boolean;
59
- schemaPath?: string;
60
- convertersPaths?: string[];
61
- enforcePaths?: string[];
62
- ignoreModifiedUntilEpoch?: number;
63
- }
64
-
65
- export interface NoDestructureConfig {
66
- mode?: NoDestructureMode;
67
- disableAllowed?: boolean;
68
- ignoreModifiedUntilEpoch?: number;
69
- }
70
-
71
- export interface NoDirectApiResolverConfig {
72
- mode?: NoDirectApiResolverMode;
73
- disableAllowed?: boolean;
74
- ignoreModifiedUntilEpoch?: number;
75
- enforcePaths?: string[];
76
- }
77
-
78
- export interface ValidateCodeOptions {
79
- methodMaxLimit?: MethodMaxLimitConfig;
80
- fileMaxLimit?: FileMaxLimitConfig;
81
- requireReturnType?: RequireReturnTypeConfig;
82
- noInlineTypeLiterals?: NoInlineTypeLiteralsConfig;
83
- noAnyUnknown?: NoAnyUnknownConfig;
84
- validateDtos?: ValidateDtosConfig;
85
- prismaConverter?: PrismaConverterConfig;
86
- noDestructure?: NoDestructureConfig;
87
- noDirectApiInResolver?: NoDirectApiResolverConfig;
88
- }
89
-
90
- export interface ExecutorResult {
91
- success: boolean;
92
- }
93
-
94
- interface OverrideInfo {
95
- active: boolean;
96
- normalMode: string;
97
- expiresDate: string;
98
- }
99
-
100
- interface ParsedConfig {
101
- methodLimit: number;
102
- methodMode: MethodMaxLimitMode;
103
- methodDisableAllowed: boolean;
104
- methodOverride: OverrideInfo | undefined;
105
- fileLimit: number;
106
- fileMode: FileMaxLimitMode;
107
- fileDisableAllowed: boolean;
108
- fileOverride: OverrideInfo | undefined;
109
- returnTypeMode: ReturnTypeMode;
110
- returnTypeDisableAllowed: boolean;
111
- returnTypeIgnoreEpoch: number | undefined;
112
- noInlineTypesMode: NoInlineTypesMode;
113
- noInlineTypesDisableAllowed: boolean;
114
- noInlineTypesIgnoreEpoch: number | undefined;
115
- noAnyUnknownMode: NoAnyUnknownMode;
116
- noAnyUnknownDisableAllowed: boolean;
117
- noAnyUnknownIgnoreEpoch: number | undefined;
118
- validateDtosMode: ValidateDtosMode;
119
- validateDtosDisableAllowed: boolean;
120
- validateDtosPrismaPath: string | undefined;
121
- validateDtosSrcPaths: string[];
122
- validateDtosIgnoreEpoch: number | undefined;
123
- prismaConverterMode: PrismaConverterMode;
124
- prismaConverterDisableAllowed: boolean;
125
- prismaConverterSchemaPath: string | undefined;
126
- prismaConverterConvertersPaths: string[];
127
- prismaConverterEnforcePaths: string[];
128
- prismaConverterIgnoreEpoch: number | undefined;
129
- noDestructureMode: NoDestructureMode;
130
- noDestructureDisableAllowed: boolean;
131
- noDestructureIgnoreEpoch: number | undefined;
132
- noDirectApiResolverMode: NoDirectApiResolverMode;
133
- noDirectApiResolverDisableAllowed: boolean;
134
- noDirectApiResolverIgnoreEpoch: number | undefined;
135
- noDirectApiResolverEnforcePaths: string[];
136
- }
137
-
138
- interface ResolvedMethodMode {
139
- mode: MethodMaxLimitMode;
140
- override: OverrideInfo | undefined;
141
- }
142
-
143
- interface ResolvedFileMode {
144
- mode: FileMaxLimitMode;
145
- override: OverrideInfo | undefined;
146
- }
147
-
148
- const VALID_MODES: Record<string, string[]> = {
149
- methodMaxLimit: ['OFF', 'NEW_METHODS', 'NEW_AND_MODIFIED_METHODS', 'MODIFIED_FILES'],
150
- fileMaxLimit: ['OFF', 'MODIFIED_FILES'],
151
- requireReturnType: ['OFF', 'NEW_METHODS', 'NEW_AND_MODIFIED_METHODS', 'MODIFIED_FILES'],
152
- noInlineTypeLiterals: ['OFF', 'NEW_METHODS', 'NEW_AND_MODIFIED_METHODS', 'MODIFIED_FILES'],
153
- noAnyUnknown: ['OFF', 'MODIFIED_CODE', 'MODIFIED_FILES'],
154
- validateDtos: ['OFF', 'MODIFIED_CLASS', 'MODIFIED_FILES'],
155
- prismaConverter: ['OFF', 'NEW_AND_MODIFIED_METHODS', 'MODIFIED_FILES'],
156
- noDestructure: ['OFF', 'MODIFIED_CODE', 'MODIFIED_FILES'],
157
- noDirectApiInResolver: ['OFF', 'MODIFIED_CODE', 'NEW_AND_MODIFIED_METHODS', 'MODIFIED_FILES'],
158
- };
159
-
160
- /**
161
- * Validate that all configured modes are valid. Produces clear error messages naming the rule.
162
- */
163
- function validateModes(options: ValidateCodeOptions): string[] {
164
- const errors: string[] = [];
165
-
166
- type ModeEntry = [string, string | undefined];
167
- const modeEntries: ModeEntry[] = [
168
- ['methodMaxLimit', options.methodMaxLimit?.mode],
169
- ['fileMaxLimit', options.fileMaxLimit?.mode],
170
- ['requireReturnType', options.requireReturnType?.mode],
171
- ['noInlineTypeLiterals', options.noInlineTypeLiterals?.mode],
172
- ['noAnyUnknown', options.noAnyUnknown?.mode],
173
- ['validateDtos', options.validateDtos?.mode],
174
- ['prismaConverter', options.prismaConverter?.mode],
175
- ['noDestructure', options.noDestructure?.mode],
176
- ['noDirectApiInResolver', options.noDirectApiInResolver?.mode],
177
- ];
178
-
179
- for (const [ruleName, modeValue] of modeEntries) {
180
- if (modeValue === undefined) continue;
181
- const validModes = VALID_MODES[ruleName];
182
- if (!validModes.includes(modeValue)) {
183
- errors.push(`${ruleName}.mode = '${modeValue}' is invalid. Valid modes: ${validModes.join(', ')}`);
184
- }
185
- }
186
-
187
- return errors;
188
- }
189
-
190
- function formatEpochDate(epoch: number): string {
191
- return new Date(epoch * 1000).toISOString().split('T')[0];
192
- }
193
-
194
- function resolveMethodMode(
195
- normalMode: MethodMaxLimitMode, epoch: number | undefined
196
- ): ResolvedMethodMode {
197
- if (epoch === undefined) {
198
- return { mode: normalMode, override: undefined };
199
- }
200
- const nowSeconds = Date.now() / 1000;
201
- if (nowSeconds < epoch) {
202
- // Active: downgrade to skip modified checking
203
- const downgraded: MethodMaxLimitMode =
204
- normalMode === 'OFF' ? 'OFF' : 'NEW_METHODS';
205
- return {
206
- mode: downgraded,
207
- override: { active: true, normalMode, expiresDate: formatEpochDate(epoch) },
208
- };
209
- }
210
- // Expired
211
- return { mode: normalMode, override: undefined };
212
- }
213
-
214
- function resolveFileMode(
215
- normalMode: FileMaxLimitMode, epoch: number | undefined
216
- ): ResolvedFileMode {
217
- if (epoch === undefined) {
218
- return { mode: normalMode, override: undefined };
219
- }
220
- const nowSeconds = Date.now() / 1000;
221
- if (nowSeconds < epoch) {
222
- // Active: file checking is inherently about modified files, so skip entirely
223
- return {
224
- mode: 'OFF',
225
- override: { active: true, normalMode, expiresDate: formatEpochDate(epoch) },
226
- };
227
- }
228
- // Expired
229
- return { mode: normalMode, override: undefined };
230
- }
231
-
232
- function parseConfig(options: ValidateCodeOptions): ParsedConfig {
233
- const methodConfig: MethodMaxLimitConfig = options.methodMaxLimit ?? {};
234
- const fileConfig: FileMaxLimitConfig = options.fileMaxLimit ?? {};
235
-
236
- const normalMethodMode = methodConfig.mode ?? 'NEW_AND_MODIFIED_METHODS';
237
- const normalFileMode = fileConfig.mode ?? 'MODIFIED_FILES';
238
-
239
- const methodResolved = resolveMethodMode(normalMethodMode, methodConfig.ignoreModifiedUntilEpoch);
240
- const fileResolved = resolveFileMode(normalFileMode, fileConfig.ignoreModifiedUntilEpoch);
241
-
242
- return {
243
- methodLimit: methodConfig.limit ?? 80,
244
- methodMode: methodResolved.mode,
245
- methodDisableAllowed: methodConfig.disableAllowed ?? true,
246
- methodOverride: methodResolved.override,
247
- fileLimit: fileConfig.limit ?? 900,
248
- fileMode: fileResolved.mode,
249
- fileDisableAllowed: fileConfig.disableAllowed ?? true,
250
- fileOverride: fileResolved.override,
251
- returnTypeMode: options.requireReturnType?.mode ?? 'OFF',
252
- returnTypeDisableAllowed: options.requireReturnType?.disableAllowed ?? true,
253
- returnTypeIgnoreEpoch: options.requireReturnType?.ignoreModifiedUntilEpoch,
254
- noInlineTypesMode: options.noInlineTypeLiterals?.mode ?? 'OFF',
255
- noInlineTypesDisableAllowed: options.noInlineTypeLiterals?.disableAllowed ?? true,
256
- noInlineTypesIgnoreEpoch: options.noInlineTypeLiterals?.ignoreModifiedUntilEpoch,
257
- noAnyUnknownMode: options.noAnyUnknown?.mode ?? 'OFF',
258
- noAnyUnknownDisableAllowed: options.noAnyUnknown?.disableAllowed ?? true,
259
- noAnyUnknownIgnoreEpoch: options.noAnyUnknown?.ignoreModifiedUntilEpoch,
260
- validateDtosMode: options.validateDtos?.mode ?? 'OFF',
261
- validateDtosDisableAllowed: options.validateDtos?.disableAllowed ?? true,
262
- validateDtosPrismaPath: options.validateDtos?.prismaSchemaPath,
263
- validateDtosSrcPaths: options.validateDtos?.dtoSourcePaths ?? [],
264
- validateDtosIgnoreEpoch: options.validateDtos?.ignoreModifiedUntilEpoch,
265
- prismaConverterMode: options.prismaConverter?.mode ?? 'OFF',
266
- prismaConverterDisableAllowed: options.prismaConverter?.disableAllowed ?? true,
267
- prismaConverterSchemaPath: options.prismaConverter?.schemaPath,
268
- prismaConverterConvertersPaths: options.prismaConverter?.convertersPaths ?? [],
269
- prismaConverterEnforcePaths: options.prismaConverter?.enforcePaths ?? [],
270
- prismaConverterIgnoreEpoch: options.prismaConverter?.ignoreModifiedUntilEpoch,
271
- noDestructureMode: options.noDestructure?.mode ?? 'OFF',
272
- noDestructureDisableAllowed: options.noDestructure?.disableAllowed ?? true,
273
- noDestructureIgnoreEpoch: options.noDestructure?.ignoreModifiedUntilEpoch,
274
- noDirectApiResolverMode: options.noDirectApiInResolver?.mode ?? 'OFF',
275
- noDirectApiResolverDisableAllowed: options.noDirectApiInResolver?.disableAllowed ?? true,
276
- noDirectApiResolverIgnoreEpoch: options.noDirectApiInResolver?.ignoreModifiedUntilEpoch,
277
- noDirectApiResolverEnforcePaths: options.noDirectApiInResolver?.enforcePaths ?? [],
278
- };
279
- }
280
-
281
- function formatOverride(override: OverrideInfo | undefined): string {
282
- if (!override) {
283
- return '';
284
- }
285
- return ` (override active, normal: ${override.normalMode}, expires: ${override.expiresDate})`;
286
- }
287
-
288
- function logConfig(config: ParsedConfig): void {
289
- console.log('\n\ud83d\udccf Running Code Validations\n');
290
- console.log(` Method limits: mode=${config.methodMode}${formatOverride(config.methodOverride)}, limit=${config.methodLimit}, disableAllowed=${config.methodDisableAllowed}`);
291
- console.log(` File limits: mode=${config.fileMode}${formatOverride(config.fileOverride)}, limit=${config.fileLimit}, disableAllowed=${config.fileDisableAllowed}`);
292
- console.log(` Require return types: mode=${config.returnTypeMode}, disableAllowed=${config.returnTypeDisableAllowed}`);
293
- console.log(` No inline type literals: mode=${config.noInlineTypesMode}, disableAllowed=${config.noInlineTypesDisableAllowed}`);
294
- console.log(` No any/unknown: mode=${config.noAnyUnknownMode}, disableAllowed=${config.noAnyUnknownDisableAllowed}`);
295
- console.log(` Validate DTOs: mode=${config.validateDtosMode}, disableAllowed=${config.validateDtosDisableAllowed}`);
296
- console.log(` Prisma converters: mode=${config.prismaConverterMode}, disableAllowed=${config.prismaConverterDisableAllowed}`);
297
- console.log(` No destructure: mode=${config.noDestructureMode}, disableAllowed=${config.noDestructureDisableAllowed}`);
298
- console.log(` No direct API in resolver: mode=${config.noDirectApiResolverMode}, disableAllowed=${config.noDirectApiResolverDisableAllowed}`);
299
- console.log('');
300
- }
301
-
302
- function isAllOff(config: ParsedConfig): boolean {
303
- return config.methodMode === 'OFF' && config.fileMode === 'OFF' &&
304
- config.returnTypeMode === 'OFF' && config.noInlineTypesMode === 'OFF' &&
305
- config.noAnyUnknownMode === 'OFF' && config.validateDtosMode === 'OFF' &&
306
- config.prismaConverterMode === 'OFF' && config.noDestructureMode === 'OFF' &&
307
- config.noDirectApiResolverMode === 'OFF';
308
- }
309
-
310
- async function runMethodValidators(config: ParsedConfig, context: ExecutorContext): Promise<ExecutorResult[]> {
311
- const results: ExecutorResult[] = [];
312
- const runNew = config.methodMode === 'NEW_METHODS' || config.methodMode === 'NEW_AND_MODIFIED_METHODS';
313
- const runModified = config.methodMode === 'NEW_AND_MODIFIED_METHODS' || config.methodMode === 'MODIFIED_FILES';
314
-
315
- if (runNew) {
316
- results.push(await runNewMethodsExecutor({
317
- limit: config.methodLimit,
318
- mode: config.methodMode, disableAllowed: config.methodDisableAllowed,
319
- }, context));
320
- }
321
- if (runModified) {
322
- results.push(await runModifiedMethodsExecutor({
323
- limit: config.methodLimit, mode: config.methodMode, disableAllowed: config.methodDisableAllowed,
324
- }, context));
325
- }
326
- return results;
327
- }
328
-
329
- export default async function runExecutor(
330
- options: ValidateCodeOptions,
331
- context: ExecutorContext
332
- ): Promise<ExecutorResult> {
333
- const modeErrors = validateModes(options);
334
- if (modeErrors.length > 0) {
335
- console.error('');
336
- for (const err of modeErrors) {
337
- console.error(`❌ ${err}`);
338
- }
339
- console.error('');
340
- return { success: false };
341
- }
342
-
343
- const config = parseConfig(options);
344
-
345
- if (isAllOff(config)) {
346
- console.log('\n\u23ed\ufe0f Skipping all code validations (all modes: OFF)\n');
347
- return { success: true };
348
- }
349
-
350
- logConfig(config);
351
-
352
- const methodResults = await runMethodValidators(config, context);
353
- const fileResult = await runModifiedFilesExecutor({
354
- limit: config.fileLimit, mode: config.fileMode, disableAllowed: config.fileDisableAllowed,
355
- }, context);
356
- const returnTypesResult = await runReturnTypesExecutor({
357
- mode: config.returnTypeMode,
358
- disableAllowed: config.returnTypeDisableAllowed,
359
- ignoreModifiedUntilEpoch: config.returnTypeIgnoreEpoch,
360
- }, context);
361
- const noInlineTypesResult = await runNoInlineTypesExecutor({
362
- mode: config.noInlineTypesMode,
363
- disableAllowed: config.noInlineTypesDisableAllowed,
364
- ignoreModifiedUntilEpoch: config.noInlineTypesIgnoreEpoch,
365
- }, context);
366
- const noAnyUnknownResult = await runNoAnyUnknownExecutor({
367
- mode: config.noAnyUnknownMode,
368
- disableAllowed: config.noAnyUnknownDisableAllowed,
369
- ignoreModifiedUntilEpoch: config.noAnyUnknownIgnoreEpoch,
370
- }, context);
371
- const validateDtosResult = await runValidateDtosExecutor({
372
- mode: config.validateDtosMode,
373
- disableAllowed: config.validateDtosDisableAllowed,
374
- prismaSchemaPath: config.validateDtosPrismaPath,
375
- dtoSourcePaths: config.validateDtosSrcPaths,
376
- ignoreModifiedUntilEpoch: config.validateDtosIgnoreEpoch,
377
- }, context);
378
- const prismaConverterResult = await runPrismaConvertersExecutor({
379
- mode: config.prismaConverterMode,
380
- disableAllowed: config.prismaConverterDisableAllowed,
381
- schemaPath: config.prismaConverterSchemaPath,
382
- convertersPaths: config.prismaConverterConvertersPaths,
383
- enforcePaths: config.prismaConverterEnforcePaths,
384
- ignoreModifiedUntilEpoch: config.prismaConverterIgnoreEpoch,
385
- }, context);
386
- const noDestructureResult = await runNoDestructureExecutor({
387
- mode: config.noDestructureMode,
388
- disableAllowed: config.noDestructureDisableAllowed,
389
- ignoreModifiedUntilEpoch: config.noDestructureIgnoreEpoch,
390
- }, context);
391
- const noDirectApiResolverResult = await runNoDirectApiResolverExecutor({
392
- mode: config.noDirectApiResolverMode,
393
- disableAllowed: config.noDirectApiResolverDisableAllowed,
394
- ignoreModifiedUntilEpoch: config.noDirectApiResolverIgnoreEpoch,
395
- enforcePaths: config.noDirectApiResolverEnforcePaths,
396
- }, context);
397
-
398
- const allSuccess = methodResults.every((r) => r.success) &&
399
- fileResult.success && returnTypesResult.success &&
400
- noInlineTypesResult.success && noAnyUnknownResult.success &&
401
- validateDtosResult.success && prismaConverterResult.success &&
402
- noDestructureResult.success && noDirectApiResolverResult.success;
403
-
404
- console.log(allSuccess ? '\n\u2705 All code validations passed\n' : '\n\u274c Some code validations failed\n');
405
- return { success: allSuccess };
406
- }
@@ -1,227 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/schema",
3
- "title": "Validate Code Executor",
4
- "description": "Combined validation for new methods, modified methods, and file sizes. Configure via targetDefaults in nx.json for runtime options (no cache issues).",
5
- "type": "object",
6
- "properties": {
7
- "methodMaxLimit": {
8
- "type": "object",
9
- "description": "Configuration for method line limit validation",
10
- "properties": {
11
- "limit": {
12
- "type": "number",
13
- "description": "Maximum lines allowed for methods",
14
- "default": 80
15
- },
16
- "mode": {
17
- "type": "string",
18
- "description": "OFF: skip validation. NEW_METHODS: only new methods in diff. NEW_AND_MODIFIED_METHODS: new methods + methods with changes. MODIFIED_FILES: all methods in modified files.",
19
- "default": "NEW_AND_MODIFIED_METHODS"
20
- },
21
- "disableAllowed": {
22
- "type": "boolean",
23
- "description": "Whether disable comments work. When false, no escape hatch (like old STRICT mode).",
24
- "default": true
25
- },
26
- "ignoreModifiedUntilEpoch": {
27
- "type": "number",
28
- "description": "Epoch seconds. Until this time, skip modified-method validation (new methods still enforced). When expired, normal mode resumes. Omit when not needed."
29
- }
30
- }
31
- },
32
- "fileMaxLimit": {
33
- "type": "object",
34
- "description": "Configuration for file line limit validation",
35
- "properties": {
36
- "limit": {
37
- "type": "number",
38
- "description": "Maximum lines for modified files",
39
- "default": 900
40
- },
41
- "mode": {
42
- "type": "string",
43
- "description": "OFF: skip validation. MODIFIED_FILES: all code in modified files.",
44
- "default": "MODIFIED_FILES"
45
- },
46
- "disableAllowed": {
47
- "type": "boolean",
48
- "description": "Whether disable comments work. When false, no escape hatch (like old STRICT mode).",
49
- "default": true
50
- },
51
- "ignoreModifiedUntilEpoch": {
52
- "type": "number",
53
- "description": "Epoch seconds. Until this time, skip modified-file validation. When expired, normal mode resumes. Omit when not needed."
54
- }
55
- }
56
- },
57
- "requireReturnType": {
58
- "type": "object",
59
- "description": "Configuration for return type validation",
60
- "properties": {
61
- "mode": {
62
- "type": "string",
63
- "description": "OFF: skip return type validation. NEW_METHODS: only new methods in diff. NEW_AND_MODIFIED_METHODS: new methods + methods with changes. MODIFIED_FILES: all methods in modified files.",
64
- "default": "OFF"
65
- },
66
- "disableAllowed": {
67
- "type": "boolean",
68
- "description": "Whether disable comments work. When false, no escape hatch.",
69
- "default": true
70
- },
71
- "ignoreModifiedUntilEpoch": {
72
- "type": "number",
73
- "description": "Epoch seconds. Until this time, skip validation entirely. When expired, normal mode resumes. Omit when not needed."
74
- }
75
- }
76
- },
77
- "noInlineTypeLiterals": {
78
- "type": "object",
79
- "description": "Configuration for no-inline-types validation",
80
- "properties": {
81
- "mode": {
82
- "type": "string",
83
- "description": "OFF: skip validation. NEW_METHODS: only new methods. NEW_AND_MODIFIED_METHODS: new + modified methods. MODIFIED_FILES: all in modified files. Disallows inline type literals like { x: number } - use named types instead.",
84
- "default": "OFF"
85
- },
86
- "disableAllowed": {
87
- "type": "boolean",
88
- "description": "Whether disable comments work. When false, no escape hatch.",
89
- "default": true
90
- },
91
- "ignoreModifiedUntilEpoch": {
92
- "type": "number",
93
- "description": "Epoch seconds. Until this time, skip validation entirely. When expired, normal mode resumes. Omit when not needed."
94
- }
95
- }
96
- },
97
- "noAnyUnknown": {
98
- "type": "object",
99
- "description": "Configuration for no-any-unknown validation",
100
- "properties": {
101
- "mode": {
102
- "type": "string",
103
- "description": "OFF: skip validation. MODIFIED_CODE: only changed lines in diff. MODIFIED_FILES: all in modified files. Disallows `any` and `unknown` TypeScript keywords.",
104
- "default": "OFF"
105
- },
106
- "disableAllowed": {
107
- "type": "boolean",
108
- "description": "Whether disable comments work. When false, no escape hatch.",
109
- "default": true
110
- },
111
- "ignoreModifiedUntilEpoch": {
112
- "type": "number",
113
- "description": "Epoch seconds. Until this time, skip validation entirely. When expired, normal mode resumes. Omit when not needed."
114
- }
115
- }
116
- },
117
- "validateDtos": {
118
- "type": "object",
119
- "description": "Validate DTO fields match Prisma Dbo model fields. Prevents AI from inventing field names.",
120
- "properties": {
121
- "mode": {
122
- "type": "string",
123
- "description": "OFF: skip validation. MODIFIED_CLASS: only validate Dto classes with changed lines. MODIFIED_FILES: validate all Dtos in modified files.",
124
- "default": "OFF"
125
- },
126
- "disableAllowed": {
127
- "type": "boolean",
128
- "description": "Whether @deprecated field exemption works. When false, all fields must match.",
129
- "default": true
130
- },
131
- "prismaSchemaPath": {
132
- "type": "string",
133
- "description": "Relative path from workspace root to schema.prisma"
134
- },
135
- "dtoSourcePaths": {
136
- "type": "array",
137
- "items": { "type": "string" },
138
- "description": "Array of directories (relative to workspace root) containing Dto files"
139
- },
140
- "ignoreModifiedUntilEpoch": {
141
- "type": "number",
142
- "description": "Epoch seconds. Until this time, skip DTO validation entirely. When expired, normal mode resumes. Omit when not needed."
143
- }
144
- }
145
- },
146
- "prismaConverter": {
147
- "type": "object",
148
- "description": "Validate Prisma converter methods follow scalable patterns: correct Dbo parameter, no async, no standalone functions, Dto creation only in converter directories.",
149
- "properties": {
150
- "mode": {
151
- "type": "string",
152
- "description": "OFF: skip validation. NEW_AND_MODIFIED_METHODS: validate new/modified methods in converters + changed lines in non-converters. MODIFIED_FILES: validate all methods in modified files.",
153
- "default": "OFF"
154
- },
155
- "disableAllowed": {
156
- "type": "boolean",
157
- "description": "Whether disable comments work. When false, no escape hatch.",
158
- "default": true
159
- },
160
- "schemaPath": {
161
- "type": "string",
162
- "description": "Relative path from workspace root to schema.prisma"
163
- },
164
- "convertersPaths": {
165
- "type": "array",
166
- "items": { "type": "string" },
167
- "description": "Array of directories (relative to workspace root) containing converter files"
168
- },
169
- "enforcePaths": {
170
- "type": "array",
171
- "items": { "type": "string" },
172
- "description": "Array of directory prefixes (relative to workspace root) to scope validation to. When set, only files under these paths are checked. When empty/omitted, all changed files are checked."
173
- },
174
- "ignoreModifiedUntilEpoch": {
175
- "type": "number",
176
- "description": "Epoch seconds. Until this time, skip prisma-converter validation entirely. When expired, normal mode resumes. Omit when not needed."
177
- }
178
- }
179
- },
180
- "noDestructure": {
181
- "type": "object",
182
- "description": "Validate no destructuring patterns are used. Destructuring hurts code traceability.",
183
- "properties": {
184
- "mode": {
185
- "type": "string",
186
- "description": "OFF: skip validation. MODIFIED_CODE: only changed lines in diff. MODIFIED_FILES: all in modified files. Disallows destructuring patterns.",
187
- "default": "OFF"
188
- },
189
- "disableAllowed": {
190
- "type": "boolean",
191
- "description": "Whether disable comments work. When false, no escape hatch.",
192
- "default": true
193
- },
194
- "ignoreModifiedUntilEpoch": {
195
- "type": "number",
196
- "description": "Epoch seconds. Until this time, skip validation entirely. When expired, normal mode resumes. Omit when not needed."
197
- }
198
- }
199
- },
200
- "noDirectApiInResolver": {
201
- "type": "object",
202
- "description": "Validate resolvers use services (not APIs) and components subscribe to service observables (not route.snapshot.data).",
203
- "properties": {
204
- "mode": {
205
- "type": "string",
206
- "description": "OFF: skip validation. MODIFIED_CODE: only changed lines in diff. NEW_AND_MODIFIED_METHODS: violations in new/modified method/route scopes. MODIFIED_FILES: all in modified files.",
207
- "default": "OFF"
208
- },
209
- "disableAllowed": {
210
- "type": "boolean",
211
- "description": "Whether disable comments work. When false, no escape hatch.",
212
- "default": true
213
- },
214
- "ignoreModifiedUntilEpoch": {
215
- "type": "number",
216
- "description": "Epoch seconds. Until this time, skip validation entirely. When expired, normal mode resumes. Omit when not needed."
217
- },
218
- "enforcePaths": {
219
- "type": "array",
220
- "items": { "type": "string" },
221
- "description": "Array of directory prefixes (relative to workspace root) to scope validation to. When set, only files under these paths are checked. When empty/omitted, all changed files are checked."
222
- }
223
- }
224
- }
225
- },
226
- "required": []
227
- }
@@ -1,42 +0,0 @@
1
- /**
2
- * Validate DTOs Executor
3
- *
4
- * Validates that every non-deprecated field in a XxxDto class/interface exists
5
- * in the corresponding XxxDbo Prisma model. This catches AI agents inventing
6
- * field names that don't match the database schema.
7
- *
8
- * ============================================================================
9
- * MODES
10
- * ============================================================================
11
- * - OFF: Skip validation entirely
12
- * - MODIFIED_CLASS: Only validate Dto classes that have changed lines in the diff
13
- * - MODIFIED_FILES: Validate ALL Dto classes in files that were modified
14
- *
15
- * ============================================================================
16
- * SKIP CONDITIONS
17
- * ============================================================================
18
- * - If schema.prisma itself is modified, validation is skipped (schema in flux)
19
- * - Dto classes ending with "JoinDto" are skipped (they compose other Dtos)
20
- * - Fields marked @deprecated in a comment are exempt
21
- *
22
- * ============================================================================
23
- * MATCHING
24
- * ============================================================================
25
- * - UserDto matches UserDbo by case-insensitive prefix ("user")
26
- * - Dbo field names are converted from snake_case to camelCase for comparison
27
- * - Dto fields must be a subset of Dbo fields
28
- * - Extra Dbo fields are allowed (e.g., password)
29
- */
30
- import type { ExecutorContext } from '@nx/devkit';
31
- export type ValidateDtosMode = 'OFF' | 'MODIFIED_CLASS' | 'MODIFIED_FILES';
32
- export interface ValidateDtosOptions {
33
- mode?: ValidateDtosMode;
34
- disableAllowed?: boolean;
35
- prismaSchemaPath?: string;
36
- dtoSourcePaths?: string[];
37
- ignoreModifiedUntilEpoch?: number;
38
- }
39
- export interface ExecutorResult {
40
- success: boolean;
41
- }
42
- export default function runExecutor(options: ValidateDtosOptions, context: ExecutorContext): Promise<ExecutorResult>;