The actual snapshot is saved in prefer-spread.js.snap
.
Generated by AVA.
1 | const x = Array.from(set);
Output
`␊
1 | const x = [...set];␊
`
Error 1/1
`␊
> 1 | const x = Array.from(set);␊
| ^^^^^^^^^^^^^^^ Prefer the spread operator over `Array.from(…)`.␊
`
1 | Array.from(set).map(() => {});
Output
`␊
1 | [...set].map(() => {});␊
`
Error 1/1
`␊
> 1 | Array.from(set).map(() => {});␊
| ^^^^^^^^^^^^^^^ Prefer the spread operator over `Array.from(…)`.␊
`
1 | Array.from(set, mapFn).reduce(() => {});
Output
`␊
1 | [...set].map(mapFn).reduce(() => {});␊
`
Error 1/1
`␊
> 1 | Array.from(set, mapFn).reduce(() => {});␊
| ^^^^^^^^^^^^^^^^^^^^^^ Prefer the spread operator over `Array.from(…)`.␊
`
1 | Array.from(set, mapFn, thisArg).reduce(() => {});
Output
`␊
1 | [...set].map(mapFn, thisArg).reduce(() => {});␊
`
Error 1/1
`␊
> 1 | Array.from(set, mapFn, thisArg).reduce(() => {});␊
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer the spread operator over `Array.from(…)`.␊
`
1 | Array.from(set, () => {}, thisArg).reduce(() => {});
Output
`␊
1 | [...set].map(() => {}, thisArg).reduce(() => {});␊
`
Error 1/1
`␊
> 1 | Array.from(set, () => {}, thisArg).reduce(() => {});␊
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer the spread operator over `Array.from(…)`.␊
`
1 | Array.from(new Set([1, 2])).map(() => {});
Output
`␊
1 | [...new Set([1, 2])].map(() => {});␊
`
Error 1/1
`␊
> 1 | Array.from(new Set([1, 2])).map(() => {});␊
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer the spread operator over `Array.from(…)`.␊
`
1 | Array.from(document.querySelectorAll("*")).map(() => {});
Output
`␊
1 | [...document.querySelectorAll("*")].map(() => {});␊
`
Error 1/1
`␊
> 1 | Array.from(document.querySelectorAll("*")).map(() => {});␊
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer the spread operator over `Array.from(…)`.␊
`
1 | const foo = []
2 | Array.from(arrayLike).forEach(doSomething)
Output
`␊
1 | const foo = []␊
2 | ;[...arrayLike].forEach(doSomething)␊
`
Error 1/1
`␊
1 | const foo = []␊
> 2 | Array.from(arrayLike).forEach(doSomething)␊
| ^^^^^^^^^^^^^^^^^^^^^ Prefer the spread operator over `Array.from(…)`.␊
`
1 | const foo = "1"
2 | Array.from(arrayLike).forEach(doSomething)
Output
`␊
1 | const foo = "1"␊
2 | ;[...arrayLike].forEach(doSomething)␊
`
Error 1/1
`␊
1 | const foo = "1"␊
> 2 | Array.from(arrayLike).forEach(doSomething)␊
| ^^^^^^^^^^^^^^^^^^^^^ Prefer the spread operator over `Array.from(…)`.␊
`
1 | const foo = null
2 | Array.from(arrayLike).forEach(doSomething)
Output
`␊
1 | const foo = null␊
2 | ;[...arrayLike].forEach(doSomething)␊
`
Error 1/1
`␊
1 | const foo = null␊
> 2 | Array.from(arrayLike).forEach(doSomething)␊
| ^^^^^^^^^^^^^^^^^^^^^ Prefer the spread operator over `Array.from(…)`.␊
`
1 | const foo = true
2 | Array.from(arrayLike).forEach(doSomething)
Output
`␊
1 | const foo = true␊
2 | ;[...arrayLike].forEach(doSomething)␊
`
Error 1/1
`␊
1 | const foo = true␊
> 2 | Array.from(arrayLike).forEach(doSomething)␊
| ^^^^^^^^^^^^^^^^^^^^^ Prefer the spread operator over `Array.from(…)`.␊
`
1 | const foo = 1
2 | Array.from(arrayLike).forEach(doSomething)
Output
`␊
1 | const foo = 1␊
2 | ;[...arrayLike].forEach(doSomething)␊
`
Error 1/1
`␊
1 | const foo = 1␊
> 2 | Array.from(arrayLike).forEach(doSomething)␊
| ^^^^^^^^^^^^^^^^^^^^^ Prefer the spread operator over `Array.from(…)`.␊
`
1 | const foo = /./
2 | Array.from(arrayLike).forEach(doSomething)
Output
`␊
1 | const foo = /./␊
2 | ;[...arrayLike].forEach(doSomething)␊
`
Error 1/1
`␊
1 | const foo = /./␊
> 2 | Array.from(arrayLike).forEach(doSomething)␊
| ^^^^^^^^^^^^^^^^^^^^^ Prefer the spread operator over `Array.from(…)`.␊
`
1 | const foo = /./g
2 | Array.from(arrayLike).forEach(doSomething)
Output
`␊
1 | const foo = /./g␊
2 | ;[...arrayLike].forEach(doSomething)␊
`
Error 1/1
`␊
1 | const foo = /./g␊
> 2 | Array.from(arrayLike).forEach(doSomething)␊
| ^^^^^^^^^^^^^^^^^^^^^ Prefer the spread operator over `Array.from(…)`.␊
`
1 | const foo = bar
2 | Array.from(arrayLike).forEach(doSomething)
Output
`␊
1 | const foo = bar␊
2 | ;[...arrayLike].forEach(doSomething)␊
`
Error 1/1
`␊
1 | const foo = bar␊
> 2 | Array.from(arrayLike).forEach(doSomething)␊
| ^^^^^^^^^^^^^^^^^^^^^ Prefer the spread operator over `Array.from(…)`.␊
`
1 | const foo = bar.baz
2 | Array.from(arrayLike).forEach(doSomething)
Output
`␊
1 | const foo = bar.baz␊
2 | ;[...arrayLike].forEach(doSomething)␊
`
Error 1/1
`␊
1 | const foo = bar.baz␊
> 2 | Array.from(arrayLike).forEach(doSomething)␊
| ^^^^^^^^^^^^^^^^^^^^^ Prefer the spread operator over `Array.from(…)`.␊
`
1 | function* foo() {
2 | yield Array.from(arrayLike).forEach(doSomething)
3 | }
Output
`␊
1 | function* foo() {␊
2 | yield [...arrayLike].forEach(doSomething)␊
3 | }␊
`
Error 1/1
`␊
1 | function* foo() {␊
> 2 | yield Array.from(arrayLike).forEach(doSomething)␊
| ^^^^^^^^^^^^^^^^^^^^^ Prefer the spread operator over `Array.from(…)`.␊
3 | }␊
`
1 | const foo = `bar`
2 | Array.from(arrayLike).forEach(doSomething)
Output
`␊
1 | const foo = `bar`␊
2 | ;[...arrayLike].forEach(doSomething)␊
`
Error 1/1
`␊
1 | const foo = `bar`␊
> 2 | Array.from(arrayLike).forEach(doSomething)␊
| ^^^^^^^^^^^^^^^^^^^^^ Prefer the spread operator over `Array.from(…)`.␊
`
1 | const foo = [];
2 | Array.from(arrayLike).forEach(doSomething)
Output
`␊
1 | const foo = [];␊
2 | [...arrayLike].forEach(doSomething)␊
`
Error 1/1
`␊
1 | const foo = [];␊
> 2 | Array.from(arrayLike).forEach(doSomething)␊
| ^^^^^^^^^^^^^^^^^^^^^ Prefer the spread operator over `Array.from(…)`.␊
`
1 | for (const key of Array.from(arrayLike)) {
2 | }
Output
`␊
1 | for (const key of [...arrayLike]) {␊
2 | }␊
`
Error 1/1
`␊
> 1 | for (const key of Array.from(arrayLike)) {␊
| ^^^^^^^^^^^^^^^^^^^^^ Prefer the spread operator over `Array.from(…)`.␊
2 | }␊
`
1 | for (const key in Array.from(arrayLike)) {
2 | }
Output
`␊
1 | for (const key in [...arrayLike]) {␊
2 | }␊
`
Error 1/1
`␊
> 1 | for (const key in Array.from(arrayLike)) {␊
| ^^^^^^^^^^^^^^^^^^^^^ Prefer the spread operator over `Array.from(…)`.␊
2 | }␊
`
1 | const foo = `${Array.from(arrayLike)}`
Output
`␊
1 | const foo = `${[...arrayLike]}`␊
`
Error 1/1
`␊
> 1 | const foo = `${Array.from(arrayLike)}`␊
| ^^^^^^^^^^^^^^^^^^^^^ Prefer the spread operator over `Array.from(…)`.␊
`
1 | async function foo(){
2 | return await Array.from(arrayLike)
3 | }
Output
`␊
1 | async function foo(){␊
2 | return await [...arrayLike]␊
3 | }␊
`
Error 1/1
`␊
1 | async function foo(){␊
> 2 | return await Array.from(arrayLike)␊
| ^^^^^^^^^^^^^^^^^^^^^ Prefer the spread operator over `Array.from(…)`.␊
3 | }␊
`
1 | foo()
2 | Array.from(arrayLike).forEach(doSomething)
Output
`␊
1 | foo()␊
2 | ;[...arrayLike].forEach(doSomething)␊
`
Error 1/1
`␊
1 | foo()␊
> 2 | Array.from(arrayLike).forEach(doSomething)␊
| ^^^^^^^^^^^^^^^^^^^^^ Prefer the spread operator over `Array.from(…)`.␊
`
1 | const foo = {}
2 | Array.from(arrayLike).forEach(doSomething)
Output
`␊
1 | const foo = {}␊
2 | ;[...arrayLike].forEach(doSomething)␊
`
Error 1/1
`␊
1 | const foo = {}␊
> 2 | Array.from(arrayLike).forEach(doSomething)␊
| ^^^^^^^^^^^^^^^^^^^^^ Prefer the spread operator over `Array.from(…)`.␊
`
1 | [1].concat(2)
Output
`␊
1 | [1, 2]␊
`
Error 1/1
`␊
> 1 | [1].concat(2)␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | [1].concat([2, 3])
Output
`␊
1 | [1, 2, 3]␊
`
Error 1/1
`␊
> 1 | [1].concat([2, 3])␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | [1].concat(2,)
Output
`␊
1 | [1, 2]␊
`
Error 1/1
`␊
> 1 | [1].concat(2,)␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | [1].concat([2, ...bar],)
Output
`␊
1 | [1, 2, ...bar]␊
`
Error 1/1
`␊
> 1 | [1].concat([2, ...bar],)␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | [1,].concat(2)
Output
`␊
1 | [1, 2,]␊
`
Error 1/1
`␊
> 1 | [1,].concat(2)␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | [1,].concat([2, 3])
Output
`␊
1 | [1, 2, 3,]␊
`
Error 1/1
`␊
> 1 | [1,].concat([2, 3])␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | [1,].concat(2,)
Output
`␊
1 | [1, 2,]␊
`
Error 1/1
`␊
> 1 | [1,].concat(2,)␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | [1,].concat([2, 3],)
Output
`␊
1 | [1, 2, 3,]␊
`
Error 1/1
`␊
> 1 | [1,].concat([2, 3],)␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | (( (([1,])).concat( (([2, 3])) ,) ))
Output
`␊
1 | (( (([1, 2, 3,])) ))␊
`
Error 1/1
`␊
> 1 | (( (([1,])).concat( (([2, 3])) ,) ))␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | (( (([1,])).concat( (([2, 3])) , bar ) ))
Output
`␊
1 | (( (([1, 2, 3,])).concat( bar ) ))␊
`
Error 1/1
`␊
> 1 | (( (([1,])).concat( (([2, 3])) , bar ) ))␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | foo.concat(2)
Output
`␊
1 | [...foo, 2]␊
`
Error 1/1
`␊
> 1 | foo.concat(2)␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | foo.concat([2, 3])
Output
`␊
1 | [...foo, 2, 3]␊
`
Error 1/1
`␊
> 1 | foo.concat([2, 3])␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | foo.concat(2,)
Output
`␊
1 | [...foo, 2]␊
`
Error 1/1
`␊
> 1 | foo.concat(2,)␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | foo.concat([2, 3],)
Output
`␊
1 | [...foo, 2, 3]␊
`
Error 1/1
`␊
> 1 | foo.concat([2, 3],)␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | (( ((foo)).concat( (([2, 3])) ,) ))
Output
`␊
1 | (( [...((foo)), 2, 3] ))␊
`
Error 1/1
`␊
> 1 | (( ((foo)).concat( (([2, 3])) ,) ))␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | (( ((foo)).concat( (([2, 3])) , bar ) ))
Output
`␊
1 | (( [...((foo)), 2, 3].concat( bar ) ))␊
`
Error 1/1
`␊
> 1 | (( ((foo)).concat( (([2, 3])) , bar ) ))␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | bar()
2 | foo.concat(2)
Output
`␊
1 | bar()␊
2 | ;[...foo, 2]␊
`
Error 1/1
`␊
1 | bar()␊
> 2 | foo.concat(2)␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | const foo = foo.concat(2)
Output
`␊
1 | const foo = [...foo, 2]␊
`
Error 1/1
`␊
> 1 | const foo = foo.concat(2)␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | const foo = () => foo.concat(2)
Output
`␊
1 | const foo = () => [...foo, 2]␊
`
Error 1/1
`␊
> 1 | const foo = () => foo.concat(2)␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | const five = 2 + 3;
2 | foo.concat(five);
Output
`␊
1 | const five = 2 + 3;␊
2 | [...foo, five];␊
`
Error 1/1
`␊
1 | const five = 2 + 3;␊
> 2 | foo.concat(five);␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | const array = [2 + 3];
2 | foo.concat(array);
Output
`␊
1 | const array = [2 + 3];␊
2 | [...foo, ...array];␊
`
Error 1/1
`␊
1 | const array = [2 + 3];␊
> 2 | foo.concat(array);␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | foo.concat([bar])
Output
`␊
1 | [...foo, bar]␊
`
Error 1/1
`␊
> 1 | foo.concat([bar])␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | foo.concat(bar)
Error 1/1
`␊
> 1 | foo.concat(bar)␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
␊
--------------------------------------------------------------------------------␊
Suggestion 1/3: First argument is an `array`.␊
1 | [...foo, ...bar]␊
␊
--------------------------------------------------------------------------------␊
Suggestion 2/3: First argument is not an `array`.␊
1 | [...foo, bar]␊
␊
--------------------------------------------------------------------------------␊
Suggestion 3/3: Test first argument with `Array.isArray(…)`.␊
1 | [...foo, ...(Array.isArray(bar) ? bar : [bar])]␊
`
1 | Array.from(set).concat([2, 3])
Output
`␊
1 | [...set, 2, 3]␊
`
Error 1/2
`␊
> 1 | Array.from(set).concat([2, 3])␊
| ^^^^^^^^^^^^^^^ Prefer the spread operator over `Array.from(…)`.␊
`
Error 2/2
`␊
> 1 | Array.from(set).concat([2, 3])␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | foo.concat([2, 3]).concat(4)
Output
`␊
1 | [...foo, 2, 3, 4]␊
`
Error 1/2
`␊
> 1 | foo.concat([2, 3]).concat(4)␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
Error 2/2
`␊
> 1 | foo.concat([2, 3]).concat(4)␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | string.concat("bar")
Output
`␊
1 | [...string, "bar"]␊
`
Error 1/1
`␊
> 1 | string.concat("bar")␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | foo.concat(2, 3)
Output
`␊
1 | [...foo, 2, 3]␊
`
Error 1/1
`␊
> 1 | foo.concat(2, 3)␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | foo.concat(2, bar)
Output
`␊
1 | [...foo, 2].concat(bar)␊
`
Error 1/1
`␊
> 1 | foo.concat(2, bar)␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | [...foo, 2].concat(bar)
Error 1/1
`␊
> 1 | [...foo, 2].concat(bar)␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
␊
--------------------------------------------------------------------------------␊
Suggestion 1/3: First argument is an `array`.␊
1 | [...foo, 2, ...bar]␊
␊
--------------------------------------------------------------------------------␊
Suggestion 2/3: First argument is not an `array`.␊
1 | [...foo, 2, bar]␊
␊
--------------------------------------------------------------------------------␊
Suggestion 3/3: Test first argument with `Array.isArray(…)`.␊
1 | [...foo, 2, ...(Array.isArray(bar) ? bar : [bar])]␊
`
1 | let sortedScores = scores.concat().sort((a, b) => b[0] - a[0]);
Output
`␊
1 | let sortedScores = [...scores].sort((a, b) => b[0] - a[0]);␊
`
Error 1/1
`␊
> 1 | let sortedScores = scores.concat().sort((a, b) => b[0] - a[0]);␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | foo.concat(bar, 2, 3)
Error 1/1
`␊
> 1 | foo.concat(bar, 2, 3)␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
␊
--------------------------------------------------------------------------------␊
Suggestion 1/3: First argument is an `array`.␊
1 | [...foo, ...bar, 2, 3]␊
␊
--------------------------------------------------------------------------------␊
Suggestion 2/3: First argument is not an `array`.␊
1 | [...foo, bar, 2, 3]␊
␊
--------------------------------------------------------------------------------␊
Suggestion 3/3: Test first argument with `Array.isArray(…)`.␊
1 | [...foo, ...(Array.isArray(bar) ? bar : [bar]), 2, 3]␊
`
1 | foo.concat(bar, 2, 3, baz)
Error 1/1
`␊
> 1 | foo.concat(bar, 2, 3, baz)␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
␊
--------------------------------------------------------------------------------␊
Suggestion 1/4: First argument is an `array`.␊
1 | [...foo, ...bar, 2, 3].concat(baz)␊
␊
--------------------------------------------------------------------------------␊
Suggestion 2/4: First argument is not an `array`.␊
1 | [...foo, bar, 2, 3].concat(baz)␊
␊
--------------------------------------------------------------------------------␊
Suggestion 3/4: Test first argument with `Array.isArray(…)`.␊
1 | [...foo, ...(Array.isArray(bar) ? bar : [bar]), 2, 3].concat(baz)␊
␊
--------------------------------------------------------------------------------␊
Suggestion 4/4: Spread all unknown arguments`.␊
1 | [...foo, ...bar, 2, 3, ...baz]␊
`
1 | async function a() {return [].concat(await bar)}
Error 1/1
`␊
> 1 | async function a() {return [].concat(await bar)}␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
␊
--------------------------------------------------------------------------------␊
Suggestion 1/2: First argument is an `array`.␊
1 | async function a() {return [...(await bar)]}␊
␊
--------------------------------------------------------------------------------␊
Suggestion 2/2: First argument is not an `array`.␊
1 | async function a() {return [await bar]}␊
`
1 | async function a() {return [].concat(((await bar)))}
Error 1/1
`␊
> 1 | async function a() {return [].concat(((await bar)))}␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
␊
--------------------------------------------------------------------------------␊
Suggestion 1/2: First argument is an `array`.␊
1 | async function a() {return [...((await bar))]}␊
␊
--------------------------------------------------------------------------------␊
Suggestion 2/2: First argument is not an `array`.␊
1 | async function a() {return [((await bar))]}␊
`
1 | foo.concat((0, 1))
Output
`␊
1 | [...foo, (0, 1)]␊
`
Error 1/1
`␊
> 1 | foo.concat((0, 1))␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | async function a() {return (await bar).concat(1)}
Output
`␊
1 | async function a() {return [...(await bar), 1]}␊
`
Error 1/1
`␊
> 1 | async function a() {return (await bar).concat(1)}␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | [].concat(...bar)
Error 1/1
`␊
> 1 | [].concat(...bar)␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | [].concat([,], [])
Output
`␊
1 | [,]␊
`
Error 1/1
`␊
> 1 | [].concat([,], [])␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | [,].concat([,], [,])
Output
`␊
1 | [, , ,]␊
`
Error 1/1
`␊
> 1 | [,].concat([,], [,])␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | [,].concat([,,], [,])
Output
`␊
1 | [, ,, ,]␊
`
Error 1/1
`␊
> 1 | [,].concat([,,], [,])␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | [,].concat([,], [,,])
Output
`␊
1 | [, , ,,]␊
`
Error 1/1
`␊
> 1 | [,].concat([,], [,,])␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | [1].concat([2,], [3,])
Output
`␊
1 | [1, 2, 3,]␊
`
Error 1/1
`␊
> 1 | [1].concat([2,], [3,])␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | [1].concat([2,,], [3,,])
Output
`␊
1 | [1, 2,, 3,,]␊
`
Error 1/1
`␊
> 1 | [1].concat([2,,], [3,,])␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | [1,].concat([2,], [3,])
Output
`␊
1 | [1, 2, 3,]␊
`
Error 1/1
`␊
> 1 | [1,].concat([2,], [3,])␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | [1,].concat([2,,], [3,,])
Output
`␊
1 | [1, 2,, 3,,]␊
`
Error 1/1
`␊
> 1 | [1,].concat([2,,], [3,,])␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | [].concat([], [])
Output
`␊
1 | []␊
`
Error 1/1
`␊
> 1 | [].concat([], [])␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
`
1 | const EMPTY_STRING = ""
2 | const EMPTY_STRING_IN_ARRAY = ""
3 | const EMPTY_STRING_IN_ARRAY_OF_ARRAY = ""
4 | const array = [].concat(
5 | undefined,
6 | null,
7 | EMPTY_STRING,
8 | false,
9 | 0,
10 | [EMPTY_STRING_IN_ARRAY],
11 | [[EMPTY_STRING_IN_ARRAY_OF_ARRAY]]
12 | )
Output
`␊
1 | const EMPTY_STRING = ""␊
2 | const EMPTY_STRING_IN_ARRAY = ""␊
3 | const EMPTY_STRING_IN_ARRAY_OF_ARRAY = ""␊
4 | const array = [undefined, null, EMPTY_STRING, false, 0, EMPTY_STRING_IN_ARRAY, [EMPTY_STRING_IN_ARRAY_OF_ARRAY]]␊
`
Error 1/1
`␊
1 | const EMPTY_STRING = ""␊
2 | const EMPTY_STRING_IN_ARRAY = ""␊
3 | const EMPTY_STRING_IN_ARRAY_OF_ARRAY = ""␊
> 4 | const array = [].concat(␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
5 | undefined,␊
6 | null,␊
7 | EMPTY_STRING,␊
8 | false,␊
9 | 0,␊
10 | [EMPTY_STRING_IN_ARRAY],␊
11 | [[EMPTY_STRING_IN_ARRAY_OF_ARRAY]]␊
12 | )␊
`
1 | [].concat((a.b.c), 2)
Error 1/1
`␊
> 1 | [].concat((a.b.c), 2)␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
␊
--------------------------------------------------------------------------------␊
Suggestion 1/3: First argument is an `array`.␊
1 | [...(a.b.c), 2]␊
␊
--------------------------------------------------------------------------------␊
Suggestion 2/3: First argument is not an `array`.␊
1 | [(a.b.c), 2]␊
␊
--------------------------------------------------------------------------------␊
Suggestion 3/3: Test first argument with `Array.isArray(…)`.␊
1 | [...(Array.isArray((a.b.c)) ? (a.b.c) : [(a.b.c)]), 2]␊
`
1 | [].concat(a.b(), 2)
Error 1/1
`␊
> 1 | [].concat(a.b(), 2)␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
␊
--------------------------------------------------------------------------------␊
Suggestion 1/2: First argument is an `array`.␊
1 | [...a.b(), 2]␊
␊
--------------------------------------------------------------------------------␊
Suggestion 2/2: First argument is not an `array`.␊
1 | [a.b(), 2]␊
`
1 | foo.concat(bar, 2, [3, 4], baz, 5, [6, 7])
Error 1/1
`␊
> 1 | foo.concat(bar, 2, [3, 4], baz, 5, [6, 7])␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
␊
--------------------------------------------------------------------------------␊
Suggestion 1/4: First argument is an `array`.␊
1 | [...foo, ...bar, 2, 3, 4].concat(baz, 5, [6, 7])␊
␊
--------------------------------------------------------------------------------␊
Suggestion 2/4: First argument is not an `array`.␊
1 | [...foo, bar, 2, 3, 4].concat(baz, 5, [6, 7])␊
␊
--------------------------------------------------------------------------------␊
Suggestion 3/4: Test first argument with `Array.isArray(…)`.␊
1 | [...foo, ...(Array.isArray(bar) ? bar : [bar]), 2, 3, 4].concat(baz, 5, [6, 7])␊
␊
--------------------------------------------------------------------------------␊
Suggestion 4/4: Spread all unknown arguments`.␊
1 | [...foo, ...bar, 2, 3, 4, ...baz, 5, 6, 7]␊
`
1 | foo.concat(bar, 2, 3, ...baz)
Error 1/1
`␊
> 1 | foo.concat(bar, 2, 3, ...baz)␊
| ^^^^^^ Prefer the spread operator over `Array#concat(…)`.␊
␊
--------------------------------------------------------------------------------␊
Suggestion 1/3: First argument is an `array`.␊
1 | [...foo, ...bar, 2, 3].concat(...baz)␊
␊
--------------------------------------------------------------------------------␊
Suggestion 2/3: First argument is not an `array`.␊
1 | [...foo, bar, 2, 3].concat(...baz)␊
␊
--------------------------------------------------------------------------------␊
Suggestion 3/3: Test first argument with `Array.isArray(…)`.␊
1 | [...foo, ...(Array.isArray(bar) ? bar : [bar]), 2, 3].concat(...baz)␊
`