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.
- package/README.md +20 -19
- package/dist/plugin.d.mts +2 -0
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +1 -0
- package/dist/plugin.mjs.map +1 -1
- package/dist/rule-types.d.mts +16 -1
- package/dist/rule-types.d.mts.map +1 -1
- package/dist/rule-types.mjs.map +1 -1
- package/dist/rules/ast-utils.d.mts +21 -34
- package/dist/rules/ast-utils.d.mts.map +1 -1
- package/dist/rules/ast-utils.mjs +53 -58
- package/dist/rules/ast-utils.mjs.map +1 -1
- package/dist/rules/constants.d.mts +2 -0
- package/dist/rules/constants.d.mts.map +1 -1
- package/dist/rules/constants.mjs +9 -0
- package/dist/rules/constants.mjs.map +1 -1
- package/dist/rules/mutable-result.d.mts +10 -0
- package/dist/rules/mutable-result.d.mts.map +1 -0
- package/dist/rules/mutable-result.mjs +145 -0
- package/dist/rules/mutable-result.mjs.map +1 -0
- package/dist/rules/no-unnecessary-type-guard.d.mts.map +1 -1
- package/dist/rules/no-unnecessary-type-guard.mjs +6 -6
- package/dist/rules/no-unnecessary-type-guard.mjs.map +1 -1
- package/dist/rules/prefer-arr-generate.d.mts +57 -0
- package/dist/rules/prefer-arr-generate.d.mts.map +1 -0
- package/dist/rules/prefer-arr-generate.mjs +588 -0
- package/dist/rules/prefer-arr-generate.mjs.map +1 -0
- package/dist/rules/prefer-arr-is-array.d.mts.map +1 -1
- package/dist/rules/prefer-arr-is-array.mjs +7 -5
- package/dist/rules/prefer-arr-is-array.mjs.map +1 -1
- package/dist/rules/prefer-arr-is-bounded-length-array.d.mts.map +1 -1
- package/dist/rules/prefer-arr-is-bounded-length-array.mjs +9 -6
- package/dist/rules/prefer-arr-is-bounded-length-array.mjs.map +1 -1
- package/dist/rules/prefer-arr-is-fixed-length-array.d.mts.map +1 -1
- package/dist/rules/prefer-arr-is-fixed-length-array.mjs +9 -6
- package/dist/rules/prefer-arr-is-fixed-length-array.mjs.map +1 -1
- package/dist/rules/prefer-arr-is-max-length-array.d.mts.map +1 -1
- package/dist/rules/prefer-arr-is-max-length-array.mjs +9 -6
- package/dist/rules/prefer-arr-is-max-length-array.mjs.map +1 -1
- package/dist/rules/prefer-arr-is-min-length-array.d.mts.map +1 -1
- package/dist/rules/prefer-arr-is-min-length-array.mjs +9 -6
- package/dist/rules/prefer-arr-is-min-length-array.mjs.map +1 -1
- package/dist/rules/prefer-arr-is-non-empty.d.mts.map +1 -1
- package/dist/rules/prefer-arr-is-non-empty.mjs +9 -6
- package/dist/rules/prefer-arr-is-non-empty.mjs.map +1 -1
- package/dist/rules/prefer-arr-scan.d.mts.map +1 -1
- package/dist/rules/prefer-arr-scan.mjs +8 -11
- package/dist/rules/prefer-arr-scan.mjs.map +1 -1
- package/dist/rules/prefer-arr-sum.d.mts.map +1 -1
- package/dist/rules/prefer-arr-sum.mjs +8 -6
- package/dist/rules/prefer-arr-sum.mjs.map +1 -1
- package/dist/rules/prefer-arr-uniq.d.mts.map +1 -1
- package/dist/rules/prefer-arr-uniq.mjs +12 -166
- package/dist/rules/prefer-arr-uniq.mjs.map +1 -1
- package/dist/rules/prefer-as-int.d.mts.map +1 -1
- package/dist/rules/prefer-as-int.mjs +6 -8
- package/dist/rules/prefer-as-int.mjs.map +1 -1
- package/dist/rules/prefer-canonical-array-slicing.d.mts.map +1 -1
- package/dist/rules/prefer-canonical-array-slicing.mjs +57 -34
- package/dist/rules/prefer-canonical-array-slicing.mjs.map +1 -1
- package/dist/rules/prefer-canonical-length-cast.d.mts.map +1 -1
- package/dist/rules/prefer-canonical-length-cast.mjs +3 -3
- package/dist/rules/prefer-canonical-length-cast.mjs.map +1 -1
- package/dist/rules/prefer-canonical-length-guard.d.mts.map +1 -1
- package/dist/rules/prefer-canonical-length-guard.mjs +4 -4
- package/dist/rules/prefer-canonical-length-guard.mjs.map +1 -1
- package/dist/rules/prefer-comparison-over-nullish-guard.d.mts.map +1 -1
- package/dist/rules/prefer-comparison-over-nullish-guard.mjs +3 -2
- package/dist/rules/prefer-comparison-over-nullish-guard.mjs.map +1 -1
- package/dist/rules/prefer-is-non-null-object.d.mts.map +1 -1
- package/dist/rules/prefer-is-non-null-object.mjs +113 -43
- package/dist/rules/prefer-is-non-null-object.mjs.map +1 -1
- package/dist/rules/prefer-is-record-and-has-key.d.mts.map +1 -1
- package/dist/rules/prefer-is-record-and-has-key.mjs +105 -48
- package/dist/rules/prefer-is-record-and-has-key.mjs.map +1 -1
- package/dist/rules/prefer-num-safe-parse-float.d.mts.map +1 -1
- package/dist/rules/prefer-num-safe-parse-float.mjs +6 -6
- package/dist/rules/prefer-num-safe-parse-float.mjs.map +1 -1
- package/dist/rules/prefer-num-safe-parse-int.d.mts.map +1 -1
- package/dist/rules/prefer-num-safe-parse-int.mjs +6 -6
- package/dist/rules/prefer-num-safe-parse-int.mjs.map +1 -1
- package/dist/rules/prefer-obj-over-entries-round-trip.d.mts.map +1 -1
- package/dist/rules/prefer-obj-over-entries-round-trip.mjs +9 -12
- package/dist/rules/prefer-obj-over-entries-round-trip.mjs.map +1 -1
- package/dist/rules/prefer-range-for-loop.d.mts.map +1 -1
- package/dist/rules/prefer-range-for-loop.mjs +104 -23
- package/dist/rules/prefer-range-for-loop.mjs.map +1 -1
- package/dist/rules/rules.d.mts +1 -0
- package/dist/rules/rules.d.mts.map +1 -1
- package/dist/rules/rules.mjs +2 -0
- package/dist/rules/rules.mjs.map +1 -1
- package/package.json +11 -10
- package/src/plugin.mts +1 -0
- package/src/rule-types.mts +17 -1
- package/src/rules/ast-utils.mts +73 -80
- package/src/rules/constants.mts +12 -0
- package/src/rules/mutable-result.mts +204 -0
- package/src/rules/no-unnecessary-type-guard.mts +14 -10
- package/src/rules/prefer-arr-generate.mts +918 -0
- package/src/rules/prefer-arr-generate.test.mts +967 -0
- package/src/rules/prefer-arr-is-array.mts +14 -7
- package/src/rules/prefer-arr-is-array.test.mts +14 -0
- package/src/rules/prefer-arr-is-bounded-length-array.mts +16 -10
- package/src/rules/prefer-arr-is-bounded-length-array.test.mts +19 -0
- package/src/rules/prefer-arr-is-fixed-length-array.mts +17 -11
- package/src/rules/prefer-arr-is-max-length-array.mts +17 -11
- package/src/rules/prefer-arr-is-max-length-array.test.mts +8 -0
- package/src/rules/prefer-arr-is-min-length-array.mts +17 -11
- package/src/rules/prefer-arr-is-min-length-array.test.mts +8 -0
- package/src/rules/prefer-arr-is-non-empty.mts +16 -13
- package/src/rules/prefer-arr-scan.mts +24 -19
- package/src/rules/prefer-arr-sum.mts +18 -14
- package/src/rules/prefer-arr-uniq.mts +25 -234
- package/src/rules/prefer-as-int.mts +19 -12
- package/src/rules/prefer-canonical-array-slicing.mts +79 -52
- package/src/rules/prefer-canonical-array-slicing.test.mts +55 -0
- package/src/rules/prefer-canonical-length-cast.mts +7 -3
- package/src/rules/prefer-canonical-length-guard.mts +9 -4
- package/src/rules/prefer-comparison-over-nullish-guard.mts +3 -2
- package/src/rules/prefer-comparison-over-nullish-guard.test.mts +16 -0
- package/src/rules/prefer-is-non-null-object.mts +171 -64
- package/src/rules/prefer-is-non-null-object.test.mts +138 -0
- package/src/rules/prefer-is-record-and-has-key.mts +159 -74
- package/src/rules/prefer-is-record-and-has-key.test.mts +118 -23
- package/src/rules/prefer-num-safe-parse-float.mts +15 -10
- package/src/rules/prefer-num-safe-parse-int.mts +15 -13
- package/src/rules/prefer-obj-over-entries-round-trip.mts +19 -22
- package/src/rules/prefer-range-for-loop.mts +157 -31
- package/src/rules/prefer-range-for-loop.test.mts +127 -5
- package/src/rules/rules.mts +2 -0
- package/dist/rules/import-utils.d.mts +0 -30
- package/dist/rules/import-utils.d.mts.map +0 -1
- package/dist/rules/import-utils.mjs +0 -98
- package/dist/rules/import-utils.mjs.map +0 -1
- 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-
|
|
75
|
-
| `prefer-arr-
|
|
76
|
-
| `prefer-arr-
|
|
77
|
-
| `prefer-arr-
|
|
78
|
-
| `prefer-
|
|
79
|
-
| `prefer-
|
|
80
|
-
| `prefer-
|
|
81
|
-
| `prefer-
|
|
82
|
-
| `prefer-
|
|
83
|
-
| `prefer-num-safe-parse-
|
|
84
|
-
| `
|
|
85
|
-
| `
|
|
86
|
-
| `prefer-
|
|
87
|
-
| `
|
|
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';
|
package/dist/plugin.d.mts.map
CHANGED
|
@@ -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;
|
|
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',
|
package/dist/plugin.mjs.map
CHANGED
|
@@ -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,wEA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D,KAAK,EAAE,gBAAgB;CACY,CAAC;AAEtC,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,IAAI,EAAE;QACJ,IAAI,EAAE,6BAA6B;KACpC;IACD,KAAK,EAAE,gBAAgB;IACvB,OAAO,EAAE;QACP,oDAAoD;QACpD,WAAW,EAAE,iBAAiB;KAC/B;CAC8B,CAAC"}
|
package/dist/rule-types.d.mts
CHANGED
|
@@ -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
|
|
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
|
'ts-data-forge/prefer-arr-sum': PreferArrSum.RuleEntry;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule-types.d.mts","sourceRoot":"","sources":["../src/rule-types.mts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,KAAK,sBAAsB,CACzB,CAAC,SAAS,SAAS,CAAC,MAAM,CAAC,cAAc,EAAE,OAAO,CAAC,IACjD,CAAC,CAAC,CAAC,CAAC,SAAS,SAAS,OAAO,EAAE,GAC/B,SAAS,CAAC,MAAM,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GACzC,CAAC,CAAC;AAEN;;;;GAIG;AACH,KAAK,aAAa,CAAC,IAAI,SAAS,MAAM,OAAO,gBAAgB,IAC3D,CAAC,OAAO,gBAAgB,CAAC,CAAC,IAAI,CAAC,SAAS,QAAQ,CAAC,UAAU,CACzD,MAAM,WAAW,SAAS,MAAM,EAChC,MAAM,OAAO,SAAS,SAAS,OAAO,EAAE,CACzC,GACG,OAAO,GACP,KAAK,CAAC;AAEZ;;;;;;;;;;GAUG;AACH,kBAAU,2BAA2B,CAAC;IACpC,KAAY,SAAS,GAAG,MAAM,CAAC,c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AqB,CAAC,SAAS,CAAC;IAC3E,qCAAqC,EAAE,kBAAkB,CAAC,SAAS,CAAC;IACpE,4CAA4C,EAAE,uBAAuB,CAAC,SAAS,CAAC;IAChF,yCAAyC,EAAE,qBAAqB,CAAC,SAAS,CAAC;IAC3E,2CAA2C,EAAE,uBAAuB,CAAC,SAAS,CAAC;IAC/E,qCAAqC,EAAE,kBAAkB,CAAC,SAAS,CAAC;IACpE,yCAAyC,EAAE,sBAAsB,CAAC,SAAS,CAAC;IAC5E,oDAAoD,EAAE,gCAAgC,CAAC,SAAS,CAAC;IACjG,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"}
|
package/dist/rule-types.mjs.map
CHANGED
|
@@ -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;
|
|
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
|
|
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: (
|
|
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,
|
|
1
|
+
{"version":3,"file":"ast-utils.d.mts","sourceRoot":"","sources":["../../src/rules/ast-utils.mts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,QAAQ,EACb,KAAK,QAAQ,EACd,MAAM,0BAA0B,CAAC;AAMlC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAOtC;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,aAEzB,QAAQ,CAAC,UAAU,CAAC,gBAAgB,CAAC,QAEzC,QAAQ,CAAC,UAAU,KACxB,OAkBF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,0BAA0B,SAC/B,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,cAE3B,QAAQ,CAAC,UAAU,KAC9B,OA0CF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,SAEnB,QAAQ,CAAC,UAAU,KACxB,QAAQ,CAAC,gBAAgB,GAAG,SAS9B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,MAEvB,QAAQ,CAAC,UAAU,KAEnB,QAAQ,CAAC,UAAU,cAEV,QAAQ,CAAC,UAAU,KAC9B,OAEsC,CAAC;AAE1C,KAAK,gBAAgB,GAAG,QAAQ,CAAC;IAC/B,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC;IAC3B,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC;IAC3B,IAAI,EAAE,KAAK,GAAG,KAAK,CAAC;CACrB,CAAC,CAAC;AAEH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,qBAAqB,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"}
|
package/dist/rules/ast-utils.mjs
CHANGED
|
@@ -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 ===
|
|
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
|
-
|
|
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
|
|
196
|
-
|
|
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 ===
|
|
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
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
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":[],"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AQ,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../../src/rules/constants.mts"],"names":[],"mappings":"
|
|
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"}
|
package/dist/rules/constants.mjs
CHANGED
|
@@ -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"}
|