Skip to content

prefix-unused-parameter-with-_ codefix now works in jsdoc @param #36152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 17, 2020

Conversation

sergeir82
Copy link
Contributor

  • Fix prepending unused TypeScript variables with underscore doesn't rename JSDoc @param.
  • Fix test for quick fix "Prefix all unused declarations with '_' where possible".

Fixes #33021

…name JSDoc @param.

Fix test for quick fix "Prefix all unused declarations with '_' where possible".
Fixes microsoft#33021.
@msftclas
Copy link

msftclas commented Jan 12, 2020

CLA assistant check
All CLA requirements met.

@sandersn sandersn added the For Backlog Bug PRs that fix a backlog bug label Feb 3, 2020
Copy link
Member

@andrewbranch andrewbranch left a comment

Choose a reason for hiding this comment

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

Thanks for taking this on! I have one suggestion if you have time to take a look.

@sandersn sandersn changed the title Bug 33021 prefix-unused-parameter-with-_ codefix now works in jsdoc @param Apr 15, 2020
@sandersn
Copy link
Member

@sergeir82 do you intend to keep working on this? Let us know if we can help -- I started tracking community PRs a couple of months ago so we don't forget to review ones like this.

@sergeir82
Copy link
Contributor Author

Yes, I will try to fix it.

…l to more ligher call of getJSDocParameterTags when searching for a parameter in jsdoc.
@sergeir82
Copy link
Contributor Author

Hi! Changes were done. You may check it.

@@ -154,6 +154,13 @@ namespace ts.codefix {
}
if (isIdentifier(token) && canPrefix(token)) {
changes.replaceNode(sourceFile, token, createIdentifier(`_${token.text}`));
if (isParameter(token.parent)) {
getJSDocParameterTags(token.parent).forEach((tag) => {
Copy link
Member

Choose a reason for hiding this comment

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

Don’t you need to do this only for the JSDoc parameter tags whose name is the same as token.text? Try adding this test:

/**
 * @param a
 * @param b
 */
function f(a, b) {
    const x = a;
}

to ensure that b gets renamed but a does not.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I see getJSDocParameterTags already handles that. My bad. Thanks for adding the test anyway.

@@ -154,6 +154,13 @@ namespace ts.codefix {
}
if (isIdentifier(token) && canPrefix(token)) {
changes.replaceNode(sourceFile, token, createIdentifier(`_${token.text}`));
if (isParameter(token.parent)) {
getJSDocParameterTags(token.parent).forEach((tag) => {
Copy link
Member

Choose a reason for hiding this comment

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

Ah, I see getJSDocParameterTags already handles that. My bad. Thanks for adding the test anyway.

@andrewbranch andrewbranch merged commit b346f57 into microsoft:master Apr 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Prepending unused TypeScript variables with underscore doesn't rename JSDoc @param
4 participants