Skip to content

Commit 318479e

Browse files
authoredAug 28, 2024··
fix(linter/no-unused-vars): mark the class/function in the new expression as used (#5306)
Fix: #5274
1 parent 08dc0ad commit 318479e

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed
 

‎crates/oxc_linter/src/rules/eslint/no_unused_vars/allowed.rs

+3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ impl<'s, 'a> Symbol<'s, 'a> {
4242
// e.g. var foo = function bar() { }
4343
// we don't want to check for violations on `bar`, just `foo`
4444
| AstKind::VariableDeclarator(_)
45+
// new (class CustomRenderer{})
46+
// new (function() {})
47+
| AstKind::NewExpression(_)
4548
=> {
4649
return true;
4750
}

‎crates/oxc_linter/src/rules/eslint/no_unused_vars/tests/oxc.rs

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ fn test_vars_simple() {
1313
("let a = 1; if (true) { console.log(a) }", None),
1414
("let _a = 1", Some(json!([{ "varsIgnorePattern": "^_" }]))),
1515
("const { foo: _foo, baz } = obj; f(baz);", Some(json!([{ "varsIgnorePattern": "^_" }]))),
16+
(
17+
r"export const rendered = marked(markdown, {
18+
renderer: new (class CustomRenderer extends Renderer {})(),
19+
});",
20+
None,
21+
),
1622
];
1723
let fail = vec![
1824
("let a = 1", None),

0 commit comments

Comments
 (0)
Please sign in to comment.