Skip to content

Commit d286dbc

Browse files
authored
prefer-prototype-methods: Add tests for new methods (#1898)
1 parent a10e3f6 commit d286dbc

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

test/prefer-prototype-methods.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ test.snapshot({
3232
'foo.bar.bind(foo)',
3333
'foo.bar.bind(bar)',
3434
'foo[{}].call(bar)',
35+
'Object.hasOwn(bar)',
3536
],
3637
invalid: [
3738
'const foo = [].push.apply(bar, elements);',
@@ -55,5 +56,7 @@ test.snapshot({
5556
'Reflect.apply([][Symbol()], baz, [])',
5657
'Reflect.apply({}[Symbol("symbol description")], baz, [])',
5758
'[][Symbol.iterator].call(foo)',
59+
'const foo = [].at.call(bar)',
60+
'const foo = [].findLast.call(bar)',
5861
],
5962
});

test/snapshots/prefer-prototype-methods.mjs.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,3 +339,35 @@ Generated by [AVA](https://avajs.dev).
339339
> 1 | [][Symbol.iterator].call(foo)␊
340340
| ^^^^^^^^^^^^^^^^^^^ Prefer using \`Array.prototype.Symbol(Symbol.iterator)\`.␊
341341
`
342+
343+
## Invalid #22
344+
1 | const foo = [].at.call(bar)
345+
346+
> Output
347+
348+
`␊
349+
1 | const foo = Array.prototype.at.call(bar)␊
350+
`
351+
352+
> Error 1/1
353+
354+
`␊
355+
> 1 | const foo = [].at.call(bar)␊
356+
| ^^^^^ Prefer using \`Array.prototype.at\`.␊
357+
`
358+
359+
## Invalid #23
360+
1 | const foo = [].findLast.call(bar)
361+
362+
> Output
363+
364+
`␊
365+
1 | const foo = Array.prototype.findLast.call(bar)␊
366+
`
367+
368+
> Error 1/1
369+
370+
`␊
371+
> 1 | const foo = [].findLast.call(bar)␊
372+
| ^^^^^^^^^^^ Prefer using \`Array.prototype.findLast\`.␊
373+
`
93 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)