mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
fix(linter/no-unused-vars): mark the class/function in the new expression as used (#5306)
Fix: #5274
This commit is contained in:
parent
08dc0adeab
commit
318479ec4d
2 changed files with 9 additions and 0 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
Loading…
Reference in a new issue