From 6428929d901472e15167d28d40bf3e94188b9860 Mon Sep 17 00:00:00 2001 From: nissy-dev Date: Thu, 13 Jul 2023 23:47:31 +0900 Subject: [PATCH 1/2] fix: suppress false potitive diagnostics --- .../tests/specs/correctness/noUnusedVariables/validExport.ts | 4 +++- .../specs/correctness/noUnusedVariables/validExport.ts.snap | 3 +++ crates/rome_js_semantic/src/events.rs | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/rome_js_analyze/tests/specs/correctness/noUnusedVariables/validExport.ts b/crates/rome_js_analyze/tests/specs/correctness/noUnusedVariables/validExport.ts index 74aa023eda2..7d66f276d57 100644 --- a/crates/rome_js_analyze/tests/specs/correctness/noUnusedVariables/validExport.ts +++ b/crates/rome_js_analyze/tests/specs/correctness/noUnusedVariables/validExport.ts @@ -6,4 +6,6 @@ export { a }; export function b() { } export const { A } = { A: 1 }; -export const [B] = [1]; \ No newline at end of file +export const [B] = [1]; + +export declare const valid; diff --git a/crates/rome_js_analyze/tests/specs/correctness/noUnusedVariables/validExport.ts.snap b/crates/rome_js_analyze/tests/specs/correctness/noUnusedVariables/validExport.ts.snap index bdf7b3f4fec..b35953a87df 100644 --- a/crates/rome_js_analyze/tests/specs/correctness/noUnusedVariables/validExport.ts.snap +++ b/crates/rome_js_analyze/tests/specs/correctness/noUnusedVariables/validExport.ts.snap @@ -13,6 +13,9 @@ export function b() { } export const { A } = { A: 1 }; export const [B] = [1]; + +export declare const valid; + ``` diff --git a/crates/rome_js_semantic/src/events.rs b/crates/rome_js_semantic/src/events.rs index b410cdefe2c..f343e5023bf 100644 --- a/crates/rome_js_semantic/src/events.rs +++ b/crates/rome_js_semantic/src/events.rs @@ -942,7 +942,7 @@ impl SemanticEventExtractor { .and_then(|declaration| declaration.parent()) .and_then(|declaration_clause| declaration_clause.parent()) .map(|x| x.kind()), - Some(JS_EXPORT) + Some(JS_EXPORT) | Some(TS_EXPORT_DECLARE_CLAUSE) ); if is_exported { From 7a223946299e83b20f55c879c9aff8a14734802d Mon Sep 17 00:00:00 2001 From: nissy-dev Date: Thu, 13 Jul 2023 23:51:51 +0900 Subject: [PATCH 2/2] docs: update --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e66a4563c5..fb1f1238d5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -275,7 +275,11 @@ if no error diagnostics are emitted. - Fix [noUndeclaredVariables](https://docs.rome.tools/lint/rules/noundeclaredvariables/)'s false positive diagnostics ([#4675](https://github.com/rome/tools/issues/4675)) - The semantic analyzer no longer handles `this` reference identifier in the semantic analyzer. + The semantic analyzer no longer handles `this` reference identifier. + +- Fix [noUnusedVariables](https://docs.rome.tools/lint/rules/nounusedvariables/)'s false positive diagnostics ([#4688](https://github.com/rome/tools/issues/4688)) + + The semantic analyzer handles ts export declaration clause correctly. ### Parser