1
- use std:: collections:: HashSet ;
2
-
3
1
use oxc_ast:: AstKind ;
4
2
use oxc_diagnostics:: OxcDiagnostic ;
5
3
use oxc_macros:: declare_oxc_lint;
6
4
use oxc_semantic:: { AstNode , NodeId } ;
7
5
use oxc_span:: { GetSpan , Span } ;
6
+ use rustc_hash:: FxHashSet ;
8
7
9
8
use crate :: {
10
9
context:: LintContext ,
@@ -70,15 +69,15 @@ declare_oxc_lint!(
70
69
71
70
impl Rule for PreferEach {
72
71
fn run_once ( & self , ctx : & LintContext < ' _ > ) {
73
- let mut skip = HashSet :: < NodeId > :: new ( ) ;
72
+ let mut skip = FxHashSet :: < NodeId > :: default ( ) ;
74
73
ctx. nodes ( ) . iter ( ) . for_each ( |node| {
75
74
Self :: run ( node, ctx, & mut skip) ;
76
75
} ) ;
77
76
}
78
77
}
79
78
80
79
impl PreferEach {
81
- fn run < ' a > ( node : & AstNode < ' a > , ctx : & LintContext < ' a > , skip : & mut HashSet < NodeId > ) {
80
+ fn run < ' a > ( node : & AstNode < ' a > , ctx : & LintContext < ' a > , skip : & mut FxHashSet < NodeId > ) {
82
81
let kind = node. kind ( ) ;
83
82
84
83
let AstKind :: CallExpression ( call_expr) = kind else { return } ;
@@ -164,7 +163,7 @@ fn test() {
164
163
});"# ,
165
164
r#"it("only returns numbers that are greater than seven", function () {
166
165
const numbers = getNumbers();
167
-
166
+
168
167
for (let i = 0; i < numbers.length; i++) {
169
168
expect(numbers[i]).toBeGreaterThan(7);
170
169
}
@@ -191,7 +190,7 @@ fn test() {
191
190
});
192
191
});
193
192
}
194
-
193
+
195
194
for (const [input, expected] of data) {
196
195
it.skip(`results in ${expected}`, () => {
197
196
expect(fn(input)).toBe(expected)
@@ -205,7 +204,7 @@ fn test() {
205
204
"it('is true', () => {
206
205
expect(true).toBe(false);
207
206
});
208
-
207
+
209
208
for (const [input, expected] of data) {
210
209
it.skip(`results in ${expected}`, () => {
211
210
expect(fn(input)).toBe(expected)
@@ -216,28 +215,28 @@ fn test() {
216
215
expect(fn(input)).toBe(expected)
217
216
});
218
217
}
219
-
218
+
220
219
it('is true', () => {
221
220
expect(true).toBe(false);
222
221
});" ,
223
222
" it('is true', () => {
224
223
expect(true).toBe(false);
225
224
});
226
-
225
+
227
226
for (const [input, expected] of data) {
228
227
it.skip(`results in ${expected}`, () => {
229
228
expect(fn(input)).toBe(expected)
230
229
});
231
230
}
232
-
231
+
233
232
it('is true', () => {
234
233
expect(true).toBe(false);
235
234
});" ,
236
235
"for (const [input, expected] of data) {
237
236
it(`results in ${expected}`, () => {
238
237
expect(fn(input)).toBe(expected)
239
238
});
240
-
239
+
241
240
it(`results in ${expected}`, () => {
242
241
expect(fn(input)).toBe(expected)
243
242
});
@@ -247,15 +246,15 @@ fn test() {
247
246
expect(fn(input)).toBe(expected)
248
247
});
249
248
}
250
-
249
+
251
250
for (const [input, expected] of data) {
252
251
it(`results in ${expected}`, () => {
253
252
expect(fn(input)).toBe(expected)
254
253
});
255
254
}" ,
256
255
"for (const [input, expected] of data) {
257
256
beforeEach(() => setupSomething(input));
258
-
257
+
259
258
test(`results in ${expected}`, () => {
260
259
expect(doSomething()).toBe(expected)
261
260
});
@@ -264,7 +263,7 @@ fn test() {
264
263
for (const [input, expected] of data) {
265
264
it("only returns numbers that are greater than seven", function () {
266
265
const numbers = getNumbers(input);
267
-
266
+
268
267
for (let i = 0; i < numbers.length; i++) {
269
268
expect(numbers[i]).toBeGreaterThan(7);
270
269
}
@@ -274,10 +273,10 @@ fn test() {
274
273
r#"
275
274
for (const [input, expected] of data) {
276
275
beforeEach(() => setupSomething(input));
277
-
276
+
278
277
it("only returns numbers that are greater than seven", function () {
279
278
const numbers = getNumbers();
280
-
279
+
281
280
for (let i = 0; i < numbers.length; i++) {
282
281
expect(numbers[i]).toBeGreaterThan(7);
283
282
}
0 commit comments