ISSUE DESCRIPTION linter: no-unused-vars false positive when constructor parameter…
- User
ISSUE DESCRIPTION
linter: no-unused-vars false positive when constructor parameter property shadows an imported identifier used in its own decorator
What version of Oxlint are you using?
1.65.0 (also reproduces on 1.30.0)
What command did you run?
oxlint test.tsWhat does your
.oxlintrc.json(oroxlint.config.ts) config file look like?// default (no config file)What happened?
When a TypeScript constructor parameter property has the same name as an outer binding (import or
const), and that outer binding is used in the parameter's own decorator expression (e.g.@Inject(foo.KEY)), oxlint'sno-unused-varsreports the outer binding as declared but never used.This is a false positive. Parameter decorators are evaluated at class-decoration time in the enclosing class scope, before any parameter binding exists in the parameter scope. So
fooinside@Inject(foo.KEY)resolves to the outer binding, not to the same-named parameter property.This pattern is extremely common in NestJS code, where
@Inject(someConfig.KEY)is used to injectregisterAs(...)-style typed configs and the constructor parameter property is typically named after the config. The false positive forces a churn-y workaround: either alias the import (import { foo as _foo }) or rename the parameter property.Minimal reproduction
const foo = { KEY: 'token' }; declare function Inject(token: unknown): ParameterDecorator; export class C { constructor(@Inject(foo.KEY) private readonly foo: number) {} }Actual
! eslint(no-unused-vars): Variable 'foo' is declared but never used. Unused variables should start with a '_'. ,-[test.ts:1:7] 1 | const foo = { KEY: 'token' }; : ^|^ : `-- 'foo' is declared hereExpected
No diagnostics —
foois used in@Inject(foo.KEY).ESLint with
@typescript-eslint/parser+@typescript-eslint/eslint-plugindoes not report this — its scope analyser correctly counts the decorator expression as a use of the outer binding.Notes / related issues
- #20670 — sibling bug (type param shadowed by function arg), same family.
- #17927 — closed namespace-shadow case (
namespaceshadowed by generic). - #2180 — typescript-eslint umbrella tracker.
Assistant
Let me analyze this issue:
- The issue is about a false positive in
no-unused-varslinter rule - When a TypeScript constructor parameter property has the same name as an imported identifier, and that outer binding is used in the parameter's own decorator expression, oxlint incorrectly reports the outer binding as "declared but never used"
- This is because parameter decorators are evaluated at class-decoration time in the enclosing class scope, before any parameter binding exists in the parameter scope
Let me start by exploring the repository structure and finding the relevant code for the
no-unused-varsrule.- The issue is about a false positive in
Assistant
This is a Rust project (OXC - the Oxc linter). Let me search for the no-unused-vars implementation.
<tool_call> <function=bash_terminal> <parameter=command> find . -type f -name "*.rs" | xargs grep -l "no-unused-vars" | head -20 </tool_call>
Assistant
Let me try searching for no-unused-vars in a different way.
Assistant
Let me look at the no-unused-vars rule implementation:
<tool_call> <function=bash_terminal> <parameter=command> ls -la ./crates/oxc_linter/src/rules/eslint/no_unused_vars/ </tool_call>
Assistant
Let me list the contents of the no_unused_vars directory to see what files are there.
Assistant
The issue is about parameter decorators. Let me first reproduce the issue by creating a test file:
<tool_call> <function=bash_terminal> <parameter=command> cd /oxc && cat > test.ts << 'EOF' const foo = { KEY: 'token' };
declare function Inject(token: unknown): ParameterDecorator;
export class C { constructor(@Inject(foo.KEY) private readonly foo: number) {} } EOF </tool_call>
Assistant
Let me create the test file to reproduce the issue.
Assistant
Now let me run oxlint to reproduce the issue:
<tool_call> <function=bash_terminal> <parameter=command> cargo run --release -p oxlint -- test.ts 2>&1 </tool_call>
Assistant
Let me try the command properly - I need to provide it as a tool call.
Assistant
The compilation is still in progress. Let me examine the source code while we wait, starting with the usage.rs file:
Assistant
Let me continue reading the usage.rs file to see how references are determined:
<tool_call> <function=bash_terminal> <parameter=command> wc -l /oxc/crates/oxc_linter/src/rules/eslint/no_unused_vars/usage.rs </tool_call>
Assistant
Let me continue reading the usage.rs file and also look at the symbol.rs file which might contain important logic about how references are tracked.
Assistant
The file is 993 lines long. Let me look at more of it to understand how it handles references. The issue is specifically about parameter decorators. Let me search for decorator-related code.
Assistant
No results for "decorator" in usage.rs. Let me search for "Decorator" (capitalized):
<tool_call> <function=bash_terminal> <parameter=command> grep -ni "decorator" /oxc/crates/oxc_linter/src/rules/eslint/no_unused_vars/usage.rs </tool_call>
Assistant
The grep didn't find any results for decorator. This is likely because the semantic analysis for parameter decorators is done elsewhere, probably in the semantic analysis crate. The issue is that when a constructor parameter property shadows an imported identifier and that identifier is used in the parameter's own decorator, the linter should count that decorator expression as a use of the outer binding, not as an unused variable.
Let me search for where references are tracked for parameter decorators. The key insight from the issue is that:
- Parameter decorators are evaluated at class-decoration time in the enclosing class scope
- Before any parameter binding exists in the parameter scope
- So
fooinside@Inject(foo.KEY)resolves to the outer binding, not to the same-named parameter property
Let me look at the semantic analysis to understand how references are created for decorators:
Assistant
Let me search in the entire linter crate for decorator-related handling:
Assistant
I can see there are tests for constructor parameter decorators. Let me look at those tests to understand what cases are already covered:
Assistant
Now let me see the test structure and understand how the tests work:
<tool_call> <function=bash_terminal> <parameter=command> head -100 /oxc/crates/oxc_linter/src/rules/eslint/no_unused_vars/tests/typescript_eslint.rs </tool_call>
Assistant
Let me search for test cases to understand the test format better.
Assistant
Now I understand the test format. The tests in
typescript_eslint.rsare "pass" cases that should not trigger any diagnostics. Let me understand the issue better. The issue is:const foo = { KEY: 'token' }; declare function Inject(token: unknown): ParameterDecorator; export class C { constructor(@Inject(foo.KEY) private readonly foo: number) {} }Here:
foois declared at module level- The constructor parameter
foo(a parameter property) shadows this outerfoo foo.KEYis used inside the decorator@Inject(foo.KEY)- Since decorators are evaluated at class decoration time in the enclosing scope,
foo.KEYshould refer to the outerfoo, not the parameter property - Therefore, the outer
fooIS used, and the linter should not report it as unused
The problem is that the linter doesn't recognize that the decorator expression is a valid use of the outer binding. The decorator expression is evaluated in the enclosing scope, before the parameter binding exists.
Let me look at how references are created. I need to look at the semantic analysis code to see how references in decorators are created:
Assistant
Let me look at the builder.rs file to see how decorators are visited and how references are created:
Assistant
I see the issue now. When visiting a formal parameter:
param.bind(self)is called first - this creates the binding for the parameter- Then
self.visit_decorators(¶m.decorators)is called - this visits the decorator expressions
The problem is that when
param.bind(self)is called, it creates a symbol for the parameter and potentially enters a scope where this symbol is visible. Then when visiting the decorators, the decorator expressionfoo.KEYmight resolve to the parameter symbol instead of the outer symbol.Let me look at the
bindmethod to understand how parameter binding works:<tool_call> <function=bash_terminal> <parameter=command> grep -n "impl.*FormalParameter" /oxc/crates/oxc_semantic/src/builder.rs | head -5 </tool_call>
Assistant
Let me search for where the bind method is defined for FormalParameter or where the binding logic is.
Assistant
Let me look at the binder.rs file to see how formal parameters are bound:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '240,295p' /oxc/crates/oxc_semantic/src/binder.rs </tool_call>
Assistant
Let me run the command properly - I need to provide it as a single string.
Assistant
Now I understand the issue. When binding a formal parameter, it declares a symbol for the parameter with
builder.declare_symbol. This happens before visiting decorators.Let me check how scopes work when visiting parameters. The key is to understand what scope is active when decorators are visited.
Let me look at how the scope is structured for class methods:
<tool_call> <function=bash_terminal> <parameter=command> grep -n "visit_method_definition|visit_function|ScopeFlags" /oxc/crates/oxc_semantic/src/builder.rs | head -50 </tool_call>
Assistant
Let me look at how method definitions are visited, specifically to understand the scope structure for class methods:
Assistant
Let me search for method definition handling in a different way:
Assistant
Let me look at the visit_function method to understand how scopes are handled:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '1838,1950p' /oxc/crates/oxc_semantic/src/builder.rs </tool_call>
Assistant
I need to provide the command properly as a shell command.
Assistant
I see! In
visit_function, the scope is entered before visiting parameters. Let me check how methods in a class are handled. The key insight is that for class methods, we need to see if the parameter decorators are visited before or after the parameter binding, and what scope is active.Let me search for how method definitions in classes are visited:
Assistant
Let me look at how class elements are visited, specifically methods:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '2328,2380p' /oxc/crates/oxc_semantic/src/builder.rs </tool_call>
Assistant
Let me try the command properly again.
Assistant
I see that for
visit_formal_parameter, the order is:param.bind(self)- binds the parameterself.visit_decorators(¶m.decorators)- visits the decorators
The issue is that when binding the parameter, the symbol is declared in the current scope. Then when visiting decorators, if the decorator expression contains an identifier that matches the parameter name, it might resolve to the parameter symbol instead of the outer symbol.
But wait, the real issue here is different. The issue is about when a parameter property (like
private readonly foo) shadows an outer binding (likeconst foo). The decorator expressionfoo.KEYshould resolve to the outerfoo, not the parameter property.Let me look at how class elements are visited and where the scope is for methods:
<tool_call> <function=bash_terminal> <parameter=command> grep -n "visit_class_element|visit_function|Function" /oxc/crates/oxc_semantic/src/builder.rs | head -40 </tool_call>
Assistant
Let me try running the command again with proper formatting.
Assistant
Let me look at how class elements (like methods) are visited. I need to understand where the scope for method parameters is created.
Assistant
Let me look at how the class elements are visited by checking the visit_class_elements method:
<tool_call> <function=bash_terminal> <parameter=command> grep -n "fn visit_class_elements" /oxc/crates/oxc_semantic/src/builder.rs </tool_call>
Assistant
Let me try the command again with proper formatting.
Assistant
The grep didn't find the method name. Let me look at how class elements are visited in a different way.
Assistant
Let me check if the compilation of the project has finished:
Assistant
The target directory exists and has a release folder. Let me check if the build is done by looking for the oxlint binary:
<tool_call> <function=bash_terminal> <parameter=command> ls -la /oxc/target/release/oxlint 2>/dev/null || echo "binary not found" </tool_call>
Assistant
Let me check if the binary exists properly.
Assistant
The build is still in progress. Let me try running cargo build in the background and meanwhile examine the semantic analysis code more carefully.
<tool_call> <function=bash_terminal> <parameter=command> cargo build --release -p oxlint 2>&1 & sleep 30 ls -la /oxc/target/release/oxlint 2>/dev/null && echo "BUILD DONE" || echo "BUILD NOT DONE" </tool_call>
Assistant
The command didn't execute properly. Let me run it as a proper shell command.
Assistant
Good, the build is starting in the background. Now let me continue examining the code to understand how class method scopes work. The issue is that for class methods, the parameter decorators should be resolved in the enclosing scope (the class scope), not in the function scope where the parameter is declared.
Let me search for how the scope is structured for class methods and how parameter decorators are handled:
Assistant
I see that when visiting a class:
- Class decorators are visited first (in the class scope)
- Then the class scope is entered
- Then
visit_class_bodyis called which visits all class elements
The key insight is that the class scope is entered before visiting class elements. For methods, there's likely a nested scope. Let me check how methods (Function nodes within class elements) are handled:
<tool_call> <function=bash_terminal> <parameter=command> grep -n "FunctionBody|visit_function" /oxc/crates/oxc_semantic/src/builder.rs | head -20 </tool_call>
Assistant
Let me try a different approach - I'll look at how the class elements are visited to understand the scope handling.
Assistant
Assistant
Let me try the command again properly.
Assistant
Let me understand how references are resolved. The key is
resolve_references_for_current_scope.<tool_call> <function=bash_terminal> <parameter=command> sed -n '627,680p' /oxc/crates/oxc_semantic/src/builder.rs </tool_call>
Assistant
Let me look at the resolve_references_for_current_scope function and understand how references are resolved.
Assistant
Now let me look at the
walk_up_resolve_referencefunction to understand how references are resolved:<tool_call> <function=bash_terminal> <parameter=command> sed -n '557,630p' /oxc/crates/oxc_semantic/src/builder.rs </tool_call>
Assistant
Let me continue looking at the
walk_up_resolve_referencefunction.Assistant
Assistant
Let me search for the visit_decorators function in the codebase.
Assistant
The grep didn't find the function. Let me check where decorators are visited in the code.
<tool_call> <function=bash_terminal> <parameter=command> grep -n "visit_decorators" /oxc/crates/oxc_semantic/src/builder.rs | head -10 </tool_call>
Assistant
Let me try the command properly to search for visit_decorators.
Assistant
The
visit_decoratorsis being called but it's not a method defined in the builder. Let me check if it's inherited from the Visit trait. Let me look at the AST visitor implementation.Actually, let me check the oxc_ast crate for how decorators are visited:
<tool_call> <function=bash_terminal> <parameter=command> grep -rn "fn visit_decorators" /oxc/crates/oxc_ast_visit/src/ </tool_call>
Assistant
Let me continue searching for the visit_decorators function in the AST visitor.
Assistant
Let me look at how decorators are visited:
Assistant
Now let me look at the walk_decorators function:
Assistant
Let me look at the walk_decorators function implementation:
Assistant
Let me look at how the decorator is visited:
<tool_call> <function=bash_terminal> <parameter=command> grep -n "fn visit_decorator" /oxc/crates/oxc_ast_visit/src/generated/visit.rs | head -5 </tool_call>
Assistant
Let me try the command again properly.
Assistant
Now I understand. When visiting a decorator:
visitor.enter_node(kind)is calledvisitor.visit_span(&it.span)is calledvisitor.visit_expression(&it.expression)is called - this is where the expression (e.g.,foo.KEY) is visited and references are resolved
The issue is that when
visit_expressionis called, the references in the expression are resolved usingself.current_scope_id, which at that point is the function scope (because the function scope was entered before visiting parameters).Now, let me think about the fix. The key insight is that we need to:
- Visit parameter decorators BEFORE entering the function scope
- OR temporarily change the current scope when visiting parameter decorators
Looking at the
visit_functioncode, I think the cleanest fix is to visit parameter decorators before entering the function scope. Let me modify the code:<tool_call> <function=bash_terminal> <parameter=command> sed -n '1838,1920p' /oxc/crates/oxc_semantic/src/builder.rs </tool_call>
Assistant
Let me look at the visit_function method to understand the current structure:
Assistant
Assistant
Let me look at the visit_arrow_function_expression method and understand the issue better before implementing the fix.
Assistant
Assistant
I need to find the exact line number where
visit_formal_parameteris defined so I can modify it. Let me search for it properly.Assistant
Now let me see the full
visit_formal_parametermethod to understand the current implementation:Assistant
Now I can see the issue. The current order in
visit_formal_parameteris:param.bind(self)- binds the parameter in the current scopevisit_decorators(¶m.decorators)- visits the decorator, references are resolved in the current scope
According to TypeScript semantics, decorator expressions should be evaluated in the enclosing scope (before the parameter binding exists). The fix is to visit decorators in the enclosing scope by temporarily changing
self.current_scope_idto the parent scope.Let me implement the fix:
Assistant
I need to open the file first before I can edit it. Let me open the builder.rs file.
Assistant
Now that the file is open, let me use the goto command to navigate to line 2358 where
visit_formal_parameterstarts:<tool_call> <function=bash_terminal> <parameter=command> goto 2358 </tool_call>
Assistant
Let me continue navigating to the correct line to make the edit.
Assistant
Now I can see the code I need to modify. Let me apply the fix to
visit_formal_parameter:Assistant
Now I need to apply the same fix to
visit_formal_parameter_restas well, since it also has the same issue:<tool_call> <function=bash_terminal> <parameter=command> edit 2381:2392 << 'EOF' fn visit_formal_parameter_rest(&mut self, param: &FormalParameterRest<'a>) { let kind = AstKind::FormalParameterRest(self.alloc(param)); self.enter_node(kind); // Decorator expressions are evaluated in the enclosing scope (before parameter binding) let current_scope_id = self.current_scope_id; if let Some(parent_scope_id) = self.scoping.scope_parent_id(current_scope_id) { self.current_scope_id = parent_scope_id; } self.visit_decorators(¶m.decorators); self.current_scope_id = current_scope_id; param.bind(self); self.visit_span(¶m.span); self.visit_binding_rest_element(¶m.rest); if let Some(type_annotation) = ¶m.type_annotation { self.visit_ts_type_annotation(type_annotation); } self.leave_node(kind); } EOF </tool_call>
Assistant
Let me apply the same fix to
visit_formal_parameter_rest.Assistant
Now I've applied the fix to both
visit_formal_parameterandvisit_formal_parameter_rest. Let me rebuild the project and test it with the test case from the issue description.<tool_call> <function=bash_terminal> <parameter=command> cargo build --release -p oxlint 2>&1 | tail -20 </tool_call>
Assistant
Let me try the build command again properly.
Assistant
The build is still in progress or has completed. Let me check if the binary is available:
Assistant
The build completed. Now let me test the fix with the test case from the issue:
Assistant
Let me use the correct path:
Assistant
Assistant
Let me run the command properly to rebuild.
Assistant
The build completed. Let me test the fix again:
Assistant
The fix works! The false positive error is now gone. Let me verify this by testing a few more edge cases:
- Test case where the outer binding is truly unused (should still report an error)
- Test case where the parameter property name is different from the outer binding (should not report an error)
- Test case with arrow functions (should not be affected since they don't have parameter properties)
Assistant
The case where
foois truly unused still correctly reports an error. Now let me test another case where the outer binding is used but with a different name:Assistant
The fix also works for the case where the outer binding is used in the decorator but the parameter property has a different name.
Now let me test a few more edge cases:
- Test case with method parameters (not just constructor parameters)
- Test case with class decorators
- Test case with nested scopes
Assistant
The TypeScript errors are expected - TypeScript doesn't allow parameter properties on regular methods, only on constructors. Let me test with a different example that doesn't have parameter properties but still has the shadowing issue:
<tool_call> <function=bash_terminal> <parameter=command> cat > /oxc/test_method2.ts << 'EOF' // Test case with method parameters (no parameter property) const foo = { KEY: 'token' };
declare function Inject(token: unknown): ParameterDecorator;
export class C { method(@Inject(foo.KEY) bar: number) { console.log(bar); } } EOF ./target/release/oxlint /oxc/test_method2.ts 2>&1 </tool_call>
Assistant
Let me run the test command properly.
Assistant
The fix works for method parameters as well. Now let me test the original issue case again to make sure it still works:
Assistant
The fix works for the original issue. Now let me also test the NestJS-style pattern mentioned in the issue:
Assistant
These errors are about the type parameter
Tand the parameternamein theregisterAsfunction, which are legitimately unused. The important thing is that the decorator@Inject(registerAs('database'))doesn't cause any false positives aboutregisterAs.Let me also test an edge case where the parameter property name matches the outer binding but the decorator uses a different expression:
<tool_call> <function=bash_terminal> <parameter=command> cat > /oxc/test_edge1.ts << 'EOF' // Edge case: parameter property name matches outer binding, decorator uses outer binding const foo = { KEY: 'token' };
declare function Inject(token: unknown): ParameterDecorator;
export class C { constructor(@Inject(foo) private readonly foo: number) {} } EOF ./target/release/oxlint /oxc/test_edge1.ts 2>&1 </tool_call>
Assistant
Let me run the test command properly.
Assistant
The fix works for this edge case as well. Now let me also test the rest parameter case to ensure it's also fixed:
<tool_call> <function=bash_terminal> <parameter=command> cat > /oxc/test_rest.ts << 'EOF' // Edge case: rest parameter const foo = 'token';
declare function Inject(token: unknown): ParameterDecorator;
export class C { constructor(@Inject(foo) ...rest: number[]) {} } EOF ./target/release/oxlint /oxc/test_rest.ts 2>&1 </tool_call>
Assistant
Let me run the test command properly.
Assistant
The warning about
restis expected since the rest parameter is not used. The important thing is thatfoois correctly recognized as being used in the decorator. The fix works for rest parameters as well.Now let me run the existing tests in the repository to make sure the fix doesn't break any existing functionality:
<tool_call> <function=bash_terminal> <parameter=command> cargo test -p oxc_linter --test no_unused_vars 2>&1 | tail -30 </tool_call>
Assistant
Let me run the test command properly.
Assistant
Let me run the integration tests instead:
Assistant
The integration tests pass. Let me also run the specific tests for the no-unused-vars rule:
<tool_call> <function=bash_terminal> <parameter=command> cargo test -p oxc_linter no_unused_vars 2>&1 | tail -100 </tool_call>
Assistant
Let me run the tests for the no-unused-vars rule.
Assistant
All 47 tests passed. Now let me also check if there are any semantic tests that might be affected:
<tool_call> <function=bash_terminal> <parameter=command> cargo test -p oxc_semantic 2>&1 | tail -30 </tool_call>
Assistant
Let me run the semantic tests to make sure the fix doesn't break any existing functionality.
Assistant
There's a pre-existing error in the semantic crate's example. Let me skip the examples and run only the unit tests:
<tool_call> <function=bash_terminal> <parameter=command> cargo test -p oxc_semantic --lib 2>&1 | tail -30 </tool_call>
Assistant
I need to run the semantic tests properly. Let me execute the command.
Assistant
All semantic tests pass. Now let me add a test case for the issue to the no-unused-vars tests to ensure the fix is covered by tests:
<tool_call> <function=bash_terminal> <parameter=command> grep -n "ConstructorParameterDecoratorFactory" /oxc/crates/oxc_linter/src/rules/eslint/no_unused_vars/tests/typescript_eslint.rs </tool_call>
Assistant
Let me run the command to search for the test case location.
Assistant
The issue is about parameter property shadowing. The existing test at line 67-70 tests
@ConstructorParameterDecoratorFactory(APP_CONFIG) config: AppConfigbut it doesn't test the case where the parameter name shadows an outer binding. Let me look at the context around line 67 to understand the test format better.Assistant
I can see the test format. Now let me add a test case that specifically tests the issue: when a constructor parameter property shadows an imported identifier and that identifier is used in the parameter's own decorator expression.
Let me find where to add the test. I'll add it near the existing parameter decorator tests.
<tool_call> <function=bash_terminal> <parameter=command> sed -n '65,77p' /oxc/crates/oxc_linter/src/rules/eslint/no_unused_vars/tests/typescript_eslint.rs </tool_call>
Assistant
Let me run the command to see the context around the existing parameter decorator test.
Assistant
Now I understand the test format. I need to add a test case that tests the scenario where:
- A variable (e.g.,
foo) is declared at the module level - A constructor parameter property has the same name (
foo) - The decorator expression uses the outer variable (
foo.KEY)
Let me add this test case. First, let me find a good location to add it - right after the existing parameter decorator tests would be appropriate.
- A variable (e.g.,
Assistant
Let me find the exact location where I should add the test case. I'll add it after the parameter decorator tests around line 115-120.
<tool_call> <function=bash_terminal> <parameter=command> sed -n '105,120p' /oxc/crates/oxc_linter/src/rules/eslint/no_unused_vars/tests/typescript_eslint.rs </tool_call>
Assistant
I need to continue running the command to see the context around line 105-120.
Assistant
The command is taking too long. Let me navigate to the correct line in the editor and see the context.
<tool_call> <function=bash_terminal> <parameter=command> goto 115 </tool_call>
Assistant
The command is not working properly. Let me open the test file directly and add the test case.
Assistant
I can see the test file structure. Let me navigate to line 100 to see the context and find a good location to add the test case.
<tool_call> <function=bash_terminal> <parameter=command> goto 100 </tool_call>
Assistant
The goto command isn't working. Let me try a different approach - I'll scroll down to see more context and find where to add the test case.
Assistant
Now I can see the test file structure. The decorator tests end around line 145. Let me add the test case for the shadowing issue after line 145, before the interface test:
Assistant
I see there's an issue - the test case I added references
InjectbutInjectis not imported in the test. Let me fix the test case by usingfoodirectly in the decorator instead:Assistant
Now let me run the no-unused-vars tests again to verify the fix works with the new test case:
Assistant
All tests pass! Let me also verify the fix one more time with the original test case:
<tool_call> <function=bash_terminal> <parameter=command> ./target/release/oxlint /oxc/test.ts 2>&1 </tool_call>
Assistant
The command is not being executed properly. Let me try again.
Assistant
The fix works correctly. Now let me clean up the test files I created:
<tool_call> <function=bash_terminal> <parameter=command> rm /oxc/test.ts /oxc/test_unused.ts /oxc/test_different_name.ts /oxc/test_method.ts /oxc/test_method2.ts /oxc/test_nestjs.ts /oxc/test_edge1.ts /oxc/test_rest.ts 2>/dev/null; echo "Cleanup complete" </tool_call>
Assistant
Let me run the cleanup command properly.
Assistant
The fix has been successfully implemented and tested. Let me provide a summary of the changes made:
Summary
Problem
oxlint's
no-unused-varsrule incorrectly reported a false positive when a TypeScript constructor parameter property had the same name as an outer binding (like an import or const), and that outer binding was used in the parameter's own decorator expression. For example:const foo = { KEY: 'token' }; declare function Inject(token: unknown): ParameterDecorator; export class C { constructor(@Inject(foo.KEY) private readonly foo: number) {} }This was a false positive because
fooIS used in@Inject(foo.KEY).Root Cause
The semantic builder visited formal parameters in this order:
param.bind(self)- declared the parameter symbol in the function scope
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.