Skip to content

Commit

Permalink
fix(linter/no-unused-vars): mark the class/function in the new expres…
Browse files Browse the repository at this point in the history
…sion as used (#5306)

Fix: #5274
  • Loading branch information
magic-akari authored Aug 28, 2024
1 parent 08dc0ad commit 318479e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crates/oxc_linter/src/rules/eslint/no_unused_vars/allowed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ impl<'s, 'a> Symbol<'s, 'a> {
// e.g. var foo = function bar() { }
// we don't want to check for violations on `bar`, just `foo`
| AstKind::VariableDeclarator(_)
// new (class CustomRenderer{})
// new (function() {})
| AstKind::NewExpression(_)
=> {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ fn test_vars_simple() {
("let a = 1; if (true) { console.log(a) }", None),
("let _a = 1", Some(json!([{ "varsIgnorePattern": "^_" }]))),
("const { foo: _foo, baz } = obj; f(baz);", Some(json!([{ "varsIgnorePattern": "^_" }]))),
(
r"export const rendered = marked(markdown, {
renderer: new (class CustomRenderer extends Renderer {})(),
});",
None,
),
];
let fail = vec![
("let a = 1", None),
Expand Down

0 comments on commit 318479e

Please sign in to comment.