eslint-plugin-ts-data-forge 0.10.2 → 0.10.4
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/dist/rules/mutable-result.mjs.map +1 -1
- package/dist/rules/no-unnecessary-type-guard.mjs +1 -1
- package/dist/rules/no-unnecessary-type-guard.mjs.map +1 -1
- package/dist/rules/prefer-arr-generate.mjs +1 -1
- package/dist/rules/prefer-arr-generate.mjs.map +1 -1
- package/dist/rules/prefer-arr-is-bounded-length-array.mjs +1 -1
- package/dist/rules/prefer-arr-is-bounded-length-array.mjs.map +1 -1
- package/dist/rules/prefer-arr-is-fixed-length-array.mjs +1 -1
- package/dist/rules/prefer-arr-is-fixed-length-array.mjs.map +1 -1
- package/dist/rules/prefer-arr-is-max-length-array.mjs +1 -1
- package/dist/rules/prefer-arr-is-max-length-array.mjs.map +1 -1
- package/dist/rules/prefer-arr-is-min-length-array.mjs +1 -1
- package/dist/rules/prefer-arr-is-min-length-array.mjs.map +1 -1
- package/dist/rules/prefer-arr-is-non-empty.mjs +1 -1
- 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 +5 -2
- package/dist/rules/prefer-arr-scan.mjs.map +1 -1
- package/dist/rules/prefer-arr-sum.mjs +1 -1
- package/dist/rules/prefer-arr-sum.mjs.map +1 -1
- package/dist/rules/prefer-arr-uniq.mjs +1 -1
- package/dist/rules/prefer-arr-uniq.mjs.map +1 -1
- package/dist/rules/prefer-as-int.mjs +1 -1
- package/dist/rules/prefer-as-int.mjs.map +1 -1
- package/dist/rules/prefer-canonical-array-slicing.mjs +1 -1
- package/dist/rules/prefer-canonical-array-slicing.mjs.map +1 -1
- package/dist/rules/prefer-canonical-length-cast.mjs +1 -1
- package/dist/rules/prefer-canonical-length-cast.mjs.map +1 -1
- package/dist/rules/prefer-canonical-length-guard.mjs +1 -1
- package/dist/rules/prefer-canonical-length-guard.mjs.map +1 -1
- package/dist/rules/prefer-comparison-over-nullish-guard.mjs +1 -1
- package/dist/rules/prefer-comparison-over-nullish-guard.mjs.map +1 -1
- package/dist/rules/prefer-obj-over-entries-round-trip.mjs +1 -1
- package/dist/rules/prefer-obj-over-entries-round-trip.mjs.map +1 -1
- package/dist/rules/prefer-pipe-map-nullable.mjs +1 -1
- package/dist/rules/prefer-pipe-map-nullable.mjs.map +1 -1
- package/dist/rules/prefer-range-for-loop.mjs +1 -1
- package/dist/rules/prefer-range-for-loop.mjs.map +1 -1
- package/package.json +10 -10
- package/src/rules/mutable-result.mts +1 -1
- package/src/rules/no-unnecessary-type-guard.mts +1 -1
- package/src/rules/prefer-arr-generate.mts +1 -1
- package/src/rules/prefer-arr-is-bounded-length-array.mts +1 -1
- package/src/rules/prefer-arr-is-fixed-length-array.mts +1 -1
- package/src/rules/prefer-arr-is-max-length-array.mts +1 -1
- package/src/rules/prefer-arr-is-min-length-array.mts +1 -1
- package/src/rules/prefer-arr-is-non-empty.mts +1 -1
- package/src/rules/prefer-arr-scan.mts +5 -2
- package/src/rules/prefer-arr-sum.mts +1 -1
- package/src/rules/prefer-arr-uniq.mts +1 -1
- package/src/rules/prefer-as-int.mts +1 -1
- package/src/rules/prefer-canonical-array-slicing.mts +2 -2
- package/src/rules/prefer-canonical-length-cast.mts +1 -1
- package/src/rules/prefer-canonical-length-guard.mts +1 -1
- package/src/rules/prefer-comparison-over-nullish-guard.mts +3 -3
- package/src/rules/prefer-obj-over-entries-round-trip.mts +1 -1
- package/src/rules/prefer-pipe-map-nullable.mts +2 -2
- package/src/rules/prefer-range-for-loop.mts +1 -1
|
@@ -33,6 +33,7 @@ export const preferArrSum: TSESLint.RuleModule<MessageIds, Options> = {
|
|
|
33
33
|
useArrSumBy:
|
|
34
34
|
'Replace with `Arr.sumBy({{arrayName}}, {{mapper}})` from ts-data-forge.',
|
|
35
35
|
},
|
|
36
|
+
defaultOptions: [],
|
|
36
37
|
},
|
|
37
38
|
|
|
38
39
|
create: (context) => {
|
|
@@ -306,5 +307,4 @@ export const preferArrSum: TSESLint.RuleModule<MessageIds, Options> = {
|
|
|
306
307
|
},
|
|
307
308
|
};
|
|
308
309
|
},
|
|
309
|
-
defaultOptions: [],
|
|
310
310
|
} as const;
|
|
@@ -45,6 +45,7 @@ export const preferArrUniq: TSESLint.RuleModule<MessageIds, Options> = {
|
|
|
45
45
|
suggestArrUniq:
|
|
46
46
|
'Replace with `Arr.uniq({{arrayName}})` from ts-data-forge (the result becomes a readonly array).',
|
|
47
47
|
},
|
|
48
|
+
defaultOptions: [],
|
|
48
49
|
},
|
|
49
50
|
|
|
50
51
|
create: (context) => {
|
|
@@ -213,7 +214,6 @@ export const preferArrUniq: TSESLint.RuleModule<MessageIds, Options> = {
|
|
|
213
214
|
},
|
|
214
215
|
};
|
|
215
216
|
},
|
|
216
|
-
defaultOptions: [],
|
|
217
217
|
} as const;
|
|
218
218
|
|
|
219
219
|
/**
|
|
@@ -30,6 +30,7 @@ export const preferAsInt: TSESLint.RuleModule<MessageIds, Options> = {
|
|
|
30
30
|
useBrandedNumberCastFunction:
|
|
31
31
|
'Replace `as {{typeName}}` with `{{functionName}}()` from ts-data-forge.',
|
|
32
32
|
},
|
|
33
|
+
defaultOptions: [],
|
|
33
34
|
},
|
|
34
35
|
|
|
35
36
|
create: (context) => {
|
|
@@ -112,7 +113,6 @@ export const preferAsInt: TSESLint.RuleModule<MessageIds, Options> = {
|
|
|
112
113
|
},
|
|
113
114
|
};
|
|
114
115
|
},
|
|
115
|
-
defaultOptions: [],
|
|
116
116
|
} as const;
|
|
117
117
|
|
|
118
118
|
const getBrandedNumberTypeInfo = (
|
|
@@ -113,7 +113,7 @@ const rootIdentifierName = (wrapped: TSESTree.Node): string | undefined => {
|
|
|
113
113
|
|
|
114
114
|
type ComparisonOperator = '!==' | '<' | '<=' | '>' | '>=';
|
|
115
115
|
|
|
116
|
-
const COMPARISON_OPERATORS: ReadonlySet<string> = new Set([
|
|
116
|
+
const COMPARISON_OPERATORS: ReadonlySet<string> = new Set<string>([
|
|
117
117
|
'!==',
|
|
118
118
|
'<',
|
|
119
119
|
'<=',
|
|
@@ -192,6 +192,7 @@ export const preferCanonicalArraySlicing: TSESLint.RuleModule<
|
|
|
192
192
|
preferCanonicalArraySlicing:
|
|
193
193
|
'Replace with `{{replacement}}` from ts-data-forge.',
|
|
194
194
|
},
|
|
195
|
+
defaultOptions: [],
|
|
195
196
|
},
|
|
196
197
|
|
|
197
198
|
create: (context) => {
|
|
@@ -877,5 +878,4 @@ export const preferCanonicalArraySlicing: TSESLint.RuleModule<
|
|
|
877
878
|
},
|
|
878
879
|
};
|
|
879
880
|
},
|
|
880
|
-
defaultOptions: [],
|
|
881
881
|
} as const;
|
|
@@ -141,6 +141,7 @@ export const preferCanonicalLengthCast: TSESLint.RuleModule<
|
|
|
141
141
|
useCanonicalCast:
|
|
142
142
|
'Use `{{arrName}}.{{replacement}}(...)` instead of `{{arrName}}.{{cast}}({{boundsText}})`: with these bounds the result type is the same (or stricter), and `{{replacement}}` names the constraint directly.',
|
|
143
143
|
},
|
|
144
|
+
defaultOptions: [],
|
|
144
145
|
},
|
|
145
146
|
|
|
146
147
|
create: (context) => {
|
|
@@ -197,7 +198,6 @@ export const preferCanonicalLengthCast: TSESLint.RuleModule<
|
|
|
197
198
|
},
|
|
198
199
|
};
|
|
199
200
|
},
|
|
200
|
-
defaultOptions: [],
|
|
201
201
|
} as const;
|
|
202
202
|
|
|
203
203
|
/** The `Arr.<cast>` method name of `node`, or `undefined` for other calls. */
|
|
@@ -116,6 +116,7 @@ export const preferCanonicalLengthGuard: TSESLint.RuleModule<
|
|
|
116
116
|
fixable: 'code',
|
|
117
117
|
schema: [],
|
|
118
118
|
messages: MESSAGES,
|
|
119
|
+
defaultOptions: [],
|
|
119
120
|
},
|
|
120
121
|
|
|
121
122
|
create: (context) => {
|
|
@@ -180,7 +181,6 @@ export const preferCanonicalLengthGuard: TSESLint.RuleModule<
|
|
|
180
181
|
},
|
|
181
182
|
]);
|
|
182
183
|
},
|
|
183
|
-
defaultOptions: [],
|
|
184
184
|
} as const;
|
|
185
185
|
|
|
186
186
|
/**
|
|
@@ -36,7 +36,7 @@ const COMPARISON_GUARDS: ReadonlyRecord<string, ComparisonSpec> = {
|
|
|
36
36
|
* intended, but are parenthesized so that the type or the grouping is not read
|
|
37
37
|
* as part of the comparison.
|
|
38
38
|
*/
|
|
39
|
-
const ARG_NEEDS_PARENS: ReadonlySet<string> = new Set([
|
|
39
|
+
const ARG_NEEDS_PARENS: ReadonlySet<string> = new Set<string>([
|
|
40
40
|
AST_NODE_TYPES.LogicalExpression,
|
|
41
41
|
AST_NODE_TYPES.ConditionalExpression,
|
|
42
42
|
AST_NODE_TYPES.AssignmentExpression,
|
|
@@ -48,7 +48,7 @@ const ARG_NEEDS_PARENS: ReadonlySet<string> = new Set([
|
|
|
48
48
|
]);
|
|
49
49
|
|
|
50
50
|
/** Binary operators that bind no tighter than `===` / `!==`. */
|
|
51
|
-
const LOOSE_BINARY_OPERATORS: ReadonlySet<string> = new Set([
|
|
51
|
+
const LOOSE_BINARY_OPERATORS: ReadonlySet<string> = new Set<string>([
|
|
52
52
|
'|',
|
|
53
53
|
'^',
|
|
54
54
|
'&',
|
|
@@ -116,6 +116,7 @@ export const preferComparisonOverNullishGuard: TSESLint.RuleModule<
|
|
|
116
116
|
preferComparison:
|
|
117
117
|
'Prefer `{{comparison}}` over calling `{{name}}` with an explicit argument.',
|
|
118
118
|
},
|
|
119
|
+
defaultOptions: [],
|
|
119
120
|
},
|
|
120
121
|
|
|
121
122
|
create: (context) => {
|
|
@@ -171,5 +172,4 @@ export const preferComparisonOverNullishGuard: TSESLint.RuleModule<
|
|
|
171
172
|
},
|
|
172
173
|
};
|
|
173
174
|
},
|
|
174
|
-
defaultOptions: [],
|
|
175
175
|
} as const;
|
|
@@ -86,6 +86,7 @@ export const preferObjOverEntriesRoundTrip: TSESLint.RuleModule<
|
|
|
86
86
|
useObjFilterMap:
|
|
87
87
|
'Replace this `Object.fromEntries(Object.entries(…).flatMap(…))` round trip with `Obj.filterMap` from ts-data-forge, which keeps the key types of the record in the result type.',
|
|
88
88
|
},
|
|
89
|
+
defaultOptions: [],
|
|
89
90
|
},
|
|
90
91
|
|
|
91
92
|
create: (context) => {
|
|
@@ -218,7 +219,6 @@ export const preferObjOverEntriesRoundTrip: TSESLint.RuleModule<
|
|
|
218
219
|
},
|
|
219
220
|
};
|
|
220
221
|
},
|
|
221
|
-
defaultOptions: [],
|
|
222
222
|
} as const;
|
|
223
223
|
|
|
224
224
|
/**
|
|
@@ -53,6 +53,7 @@ export const preferPipeMapNullable: TSESLint.RuleModule<MessageIds, Options> = {
|
|
|
53
53
|
suggestMapNullable:
|
|
54
54
|
'Replace `.map({{mapNullableName}}(…))` with `.mapNullable(…)` (the inferred type may be widened, or a comment or type assertion dropped).',
|
|
55
55
|
},
|
|
56
|
+
defaultOptions: [],
|
|
56
57
|
},
|
|
57
58
|
|
|
58
59
|
create: (context) => {
|
|
@@ -283,7 +284,6 @@ export const preferPipeMapNullable: TSESLint.RuleModule<MessageIds, Options> = {
|
|
|
283
284
|
},
|
|
284
285
|
};
|
|
285
286
|
},
|
|
286
|
-
defaultOptions: [],
|
|
287
287
|
} as const;
|
|
288
288
|
|
|
289
289
|
/**
|
|
@@ -294,7 +294,7 @@ export const preferPipeMapNullable: TSESLint.RuleModule<MessageIds, Options> = {
|
|
|
294
294
|
const PIPE_MODULES = [TS_DATA_FORGE_MODULE, 'ts-std-forge'] as const;
|
|
295
295
|
|
|
296
296
|
/** The methods of a `Pipe` that return another `Pipe`. */
|
|
297
|
-
const PIPE_CHAIN_METHODS: ReadonlySet<string> = new Set([
|
|
297
|
+
const PIPE_CHAIN_METHODS: ReadonlySet<string> = new Set<string>([
|
|
298
298
|
'map',
|
|
299
299
|
'mapNullable',
|
|
300
300
|
'mapOptional',
|
|
@@ -31,6 +31,7 @@ export const preferRangeForLoop: TSESLint.RuleModule<MessageIds, Options> = {
|
|
|
31
31
|
useRangeForLoop:
|
|
32
32
|
'Replace with `for (const {{varName}} of range({{begin}}, {{end}}))` from ts-data-forge.',
|
|
33
33
|
},
|
|
34
|
+
defaultOptions: [],
|
|
34
35
|
},
|
|
35
36
|
|
|
36
37
|
create: (context) => {
|
|
@@ -262,7 +263,6 @@ export const preferRangeForLoop: TSESLint.RuleModule<MessageIds, Options> = {
|
|
|
262
263
|
},
|
|
263
264
|
};
|
|
264
265
|
},
|
|
265
|
-
defaultOptions: [],
|
|
266
266
|
} as const;
|
|
267
267
|
|
|
268
268
|
const isNegatedLiteral = (
|