Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
incorporate is_exported into noUnusedVariables
Browse files Browse the repository at this point in the history
  • Loading branch information
xunilrj committed Aug 10, 2022
1 parent f18dc45 commit c0f2624
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ impl Rule for NoUnusedVariables {
return None;
}

if model.is_exported(binding) {
return None;
}

let all_references = binding.all_references(model);

if all_references.count() == 0 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,8 @@ const f6 = () => {

try {
} catch (e) {}

export function exported_function() {}

function exported_function_2() {}
export { exported_function_2 };
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ const f6 = () => {
try {
} catch (e) {}
export function exported_function() {}
function exported_function_2() {}
export { exported_function_2 };
```

# Diagnostics
Expand Down Expand Up @@ -264,7 +269,7 @@ warning[no_unused_variables/noUnusedVariables]: This variable is unused.
--
Suggested fix: Remove this variable.
| @@ -31,9 +31,5 @@
| @@ -31,10 +31,6 @@
30 30 |
31 31 | const f5 = () => {};
32 32 |
Expand All @@ -274,6 +279,7 @@ Suggested fix: Remove this variable.
36 | -
37 33 | try {
38 34 | } catch (e) {}
39 35 |
= note: Unused variables usually are result of incomplete refactoring, typos and other source of bugs.
Expand All @@ -288,12 +294,15 @@ warning[no_unused_variables/noUnusedVariables]: This variable is unused.
-
Suggested fix: Remove this variable.
| @@ -36,4 +36,4 @@
| @@ -36,7 +36,7 @@
35 35 | };
36 36 |
37 37 | try {
38 | - } catch (e) {}
38 | + } catch {}
39 39 |
40 40 | export function exported_function() {}
41 41 |
= note: Unused variables usually are result of incomplete refactoring, typos and other source of bugs.
Expand Down

0 comments on commit c0f2624

Please sign in to comment.