diff --git a/crates/oxc_linter/src/rules/unicorn/prefer_spread.rs b/crates/oxc_linter/src/rules/unicorn/prefer_spread.rs index abee4f3f00695..9645ec774e024 100644 --- a/crates/oxc_linter/src/rules/unicorn/prefer_spread.rs +++ b/crates/oxc_linter/src/rules/unicorn/prefer_spread.rs @@ -87,7 +87,7 @@ fn check_unicorn_prefer_spread(call_expr: &CallExpression, ctx: &LintContext) { return; } - ctx.diagnostic(unicorn_prefer_spread_diagnostic(call_expr.span, "Array.from()")); + report_with_spread_fixer(ctx, call_expr.span, "Array.from()", expr); } // `array.concat()` "concat" => { @@ -131,7 +131,7 @@ fn check_unicorn_prefer_spread(call_expr: &CallExpression, ctx: &LintContext) { } } - ctx.diagnostic(unicorn_prefer_spread_diagnostic(call_expr.span, "array.slice()")); + report_with_spread_fixer(ctx, call_expr.span, "array.slice()", member_expr_obj); } // `array.toSpliced()` "toSpliced" => { @@ -144,7 +144,12 @@ fn check_unicorn_prefer_spread(call_expr: &CallExpression, ctx: &LintContext) { return; } - ctx.diagnostic(unicorn_prefer_spread_diagnostic(call_expr.span, "array.toSpliced()")); + report_with_spread_fixer( + ctx, + call_expr.span, + "array.toSpliced()", + member_expr.object(), + ); } // `string.split()` "split" => { @@ -235,6 +240,21 @@ fn is_not_array(expr: &Expression, ctx: &LintContext) -> bool { false } +fn report_with_spread_fixer( + ctx: &LintContext, + span: Span, + bad_method: &str, + expr_to_spread: &Expression, +) { + ctx.diagnostic_with_fix(unicorn_prefer_spread_diagnostic(span, bad_method), |fixer| { + let mut codegen = fixer.codegen(); + codegen.print_str("[..."); + codegen.print_expression(expr_to_spread); + codegen.print_str("]"); + fixer.replace(span, codegen) + }); +} + #[test] fn test() { use crate::tester::Tester; @@ -248,6 +268,7 @@ fn test() { r"Uint16Array.from(set);", r"Int32Array.from(set);", r"Uint32Array.from(set);", + r"Float16Array.from(set);", r"Float32Array.from(set);", r"Float64Array.from(set);", r"BigInt64Array.from(set);", @@ -271,14 +292,16 @@ fn test() { r"array[concat](1)", r#""foo".concat("bar")"#, r#"`${foo}`.concat("bar")"#, - r"const bufA = Buffer.concat([buf1, buf2, buf3], totalLength);", - r"Foo.concat(1)", - r"FooBar.concat(1)", - r"global.Buffer.concat([])", + r#"const string = 'foo'; + foo = string.concat("bar");"#, + "const bufA = Buffer.concat([buf1, buf2, buf3], totalLength);", + "Foo.concat(1)", + "FooBar.concat(1)", + "global.Buffer.concat([])", r#"["1", "2"].join(",").concat("...")"#, r#"foo.join(",").concat("...")"#, - r"foo.join().concat(bar)", - // r#"(a + b).concat(c)"#, + "foo.join().concat(bar)", + //"(a + b).concat(c)", r"new Array.slice()", r"slice()", r"array[slice]()", @@ -343,108 +366,173 @@ fn test() { ]; let fail = vec![ - r"const x = Array.from(set);", - r"Array.from(set).map(() => {});", - r"Array.from(new Set([1, 2])).map(() => {});", + "const x = Array.from(set);", + "Array.from(set).map(() => {});", + "Array.from(new Set([1, 2])).map(() => {});", r#"Array.from(document.querySelectorAll("*")).map(() => {});"#, - r"const foo = `${Array.from(arrayLike)}`", - r"(Array).from(foo)", - r"(Array.from)(foo)", - r"((Array).from)(foo)", - r"(Array).from((0, foo))", - r"(Array.from)((0, foo))", - r"((Array).from)((0, foo))", - r"Array.from(a ? b : c)", - r"Array.from([...a, ...b], )", - r"Array.from([1])", - r"Array.from([...a, ...b])", - r"/* 1 */ Array /* 2 */ .from /* 3 */ ( /* 4 */ a /* 5 */,)", - r"[1].concat(2)", - r"[1].concat([2, 3])", - r"[1].concat(2,)", - r"[1].concat([2, ...bar],)", - r"[1,].concat(2)", - r"[1,].concat([2, 3])", - r"[1,].concat(2,)", - r"[1,].concat([2, 3],)", - r"(( (( (( [1,] )).concat ))( (([2, 3])) ,) ))", - r"(( (( (( [1,] )).concat ))( (([2, 3])) , bar ) ))", - r"foo.concat(2)", - r"foo.concat([2, 3])", - r"foo.concat(2,)", - r"foo.concat([2, 3],)", - r"(( (( ((foo)).concat ))( (([2, 3])) ,) ))", - r"(( (( ((foo)).concat ))( (([2, 3])) , bar ) ))", - r"const foo = foo.concat(2)", - r"const foo = () => foo.concat(2)", - r"foo.concat([bar])", - r"foo.concat(bar)", - r"Array.from(set).concat([2, 3])", - r"foo.concat([2, 3]).concat(4)", + "const foo = [] + Array.from(arrayLike).forEach(doSomething)", + r#"const foo = "1" + Array.from(arrayLike).forEach(doSomething)"#, + "const foo = null + Array.from(arrayLike).forEach(doSomething)", + "const foo = true + Array.from(arrayLike).forEach(doSomething)", + "const foo = 1 + Array.from(arrayLike).forEach(doSomething)", + "const foo = /./ + Array.from(arrayLike).forEach(doSomething)", + "const foo = /./g + Array.from(arrayLike).forEach(doSomething)", + "const foo = bar + Array.from(arrayLike).forEach(doSomething)", + "const foo = bar.baz + Array.from(arrayLike).forEach(doSomething)", + "function* foo() { + yield Array.from(arrayLike).forEach(doSomething) + }", + "const foo = \\`bar\\` + Array.from(arrayLike).forEach(doSomething)", + "const foo = []; + Array.from(arrayLike).forEach(doSomething)", + "for (const key of Array.from(arrayLike)) { + }", + "for (const key in Array.from(arrayLike)) { + }", + "const foo = `${Array.from(arrayLike)}`", + "async function foo(){ + return await Array.from(arrayLike) + }", + "foo() + Array.from(arrayLike).forEach(doSomething)", + "const foo = {} + Array.from(arrayLike).forEach(doSomething)", + "(Array).from(foo)", + "(Array.from)(foo)", + "((Array).from)(foo)", + "(Array).from((0, foo))", + "(Array.from)((0, foo))", + "((Array).from)((0, foo))", + "Array.from(a ? b : c)", + "Array.from((0, a))", + "Array.from([...a, ...b], )", + "Array.from([1])", + "Array.from([...a, ...b])", + "/* 1 */ Array /* 2 */ .from /* 3 */ ( /* 4 */ a /* 5 */,)", + "[1].concat(2)", + "[1].concat([2, 3])", + "[1].concat(2,)", + "[1].concat([2, ...bar],)", + "[1,].concat(2)", + "[1,].concat([2, 3])", + "[1,].concat(2,)", + "[1,].concat([2, 3],)", + "(( (( (( [1,] )).concat ))( (([2, 3])) ,) ))", + "(( (( (( [1,] )).concat ))( (([2, 3])) , bar ) ))", + "foo.concat(2)", + "foo.concat([2, 3])", + "foo.concat(2,)", + "foo.concat([2, 3],)", + "(( (( ((foo)).concat ))( (([2, 3])) ,) ))", + "(( (( ((foo)).concat ))( (([2, 3])) , bar ) ))", + "bar() + foo.concat(2)", + "const foo = foo.concat(2)", + "const foo = () => foo.concat(2)", + "const five = 2 + 3; + foo.concat(five);", + "const array = [2 + 3]; + foo.concat(array);", + "foo.concat([bar])", + "foo.concat(bar)", + "Array.from(set).concat([2, 3])", + "foo.concat([2, 3]).concat(4)", r#"string.concat("bar")"#, - r"foo.concat(2, 3)", - r"foo.concat(2, bar)", - r"[...foo, 2].concat(bar)", - r"let sortedScores = scores.concat().sort((a, b) => b[0] - a[0]);", - r"foo.concat(bar, 2, 3)", - r"foo.concat(bar, 2, 3, baz)", - r"async function a() {return [].concat(await bar)}", - r"async function a() {return [].concat(((await bar)))}", - r"foo.concat((0, 1))", - r"async function a() {return (await bar).concat(1)}", - r"[].concat(...bar)", - r"[].concat([,], [])", - r"[,].concat([,], [,])", - r"[,].concat([,,], [,])", - r"[,].concat([,], [,,])", - r"[1].concat([2,], [3,])", - r"[1].concat([2,,], [3,,])", - r"[1,].concat([2,], [3,])", - r"[1,].concat([2,,], [3,,])", - r"[].concat([], [])", - r"[].concat((a.b.c), 2)", - r"[].concat(a.b(), 2)", - r"foo.concat(bar, 2, [3, 4], baz, 5, [6, 7])", - r"foo.concat(bar, 2, 3, ...baz)", - r"notClass.concat(1)", - r"_A.concat(1)", - r"FOO.concat(1)", - r"A.concat(1)", - r"Foo.x.concat(1)", - r"if (test) foo.concat(1)", - r"if (test) {} else foo.concat(1)", - r"if (test) {} else foo.concat(1)", - r"for (;;) foo.concat(1)", - r"for (a in b) foo.concat(1)", - r"for (a in b) foo.concat(1)", - r"for (const a of b) foo.concat(1)", - r"while (test) foo.concat(1)", - r"do foo.concat(1); while (test)", - r"with (foo) foo.concat(1)", + "foo.concat(2, 3)", + "foo.concat(2, bar)", + "[...foo, 2].concat(bar)", + "let sortedScores = scores.concat().sort((a, b) => b[0] - a[0]);", + "foo.concat(bar, 2, 3)", + "foo.concat(bar, 2, 3, baz)", + "async function a() {return [].concat(await bar)}", + "async function a() {return [].concat((0, bar))}", + "async function a() {return [].concat(((await bar)))}", + "foo.concat((0, 1))", + "async function a() {return (await bar).concat(1)}", + "[].concat(...bar)", + "[].concat([,], [])", + "[,].concat([,], [,])", + "[,].concat([,,], [,])", + "[,].concat([,], [,,])", + "[1].concat([2,], [3,])", + "[1].concat([2,,], [3,,])", + "[1,].concat([2,], [3,])", + "[1,].concat([2,,], [3,,])", + "[].concat([], [])", + r#"const EMPTY_STRING = "" + const EMPTY_STRING_IN_ARRAY = "" + const EMPTY_STRING_IN_ARRAY_OF_ARRAY = "" + const array = [].concat( + undefined, + null, + EMPTY_STRING, + false, + 0, + [EMPTY_STRING_IN_ARRAY], + [[EMPTY_STRING_IN_ARRAY_OF_ARRAY]] + )"#, + "[].concat((a.b.c), 2)", + "[].concat(a.b(), 2)", + "foo.concat(bar, 2, [3, 4], baz, 5, [6, 7])", + "foo.concat(bar, 2, 3, ...baz)", + "notClass.concat(1)", + "_A.concat(1)", + "FOO.concat(1)", + "A.concat(1)", + "Foo.x.concat(1)", + "if (test) foo.concat(1)", + "if (test) {} else foo.concat(1)", + "if (test) {} else foo.concat(1)", + "for (;;) foo.concat(1)", + "for (a in b) foo.concat(1)", + "for (a in b) foo.concat(1)", + "for (const a of b) foo.concat(1)", + "while (test) foo.concat(1)", + "do foo.concat(1); while (test)", + "with (foo) foo.concat(1)", // {"parserOptions": {"ecmaVersion": 6, "sourceType": "script"}}, + "const baz = [2]; + call(foo, ...[bar].concat(baz));", r#"foo.join(foo, bar).concat("...")"#, - r"array.slice()", - r"array.slice().slice()", - r"array.slice(1).slice()", - r"array.slice().slice(1)", - r"const copy = array.slice()", - r"(( (( (( array )).slice ))() ))", + "array.slice()", + "array.slice().slice()", + "array.slice(1).slice()", + "array.slice().slice(1)", + "const copy = array.slice()", + "(( (( (( array )).slice ))() ))", + "(scopeManager?.scopes).slice()", + "bar() + foo.slice()", r#""".slice()"#, - r"new Uint8Array([10, 20, 30, 40, 50]).slice()", - r"array.slice(0)", - r"array.slice(0b0)", - r"array.slice(0.00)", - r"array.slice(0.00, )", - r"array.toSpliced()", - r"array.toSpliced().toSpliced()", - r"const copy = array.toSpliced()", - r"(( (( (( array )).toSpliced ))() ))", + "new Uint8Array([10, 20, 30, 40, 50]).slice()", + "array.slice(0)", + "array.slice(0b0)", + "array.slice(0.00)", + "array.slice(0.00, )", + "array.toSpliced()", + "array.toSpliced().toSpliced()", + "const copy = array.toSpliced()", + "(( (( (( array )).toSpliced ))() ))", + "bar() + foo.toSpliced()", r#""".toSpliced()"#, - r"new Uint8Array([10, 20, 30, 40, 50]).toSpliced()", + "new Uint8Array([10, 20, 30, 40, 50]).toSpliced()", r#""string".split("")"#, r#""string".split('')"#, r#"unknown.split("")"#, r#"const characters = "string".split("")"#, r#"(( (( (( "string" )).split ))( (("")) ) ))"#, + r#"bar() + foo.split("")"#, r#"unknown.split("")"#, r#""๐Ÿฆ„".split("")"#, r#"const {length} = "๐Ÿฆ„".split("")"#, @@ -452,8 +540,16 @@ fn test() { let expect_fix = vec![ // `Array.from()` + ("const x = Array.from(set);", "const x = [...set];", None), + ("Array.from(new Set([1, 2])).map(() => {});", "[...new Set([1, 2])].map(() => {});", None), // `array.slice()` + ("array.slice()", "[...array]", None), + ("array.slice(1).slice()", "[...array.slice(1)]", None), // `array.toSpliced()` + ("array.toSpliced()", "[...array]", None), + ("const copy = array.toSpliced()", "const copy = [...array]", None), + // ("", "", None), + // ("", "", None), // `string.split()` (r#""๐Ÿฆ„".split("")"#, r#"[..."๐Ÿฆ„"]"#, None), (r#""foo bar baz".split("")"#, r#"[..."foo bar baz"]"#, None), diff --git a/crates/oxc_linter/src/snapshots/unicorn_prefer_spread.snap b/crates/oxc_linter/src/snapshots/unicorn_prefer_spread.snap index f099df280877e..38ed2599883a2 100644 --- a/crates/oxc_linter/src/snapshots/unicorn_prefer_spread.snap +++ b/crates/oxc_linter/src/snapshots/unicorn_prefer_spread.snap @@ -29,6 +29,125 @@ source: crates/oxc_linter/src/tester.rs โ•ฐโ”€โ”€โ”€โ”€ help: The spread operator (`...`) is more concise and readable. + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over Array.from() + โ•ญโ”€[prefer_spread.tsx:2:4] + 1 โ”‚ const foo = [] + 2 โ”‚ Array.from(arrayLike).forEach(doSomething) + ยท โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + โ•ฐโ”€โ”€โ”€โ”€ + help: The spread operator (`...`) is more concise and readable. + + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over Array.from() + โ•ญโ”€[prefer_spread.tsx:2:4] + 1 โ”‚ const foo = "1" + 2 โ”‚ Array.from(arrayLike).forEach(doSomething) + ยท โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + โ•ฐโ”€โ”€โ”€โ”€ + help: The spread operator (`...`) is more concise and readable. + + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over Array.from() + โ•ญโ”€[prefer_spread.tsx:2:4] + 1 โ”‚ const foo = null + 2 โ”‚ Array.from(arrayLike).forEach(doSomething) + ยท โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + โ•ฐโ”€โ”€โ”€โ”€ + help: The spread operator (`...`) is more concise and readable. + + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over Array.from() + โ•ญโ”€[prefer_spread.tsx:2:4] + 1 โ”‚ const foo = true + 2 โ”‚ Array.from(arrayLike).forEach(doSomething) + ยท โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + โ•ฐโ”€โ”€โ”€โ”€ + help: The spread operator (`...`) is more concise and readable. + + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over Array.from() + โ•ญโ”€[prefer_spread.tsx:2:4] + 1 โ”‚ const foo = 1 + 2 โ”‚ Array.from(arrayLike).forEach(doSomething) + ยท โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + โ•ฐโ”€โ”€โ”€โ”€ + help: The spread operator (`...`) is more concise and readable. + + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over Array.from() + โ•ญโ”€[prefer_spread.tsx:2:4] + 1 โ”‚ const foo = /./ + 2 โ”‚ Array.from(arrayLike).forEach(doSomething) + ยท โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + โ•ฐโ”€โ”€โ”€โ”€ + help: The spread operator (`...`) is more concise and readable. + + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over Array.from() + โ•ญโ”€[prefer_spread.tsx:2:4] + 1 โ”‚ const foo = /./g + 2 โ”‚ Array.from(arrayLike).forEach(doSomething) + ยท โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + โ•ฐโ”€โ”€โ”€โ”€ + help: The spread operator (`...`) is more concise and readable. + + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over Array.from() + โ•ญโ”€[prefer_spread.tsx:2:4] + 1 โ”‚ const foo = bar + 2 โ”‚ Array.from(arrayLike).forEach(doSomething) + ยท โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + โ•ฐโ”€โ”€โ”€โ”€ + help: The spread operator (`...`) is more concise and readable. + + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over Array.from() + โ•ญโ”€[prefer_spread.tsx:2:4] + 1 โ”‚ const foo = bar.baz + 2 โ”‚ Array.from(arrayLike).forEach(doSomething) + ยท โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + โ•ฐโ”€โ”€โ”€โ”€ + help: The spread operator (`...`) is more concise and readable. + + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over Array.from() + โ•ญโ”€[prefer_spread.tsx:2:11] + 1 โ”‚ function* foo() { + 2 โ”‚ yield Array.from(arrayLike).forEach(doSomething) + ยท โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + 3 โ”‚ } + โ•ฐโ”€โ”€โ”€โ”€ + help: The spread operator (`...`) is more concise and readable. + + ร— Invalid Unicode escape sequence + โ•ญโ”€[prefer_spread.tsx:1:14] + 1 โ”‚ const foo = \`bar\` + ยท โ”€ + 2 โ”‚ Array.from(arrayLike).forEach(doSomething) + โ•ฐโ”€โ”€โ”€โ”€ + + ร— Invalid Unicode escape sequence + โ•ญโ”€[prefer_spread.tsx:1:19] + 1 โ”‚ const foo = \`bar\` + ยท โ”€ + 2 โ”‚ Array.from(arrayLike).forEach(doSomething) + โ•ฐโ”€โ”€โ”€โ”€ + + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over Array.from() + โ•ญโ”€[prefer_spread.tsx:2:4] + 1 โ”‚ const foo = []; + 2 โ”‚ Array.from(arrayLike).forEach(doSomething) + ยท โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + โ•ฐโ”€โ”€โ”€โ”€ + help: The spread operator (`...`) is more concise and readable. + + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over Array.from() + โ•ญโ”€[prefer_spread.tsx:1:19] + 1 โ”‚ for (const key of Array.from(arrayLike)) { + ยท โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + 2 โ”‚ } + โ•ฐโ”€โ”€โ”€โ”€ + help: The spread operator (`...`) is more concise and readable. + + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over Array.from() + โ•ญโ”€[prefer_spread.tsx:1:19] + 1 โ”‚ for (const key in Array.from(arrayLike)) { + ยท โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + 2 โ”‚ } + โ•ฐโ”€โ”€โ”€โ”€ + help: The spread operator (`...`) is more concise and readable. + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over Array.from() โ•ญโ”€[prefer_spread.tsx:1:16] 1 โ”‚ const foo = `${Array.from(arrayLike)}` @@ -36,6 +155,31 @@ source: crates/oxc_linter/src/tester.rs โ•ฐโ”€โ”€โ”€โ”€ help: The spread operator (`...`) is more concise and readable. + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over Array.from() + โ•ญโ”€[prefer_spread.tsx:2:18] + 1 โ”‚ async function foo(){ + 2 โ”‚ return await Array.from(arrayLike) + ยท โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + 3 โ”‚ } + โ•ฐโ”€โ”€โ”€โ”€ + help: The spread operator (`...`) is more concise and readable. + + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over Array.from() + โ•ญโ”€[prefer_spread.tsx:2:4] + 1 โ”‚ foo() + 2 โ”‚ Array.from(arrayLike).forEach(doSomething) + ยท โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + โ•ฐโ”€โ”€โ”€โ”€ + help: The spread operator (`...`) is more concise and readable. + + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over Array.from() + โ•ญโ”€[prefer_spread.tsx:2:4] + 1 โ”‚ const foo = {} + 2 โ”‚ Array.from(arrayLike).forEach(doSomething) + ยท โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + โ•ฐโ”€โ”€โ”€โ”€ + help: The spread operator (`...`) is more concise and readable. + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over Array.from() โ•ญโ”€[prefer_spread.tsx:1:1] 1 โ”‚ (Array).from(foo) @@ -85,6 +229,13 @@ source: crates/oxc_linter/src/tester.rs โ•ฐโ”€โ”€โ”€โ”€ help: The spread operator (`...`) is more concise and readable. + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over Array.from() + โ•ญโ”€[prefer_spread.tsx:1:1] + 1 โ”‚ Array.from((0, a)) + ยท โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + โ•ฐโ”€โ”€โ”€โ”€ + help: The spread operator (`...`) is more concise and readable. + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over Array.from() โ•ญโ”€[prefer_spread.tsx:1:1] 1 โ”‚ Array.from([...a, ...b], ) @@ -225,6 +376,14 @@ source: crates/oxc_linter/src/tester.rs โ•ฐโ”€โ”€โ”€โ”€ help: The spread operator (`...`) is more concise and readable. + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over array.concat() + โ•ญโ”€[prefer_spread.tsx:2:4] + 1 โ”‚ bar() + 2 โ”‚ foo.concat(2) + ยท โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + โ•ฐโ”€โ”€โ”€โ”€ + help: The spread operator (`...`) is more concise and readable. + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over array.concat() โ•ญโ”€[prefer_spread.tsx:1:13] 1 โ”‚ const foo = foo.concat(2) @@ -239,6 +398,22 @@ source: crates/oxc_linter/src/tester.rs โ•ฐโ”€โ”€โ”€โ”€ help: The spread operator (`...`) is more concise and readable. + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over array.concat() + โ•ญโ”€[prefer_spread.tsx:2:4] + 1 โ”‚ const five = 2 + 3; + 2 โ”‚ foo.concat(five); + ยท โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + โ•ฐโ”€โ”€โ”€โ”€ + help: The spread operator (`...`) is more concise and readable. + + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over array.concat() + โ•ญโ”€[prefer_spread.tsx:2:4] + 1 โ”‚ const array = [2 + 3]; + 2 โ”‚ foo.concat(array); + ยท โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + โ•ฐโ”€โ”€โ”€โ”€ + help: The spread operator (`...`) is more concise and readable. + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over array.concat() โ•ญโ”€[prefer_spread.tsx:1:1] 1 โ”‚ foo.concat([bar]) @@ -337,6 +512,13 @@ source: crates/oxc_linter/src/tester.rs โ•ฐโ”€โ”€โ”€โ”€ help: The spread operator (`...`) is more concise and readable. + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over array.concat() + โ•ญโ”€[prefer_spread.tsx:1:28] + 1 โ”‚ async function a() {return [].concat((0, bar))} + ยท โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + โ•ฐโ”€โ”€โ”€โ”€ + help: The spread operator (`...`) is more concise and readable. + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over array.concat() โ•ญโ”€[prefer_spread.tsx:1:28] 1 โ”‚ async function a() {return [].concat(((await bar)))} @@ -428,6 +610,21 @@ source: crates/oxc_linter/src/tester.rs โ•ฐโ”€โ”€โ”€โ”€ help: The spread operator (`...`) is more concise and readable. + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over array.concat() + โ•ญโ”€[prefer_spread.tsx:4:18] + 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 โ”‚ โ•ฐโ”€โ–ถ ) + โ•ฐโ”€โ”€โ”€โ”€ + help: The spread operator (`...`) is more concise and readable. + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over array.concat() โ•ญโ”€[prefer_spread.tsx:1:1] 1 โ”‚ [].concat((a.b.c), 2) @@ -561,6 +758,14 @@ source: crates/oxc_linter/src/tester.rs โ•ฐโ”€โ”€โ”€โ”€ help: The spread operator (`...`) is more concise and readable. + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over array.concat() + โ•ญโ”€[prefer_spread.tsx:2:17] + 1 โ”‚ const baz = [2]; + 2 โ”‚ call(foo, ...[bar].concat(baz)); + ยท โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + โ•ฐโ”€โ”€โ”€โ”€ + help: The spread operator (`...`) is more concise and readable. + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over array.concat() โ•ญโ”€[prefer_spread.tsx:1:1] 1 โ”‚ foo.join(foo, bar).concat("...") @@ -617,6 +822,21 @@ source: crates/oxc_linter/src/tester.rs โ•ฐโ”€โ”€โ”€โ”€ help: The spread operator (`...`) is more concise and readable. + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over array.slice() + โ•ญโ”€[prefer_spread.tsx:1:1] + 1 โ”‚ (scopeManager?.scopes).slice() + ยท โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + โ•ฐโ”€โ”€โ”€โ”€ + help: The spread operator (`...`) is more concise and readable. + + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over array.slice() + โ•ญโ”€[prefer_spread.tsx:2:4] + 1 โ”‚ bar() + 2 โ”‚ foo.slice() + ยท โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + โ•ฐโ”€โ”€โ”€โ”€ + help: The spread operator (`...`) is more concise and readable. + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over array.slice() โ•ญโ”€[prefer_spread.tsx:1:1] 1 โ”‚ "".slice() @@ -694,6 +914,14 @@ source: crates/oxc_linter/src/tester.rs โ•ฐโ”€โ”€โ”€โ”€ help: The spread operator (`...`) is more concise and readable. + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over array.toSpliced() + โ•ญโ”€[prefer_spread.tsx:2:9] + 1 โ”‚ bar() + 2 โ”‚ foo.toSpliced() + ยท โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + โ•ฐโ”€โ”€โ”€โ”€ + help: The spread operator (`...`) is more concise and readable. + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over array.toSpliced() โ•ญโ”€[prefer_spread.tsx:1:1] 1 โ”‚ "".toSpliced() @@ -743,6 +971,14 @@ source: crates/oxc_linter/src/tester.rs โ•ฐโ”€โ”€โ”€โ”€ help: The spread operator (`...`) is more concise and readable. + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over string.split() + โ•ญโ”€[prefer_spread.tsx:2:9] + 1 โ”‚ bar() + 2 โ”‚ foo.split("") + ยท โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + โ•ฐโ”€โ”€โ”€โ”€ + help: The spread operator (`...`) is more concise and readable. + โš  eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (`...`) over string.split() โ•ญโ”€[prefer_spread.tsx:1:1] 1 โ”‚ unknown.split("")