diff --git a/crates/oxc_linter/src/rules/eslint/no_unused_vars/symbol.rs b/crates/oxc_linter/src/rules/eslint/no_unused_vars/symbol.rs index ce4eac741f2d2..20f65a9a74921 100644 --- a/crates/oxc_linter/src/rules/eslint/no_unused_vars/symbol.rs +++ b/crates/oxc_linter/src/rules/eslint/no_unused_vars/symbol.rs @@ -182,7 +182,16 @@ impl<'s, 'a> Symbol<'s, 'a> { AstKind::ModuleDeclaration(module) => { return module.is_export(); } - AstKind::VariableDeclaration(_) => { + AstKind::ExportDefaultDeclaration(_) => { + return true; + } + AstKind::VariableDeclaration(_) + | AstKind::ExpressionArrayElement(_) + | AstKind::ArrayExpressionElement(_) + | AstKind::ArrayExpression(_) + | AstKind::ParenthesizedExpression(_) + | AstKind::TSAsExpression(_) + | AstKind::TSSatisfiesExpression(_) => { continue; } _ => { diff --git a/crates/oxc_linter/src/rules/eslint/no_unused_vars/tests/oxc.rs b/crates/oxc_linter/src/rules/eslint/no_unused_vars/tests/oxc.rs index 92555dc9dbdee..844bf2e714808 100644 --- a/crates/oxc_linter/src/rules/eslint/no_unused_vars/tests/oxc.rs +++ b/crates/oxc_linter/src/rules/eslint/no_unused_vars/tests/oxc.rs @@ -730,6 +730,15 @@ fn test_exports() { "export interface A {}", "export type A = string", "export enum E { }", + // default exports + "export default class Foo {}", + "export default [ class Foo {} ];", + "export default function foo() {}", + "export default { foo() {} };", + "export default { foo: function foo() {} };", + "export default { get foo() {} };", + "export default [ function foo() {} ];", + "export default (function foo() { return 1 })();", // "export enum E { A, B }", "const a = 1; export { a }", "const a = 1; export default a",