From b622ef87adf1bbed1e76ba0f610b653acb93e72b Mon Sep 17 00:00:00 2001 From: connorshea <2977353+connorshea@users.noreply.github.com> Date: Wed, 19 Nov 2025 10:43:42 +0000 Subject: [PATCH] fix(linter): Fix `oxc/bad_array_method_on_arguments` rule behavior. (#15854) This was allowing a number of methods which are entirely invalid to call on the `arguments` object, based on what TypeScript reports and from testing most of these additions in Firefox. It was missing some methods that have been added in the last few years, including findLast, findLastIndex, toReversed, etc. It also was still referring to `groupBy` as `groupToMap`. Also improve the docs and all that. I think we should consider adding a rule to just ban the usage of `arguments` entirely, with rest parameters being fully standardized for a decade now. [TS Playground example](https://www.typescriptlang.org/play/?target=9#code/GYVwdgxgLglg9mABMMAKAlIg3gKEYgQwCcBzEAWwFMwoBnAOmBjABMAZA2qVDRAXgB82AL7oA3DmE4coSLATIwAJl658xMlRoMmrDlwCSrSgA8emQSPGTps6PCQoAzKryFSFanXokicEAAOAEIAnub8QliiElIy4PYKKAAsqu6aXgxQcABKlABulES0lCzhllGYUnbyjmAArKkantr0WQDKcERQJWWRoohV8TWKAGyNHlre7QEANjAQPQAMlUA) --- .../oxc/bad_array_method_on_arguments.rs | 45 +++-- .../oxc_bad_array_method_on_arguments.snap | 183 +++++++++++------- 2 files changed, 148 insertions(+), 80 deletions(-) diff --git a/crates/oxc_linter/src/rules/oxc/bad_array_method_on_arguments.rs b/crates/oxc_linter/src/rules/oxc/bad_array_method_on_arguments.rs index d910f63704d3b..5f7954f9d1fd7 100644 --- a/crates/oxc_linter/src/rules/oxc/bad_array_method_on_arguments.rs +++ b/crates/oxc_linter/src/rules/oxc/bad_array_method_on_arguments.rs @@ -6,9 +6,9 @@ use oxc_span::{GetSpan, Span}; use crate::{AstNode, context::LintContext, rule::Rule}; fn bad_array_method_on_arguments_diagnostic(method_name: &str, span: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("Bad array method on arguments") + OxcDiagnostic::warn("Bad array method on `arguments`.") .with_help(format!( - "The 'arguments' object does not have a '{method_name}()' method. If you intended to use an array method, consider converting the 'arguments' object to an array or using an ES2015 rest parameter instead." + "The `arguments` object does not have a `{method_name}()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array." )) .with_label(span) } @@ -23,9 +23,16 @@ declare_oxc_lint!( /// /// ### Why is this bad? /// - /// The arguments object is not an array, but an array-like object. It should be converted to a real array before calling an array method. + /// The [arguments object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments) + /// is not an array, but an array-like object. It should be converted to a real array before calling an array method. /// Otherwise, a TypeError exception will be thrown because of the non-existent method. /// + /// Note that you probably don't need this rule if you are using exclusively + /// TypeScript, as it will catch these errors when typechecking. + /// + /// `arguments` usage is usually discouraged in modern JavaScript, and you should prefer using + /// rest parameters instead, e.g. `function sum(...args)`. + /// /// ### Examples /// /// Examples of **incorrect** code for this rule: @@ -43,6 +50,7 @@ declare_oxc_lint!( /// function add(x, y) { /// return x + y; /// } + /// /// function sum(...args) { /// return args.reduce(add, 0); /// } @@ -76,24 +84,27 @@ impl Rule for BadArrayMethodOnArguments { } } -/// `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array#instance_methods` +/// #[rustfmt::skip] -const ARRAY_METHODS: [&str; 32] = [ +const ARRAY_METHODS: [&str; 38] = [ "@@iterator", "at", "concat", "copyWithin", "entries", "every", - "fill", "filter", "find", "findIndex", "flat", "flatMap", "forEach", + "fill", "filter", "find", "findIndex", "findLast", "findLastIndex", "flat", "flatMap", "forEach", + "groupBy", "includes", "indexOf", "join", "keys", "lastIndexOf", "map", - "pop", "push", "push", + "pop", "push", "reduce", "reduceRight", "reverse", "shift", "slice", "some", "sort", "splice", + "toReversed", "toSorted", "toSpliced", "unshift", "values", + "with", ]; #[test] @@ -116,13 +127,7 @@ fn test() { ("function fn() {arguments[`${'map'}`]((prev, cur) => prev + cur, 0)}", None), ("function fn() {arguments.toLocaleString(() => {})}", None), ("function fn() {arguments.toString(() => {})}", None), - ("function fn() {arguments.findLast(() => {})}", None), - ("function fn() {arguments.group(() => {})}", None), - ("function fn() {arguments.groupToMap(() => {})}", None), - ("function fn() {arguments.toReversed(() => {})}", None), - ("function fn() {arguments.toSorted(() => {})}", None), - ("function fn() {arguments.toSpliced(0)}", None), - ("function fn() {arguments.with(1, 1)}", None), + ("function fn() { Array.prototype.slice.call(arguments) }", None), ]; let fail = vec![ @@ -137,9 +142,12 @@ fn test() { ("function fn() {arguments.filter(() => {})}", None), ("function fn() {arguments.find(() => {})}", None), ("function fn() {arguments.findIndex(() => {})}", None), + ("function fn() {arguments.findLast(() => {})}", None), + ("function fn() {arguments.findLastIndex(() => {})}", None), ("function fn() {arguments.flat(() => {})}", None), ("function fn() {arguments.flatMap(() => {})}", None), ("function fn() {arguments.forEach(() => {})}", None), + ("function fn() {arguments.groupBy(() => {})}", None), ("function fn() {arguments.includes(() => {})}", None), ("function fn() {arguments.indexOf(() => {})}", None), ("function fn() {arguments.join()}", None), @@ -156,9 +164,18 @@ fn test() { ("function fn() {arguments.some(() => {})}", None), ("function fn() {arguments.sort(() => {})}", None), ("function fn() {arguments.splice(() => {})}", None), + ("function fn() {arguments.toReversed(() => {})}", None), + ("function fn() {arguments.toSorted(() => {})}", None), + ("function fn() {arguments.toSpliced(0)}", None), ("function fn() {arguments.unshift()}", None), ("function fn() {arguments.values()}", None), ("function fn() {arguments['@@iterator'](() => {})}", None), + ( + "const arr = [1, 2, 3, 4, 5]; + function fn() { arguments.with(2, 6) } + fn(arr)", + None, + ), ]; Tester::new(BadArrayMethodOnArguments::NAME, BadArrayMethodOnArguments::PLUGIN, pass, fail) diff --git a/crates/oxc_linter/src/snapshots/oxc_bad_array_method_on_arguments.snap b/crates/oxc_linter/src/snapshots/oxc_bad_array_method_on_arguments.snap index 41a1dd4c86b61..b4adc450beb28 100644 --- a/crates/oxc_linter/src/snapshots/oxc_bad_array_method_on_arguments.snap +++ b/crates/oxc_linter/src/snapshots/oxc_bad_array_method_on_arguments.snap @@ -1,233 +1,284 @@ --- source: crates/oxc_linter/src/tester.rs --- - ⚠ oxc(bad-array-method-on-arguments): Bad array method on arguments + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. ╭─[bad_array_method_on_arguments.tsx:1:16] 1 │ function fn() {arguments['map'](() => {})} · ──────────────── ╰──── - help: The 'arguments' object does not have a 'map()' method. If you intended to use an array method, consider converting the 'arguments' object to an array or using an ES2015 rest parameter instead. + help: The `arguments` object does not have a `map()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. - ⚠ oxc(bad-array-method-on-arguments): Bad array method on arguments + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. ╭─[bad_array_method_on_arguments.tsx:1:16] 1 │ function fn() {arguments[`map`](() => {})} · ──────────────── ╰──── - help: The 'arguments' object does not have a 'map()' method. If you intended to use an array method, consider converting the 'arguments' object to an array or using an ES2015 rest parameter instead. + help: The `arguments` object does not have a `map()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. - ⚠ oxc(bad-array-method-on-arguments): Bad array method on arguments + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. ╭─[bad_array_method_on_arguments.tsx:1:16] 1 │ function fn() {arguments.at(0)} · ──────────── ╰──── - help: The 'arguments' object does not have a 'at()' method. If you intended to use an array method, consider converting the 'arguments' object to an array or using an ES2015 rest parameter instead. + help: The `arguments` object does not have a `at()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. - ⚠ oxc(bad-array-method-on-arguments): Bad array method on arguments + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. ╭─[bad_array_method_on_arguments.tsx:1:16] 1 │ function fn() {arguments.concat([])} · ──────────────── ╰──── - help: The 'arguments' object does not have a 'concat()' method. If you intended to use an array method, consider converting the 'arguments' object to an array or using an ES2015 rest parameter instead. + help: The `arguments` object does not have a `concat()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. - ⚠ oxc(bad-array-method-on-arguments): Bad array method on arguments + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. ╭─[bad_array_method_on_arguments.tsx:1:16] 1 │ function fn() {arguments.copyWithin(0)} · ──────────────────── ╰──── - help: The 'arguments' object does not have a 'copyWithin()' method. If you intended to use an array method, consider converting the 'arguments' object to an array or using an ES2015 rest parameter instead. + help: The `arguments` object does not have a `copyWithin()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. - ⚠ oxc(bad-array-method-on-arguments): Bad array method on arguments + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. ╭─[bad_array_method_on_arguments.tsx:1:16] 1 │ function fn() {arguments.entries()} · ───────────────── ╰──── - help: The 'arguments' object does not have a 'entries()' method. If you intended to use an array method, consider converting the 'arguments' object to an array or using an ES2015 rest parameter instead. + help: The `arguments` object does not have a `entries()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. - ⚠ oxc(bad-array-method-on-arguments): Bad array method on arguments + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. ╭─[bad_array_method_on_arguments.tsx:1:16] 1 │ function fn() {arguments.every(() => {})} · ─────────────── ╰──── - help: The 'arguments' object does not have a 'every()' method. If you intended to use an array method, consider converting the 'arguments' object to an array or using an ES2015 rest parameter instead. + help: The `arguments` object does not have a `every()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. - ⚠ oxc(bad-array-method-on-arguments): Bad array method on arguments + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. ╭─[bad_array_method_on_arguments.tsx:1:16] 1 │ function fn() {arguments.fill(() => {})} · ────────────── ╰──── - help: The 'arguments' object does not have a 'fill()' method. If you intended to use an array method, consider converting the 'arguments' object to an array or using an ES2015 rest parameter instead. + help: The `arguments` object does not have a `fill()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. - ⚠ oxc(bad-array-method-on-arguments): Bad array method on arguments + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. ╭─[bad_array_method_on_arguments.tsx:1:16] 1 │ function fn() {arguments.filter(() => {})} · ──────────────── ╰──── - help: The 'arguments' object does not have a 'filter()' method. If you intended to use an array method, consider converting the 'arguments' object to an array or using an ES2015 rest parameter instead. + help: The `arguments` object does not have a `filter()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. - ⚠ oxc(bad-array-method-on-arguments): Bad array method on arguments + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. ╭─[bad_array_method_on_arguments.tsx:1:16] 1 │ function fn() {arguments.find(() => {})} · ────────────── ╰──── - help: The 'arguments' object does not have a 'find()' method. If you intended to use an array method, consider converting the 'arguments' object to an array or using an ES2015 rest parameter instead. + help: The `arguments` object does not have a `find()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. - ⚠ oxc(bad-array-method-on-arguments): Bad array method on arguments + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. ╭─[bad_array_method_on_arguments.tsx:1:16] 1 │ function fn() {arguments.findIndex(() => {})} · ─────────────────── ╰──── - help: The 'arguments' object does not have a 'findIndex()' method. If you intended to use an array method, consider converting the 'arguments' object to an array or using an ES2015 rest parameter instead. + help: The `arguments` object does not have a `findIndex()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. - ⚠ oxc(bad-array-method-on-arguments): Bad array method on arguments + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. + ╭─[bad_array_method_on_arguments.tsx:1:16] + 1 │ function fn() {arguments.findLast(() => {})} + · ────────────────── + ╰──── + help: The `arguments` object does not have a `findLast()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. + + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. + ╭─[bad_array_method_on_arguments.tsx:1:16] + 1 │ function fn() {arguments.findLastIndex(() => {})} + · ─────────────────────── + ╰──── + help: The `arguments` object does not have a `findLastIndex()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. + + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. ╭─[bad_array_method_on_arguments.tsx:1:16] 1 │ function fn() {arguments.flat(() => {})} · ────────────── ╰──── - help: The 'arguments' object does not have a 'flat()' method. If you intended to use an array method, consider converting the 'arguments' object to an array or using an ES2015 rest parameter instead. + help: The `arguments` object does not have a `flat()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. - ⚠ oxc(bad-array-method-on-arguments): Bad array method on arguments + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. ╭─[bad_array_method_on_arguments.tsx:1:16] 1 │ function fn() {arguments.flatMap(() => {})} · ───────────────── ╰──── - help: The 'arguments' object does not have a 'flatMap()' method. If you intended to use an array method, consider converting the 'arguments' object to an array or using an ES2015 rest parameter instead. + help: The `arguments` object does not have a `flatMap()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. - ⚠ oxc(bad-array-method-on-arguments): Bad array method on arguments + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. ╭─[bad_array_method_on_arguments.tsx:1:16] 1 │ function fn() {arguments.forEach(() => {})} · ───────────────── ╰──── - help: The 'arguments' object does not have a 'forEach()' method. If you intended to use an array method, consider converting the 'arguments' object to an array or using an ES2015 rest parameter instead. + help: The `arguments` object does not have a `forEach()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. + + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. + ╭─[bad_array_method_on_arguments.tsx:1:16] + 1 │ function fn() {arguments.groupBy(() => {})} + · ───────────────── + ╰──── + help: The `arguments` object does not have a `groupBy()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. - ⚠ oxc(bad-array-method-on-arguments): Bad array method on arguments + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. ╭─[bad_array_method_on_arguments.tsx:1:16] 1 │ function fn() {arguments.includes(() => {})} · ────────────────── ╰──── - help: The 'arguments' object does not have a 'includes()' method. If you intended to use an array method, consider converting the 'arguments' object to an array or using an ES2015 rest parameter instead. + help: The `arguments` object does not have a `includes()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. - ⚠ oxc(bad-array-method-on-arguments): Bad array method on arguments + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. ╭─[bad_array_method_on_arguments.tsx:1:16] 1 │ function fn() {arguments.indexOf(() => {})} · ───────────────── ╰──── - help: The 'arguments' object does not have a 'indexOf()' method. If you intended to use an array method, consider converting the 'arguments' object to an array or using an ES2015 rest parameter instead. + help: The `arguments` object does not have a `indexOf()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. - ⚠ oxc(bad-array-method-on-arguments): Bad array method on arguments + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. ╭─[bad_array_method_on_arguments.tsx:1:16] 1 │ function fn() {arguments.join()} · ────────────── ╰──── - help: The 'arguments' object does not have a 'join()' method. If you intended to use an array method, consider converting the 'arguments' object to an array or using an ES2015 rest parameter instead. + help: The `arguments` object does not have a `join()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. - ⚠ oxc(bad-array-method-on-arguments): Bad array method on arguments + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. ╭─[bad_array_method_on_arguments.tsx:1:16] 1 │ function fn() {arguments.keys()} · ────────────── ╰──── - help: The 'arguments' object does not have a 'keys()' method. If you intended to use an array method, consider converting the 'arguments' object to an array or using an ES2015 rest parameter instead. + help: The `arguments` object does not have a `keys()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. - ⚠ oxc(bad-array-method-on-arguments): Bad array method on arguments + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. ╭─[bad_array_method_on_arguments.tsx:1:16] 1 │ function fn() {arguments.lastIndexOf('')} · ───────────────────── ╰──── - help: The 'arguments' object does not have a 'lastIndexOf()' method. If you intended to use an array method, consider converting the 'arguments' object to an array or using an ES2015 rest parameter instead. + help: The `arguments` object does not have a `lastIndexOf()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. - ⚠ oxc(bad-array-method-on-arguments): Bad array method on arguments + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. ╭─[bad_array_method_on_arguments.tsx:1:16] 1 │ function fn() {arguments.map(() => {})} · ───────────── ╰──── - help: The 'arguments' object does not have a 'map()' method. If you intended to use an array method, consider converting the 'arguments' object to an array or using an ES2015 rest parameter instead. + help: The `arguments` object does not have a `map()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. - ⚠ oxc(bad-array-method-on-arguments): Bad array method on arguments + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. ╭─[bad_array_method_on_arguments.tsx:1:16] 1 │ function fn() {arguments.pop()} · ───────────── ╰──── - help: The 'arguments' object does not have a 'pop()' method. If you intended to use an array method, consider converting the 'arguments' object to an array or using an ES2015 rest parameter instead. + help: The `arguments` object does not have a `pop()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. - ⚠ oxc(bad-array-method-on-arguments): Bad array method on arguments + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. ╭─[bad_array_method_on_arguments.tsx:1:16] 1 │ function fn() {arguments.push('')} · ────────────── ╰──── - help: The 'arguments' object does not have a 'push()' method. If you intended to use an array method, consider converting the 'arguments' object to an array or using an ES2015 rest parameter instead. + help: The `arguments` object does not have a `push()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. - ⚠ oxc(bad-array-method-on-arguments): Bad array method on arguments + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. ╭─[bad_array_method_on_arguments.tsx:1:16] 1 │ function fn() {arguments.reduce(() => {})} · ──────────────── ╰──── - help: The 'arguments' object does not have a 'reduce()' method. If you intended to use an array method, consider converting the 'arguments' object to an array or using an ES2015 rest parameter instead. + help: The `arguments` object does not have a `reduce()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. - ⚠ oxc(bad-array-method-on-arguments): Bad array method on arguments + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. ╭─[bad_array_method_on_arguments.tsx:1:16] 1 │ function fn() {arguments.reduceRight(() => {})} · ───────────────────── ╰──── - help: The 'arguments' object does not have a 'reduceRight()' method. If you intended to use an array method, consider converting the 'arguments' object to an array or using an ES2015 rest parameter instead. + help: The `arguments` object does not have a `reduceRight()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. - ⚠ oxc(bad-array-method-on-arguments): Bad array method on arguments + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. ╭─[bad_array_method_on_arguments.tsx:1:16] 1 │ function fn() {arguments.reverse()} · ───────────────── ╰──── - help: The 'arguments' object does not have a 'reverse()' method. If you intended to use an array method, consider converting the 'arguments' object to an array or using an ES2015 rest parameter instead. + help: The `arguments` object does not have a `reverse()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. - ⚠ oxc(bad-array-method-on-arguments): Bad array method on arguments + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. ╭─[bad_array_method_on_arguments.tsx:1:16] 1 │ function fn() {arguments.shift()} · ─────────────── ╰──── - help: The 'arguments' object does not have a 'shift()' method. If you intended to use an array method, consider converting the 'arguments' object to an array or using an ES2015 rest parameter instead. + help: The `arguments` object does not have a `shift()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. - ⚠ oxc(bad-array-method-on-arguments): Bad array method on arguments + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. ╭─[bad_array_method_on_arguments.tsx:1:16] 1 │ function fn() {arguments.slice()} · ─────────────── ╰──── - help: The 'arguments' object does not have a 'slice()' method. If you intended to use an array method, consider converting the 'arguments' object to an array or using an ES2015 rest parameter instead. + help: The `arguments` object does not have a `slice()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. - ⚠ oxc(bad-array-method-on-arguments): Bad array method on arguments + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. ╭─[bad_array_method_on_arguments.tsx:1:16] 1 │ function fn() {arguments.some(() => {})} · ────────────── ╰──── - help: The 'arguments' object does not have a 'some()' method. If you intended to use an array method, consider converting the 'arguments' object to an array or using an ES2015 rest parameter instead. + help: The `arguments` object does not have a `some()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. - ⚠ oxc(bad-array-method-on-arguments): Bad array method on arguments + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. ╭─[bad_array_method_on_arguments.tsx:1:16] 1 │ function fn() {arguments.sort(() => {})} · ────────────── ╰──── - help: The 'arguments' object does not have a 'sort()' method. If you intended to use an array method, consider converting the 'arguments' object to an array or using an ES2015 rest parameter instead. + help: The `arguments` object does not have a `sort()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. - ⚠ oxc(bad-array-method-on-arguments): Bad array method on arguments + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. ╭─[bad_array_method_on_arguments.tsx:1:16] 1 │ function fn() {arguments.splice(() => {})} · ──────────────── ╰──── - help: The 'arguments' object does not have a 'splice()' method. If you intended to use an array method, consider converting the 'arguments' object to an array or using an ES2015 rest parameter instead. + help: The `arguments` object does not have a `splice()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. + + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. + ╭─[bad_array_method_on_arguments.tsx:1:16] + 1 │ function fn() {arguments.toReversed(() => {})} + · ──────────────────── + ╰──── + help: The `arguments` object does not have a `toReversed()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. + + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. + ╭─[bad_array_method_on_arguments.tsx:1:16] + 1 │ function fn() {arguments.toSorted(() => {})} + · ────────────────── + ╰──── + help: The `arguments` object does not have a `toSorted()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. - ⚠ oxc(bad-array-method-on-arguments): Bad array method on arguments + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. + ╭─[bad_array_method_on_arguments.tsx:1:16] + 1 │ function fn() {arguments.toSpliced(0)} + · ─────────────────── + ╰──── + help: The `arguments` object does not have a `toSpliced()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. + + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. ╭─[bad_array_method_on_arguments.tsx:1:16] 1 │ function fn() {arguments.unshift()} · ───────────────── ╰──── - help: The 'arguments' object does not have a 'unshift()' method. If you intended to use an array method, consider converting the 'arguments' object to an array or using an ES2015 rest parameter instead. + help: The `arguments` object does not have a `unshift()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. - ⚠ oxc(bad-array-method-on-arguments): Bad array method on arguments + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. ╭─[bad_array_method_on_arguments.tsx:1:16] 1 │ function fn() {arguments.values()} · ──────────────── ╰──── - help: The 'arguments' object does not have a 'values()' method. If you intended to use an array method, consider converting the 'arguments' object to an array or using an ES2015 rest parameter instead. + help: The `arguments` object does not have a `values()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. - ⚠ oxc(bad-array-method-on-arguments): Bad array method on arguments + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. ╭─[bad_array_method_on_arguments.tsx:1:16] 1 │ function fn() {arguments['@@iterator'](() => {})} · ─────────────────────── ╰──── - help: The 'arguments' object does not have a '@@iterator()' method. If you intended to use an array method, consider converting the 'arguments' object to an array or using an ES2015 rest parameter instead. + help: The `arguments` object does not have a `@@iterator()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array. + + ⚠ oxc(bad-array-method-on-arguments): Bad array method on `arguments`. + ╭─[bad_array_method_on_arguments.tsx:2:30] + 1 │ const arr = [1, 2, 3, 4, 5]; + 2 │ function fn() { arguments.with(2, 6) } + · ────────────── + 3 │ fn(arr) + ╰──── + help: The `arguments` object does not have a `with()` method. If you intended to use an array method, consider using rest parameters instead or converting the `arguments` object to an array.