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
38 changes: 20 additions & 18 deletions crates/oxc_linter/src/rules/eslint/no_console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,28 +111,30 @@ impl Rule for NoConsole {
return;
};

if ident.name == "console"
&& ctx.scoping().root_unresolved_references().contains_key("console")
if ident.name != "console"
|| !ctx.scoping().root_unresolved_references().contains_key("console")
{
if let Some((mem_span, prop_name)) = member_expr.static_property_info() {
if self.allow.iter().any(|allowed_name| allowed_name == prop_name) {
return;
}
return;
}

let diagnostic_span = ident.span().merge(mem_span);
if let Some((mem_span, prop_name)) = member_expr.static_property_info() {
if self.allow.iter().any(|allowed_name| allowed_name == prop_name) {
return;
}

ctx.diagnostic_with_suggestion(
no_console_diagnostic(diagnostic_span, &self.allow),
|fixer| {
if let Some(parent) = ctx.nodes().parent_node(node.id()) {
if let AstKind::CallExpression(_) = parent.kind() {
return remove_console(fixer, ctx, parent);
}
let diagnostic_span = ident.span().merge(mem_span);

ctx.diagnostic_with_suggestion(
no_console_diagnostic(diagnostic_span, &self.allow),
|fixer| {
if let Some(parent) = ctx.nodes().parent_node(node.id()) {
if let AstKind::CallExpression(_) = parent.kind() {
return remove_console(fixer, ctx, parent);
}
fixer.noop()
},
);
}
}
fixer.noop()
},
);
}
}
}
Expand Down
Loading