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

fix(rome_js_analyze): suppress noUnusedVariables's false positive diagnostics when using indexed type #4647

Closed
wants to merge 3 commits into from

Conversation

nissy-dev
Copy link
Contributor

Summary

Fix #4634

Test Plan

I update some snapshot tests.

@netlify
Copy link

netlify bot commented Jul 2, 2023

Deploy Preview for docs-rometools canceled.

Name Link
🔨 Latest commit 9607034
🔍 Latest deploy log https://app.netlify.com/sites/docs-rometools/deploys/64a4151a1ab5fa0008ab016c

@nissy-dev nissy-dev changed the title fix: suppress noUnusedVariables's false positive diagnostics when using indexed type fix(rome_js_analyze): suppress noUnusedVariables's false positive diagnostics when using indexed type Jul 2, 2023
@github-actions github-actions bot added the A-Linter Area: linter label Jul 2, 2023
@@ -25,6 +25,5 @@
"function f() { var a; if (test) { var a; } }",
"for (var a, a;;);",
"for (;;){ var a, a,;}",
"function f(x) { var x = 5; }",
"interface A { [index: number]: string; [index: number]: string; }"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Semantic analyzer no longer handle identifiers of type variable, so I removed.

In this case, tsc throw the syntax error.
Thus, I seem that it is better to make this rule in syntax rule like noDuplicatePrivateClassMembers.

https://typescript-eslint.io/play/#ts=4.9.3&jsx=true&sourceType=module&code=JYOwLgpgTgZghgYwgAgILIN7IFDOQbVABMIAPALmQGcwpQBzAXUprpHoG5cDiyXaGzagPZcAvkA&eslintrc=N4KABGBEBOCuA2BTAzpAXGYBfEWg&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA

Comment on lines +133 to +137
redeclarations.push(Redeclaration {
name,
declaration: *first_text_range,
redeclaration: id_binding.syntax().text_trimmed_range(),
})
Copy link
Contributor Author

@nissy-dev nissy-dev Jul 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rule no longer handles the case like interface A { [index: number]: string; [index: number]: string; }, so I removed unnecessary logic.

@github-actions github-actions bot added A-Formatter Area: formatter A-Parser Area: parser A-Tooling Area: our own build, development, and release tooling labels Jul 4, 2023
@@ -2066,9 +2066,11 @@ TsIndexSignatureTypeMember =
// { [a: string]: number }
// ^^^^^^^^^
TsIndexSignatureParameter =
binding: JsIdentifierBinding
binding: TsIndexSignatureParameterName
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I introduce the new CST node for the binding of TsIndexSignatureParameter. I think this binding is not JsIdentifierBinding.

@github-actions
Copy link

github-actions bot commented Jul 4, 2023

Parser conformance results on ubuntu-latest

js/262

Test result main count This PR count Difference
Total 48863 48863 0
Passed 47810 47810 0
Failed 1053 1053 0
Panics 0 0 0
Coverage 97.84% 97.84% 0.00%

jsx/babel

Test result main count This PR count Difference
Total 40 40 0
Passed 37 37 0
Failed 3 3 0
Panics 0 0 0
Coverage 92.50% 92.50% 0.00%

symbols/microsoft

Test result main count This PR count Difference
Total 6212 6212 0
Passed 1764 1736 ❌ ⏬ -28
Failed 4448 4476 ❌ ⏫ +28
Panics 0 0 0
Coverage 28.40% 27.95% -0.45%
🔥 Regression (28):
classDoesNotDependOnBaseTypes.symbols
classIndexer.symbols
computedPropertyNamesContextualType4_ES5.symbols
computedPropertyNamesContextualType4_ES6.symbols
computedPropertyNamesContextualType5_ES5.symbols
computedPropertyNamesContextualType5_ES6.symbols
declFileClassWithIndexSignature.symbols
declFileIndexSignatures.symbols
hidingIndexSignatures.symbols
incrementOnNullAssertion.symbols
indexerAssignability.symbols
inferredIndexerOnNamespaceImport.symbols
nestedIndexer.symbols
parserClassDeclarationIndexSignature1.symbols
parserES5SymbolIndexer1.symbols
parserES5SymbolIndexer2.symbols
parserES5SymbolIndexer3.symbols
parserIndexMemberDeclaration1.symbols
parserIndexMemberDeclaration6.symbols
parserSymbolIndexer1.symbols
parserSymbolIndexer2.symbols
parserSymbolIndexer3.symbols
parserSymbolIndexer4.symbols
spreadObjectWithIndexDoesNotAddUndefinedToLocalIndex.symbols
staticIndexSignature6.symbols
staticIndexSignatureAndNormalIndexSignature.symbols
tsxPreserveEmit3.symbols
typeGuardOnContainerTypeNoHang.symbols

ts/babel

Test result main count This PR count Difference
Total 639 639 0
Passed 573 573 0
Failed 66 66 0
Panics 0 0 0
Coverage 89.67% 89.67% 0.00%

ts/microsoft

Test result main count This PR count Difference
Total 17224 17224 0
Passed 13121 13121 0
Failed 4103 4103 0
Panics 0 0 0
Coverage 76.18% 76.18% 0.00%

@nissy-dev
Copy link
Contributor Author

This PR doesn't pass some tests, so I will rework and create the another PR.

@nissy-dev nissy-dev closed this Jul 4, 2023
@nissy-dev nissy-dev deleted the fix-4634 branch July 30, 2023 02:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Formatter Area: formatter A-Linter Area: linter A-Parser Area: parser A-Tooling Area: our own build, development, and release tooling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 correctness/noUnusedVariables false positive when using indexed type
2 participants