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

fix:check-values for @version and @since reported invalid version with leading/trailing whitespace #480

Merged
merged 1 commit into from Jan 15, 2020

Conversation

sbusch
Copy link
Contributor

@sbusch sbusch commented Jan 15, 2020

semver.valid() requires a trimmed string: with leading or trailing whitespace, semver.valid()always returns false

@brettz9
Copy link
Collaborator

brettz9 commented Jan 15, 2020

I think this may be working as intended. The reason for the trim on the check was to avoid it saying it was "Missing" when it really did have something (even if just some extra whitespace).

But trimming the version value itself suggests allowing extra whitespace with a valid version to be treated as valid, and I'd personally like to avoid this being treated as valid (I like the enforcement of searching through files in a predictable manner, e.g., one could rely on searching for @version \d).

If a change were to be made, I would think we could just remove the trim() entirely (since it's not actually needed here at all in this case).

Did you come across this in your own code or just in browsing our library code?

@sbusch
Copy link
Contributor Author

sbusch commented Jan 15, 2020

I stumbled about this here https://github.com/autoNumeric/autoNumeric/blob/next/src/AutoNumeric.js where the JSDoc tag values are aligned with whitespace.

…urrounded by whitespace

`semver.valid()` requires a trimmed string. With leading or trailing whitespace, `semver.valid()`
returns `false`.
@brettz9 brettz9 merged commit 37466a8 into gajus:master Jan 15, 2020
@gajus
Copy link
Owner

gajus commented Jan 15, 2020

🎉 This PR is included in version 20.3.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@gajus gajus added the released label Jan 15, 2020
@brettz9
Copy link
Collaborator

brettz9 commented Jan 15, 2020

Makes sense. I've added. We want tests for any change, so just letting you know if you submit other PRs in the future (I added a couple this time).

Btw, FWIW, I noticed your branch on @throws. That sounds like a good idea, but I recommend adding instead as an option to valid-types similar to checkSeesForNamepaths (but instead of checking for namepaths, it would be checking types; and actually, come to think of it, I think it should accept an array instead so users could require types on other tags where it is normally optional, e.g., typedef). (It should be optional though as it technically can be a free-form description.)

@sbusch sbusch deleted the check-values-trim-version branch January 15, 2020 12:11
@sbusch
Copy link
Contributor Author

sbusch commented Jan 15, 2020

Thanks for your quick responses & the merge!

Tests: thanks for the hint, I added some for my new PR #481 (the one about @throws). I'll add your other comments to this PR (which I sent before seeing your comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants