Skip to content
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

Update: use doctrine range information in valid-jsdoc #9831

Merged
merged 2 commits into from Jan 14, 2018

Conversation

not-an-aardvark
Copy link
Member

@not-an-aardvark not-an-aardvark commented Jan 8, 2018

What is the purpose of this pull request? (put an "X" next to item)

[x] Changes an existing rule
[x] Add autofixing to a rule

What rule do you want to change?

valid-jsdoc

Does this change cause the rule to produce more or fewer warnings?

The same amount

How will the change be implemented? (New option, new default behavior, etc.)?

New default behavior

Please provide some example code that this change will affect:

/**
 * @param {number} a
 * @param {number} notB
 */
function foo(a, b) {}

What does the rule currently do for this code?

It reports the entire JSDoc comment to indicate that the second parameter name is wrong.

What will the rule do after it's changed?

It will report only the text @param {number} notB in the comment to indicate that the second parameter name is wrong.

What changes did you make? (Give an overview)

Now that doctrine can provide range information in JSDoc tags, this makes a few improvements to the valid-jsdoc rule:

  • When reporting a specific tag or type annotation, the rule now uses that tag as the report location, rather than reporting the entire comment.
  • The rule can now autofix type annotations based on the existing prefer and preferType options (for example, it can replace object with Object if the rule is configured to prefer the latter).

Is there anything you'd like reviewers to focus on?

Nothing in particular

@not-an-aardvark not-an-aardvark added enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Jan 8, 2018
@not-an-aardvark not-an-aardvark self-assigned this Jan 8, 2018
@j-f1
Copy link
Contributor

j-f1 commented Jan 8, 2018

Would it be possible to only report the notB segment of the comment?

Copy link
Member

@platinumazure platinumazure left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@not-an-aardvark
Copy link
Member Author

@j-f1 Unfortunately, that information is not provided by doctrine because it's a string property of the tag object, so it doesn't have its own range.

@not-an-aardvark
Copy link
Member Author

@platinumazure @ilyavolodin @gyandeeps Thanks for reviewing. To clarify, are you also 👍 for adding this feature? If so, can you add a 👍 to the issue so that we can mark it as accepted?

@ilyavolodin
Copy link
Member

Definitely 👍 seems like a significant improvement over current situation.

@not-an-aardvark
Copy link
Member Author

@eslint/eslint-team We need one more 👍 from a team member to accept this issue.

@not-an-aardvark not-an-aardvark added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Jan 14, 2018
@not-an-aardvark not-an-aardvark merged commit 1d61930 into master Jan 14, 2018
@not-an-aardvark not-an-aardvark deleted the valid-jsdoc-better-columns branch January 14, 2018 19:52
@soruly
Copy link

soruly commented Mar 8, 2018

This change does not seem to handle optional array types using []

When eslint rules has a preferType that maps undefined

"valid-jsdoc": ["warn", {
  "preferType": {
    "number": "Number",
    "string": "String",
    "undefined": "Void"
  }
}],
/**
 * @param {number[]} [a=1]
 * @param {string[]} [b=""]
 */
function foo(a=1, b="") {}

The code above should be fixed to {Number[]} and {String[]}, but eslint fixed them to {Void} instead

This is happening since eslint 4.16.0 till 4.18.2

@not-an-aardvark
Copy link
Member Author

@soruly If you've found a bug, please create a new issue and fill out the bug report template. Thanks!

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Jul 14, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Jul 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants