eslint-plugin-ts-data-forge 0.8.5 → 0.9.0

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 (135) hide show
  1. package/README.md +20 -19
  2. package/dist/plugin.d.mts +2 -0
  3. package/dist/plugin.d.mts.map +1 -1
  4. package/dist/plugin.mjs +1 -0
  5. package/dist/plugin.mjs.map +1 -1
  6. package/dist/rule-types.d.mts +16 -1
  7. package/dist/rule-types.d.mts.map +1 -1
  8. package/dist/rule-types.mjs.map +1 -1
  9. package/dist/rules/ast-utils.d.mts +21 -34
  10. package/dist/rules/ast-utils.d.mts.map +1 -1
  11. package/dist/rules/ast-utils.mjs +53 -58
  12. package/dist/rules/ast-utils.mjs.map +1 -1
  13. package/dist/rules/constants.d.mts +2 -0
  14. package/dist/rules/constants.d.mts.map +1 -1
  15. package/dist/rules/constants.mjs +9 -0
  16. package/dist/rules/constants.mjs.map +1 -1
  17. package/dist/rules/mutable-result.d.mts +10 -0
  18. package/dist/rules/mutable-result.d.mts.map +1 -0
  19. package/dist/rules/mutable-result.mjs +145 -0
  20. package/dist/rules/mutable-result.mjs.map +1 -0
  21. package/dist/rules/no-unnecessary-type-guard.d.mts.map +1 -1
  22. package/dist/rules/no-unnecessary-type-guard.mjs +6 -6
  23. package/dist/rules/no-unnecessary-type-guard.mjs.map +1 -1
  24. package/dist/rules/prefer-arr-generate.d.mts +57 -0
  25. package/dist/rules/prefer-arr-generate.d.mts.map +1 -0
  26. package/dist/rules/prefer-arr-generate.mjs +588 -0
  27. package/dist/rules/prefer-arr-generate.mjs.map +1 -0
  28. package/dist/rules/prefer-arr-is-array.d.mts.map +1 -1
  29. package/dist/rules/prefer-arr-is-array.mjs +7 -5
  30. package/dist/rules/prefer-arr-is-array.mjs.map +1 -1
  31. package/dist/rules/prefer-arr-is-bounded-length-array.d.mts.map +1 -1
  32. package/dist/rules/prefer-arr-is-bounded-length-array.mjs +9 -6
  33. package/dist/rules/prefer-arr-is-bounded-length-array.mjs.map +1 -1
  34. package/dist/rules/prefer-arr-is-fixed-length-array.d.mts.map +1 -1
  35. package/dist/rules/prefer-arr-is-fixed-length-array.mjs +9 -6
  36. package/dist/rules/prefer-arr-is-fixed-length-array.mjs.map +1 -1
  37. package/dist/rules/prefer-arr-is-max-length-array.d.mts.map +1 -1
  38. package/dist/rules/prefer-arr-is-max-length-array.mjs +9 -6
  39. package/dist/rules/prefer-arr-is-max-length-array.mjs.map +1 -1
  40. package/dist/rules/prefer-arr-is-min-length-array.d.mts.map +1 -1
  41. package/dist/rules/prefer-arr-is-min-length-array.mjs +9 -6
  42. package/dist/rules/prefer-arr-is-min-length-array.mjs.map +1 -1
  43. package/dist/rules/prefer-arr-is-non-empty.d.mts.map +1 -1
  44. package/dist/rules/prefer-arr-is-non-empty.mjs +9 -6
  45. package/dist/rules/prefer-arr-is-non-empty.mjs.map +1 -1
  46. package/dist/rules/prefer-arr-scan.d.mts.map +1 -1
  47. package/dist/rules/prefer-arr-scan.mjs +8 -11
  48. package/dist/rules/prefer-arr-scan.mjs.map +1 -1
  49. package/dist/rules/prefer-arr-sum.d.mts.map +1 -1
  50. package/dist/rules/prefer-arr-sum.mjs +8 -6
  51. package/dist/rules/prefer-arr-sum.mjs.map +1 -1
  52. package/dist/rules/prefer-arr-uniq.d.mts.map +1 -1
  53. package/dist/rules/prefer-arr-uniq.mjs +12 -166
  54. package/dist/rules/prefer-arr-uniq.mjs.map +1 -1
  55. package/dist/rules/prefer-as-int.d.mts.map +1 -1
  56. package/dist/rules/prefer-as-int.mjs +6 -8
  57. package/dist/rules/prefer-as-int.mjs.map +1 -1
  58. package/dist/rules/prefer-canonical-array-slicing.d.mts.map +1 -1
  59. package/dist/rules/prefer-canonical-array-slicing.mjs +57 -34
  60. package/dist/rules/prefer-canonical-array-slicing.mjs.map +1 -1
  61. package/dist/rules/prefer-canonical-length-cast.d.mts.map +1 -1
  62. package/dist/rules/prefer-canonical-length-cast.mjs +3 -3
  63. package/dist/rules/prefer-canonical-length-cast.mjs.map +1 -1
  64. package/dist/rules/prefer-canonical-length-guard.d.mts.map +1 -1
  65. package/dist/rules/prefer-canonical-length-guard.mjs +4 -4
  66. package/dist/rules/prefer-canonical-length-guard.mjs.map +1 -1
  67. package/dist/rules/prefer-comparison-over-nullish-guard.d.mts.map +1 -1
  68. package/dist/rules/prefer-comparison-over-nullish-guard.mjs +3 -2
  69. package/dist/rules/prefer-comparison-over-nullish-guard.mjs.map +1 -1
  70. package/dist/rules/prefer-is-non-null-object.d.mts.map +1 -1
  71. package/dist/rules/prefer-is-non-null-object.mjs +113 -43
  72. package/dist/rules/prefer-is-non-null-object.mjs.map +1 -1
  73. package/dist/rules/prefer-is-record-and-has-key.d.mts.map +1 -1
  74. package/dist/rules/prefer-is-record-and-has-key.mjs +105 -48
  75. package/dist/rules/prefer-is-record-and-has-key.mjs.map +1 -1
  76. package/dist/rules/prefer-num-safe-parse-float.d.mts.map +1 -1
  77. package/dist/rules/prefer-num-safe-parse-float.mjs +6 -6
  78. package/dist/rules/prefer-num-safe-parse-float.mjs.map +1 -1
  79. package/dist/rules/prefer-num-safe-parse-int.d.mts.map +1 -1
  80. package/dist/rules/prefer-num-safe-parse-int.mjs +6 -6
  81. package/dist/rules/prefer-num-safe-parse-int.mjs.map +1 -1
  82. package/dist/rules/prefer-obj-over-entries-round-trip.d.mts.map +1 -1
  83. package/dist/rules/prefer-obj-over-entries-round-trip.mjs +9 -12
  84. package/dist/rules/prefer-obj-over-entries-round-trip.mjs.map +1 -1
  85. package/dist/rules/prefer-range-for-loop.d.mts.map +1 -1
  86. package/dist/rules/prefer-range-for-loop.mjs +104 -23
  87. package/dist/rules/prefer-range-for-loop.mjs.map +1 -1
  88. package/dist/rules/rules.d.mts +1 -0
  89. package/dist/rules/rules.d.mts.map +1 -1
  90. package/dist/rules/rules.mjs +2 -0
  91. package/dist/rules/rules.mjs.map +1 -1
  92. package/package.json +11 -10
  93. package/src/plugin.mts +1 -0
  94. package/src/rule-types.mts +17 -1
  95. package/src/rules/ast-utils.mts +73 -80
  96. package/src/rules/constants.mts +12 -0
  97. package/src/rules/mutable-result.mts +204 -0
  98. package/src/rules/no-unnecessary-type-guard.mts +14 -10
  99. package/src/rules/prefer-arr-generate.mts +918 -0
  100. package/src/rules/prefer-arr-generate.test.mts +967 -0
  101. package/src/rules/prefer-arr-is-array.mts +14 -7
  102. package/src/rules/prefer-arr-is-array.test.mts +14 -0
  103. package/src/rules/prefer-arr-is-bounded-length-array.mts +16 -10
  104. package/src/rules/prefer-arr-is-bounded-length-array.test.mts +19 -0
  105. package/src/rules/prefer-arr-is-fixed-length-array.mts +17 -11
  106. package/src/rules/prefer-arr-is-max-length-array.mts +17 -11
  107. package/src/rules/prefer-arr-is-max-length-array.test.mts +8 -0
  108. package/src/rules/prefer-arr-is-min-length-array.mts +17 -11
  109. package/src/rules/prefer-arr-is-min-length-array.test.mts +8 -0
  110. package/src/rules/prefer-arr-is-non-empty.mts +16 -13
  111. package/src/rules/prefer-arr-scan.mts +24 -19
  112. package/src/rules/prefer-arr-sum.mts +18 -14
  113. package/src/rules/prefer-arr-uniq.mts +25 -234
  114. package/src/rules/prefer-as-int.mts +19 -12
  115. package/src/rules/prefer-canonical-array-slicing.mts +79 -52
  116. package/src/rules/prefer-canonical-array-slicing.test.mts +55 -0
  117. package/src/rules/prefer-canonical-length-cast.mts +7 -3
  118. package/src/rules/prefer-canonical-length-guard.mts +9 -4
  119. package/src/rules/prefer-comparison-over-nullish-guard.mts +3 -2
  120. package/src/rules/prefer-comparison-over-nullish-guard.test.mts +16 -0
  121. package/src/rules/prefer-is-non-null-object.mts +171 -64
  122. package/src/rules/prefer-is-non-null-object.test.mts +138 -0
  123. package/src/rules/prefer-is-record-and-has-key.mts +159 -74
  124. package/src/rules/prefer-is-record-and-has-key.test.mts +118 -23
  125. package/src/rules/prefer-num-safe-parse-float.mts +15 -10
  126. package/src/rules/prefer-num-safe-parse-int.mts +15 -13
  127. package/src/rules/prefer-obj-over-entries-round-trip.mts +19 -22
  128. package/src/rules/prefer-range-for-loop.mts +157 -31
  129. package/src/rules/prefer-range-for-loop.test.mts +127 -5
  130. package/src/rules/rules.mts +2 -0
  131. package/dist/rules/import-utils.d.mts +0 -30
  132. package/dist/rules/import-utils.d.mts.map +0 -1
  133. package/dist/rules/import-utils.mjs +0 -98
  134. package/dist/rules/import-utils.mjs.map +0 -1
  135. package/src/rules/import-utils.mts +0 -175
package/README.md CHANGED
@@ -66,25 +66,26 @@ export default [
66
66
 
67
67
  ## Rules
68
68
 
69
- | Rule | Description |
70
- | -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
71
- | `prefer-canonical-array-slicing` | Unify non-mutating array add/remove patterns into `Arr.tail`/`skip`/`take`/etc. |
72
- | `prefer-canonical-length-guard` | Normalize array-length checks to the canonical `Arr` guard (`xs.length > 0` → `Arr.isNonEmpty`, `Arr.isFixedLengthArray(0, xs)` → `Arr.isEmpty`, `Arr.isFixedLengthTuple(0, xs)` → `Arr.isEmptyTuple`, …). |
73
- | `prefer-canonical-length-cast` | Normalize a degenerate `Arr` length cast to the canonical one (`Arr.asMinLengthArray(1, xs)` → `Arr.asNonEmptyArray(xs)`, `Arr.asBoundedLengthArray(n, n, xs)` → `Arr.asFixedLengthArray(n, xs)`, …). |
74
- | `prefer-arr-is-array` | Replace `Array.isArray` with `Arr.isArray`. |
75
- | `prefer-arr-scan` | Report an accumulated value rebuilt for every element (`xs.map((_, i) => f(...xs.slice(0, i + 1)))`, or a `reduce` that appends to its accumulator) and point at `Arr.scan`. Fixes the `reduce` form. |
76
- | `prefer-arr-sum` | Replace `xs.reduce((a, b) => a + b, 0)` with `Arr.sum(xs)` / `Arr.sumBy(xs, fn)`. |
77
- | `prefer-arr-uniq` | Replace `Array.from(new Set(xs))` / `[...new Set(xs)]` with `Arr.uniq(xs)` when `xs` is an array of primitives (type-aware). Suggests instead of fixing when the result is used as a mutable array. |
78
- | `prefer-as-int` | Replace branded-number assertions (`x as Int`) with `asInt(x)`-style casts. |
79
- | `prefer-is-non-null-object` | Replace `typeof u === 'object' && u !== null` with `isNonNullObject(u)`. |
80
- | `prefer-range-for-loop` | Replace C-style `for` loops with `for (const i of range(begin, end))`. |
81
- | `prefer-is-record-and-has-key` | Replace `Object.hasOwn(obj, key)` / `key in obj` with `isRecord(obj) && hasKey(…)`. |
82
- | `prefer-num-safe-parse-int` | Replace `parseInt(x, 10)` with `Result.unwrapOkOr(Num.safeParseInt(x), NaN)`. |
83
- | `prefer-num-safe-parse-float` | Replace `parseFloat(x)` / `Number(x)` with `Num.safeParseFloat`-based parsing. |
84
- | `no-unnecessary-type-guard` | Flag `ts-data-forge` type-guard calls that do no narrowing (type-aware). |
85
- | `prefer-comparison-over-nullish-guard` | Prefer direct `=== null` / `!== undefined` over `isNull` / `isNotUndefined` calls. |
86
- | `prefer-obj-over-entries-round-trip` | Replace an `Object.fromEntries(Object.entries(o).map/filter/flatMap(…))` round trip with `Obj.map` / `Obj.filter` / `Obj.filterMap`. |
87
- | `no-side-effect-import` | Remove a side-effect-only `import 'ts-data-forge';`; the package declares `sideEffects: false`, so it binds no name and does nothing. |
69
+ | Rule | Description |
70
+ | -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
71
+ | `prefer-canonical-array-slicing` | Unify non-mutating array add/remove patterns into `Arr.tail`/`skip`/`take`/etc. |
72
+ | `prefer-canonical-length-guard` | Normalize array-length checks to the canonical `Arr` guard (`xs.length > 0` → `Arr.isNonEmpty`, `Arr.isFixedLengthArray(0, xs)` → `Arr.isEmpty`, `Arr.isFixedLengthTuple(0, xs)` → `Arr.isEmptyTuple`, …). |
73
+ | `prefer-canonical-length-cast` | Normalize a degenerate `Arr` length cast to the canonical one (`Arr.asMinLengthArray(1, xs)` → `Arr.asNonEmptyArray(xs)`, `Arr.asBoundedLengthArray(n, n, xs)` → `Arr.asFixedLengthArray(n, xs)`, …). |
74
+ | `prefer-arr-generate` | Replace the filter-and-map idiom `xs.flatMap((x) => (cond ? [f(x)] : []))` with a `for…of` loop in `Arr.generate` (type-aware). Suggests instead of fixing when the result is used as a mutable array, when a type annotation, a type wrapper or a comment would be dropped, when the receiver relies on a narrowing the generator function would not see, or when it is a `filter()` call. |
75
+ | `prefer-arr-is-array` | Replace `Array.isArray` with `Arr.isArray`. |
76
+ | `prefer-arr-scan` | Report an accumulated value rebuilt for every element (`xs.map((_, i) => f(...xs.slice(0, i + 1)))`, or a `reduce` that appends to its accumulator) and point at `Arr.scan`. Fixes the `reduce` form. |
77
+ | `prefer-arr-sum` | Replace `xs.reduce((a, b) => a + b, 0)` with `Arr.sum(xs)` / `Arr.sumBy(xs, fn)`. |
78
+ | `prefer-arr-uniq` | Replace `Array.from(new Set(xs))` / `[...new Set(xs)]` with `Arr.uniq(xs)` when `xs` is an array of primitives (type-aware). Suggests instead of fixing when the result is used as a mutable array. |
79
+ | `prefer-as-int` | Replace branded-number assertions (`x as Int`) with `asInt(x)`-style casts. |
80
+ | `prefer-is-non-null-object` | Replace `typeof u === 'object' && u !== null` with `isNonNullObject(u)`. |
81
+ | `prefer-range-for-loop` | Replace C-style `for` loops with `for (const i of range(begin, end))`. |
82
+ | `prefer-is-record-and-has-key` | Replace `Object.hasOwn(obj, key)` / `key in obj` with `isRecord(obj) && hasKey(…)`. |
83
+ | `prefer-num-safe-parse-int` | Replace `parseInt(x, 10)` with `Result.unwrapOkOr(Num.safeParseInt(x), NaN)`. |
84
+ | `prefer-num-safe-parse-float` | Replace `parseFloat(x)` / `Number(x)` with `Num.safeParseFloat`-based parsing. |
85
+ | `no-unnecessary-type-guard` | Flag `ts-data-forge` type-guard calls that do no narrowing (type-aware). |
86
+ | `prefer-comparison-over-nullish-guard` | Prefer direct `=== null` / `!== undefined` over `isNull` / `isNotUndefined` calls. |
87
+ | `prefer-obj-over-entries-round-trip` | Replace an `Object.fromEntries(Object.entries(o).map/filter/flatMap(…))` round trip with `Obj.map` / `Obj.filter` / `Obj.filterMap`. |
88
+ | `no-side-effect-import` | Remove a side-effect-only `import 'ts-data-forge';`; the package declares `sideEffects: false`, so it binds no name and does nothing. |
88
89
 
89
90
  ## License
90
91
 
package/dist/plugin.d.mts CHANGED
@@ -7,6 +7,7 @@ export declare const eslintPluginTsDataForge: {
7
7
  readonly 'prefer-canonical-array-slicing': import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferCanonicalArraySlicing", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
8
8
  readonly 'prefer-canonical-length-guard': import("@typescript-eslint/utils/ts-eslint").RuleModule<"useCanonicalGuard" | "useIsBoundedLengthArray" | "useIsFixedLengthArray" | "useIsMaxLengthArray" | "useIsMinLengthArray" | "useIsNonEmpty", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
9
9
  readonly 'prefer-canonical-length-cast': import("@typescript-eslint/utils/ts-eslint").RuleModule<"useCanonicalCast", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
10
+ readonly 'prefer-arr-generate': import("@typescript-eslint/utils/ts-eslint").RuleModule<"suggestArrGenerate" | "useArrGenerate", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
10
11
  readonly 'prefer-arr-is-array': import("@typescript-eslint/utils/ts-eslint").RuleModule<"useArrIsArray", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
11
12
  readonly 'prefer-arr-scan': import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferArrScanAccumulate" | "preferArrScanPrefix", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
12
13
  readonly 'prefer-arr-sum': import("@typescript-eslint/utils/ts-eslint").RuleModule<"useArrSum" | "useArrSumBy", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
@@ -35,6 +36,7 @@ export declare const eslintPluginTsDataForge: {
35
36
  readonly 'ts-data-forge/prefer-canonical-array-slicing': 'error';
36
37
  readonly 'ts-data-forge/prefer-canonical-length-cast': 'error';
37
38
  readonly 'ts-data-forge/prefer-canonical-length-guard': 'error';
39
+ readonly 'ts-data-forge/prefer-arr-generate': 'error';
38
40
  readonly 'ts-data-forge/prefer-arr-is-array': 'error';
39
41
  readonly 'ts-data-forge/prefer-arr-scan': 'error';
40
42
  readonly 'ts-data-forge/prefer-arr-sum': 'error';
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.mts","sourceRoot":"","sources":["../src/plugin.mts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAoB,YAAY,EAAE,MAAM,aAAa,CAAC;AAgDlE,eAAO,MAAM,uBAAuB;;iBAEhC,IAAI,EAAE,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;QAInC,oDAAoD;iBACpD,WAAW;2BAtBP,2BAA2B;;yBAQ3B,eAAe,EAAI,YAAY;;;yEA/BW,OAAO;uEACT,OAAO;wEACN,OAAO;8DACjB,OAAO;0DACX,OAAO;yDACR,OAAO;0DACN,OAAO;wDACT,OAAO;oEACK,OAAO;gEACX,OAAO;uEACA,OAAO;oEACV,OAAO;sEACL,OAAO;gEACb,OAAO;oEACH,OAAO;+EACI,OAAO;6EACT,OAAO;;;;CA+B5B,CAAC"}
1
+ {"version":3,"file":"plugin.d.mts","sourceRoot":"","sources":["../src/plugin.mts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAoB,YAAY,EAAE,MAAM,aAAa,CAAC;AAiDlE,eAAO,MAAM,uBAAuB;;iBAEhC,IAAI,EAAE,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;QAInC,oDAAoD;iBACpD,WAAW;2BAtBP,2BAA2B;;yBAQ3B,eAAe,EAAI,YAAY;;;yEAhCW,OAAO;uEACT,OAAO;wEACN,OAAO;8DACjB,OAAO;8DACP,OAAO;0DACX,OAAO;yDACR,OAAO;0DACN,OAAO;wDACT,OAAO;oEACK,OAAO;gEACX,OAAO;uEACA,OAAO;oEACV,OAAO;sEACL,OAAO;gEACb,OAAO;oEACH,OAAO;+EACI,OAAO;6EACT,OAAO;;;;CA+B5B,CAAC"}
package/dist/plugin.mjs CHANGED
@@ -10,6 +10,7 @@ const recommendedRules = {
10
10
  'ts-data-forge/prefer-canonical-array-slicing': 'error',
11
11
  'ts-data-forge/prefer-canonical-length-cast': 'error',
12
12
  'ts-data-forge/prefer-canonical-length-guard': 'error',
13
+ 'ts-data-forge/prefer-arr-generate': 'error',
13
14
  'ts-data-forge/prefer-arr-is-array': 'error',
14
15
  'ts-data-forge/prefer-arr-scan': 'error',
15
16
  'ts-data-forge/prefer-arr-sum': 'error',
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.mjs","sourceRoot":"","sources":["../src/plugin.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAGrD;;;;;;GAMG;AACH,MAAM,gBAAgB,GAAG;IACvB,8CAA8C,EAAE,OAAO;IACvD,4CAA4C,EAAE,OAAO;IACrD,6CAA6C,EAAE,OAAO;IACtD,mCAAmC,EAAE,OAAO;IAC5C,+BAA+B,EAAE,OAAO;IACxC,8BAA8B,EAAE,OAAO;IACvC,+BAA+B,EAAE,OAAO;IACxC,6BAA6B,EAAE,OAAO;IACtC,yCAAyC,EAAE,OAAO;IAClD,qCAAqC,EAAE,OAAO;IAC9C,4CAA4C,EAAE,OAAO;IACrD,yCAAyC,EAAE,OAAO;IAClD,2CAA2C,EAAE,OAAO;IACpD,qCAAqC,EAAE,OAAO;IAC9C,yCAAyC,EAAE,OAAO;IAClD,oDAAoD,EAAE,OAAO;IAC7D,kDAAkD,EAAE,OAAO;CAI5D,CAAC;AAEF,MAAM,iBAAiB,GAAG;IACxB,IAAI,EAAE,2BAA2B;IACjC,OAAO,EAAE;QACP,uEAAuE;QACvE,yEAAyE;QACzE,wEAAwE;QACxE,mDAAmD;QACnD,0EAA0E;QAC1E,wDAAwD;QACxD,IAAI,eAAe;YACjB,OAAO,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AAE;QACJ,IAAI,EAAE,6BAA6B;KACpC;IACD,KAAK,EAAE,gBAAgB;IACvB,OAAO,EAAE;QACP,oDAAoD;QACpD,WAAW,EAAE,iBAAiB;KAC/B;CAC8B,CAAC"}
@@ -50,6 +50,20 @@ declare namespace PreferCanonicalLengthGuard {
50
50
  declare namespace PreferCanonicalLengthCast {
51
51
  type RuleEntry = Linter.StringSeverity;
52
52
  }
53
+ /**
54
+ * @description Replace the filter-and-map idiom `xs.flatMap((x) => (cond ? [f(x)] : []))` with a loop in `Arr.generate` from ts-data-forge.
55
+ *
56
+ * ```md
57
+ * | key | value |
58
+ * | :--------- | :--------- |
59
+ * | type | suggestion |
60
+ * | deprecated | false |
61
+ * | fixable | code |
62
+ * ```
63
+ */
64
+ declare namespace PreferArrGenerate {
65
+ type RuleEntry = Linter.StringSeverity;
66
+ }
53
67
  /**
54
68
  * @description Replace `Array.isArray` with `Arr.isArray` from ts-data-forge.
55
69
  *
@@ -121,7 +135,7 @@ declare namespace PreferAsInt {
121
135
  type RuleEntry = Linter.StringSeverity;
122
136
  }
123
137
  /**
124
- * @description Replace `typeof u === "object" && u !== null` with `isNonNullObject(u)` from ts-data-forge.
138
+ * @description Replace `typeof u === "object" && u !== null`, in either order and anywhere in an `&&` chain, with `isNonNullObject(u)` from ts-data-forge.
125
139
  *
126
140
  * ```md
127
141
  * | key | value |
@@ -272,6 +286,7 @@ export type EslintTsDataForgeRules = Readonly<{
272
286
  'ts-data-forge/prefer-canonical-array-slicing': PreferCanonicalArraySlicing.RuleEntry;
273
287
  'ts-data-forge/prefer-canonical-length-guard': PreferCanonicalLengthGuard.RuleEntry;
274
288
  'ts-data-forge/prefer-canonical-length-cast': PreferCanonicalLengthCast.RuleEntry;
289
+ 'ts-data-forge/prefer-arr-generate': PreferArrGenerate.RuleEntry;
275
290
  'ts-data-forge/prefer-arr-is-array': PreferArrIsArray.RuleEntry;
276
291
  'ts-data-forge/prefer-arr-scan': PreferArrScan.RuleEntry;
277
292
  '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,kDAAkD,EAAE,6BAA6B,CAAC,SAAS,CAAC;CAC7F,CAAC,CAAC;AAEH,MAAM,MAAM,4BAA4B,GAAG,QAAQ,CAAC;IAClD,yCAAyC,EAAE,sBAAsB,CAAC,OAAO,CAAC;CAC3E,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"rule-types.mjs","sourceRoot":"","sources":["../src/rule-types.mts"],"names":[],"mappings":"AAAA,oBAAoB;AAOpB,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAyU3C,8EAA8E;AAC9E,8DAA8D;AAC9D,UAAU,CAGR,GAAG,CAAC,CAAC"}
1
+ {"version":3,"file":"rule-types.mjs","sourceRoot":"","sources":["../src/rule-types.mts"],"names":[],"mappings":"AAAA,oBAAoB;AAOpB,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAyV3C,8EAA8E;AAC9E,8DAA8D;AAC9D,UAAU,CAGR,GAAG,CAAC,CAAC"}
@@ -1,37 +1,6 @@
1
1
  import { type TSESLint, type TSESTree } from '@typescript-eslint/utils';
2
2
  import type { DeepReadonly } from 'ts-type-forge';
3
- /**
4
- * `node` with every `as`, `satisfies`, `!` and `<T>` around it taken off: the
5
- * expression whose value it is. A wrapper changes no value, so a rule judges
6
- * syntax on this — `xs.length > (0 as number)` compares with the literal `0`
7
- * — and writes its fix from the original node so the wrapper is kept. A type
8
- * is another matter: see {@link typeWrapperLayers}. See
9
- * `docs/writing-lint-rules.md` at the repository root. A copy of
10
- * `eslint-config-typed`'s `type-wrapper-utils.mts`, since this package is
11
- * published on its own.
12
- */
13
- export declare const skipTypeWrappers: <N extends TSESTree.Node>(node: N) => N | TSESTree.Expression;
14
- /**
15
- * `node` and every expression inside the type wrappers around it, outermost
16
- * first: `x as A as B` gives `x as A as B`, `x as A` and `x`.
17
- *
18
- * A conclusion a rule draws from a type — that a guard always holds, that a
19
- * value is an array, that `?? 0` is dead — has to hold for the type of every
20
- * layer. An assertion therefore only ever makes a rule more cautious: one
21
- * that widens (`x as string | null`) is the author saying the value may be
22
- * `null`, and is respected; one that narrows (`x!`, `v as string` on an
23
- * `unknown`) is a claim the checker cannot verify, and the value's own type
24
- * still decides.
25
- */
26
- export declare const typeWrapperLayers: <N extends TSESTree.Node>(node: N) => readonly (N | TSESTree.Expression)[];
27
- export declare const isTypeWrapper: (node: DeepReadonly<TSESTree.Node>) => node is TypeWrapper;
28
- export type TypeWrapper = TSESTree.TSAsExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion;
29
- /**
30
- * The source text of `node` for an argument position. A node's text never
31
- * includes the parentheses the source wrote around it, so a comma (sequence)
32
- * expression gets them back rather than spilling into the next argument.
33
- */
34
- export declare const toArgumentText: (node: TSESTree.Node, sourceCode: TSESLint.SourceCode) => string;
3
+ import type * as ts from 'typescript';
35
4
  /**
36
5
  * Whether `node` is an array or a tuple at every layer of type wrappers (see
37
6
  * {@link typeWrapperLayers}): a cast does not make a string an array, and the
@@ -65,21 +34,39 @@ type LengthComparison = Readonly<{
65
34
  * Parses a `<array>.length <op> <bound>` comparison (in either operand order)
66
35
  * into its array expression, integer-literal/`const` `bound`, and whether it is
67
36
  * a lower (`min`) or upper (`max`) length bound. Returns `undefined` for
68
- * anything else. The length and the bound are read through type wrappers; the
37
+ * anything else. The comparison, the length and the bound are read through
38
+ * type wrappers; the
69
39
  * `bound` returned is the literal or constant underneath, since a wrapper such
70
40
  * as `as number` would only widen the length a guard narrows to.
71
41
  *
72
42
  * - `xs.length >= n` / `n <= xs.length` → `min`
73
43
  * - `xs.length <= n` / `n >= xs.length` → `max`
74
44
  */
75
- export declare const parseLengthComparison: (node: TSESTree.Expression, sourceCode: TSESLint.SourceCode) => LengthComparison | undefined;
45
+ export declare const parseLengthComparison: (wrapped: TSESTree.Expression, sourceCode: TSESLint.SourceCode) => LengthComparison | undefined;
76
46
  /**
77
47
  * `true` when `node` is one operand of an `a && b` whose other operand is the
78
48
  * complementary length bound (`min` vs `max`) on the same array — i.e. the two
79
49
  * together form the `Arr.isBoundedLengthArray` pattern handled by
80
50
  * `prefer-arr-is-bounded-length-array`. The single-bound rules skip such
81
51
  * operands so the bounded rule rewrites the whole `&&` instead of the parts.
52
+ * A comparison wrapped as a whole (`(xs.length >= 1 satisfies boolean) && …`)
53
+ * is still the operand.
82
54
  */
83
55
  export declare const isPartOfBoundedLengthCheck: (node: TSESTree.BinaryExpression, sourceCode: TSESLint.SourceCode) => boolean;
56
+ /**
57
+ * Whether `node`, read through its type wrappers, is the identifier `name`:
58
+ * `Number`, `(Number as NumberConstructor)` and `Number!` are the same object.
59
+ */
60
+ export declare const isIdentifierNamed: (node: TSESTree.Node, name: string) => boolean;
61
+ /**
62
+ * Whether `holds` is true of the type of every layer of type wrappers around
63
+ * `node` (see {@link typeWrapperLayers}), outermost to innermost; `false`
64
+ * without type information. A widening cast (`s as string | number`) is the
65
+ * author saying the value may be more than it is, and is respected; a
66
+ * narrowing one (`s!`, `v as unknown as string`) cannot vouch for what the
67
+ * value's own type does not, and the fix, which keeps the wrapper, has to
68
+ * type-check at every layer too.
69
+ */
70
+ export declare const typeHoldsAtEveryLayer: (sourceCode: TSESLint.SourceCode, node: TSESTree.Node, holds: (type: ts.Type, typeChecker: ts.TypeChecker) => boolean) => boolean;
84
71
  export {};
85
72
  //# sourceMappingURL=ast-utils.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ast-utils.d.mts","sourceRoot":"","sources":["../../src/rules/ast-utils.mts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,QAAQ,EACd,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,QAAQ,CAAC,IAAI,QAChD,CAAC,KACN,CAAC,GAAG,QAAQ,CAAC,UACgD,CAAC;AAEjE;;;;;;;;;;;GAW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AAqB,YAEvB,QAAQ,CAAC,UAAU,cAEhB,QAAQ,CAAC,UAAU,KAC9B,gBAAgB,GAAG,SAuCrB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,0BAA0B,SAE/B,QAAQ,CAAC,gBAAgB,cAEnB,QAAQ,CAAC,UAAU,KAC9B,OA8BF,CAAC;AAuBF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,SAEtB,QAAQ,CAAC,IAAI,QACb,MAAM,KACX,OAMF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,eAEpB,QAAQ,CAAC,UAAU,QAEzB,QAAQ,CAAC,IAAI,SAEZ,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,EAAE,CAAC,WAAW,KAAK,OAAO,KAC7D,OAgBF,CAAC"}
@@ -1,37 +1,5 @@
1
- import { AST_NODE_TYPES, } from '@typescript-eslint/utils';
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
- export const skipTypeWrappers = (node) => isTypeWrapper(node) ? skipTypeWrappers(node.expression) : node;
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
- export const typeWrapperLayers = (node) => isTypeWrapper(node)
26
- ? [node, ...typeWrapperLayers(node.expression)]
27
- : [node];
28
- export const isTypeWrapper = (node) => TYPE_WRAPPERS.has(node.type);
29
- const TYPE_WRAPPERS = new Set([
30
- AST_NODE_TYPES.TSAsExpression,
31
- AST_NODE_TYPES.TSNonNullExpression,
32
- AST_NODE_TYPES.TSSatisfiesExpression,
33
- AST_NODE_TYPES.TSTypeAssertion,
34
- ]);
1
+ import { AST_NODE_TYPES, ASTUtils, } from '@typescript-eslint/utils';
2
+ import { isTypeWrapper, skipTypeWrappers, typeWrapperLayers, } from 'eslint-rule-forge';
35
3
  const isIntegerLiteral = (node) => node.type === AST_NODE_TYPES.Literal &&
36
4
  typeof node.value === 'number' &&
37
5
  Number.isInteger(node.value);
@@ -40,19 +8,6 @@ const isIntegerLiteral = (node) => node.type === AST_NODE_TYPES.Literal &&
40
8
 
41
9
 
42
10
 
43
- export const toArgumentText = (
44
-
45
- node,
46
-
47
- sourceCode) => {
48
- const text = sourceCode.getText(node);
49
- return node.type === AST_NODE_TYPES.SequenceExpression ? `(${text})` : text;
50
- };
51
-
52
-
53
-
54
-
55
-
56
11
 
57
12
  export const isArrayOrTupleExpression = (
58
13
 
@@ -93,8 +48,8 @@ sourceCode) => {
93
48
  }
94
49
 
95
50
  const scope = sourceCode.getScope(node);
96
- const variable = findVariable(scope, node.name);
97
- if (variable === undefined) {
51
+ const variable = ASTUtils.findVariable(scope, node.name);
52
+ if (variable === null) {
98
53
  return false;
99
54
  }
100
55
 
@@ -151,11 +106,13 @@ sourceCode) => sourceCode.getText(skipTypeWrappers(a)) ===
151
106
 
152
107
 
153
108
 
109
+
154
110
  export const parseLengthComparison = (
155
111
 
156
- node,
112
+ wrapped,
157
113
 
158
114
  sourceCode) => {
115
+ const node = skipTypeWrappers(wrapped);
159
116
  if (node.type !== AST_NODE_TYPES.BinaryExpression ||
160
117
  (node.operator !== '>=' && node.operator !== '<=')) {
161
118
  return undefined;
@@ -187,13 +144,16 @@ sourceCode) => {
187
144
 
188
145
 
189
146
 
147
+
148
+
190
149
  export const isPartOfBoundedLengthCheck = (
191
150
 
192
151
  node,
193
152
 
194
153
  sourceCode) => {
195
- const { parent } = node;
196
- if (parent.type !== AST_NODE_TYPES.LogicalExpression ||
154
+ const operand = outermostTypeWrapper(node);
155
+ const { parent } = operand;
156
+ if (parent?.type !== AST_NODE_TYPES.LogicalExpression ||
197
157
  parent.operator !== '&&') {
198
158
  return false;
199
159
  }
@@ -201,7 +161,7 @@ sourceCode) => {
201
161
  if (self === undefined) {
202
162
  return false;
203
163
  }
204
- const sibling = parent.left === node ? parent.right : parent.left;
164
+ const sibling = parent.left === operand ? parent.right : parent.left;
205
165
  const other = parseLengthComparison(sibling, sourceCode);
206
166
  if (other === undefined) {
207
167
  return false;
@@ -209,14 +169,49 @@ sourceCode) => {
209
169
  return (self.kind !== other.kind &&
210
170
  isSameArrayText(self.array, other.array, sourceCode));
211
171
  };
172
+
173
+ const outermostTypeWrapper = (
174
+
175
+ node) => node.parent !== undefined && isTypeWrapper(node.parent)
176
+ ? outermostTypeWrapper(node.parent)
177
+ : node;
212
178
  const isVariableDefinition = (
213
179
 
214
180
  def) => def.type === 'Variable';
215
- const findVariable = (
216
181
 
217
- scope, name) => {
218
- const variable = scope.set.get(name);
219
- return (variable ??
220
- (scope.upper === null ? undefined : findVariable(scope.upper, name)));
182
+
183
+
184
+
185
+ export const isIdentifierNamed = (
186
+
187
+ node, name) => {
188
+ const unwrapped = skipTypeWrappers(node);
189
+ return (unwrapped.type === AST_NODE_TYPES.Identifier && unwrapped.name === name);
190
+ };
191
+
192
+
193
+
194
+
195
+
196
+
197
+
198
+
199
+
200
+ export const typeHoldsAtEveryLayer = (
201
+
202
+ sourceCode,
203
+
204
+ node,
205
+
206
+ holds) => {
207
+ const services = sourceCode.parserServices;
208
+ const checker = services?.program?.getTypeChecker();
209
+ if (checker === undefined) {
210
+ return false;
211
+ }
212
+ return typeWrapperLayers(node).every((layer) => {
213
+ const tsNode = services?.esTreeNodeToTSNodeMap?.get(layer);
214
+ return (tsNode !== undefined && holds(checker.getTypeAtLocation(tsNode), checker));
215
+ });
221
216
  };
222
217
  //# sourceMappingURL=ast-utils.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ast-utils.mjs","sourceRoot":"","sources":["../../src/rules/ast-utils.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,GAGf,MAAM,0BAA0B,CAAC;AAGlC;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,IAAO,EACkB,EAAE,CAC3B,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IA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CAAC;IAE3C,MAAM,OAAO,GAAG,QAAQ,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC;IAEpD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QAC7C,MAAM,MAAM,GAAG,QAAQ,EAAE,qBAAqB,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;QAE3D,OAAO,CACL,MAAM,KAAK,SAAS,IAAI,KAAK,CAAC,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAC1E,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -1,2 +1,4 @@
1
1
  export declare const TS_DATA_FORGE_MODULE = "ts-data-forge";
2
+ /** The type flags of every primitive type but `void`. */
3
+ export declare const primitiveTypeFlags: number;
2
4
  //# sourceMappingURL=constants.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../../src/rules/constants.mts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,kBAAkB,CAAC"}
1
+ {"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../../src/rules/constants.mts"],"names":[],"mappings":"AAEA,eAAO,MAAM,oBAAoB,kBAAkB,CAAC;AAEpD,yDAAyD;AACzD,eAAO,MAAM,kBAAkB,QAOP,CAAC"}
@@ -1,2 +1,11 @@
1
+ import * as ts from 'typescript';
1
2
  export const TS_DATA_FORGE_MODULE = 'ts-data-forge';
3
+
4
+ export const primitiveTypeFlags = ts.TypeFlags.StringLike |
5
+ ts.TypeFlags.NumberLike |
6
+ ts.TypeFlags.BigIntLike |
7
+ ts.TypeFlags.BooleanLike |
8
+ ts.TypeFlags.ESSymbolLike |
9
+ ts.TypeFlags.Null |
10
+ ts.TypeFlags.Undefined;
2
11
  //# sourceMappingURL=constants.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../../src/rules/constants.mts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG,eAAe,CAAC"}
1
+ {"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../../src/rules/constants.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,MAAM,CAAC,MAAM,oBAAoB,GAAG,eAAe,CAAC;AAEpD,yDAAyD;AACzD,MAAM,CAAC,MAAM,kBAAkB,GAC7B,EAAE,CAAC,SAAS,CAAC,UAAU;IACvB,EAAE,CAAC,SAAS,CAAC,UAAU;IACvB,EAAE,CAAC,SAAS,CAAC,UAAU;IACvB,EAAE,CAAC,SAAS,CAAC,WAAW;IACxB,EAAE,CAAC,SAAS,CAAC,YAAY;IACzB,EAAE,CAAC,SAAS,CAAC,IAAI;IACjB,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { type TSESLint, type TSESTree } from '@typescript-eslint/utils';
2
+ import * as ts from 'typescript';
3
+ /**
4
+ * Whether the code around `node` visibly relies on the result being a mutable
5
+ * array, so that swapping in the readonly array `Arr.uniq` or `Arr.generate`
6
+ * returns would not compile. Looks at `node` itself and, when it initializes a variable without a
7
+ * type annotation, at every read of that variable.
8
+ */
9
+ export declare const needsMutableResult: (sourceCode: TSESLint.SourceCode, checker: ts.TypeChecker, getTsNode: (esNode: TSESTree.Node) => ts.Node | undefined, node: TSESTree.Node) => boolean;
10
+ //# sourceMappingURL=mutable-result.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mutable-result.d.mts","sourceRoot":"","sources":["../../src/rules/mutable-result.mts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,QAAQ,EACd,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAGjC;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,eAEjB,QAAQ,CAAC,UAAU,WAEtB,EAAE,CAAC,WAAW,aAEZ,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,KAAK,EAAE,CAAC,IAAI,GAAG,SAAS,QAEnD,QAAQ,CAAC,IAAI,KAClB,OA+BF,CAAC"}