@webpieces/code-rules 0.0.1 → 0.2.113

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 (63) hide show
  1. package/package.json +4 -3
  2. package/src/cli.d.ts +1 -0
  3. package/src/cli.js +19 -0
  4. package/src/cli.js.map +1 -0
  5. package/src/diff-utils.d.ts +24 -0
  6. package/src/{diff-utils.ts → diff-utils.js} +30 -38
  7. package/src/diff-utils.js.map +1 -0
  8. package/src/from-shared-config.d.ts +28 -0
  9. package/src/from-shared-config.js +119 -0
  10. package/src/from-shared-config.js.map +1 -0
  11. package/src/index.js +33 -0
  12. package/src/index.js.map +1 -0
  13. package/src/validate-catch-error-pattern.d.ts +47 -0
  14. package/src/{validate-catch-error-pattern.ts → validate-catch-error-pattern.js} +74 -195
  15. package/src/validate-catch-error-pattern.js.map +1 -0
  16. package/src/validate-code.d.ts +98 -0
  17. package/src/{validate-code.ts → validate-code.js} +65 -259
  18. package/src/validate-code.js.map +1 -0
  19. package/src/validate-dtos.d.ts +41 -0
  20. package/src/{validate-dtos.ts → validate-dtos.js} +88 -215
  21. package/src/validate-dtos.js.map +1 -0
  22. package/src/validate-modified-files.d.ts +24 -0
  23. package/src/{validate-modified-files.ts → validate-modified-files.js} +46 -115
  24. package/src/validate-modified-files.js.map +1 -0
  25. package/src/validate-modified-methods.d.ts +30 -0
  26. package/src/{validate-modified-methods.ts → validate-modified-methods.js} +94 -196
  27. package/src/validate-modified-methods.js.map +1 -0
  28. package/src/validate-new-methods.d.ts +27 -0
  29. package/src/{validate-new-methods.ts → validate-new-methods.js} +63 -133
  30. package/src/validate-new-methods.js.map +1 -0
  31. package/src/validate-no-any-unknown.d.ts +41 -0
  32. package/src/{validate-no-any-unknown.ts → validate-no-any-unknown.js} +69 -146
  33. package/src/validate-no-any-unknown.js.map +1 -0
  34. package/src/validate-no-destructure.d.ts +51 -0
  35. package/src/{validate-no-destructure.ts → validate-no-destructure.js} +80 -166
  36. package/src/validate-no-destructure.js.map +1 -0
  37. package/src/validate-no-direct-api-resolver.d.ts +46 -0
  38. package/src/{validate-no-direct-api-resolver.ts → validate-no-direct-api-resolver.js} +112 -211
  39. package/src/validate-no-direct-api-resolver.js.map +1 -0
  40. package/src/validate-no-implicit-any.d.ts +36 -0
  41. package/src/{validate-no-implicit-any.ts → validate-no-implicit-any.js} +94 -141
  42. package/src/validate-no-implicit-any.js.map +1 -0
  43. package/src/validate-no-inline-types.d.ts +90 -0
  44. package/src/{validate-no-inline-types.ts → validate-no-inline-types.js} +93 -198
  45. package/src/validate-no-inline-types.js.map +1 -0
  46. package/src/validate-no-unmanaged-exceptions.d.ts +43 -0
  47. package/src/{validate-no-unmanaged-exceptions.ts → validate-no-unmanaged-exceptions.js} +71 -140
  48. package/src/validate-no-unmanaged-exceptions.js.map +1 -0
  49. package/src/validate-prisma-converters.d.ts +59 -0
  50. package/src/{validate-prisma-converters.ts → validate-prisma-converters.js} +120 -307
  51. package/src/validate-prisma-converters.js.map +1 -0
  52. package/src/validate-return-types.d.ts +28 -0
  53. package/src/{validate-return-types.ts → validate-return-types.js} +84 -168
  54. package/src/validate-return-types.js.map +1 -0
  55. package/LICENSE +0 -373
  56. package/jest.config.ts +0 -20
  57. package/project.json +0 -22
  58. package/src/cli.ts +0 -17
  59. package/src/from-shared-config.ts +0 -118
  60. package/tsconfig.json +0 -22
  61. package/tsconfig.lib.json +0 -10
  62. package/tsconfig.spec.json +0 -14
  63. /package/src/{index.ts → index.d.ts} +0 -0
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Validate No Inline Types Executor
3
+ *
4
+ * Validates that inline type literals AND tuple types are not used in type positions.
5
+ * Prefer named types/interfaces/classes for clarity and reusability.
6
+ *
7
+ * ============================================================================
8
+ * VIOLATIONS (BAD) - These patterns are flagged:
9
+ * ============================================================================
10
+ *
11
+ * 1. INLINE TYPE LITERALS { }
12
+ * -------------------------
13
+ * - Inline parameter type: function foo(arg: { x: number }) { }
14
+ * - Inline return type: function foo(): { x: number } { }
15
+ * - Inline variable type: const config: { timeout: number } = { timeout: 5 };
16
+ * - Inline property type: class C { data: { id: number }; }
17
+ * - Inline in union: type T = { x: number } | null;
18
+ * - Inline in intersection: type T = { x: number } & { y: number };
19
+ * - Inline in generic: Promise<{ data: string }>
20
+ * - Inline in array: function foo(): { id: string }[] { }
21
+ * - Nested inline in alias: type T = { data: { nested: number } }; // inner { } flagged
22
+ * - Inline in tuple: type T = [{ x: number }, string];
23
+ *
24
+ * 2. TUPLE TYPES [ ]
25
+ * ----------------
26
+ * - Tuple return type: function foo(): [Items[], number] { }
27
+ * - Tuple parameter type: function foo(arg: [string, number]) { }
28
+ * - Tuple variable type: const result: [Data[], number] = getData();
29
+ * - Tuple in generic: Promise<[Items[], number]>
30
+ * - Tuple in union: type T = [A, B] | null;
31
+ * - Nested tuple: type T = { data: [A, B] };
32
+ *
33
+ * ============================================================================
34
+ * ALLOWED (GOOD) - These patterns pass validation:
35
+ * ============================================================================
36
+ *
37
+ * 1. TYPE ALIAS DEFINITIONS (direct body only)
38
+ * -----------------------------------------
39
+ * - Type alias with literal: type MyConfig = { timeout: number };
40
+ * - Type alias with tuple: type MyResult = [Items[], number];
41
+ * - Interface definition: interface MyData { id: number }
42
+ * - Class definition: class UserData { id: number; name: string; }
43
+ *
44
+ * 2. USING NAMED TYPES
45
+ * ------------------
46
+ * - Named param type: function foo(arg: MyConfig) { }
47
+ * - Named return type: function foo(): MyConfig { }
48
+ * - Named with null: function foo(): MyConfig | null { }
49
+ * - Named with undefined: function foo(): MyConfig | undefined { }
50
+ * - Union of named types: type Either = TypeA | TypeB;
51
+ * - Named in generic: Promise<MyResult>
52
+ * - Named tuple alias: function foo(): MyTupleResult { }
53
+ *
54
+ * 3. PRIMITIVES AND BUILT-INS
55
+ * -------------------------
56
+ * - Primitive types: function foo(): string { }
57
+ * - Primitive arrays: function foo(): string[] { }
58
+ * - Built-in generics: function foo(): Promise<string> { }
59
+ * - Void return: function foo(): void { }
60
+ *
61
+ * ============================================================================
62
+ * MODES
63
+ * ============================================================================
64
+ * - OFF: Skip validation entirely
65
+ * - NEW_METHODS: Only validate in new methods (detected via git diff)
66
+ * - NEW_AND_MODIFIED_METHODS: Validate in new methods + methods with changes
67
+ * - MODIFIED_FILES: Validate all violations in modified files
68
+ *
69
+ * ============================================================================
70
+ * ESCAPE HATCH
71
+ * ============================================================================
72
+ * Add comment above the violation:
73
+ * // webpieces-disable no-inline-types -- [your justification]
74
+ * function foo(arg: { x: number }) { }
75
+ *
76
+ * Use sparingly! Common valid reasons:
77
+ * - Prisma payload types that require inline generics
78
+ * - Third-party library APIs that expect inline types
79
+ * - Legacy code being incrementally migrated
80
+ */
81
+ export type NoInlineTypesMode = 'OFF' | 'NEW_METHODS' | 'NEW_AND_MODIFIED_METHODS' | 'MODIFIED_FILES';
82
+ export interface ValidateNoInlineTypesOptions {
83
+ mode?: NoInlineTypesMode;
84
+ disableAllowed?: boolean;
85
+ ignoreModifiedUntilEpoch?: number;
86
+ }
87
+ export interface ExecutorResult {
88
+ success: boolean;
89
+ }
90
+ export default function runValidator(options: ValidateNoInlineTypesOptions, workspaceRoot: string): Promise<ExecutorResult>;