Skip to content

Commit c73225e

Browse files
say8425camchenry
andauthored
feat(linter/eslint): implement prefer-arrow-callback rule (#22312)
this PR implements `eslint/prefer-arrow-callback` rule, passes all upstream tests (39 pass + 68 fail cases, 51 autofix snapshots). Highlights: - Honors `allowNamedFunctions` and `allowUnboundThis` options (defaults match ESLint). - Strips `.bind(this)` chains during autofix and re-wraps the arrow in parens when needed (member access, logical/binary operands). - Handles optional chaining (`function?.bind(this)`, `foo?.(...)`) and parenthesized callbacks. issue #479 **AI Disclosure**: I used AI (Claude) to help with Rust idioms and oxc internals. All output was reviewed locally; `cargo test -p oxc_linter`, `cargo clippy -p oxc_linter --no-deps`, and `cargo fmt --check` are clean. --------- Co-authored-by: Cam McHenry <camchenry@users.noreply.github.com>
1 parent 3c53a95 commit c73225e

8 files changed

Lines changed: 1088 additions & 2 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,7 @@ export interface DummyRuleMap {
866866
"oxc/number-arg-out-of-range"?: DummyRule;
867867
"oxc/only-used-in-recursion"?: DummyRule;
868868
"oxc/uninvoked-array-callback"?: DummyRule;
869+
"prefer-arrow-callback"?: DummyRule;
869870
"prefer-const"?: DummyRule;
870871
"prefer-destructuring"?: DummyRule;
871872
"prefer-exponentiation-operator"?: DummyRule;

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: 28 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
@@ -195,6 +195,7 @@ pub(crate) mod eslint {
195195
pub mod no_with;
196196
pub mod object_shorthand;
197197
pub mod operator_assignment;
198+
pub mod prefer_arrow_callback;
198199
pub mod prefer_const;
199200
pub mod prefer_destructuring;
200201
pub mod prefer_exponentiation_operator;

0 commit comments

Comments
 (0)