FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat(linter/unicorn): implement `no-confusing-array-with` rule (#23638) · oxc-project/oxc@85735cb · GitHub

Repository navigation

Commit 85735cb

Browse files
andauthored
feat(linter/unicorn): implement no-confusing-array-with rule (#23638)
Implements unicorn/no-confusing-array-with, which flags two ways Array#with() calls can silently misbehave: A literal negative index (array.with(-1, value)). Unlike slice()/splice(), with() treats a negative index as an offset from the end of the array, which is easy to assume incorrectly. .length used as the index (array.with(array.length, value)), which is always out of bounds and always produces a RangeError / unintended result, since valid indices run 0 .. length - 1. --------- Co-authored-by: Cameron <cameron.clark@hey.com>
1 parent e703120 commit 85735cb

7 files changed

Lines changed: 469 additions & 1 deletion

File tree

‎apps/oxlint/src-js/package/config.generated.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,6 +1530,7 @@ export interface DummyRuleMap {
15301530
"unicorn/no-array-sort"?: RuleNoConfig | [AllowWarnDeny, NoArraySort];
15311531
"unicorn/no-await-expression-member"?: RuleNoConfig;
15321532
"unicorn/no-await-in-promise-methods"?: RuleNoConfig;
1533+
"unicorn/no-confusing-array-with"?: RuleNoConfig;
15331534
"unicorn/no-console-spaces"?: RuleNoConfig;
15341535
"unicorn/no-document-cookie"?: RuleNoConfig;
15351536
"unicorn/no-empty-file"?: RuleNoConfig;

‎crates/oxc_linter/src/generated/rule_runner_impls.rs‎

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎crates/oxc_linter/src/generated/rules_enum.rs‎

Lines changed: 29 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎crates/oxc_linter/src/rules.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,7 @@ pub(crate) mod unicorn {
512512
pub mod no_array_sort;
513513
pub mod no_await_expression_member;
514514
pub mod no_await_in_promise_methods;
515+
pub mod no_confusing_array_with;
515516
pub mod no_console_spaces;
516517
pub mod no_document_cookie;
517518
pub mod no_empty_file;

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL