This repository has been archived by the owner on Aug 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 660
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
212 additions
and
60 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
crates/rome_js_analyze/src/semantic_analyzers/no_unused_variables.rs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 0 additions & 40 deletions
40
crates/rome_js_analyze/tests/specs/js/noUnusedVariablesTypescript.ts.snap
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
99 changes: 99 additions & 0 deletions
99
crates/rome_js_analyze/tests/specs/no_unused_variables/noUnusedVariables.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
--- | ||
source: crates/rome_js_analyze/tests/spec_tests.rs | ||
expression: noUnusedVariables.ts | ||
--- | ||
# Input | ||
```js | ||
// Invalid | ||
class D { | ||
constructor(a: number) {} | ||
f(a: number) {} | ||
set a(a: number) {} | ||
} | ||
console.log(new D()); | ||
// Valid | ||
interface A { | ||
f(a: number); | ||
set a(a: number); | ||
[key: string]: string; | ||
} | ||
abstract class B { | ||
constructor(a: number); | ||
abstract f(a: number); | ||
g(a: number); | ||
abstract set a(a: number); | ||
} | ||
console.log(new B()); | ||
class C { | ||
constructor(a: number); | ||
f(a: number); | ||
} | ||
console.log(new C()); | ||
``` | ||
|
||
# Diagnostics | ||
``` | ||
warning[no_unused_variables/noUnusedVariables]: This parameter is unused. | ||
┌─ noUnusedVariables.ts:4:14 | ||
│ | ||
4 │ constructor(a: number) {} | ||
│ - | ||
Suggested fix: Remove this parameter. | ||
| @@ -1,7 +1,7 @@ | ||
0 0 | // Invalid | ||
1 1 | | ||
2 2 | class D { | ||
3 | - constructor(a: number) {} | ||
3 | + constructor() {} | ||
4 4 | f(a: number) {} | ||
5 5 | set a(a: number) {} | ||
6 6 | } | ||
= note: Unused variables usually are result of incomplete refactoring, typos and other source of bugs. | ||
``` | ||
|
||
``` | ||
warning[no_unused_variables/noUnusedVariables]: This parameter is unused. | ||
┌─ noUnusedVariables.ts:5:4 | ||
│ | ||
5 │ f(a: number) {} | ||
│ - | ||
Suggested fix: Remove this parameter. | ||
| @@ -2,7 +2,7 @@ | ||
1 1 | | ||
2 2 | class D { | ||
3 3 | constructor(a: number) {} | ||
4 | - f(a: number) {} | ||
4 | + f() {} | ||
5 5 | set a(a: number) {} | ||
6 6 | } | ||
7 7 | console.log(new D()); | ||
= note: Unused variables usually are result of incomplete refactoring, typos and other source of bugs. | ||
``` | ||
|
||
``` | ||
warning[no_unused_variables/noUnusedVariables]: This parameter is unused. | ||
┌─ noUnusedVariables.ts:6:8 | ||
│ | ||
6 │ set a(a: number) {} | ||
│ - | ||
= note: Unused variables usually are result of incomplete refactoring, typos and other source of bugs. | ||
``` | ||
|
||
|
Oops, something went wrong.