Skip to content

Commit 1db02c1

Browse files
committed
chore: pr feedback
1 parent bfd359e commit 1db02c1

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

src/rules/prefer-slice-over-split-index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type {
22
CallExpression,
33
Expression,
4-
Literal,
54
MemberExpression,
65
SpreadElement
76
} from 'estree';
@@ -24,7 +23,7 @@ function isSupportedLimit(
2423
): boolean {
2524
if (!limit) return true;
2625
if (limit.type !== 'Literal') return false;
27-
const {value} = limit as Literal;
26+
const {value} = limit;
2827
return typeof value === 'number' && Number.isInteger(value) && value > index;
2928
}
3029

@@ -54,9 +53,9 @@ export const preferSliceOverSplitIndex: Rule.RuleModule = {
5453
schema: [],
5554
messages: {
5655
preferSliceFirst:
57-
'Prefer indexOf()+slice() over split(separator)[0] for string separators; split allocates an intermediate array. Preserve the missing-separator fallback explicitly.',
56+
'Prefer `indexOf(needle)` and `slice(0, index)` over `split(needle)[0]` for string separators. `split` will allocate an intermediate array, resulting in poorer performance. Preserve the missing-separator fallback explicitly.',
5857
preferSliceSecond:
59-
'Prefer indexOf()+slice() over split(separator)[1] for string separators; split allocates an intermediate array. Preserve missing and repeated-separator behavior explicitly.'
58+
'Prefer `indexOf(needle)` and `slice(index)` over `split(needle)[1]` for string separators. `split` will allocate an intermediate array, resulting in poorer performance. Preserve the missing-separator fallback explicitly.'
6059
}
6160
},
6261
create(context) {

0 commit comments

Comments
 (0)