-
Notifications
You must be signed in to change notification settings - Fork 442
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some context to the unused variable warning (#7050)
* add some context to the unused variable warning * changelog * Update jscomp/build_tests/super_errors/expected/unused_variable.res.expected Co-authored-by: Christoph Knittel <ck@cca.io> * Update jscomp/ext/warnings.ml Co-authored-by: Christoph Knittel <ck@cca.io> * add suggestion to remove unused variable --------- Co-authored-by: Christoph Knittel <ck@cca.io>
- Loading branch information
Showing
4 changed files
with
22 additions
and
1 deletion.
There are no files selected for viewing
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
15 changes: 15 additions & 0 deletions
15
jscomp/build_tests/super_errors/expected/unused_variable.res.expected
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,15 @@ | ||
|
||
[1;33mWarning number 26[0m | ||
[36m/.../fixtures/unused_variable.res[0m:[2m2:7[0m | ||
|
||
1 [2m│[0m let x = { | ||
[1;33m2[0m [2m│[0m let [1;33mf[0m = 12 | ||
3 [2m│[0m 13 | ||
4 [2m│[0m } | ||
|
||
unused variable f. | ||
|
||
Fix this by: | ||
- Deleting the variable if it's not used anymiore. | ||
- Prepending the variable name with `_` (like `_f`) to ignore that the variable is unused. | ||
- Using the variable somewhere. |
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,4 @@ | ||
let x = { | ||
let f = 12 | ||
13 | ||
} |
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