Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,13 @@ impl Rule for PreferNumberProperties {

let fixer = |fixer: RuleFixer<'_, 'a>| match &call_expr.callee {
Expression::Identifier(ident) => {
fixer.insert_text_before(&ident.span, "Number.")
// Use replace on the full call expression span instead of insert_text_before.
// This ensures the fix span overlaps with prefer_numeric_literals fixes,
// so the fixer's conflict resolution will skip one of them instead of
// applying both and producing invalid code like `Number.0o111`.
let args_span = Span::new(ident.span.end, call_expr.span.end);
let args_text = ctx.source_range(args_span);
fixer.replace(call_expr.span, format!("Number.{ident_name}{args_text}"))
}
match_member_expression!(Expression) => {
let member_expr = call_expr.callee.to_member_expression();
Expand Down Expand Up @@ -550,6 +556,7 @@ function inner() {
"let a = +(Number.POSITIVE_INFINITY)",
Some(json!([{"checkInfinity":true}])),
),
(r#"parseInt("111", 8)"#, r#"Number.parseInt("111", 8)"#, None),
];

Tester::new(PreferNumberProperties::NAME, PreferNumberProperties::PLUGIN, pass, fail)
Expand Down
Loading