@webpieces/dev-config 0.2.82 → 0.2.84

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 (31) hide show
  1. package/architecture/executors/validate-code/executor.d.ts +22 -3
  2. package/architecture/executors/validate-code/executor.js +37 -11
  3. package/architecture/executors/validate-code/executor.js.map +1 -1
  4. package/architecture/executors/validate-code/executor.ts +72 -14
  5. package/architecture/executors/validate-code/schema.json +78 -15
  6. package/architecture/executors/validate-dtos/executor.d.ts +2 -0
  7. package/architecture/executors/validate-dtos/executor.js +94 -16
  8. package/architecture/executors/validate-dtos/executor.js.map +1 -1
  9. package/architecture/executors/validate-dtos/executor.ts +103 -15
  10. package/architecture/executors/validate-dtos/schema.json +9 -0
  11. package/architecture/executors/validate-no-any-unknown/executor.d.ts +2 -0
  12. package/architecture/executors/validate-no-any-unknown/executor.js +27 -7
  13. package/architecture/executors/validate-no-any-unknown/executor.js.map +1 -1
  14. package/architecture/executors/validate-no-any-unknown/executor.ts +31 -7
  15. package/architecture/executors/validate-no-any-unknown/schema.json +9 -0
  16. package/architecture/executors/validate-no-inline-types/executor.d.ts +2 -0
  17. package/architecture/executors/validate-no-inline-types/executor.js +30 -10
  18. package/architecture/executors/validate-no-inline-types/executor.js.map +1 -1
  19. package/architecture/executors/validate-no-inline-types/executor.ts +35 -10
  20. package/architecture/executors/validate-no-inline-types/schema.json +9 -0
  21. package/architecture/executors/validate-prisma-converters/executor.d.ts +2 -0
  22. package/architecture/executors/validate-prisma-converters/executor.js +33 -12
  23. package/architecture/executors/validate-prisma-converters/executor.js.map +1 -1
  24. package/architecture/executors/validate-prisma-converters/executor.ts +44 -12
  25. package/architecture/executors/validate-prisma-converters/schema.json +9 -0
  26. package/architecture/executors/validate-return-types/executor.d.ts +2 -0
  27. package/architecture/executors/validate-return-types/executor.js +30 -10
  28. package/architecture/executors/validate-return-types/executor.js.map +1 -1
  29. package/architecture/executors/validate-return-types/executor.ts +35 -10
  30. package/architecture/executors/validate-return-types/schema.json +9 -0
  31. package/package.json +1 -1
@@ -27,6 +27,8 @@ export type ReturnTypeMode = 'OFF' | 'NEW_METHODS' | 'MODIFIED_AND_NEW_METHODS'
27
27
 
28
28
  export interface ValidateReturnTypesOptions {
29
29
  mode?: ReturnTypeMode;
30
+ disableAllowed?: boolean;
31
+ ignoreModifiedUntilEpoch?: number;
30
32
  }
31
33
 
32
34
  export interface ExecutorResult {
@@ -286,7 +288,8 @@ function findViolationsForNewMethods(
286
288
  workspaceRoot: string,
287
289
  changedFiles: string[],
288
290
  base: string,
289
- head?: string
291
+ head: string | undefined,
292
+ disableAllowed: boolean
290
293
  ): MethodViolation[] {
291
294
  const violations: MethodViolation[] = [];
292
295
 
@@ -301,7 +304,7 @@ function findViolationsForNewMethods(
301
304
  for (const method of methods) {
302
305
  if (!newMethodNames.has(method.name)) continue;
303
306
  if (method.hasReturnType) continue;
304
- if (method.hasDisableComment) continue;
307
+ if (disableAllowed && method.hasDisableComment) continue;
305
308
 
306
309
  violations.push({
307
310
  file,
@@ -322,7 +325,8 @@ function findViolationsForModifiedAndNewMethods(
322
325
  workspaceRoot: string,
323
326
  changedFiles: string[],
324
327
  base: string,
325
- head?: string
328
+ head: string | undefined,
329
+ disableAllowed: boolean
326
330
  ): MethodViolation[] {
327
331
  const violations: MethodViolation[] = [];
328
332
 
@@ -335,7 +339,7 @@ function findViolationsForModifiedAndNewMethods(
335
339
 
336
340
  for (const method of methods) {
337
341
  if (method.hasReturnType) continue;
338
- if (method.hasDisableComment) continue;
342
+ if (disableAllowed && method.hasDisableComment) continue;
339
343
 
340
344
  const isNewMethod = newMethodNames.has(method.name);
341
345
  const isModifiedMethod = methodHasChanges(method, changedLines);
@@ -356,7 +360,7 @@ function findViolationsForModifiedAndNewMethods(
356
360
  /**
357
361
  * Find all methods without explicit return types in modified files (MODIFIED_FILES mode).
358
362
  */
359
- function findViolationsForModifiedFiles(workspaceRoot: string, changedFiles: string[]): MethodViolation[] {
363
+ function findViolationsForModifiedFiles(workspaceRoot: string, changedFiles: string[], disableAllowed: boolean): MethodViolation[] {
360
364
  const violations: MethodViolation[] = [];
361
365
 
362
366
  for (const file of changedFiles) {
@@ -364,7 +368,7 @@ function findViolationsForModifiedFiles(workspaceRoot: string, changedFiles: str
364
368
 
365
369
  for (const method of methods) {
366
370
  if (method.hasReturnType) continue;
367
- if (method.hasDisableComment) continue;
371
+ if (disableAllowed && method.hasDisableComment) continue;
368
372
 
369
373
  violations.push({
370
374
  file,
@@ -438,12 +442,33 @@ function reportViolations(violations: MethodViolation[], mode: ReturnTypeMode):
438
442
  console.error('');
439
443
  }
440
444
 
445
+ /**
446
+ * Resolve mode considering ignoreModifiedUntilEpoch override.
447
+ * When active, downgrades to OFF. When expired, logs a warning.
448
+ */
449
+ function resolveMode(normalMode: ReturnTypeMode, epoch: number | undefined): ReturnTypeMode {
450
+ if (epoch === undefined || normalMode === 'OFF') {
451
+ return normalMode;
452
+ }
453
+ const nowSeconds = Date.now() / 1000;
454
+ if (nowSeconds < epoch) {
455
+ const expiresDate = new Date(epoch * 1000).toISOString().split('T')[0];
456
+ console.log(`\n⏭️ Skipping require-return-type validation (ignoreModifiedUntilEpoch active, expires: ${expiresDate})`);
457
+ console.log('');
458
+ return 'OFF';
459
+ }
460
+ const expiresDate = new Date(epoch * 1000).toISOString().split('T')[0];
461
+ console.log(`\n⚠️ requireReturnType.ignoreModifiedUntilEpoch (${epoch}) has expired (${expiresDate}). Remove it from nx.json. Using normal mode: ${normalMode}\n`);
462
+ return normalMode;
463
+ }
464
+
441
465
  export default async function runExecutor(
442
466
  options: ValidateReturnTypesOptions,
443
467
  context: ExecutorContext
444
468
  ): Promise<ExecutorResult> {
445
469
  const workspaceRoot = context.root;
446
- const mode: ReturnTypeMode = options.mode ?? 'NEW_METHODS';
470
+ const mode: ReturnTypeMode = resolveMode(options.mode ?? 'NEW_METHODS', options.ignoreModifiedUntilEpoch);
471
+ const disableAllowed = options.disableAllowed ?? true;
447
472
 
448
473
  if (mode === 'OFF') {
449
474
  console.log('\n⏭️ Skipping return type validation (mode: OFF)');
@@ -483,11 +508,11 @@ export default async function runExecutor(
483
508
  let violations: MethodViolation[] = [];
484
509
 
485
510
  if (mode === 'NEW_METHODS') {
486
- violations = findViolationsForNewMethods(workspaceRoot, changedFiles, base, head);
511
+ violations = findViolationsForNewMethods(workspaceRoot, changedFiles, base, head, disableAllowed);
487
512
  } else if (mode === 'MODIFIED_AND_NEW_METHODS') {
488
- violations = findViolationsForModifiedAndNewMethods(workspaceRoot, changedFiles, base, head);
513
+ violations = findViolationsForModifiedAndNewMethods(workspaceRoot, changedFiles, base, head, disableAllowed);
489
514
  } else if (mode === 'MODIFIED_FILES') {
490
- violations = findViolationsForModifiedFiles(workspaceRoot, changedFiles);
515
+ violations = findViolationsForModifiedFiles(workspaceRoot, changedFiles, disableAllowed);
491
516
  }
492
517
 
493
518
  if (violations.length === 0) {
@@ -9,6 +9,15 @@
9
9
  "enum": ["OFF", "NEW_METHODS", "MODIFIED_AND_NEW_METHODS", "MODIFIED_FILES"],
10
10
  "description": "OFF: skip validation. NEW_METHODS: only new methods in diff. MODIFIED_AND_NEW_METHODS: new methods + methods with changes. MODIFIED_FILES: all methods in modified files.",
11
11
  "default": "NEW_METHODS"
12
+ },
13
+ "disableAllowed": {
14
+ "type": "boolean",
15
+ "description": "Whether disable comments work. When false, no escape hatch.",
16
+ "default": true
17
+ },
18
+ "ignoreModifiedUntilEpoch": {
19
+ "type": "number",
20
+ "description": "Epoch seconds. Until this time, skip validation entirely. When expired, normal mode resumes. Omit when not needed."
12
21
  }
13
22
  },
14
23
  "required": []
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webpieces/dev-config",
3
- "version": "0.2.82",
3
+ "version": "0.2.84",
4
4
  "description": "Development configuration, scripts, and patterns for WebPieces projects",
5
5
  "type": "commonjs",
6
6
  "bin": {