Fix syntax of JSDoc annotations @param/@returns to enable type hinting in IDE#20742
Merged
sgiehl merged 3 commits intomatomo-org:5.x-devfrom Jun 1, 2023
Merged
Conversation
@param/@returns to enable type hinting in IDE@param/@returns to enable type hinting in IDE
Contributor
|
Thanks for the contribution @rr-it, nice one! I'll let the test suites run and then look at merging these. Went over the diff and it all looks ok. |
Contributor
|
Can you please commit the minified version of |
Contributor
Author
|
@michalkleiner Minified tracker js added. |
All changes done via Regex replacements: Find: `@return ` Replace: `@returns ` Find: `(@param|@returns) array($| )` Replace: `$1 {Array}$2` Find: `(@param|@returns) (.+\|)array($| )` Replace: `$1 {$2Array}$3` Find: `(@param|@returns) bool($| )` Replace: `$1 {boolean}$2` Find: `(@param|@returns) DOMElement($| )` Replace: `$1 {Element}$2` Find: `(@param|@returns) function($| )` Replace: `$1 {Function}$2` Find: `(@param|@returns) integer($| )` Replace: `$1 {int}$2` Find: `(@param|@returns) mixed($| )` Replace: `$1 {\*}$2` Find: `(@param|@returns) ((?:boolean|int|float|null|number|string|Array|Element|Function|Object)(?:\|(?:boolean|int|float|null|number|string|Array|Element|Function|Object))*)($| )` Replace: `$1 {$2}$3` Find: `@returns (Tracker(?:\[\])?)($| )` Replace: `@returns {$1}$2`
Manually fix: - missing/wrong name of parameter - `@param` used instead of `@returns`
30258ec to
58a6847
Compare
sgiehl
approved these changes
Jun 1, 2023
Member
sgiehl
left a comment
There was a problem hiding this comment.
looks good to me as well. relevant tests seem to be passing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
Some functions are already somehow annotated via JSDoc. But the syntax especially for
typedoes not follow JSDoc standards.This PR fixes the JSDoc syntax of already annotated functions. Thereby IDEs apply correct type hinting.
No actual changes on the JavaScript code itself.
For JSDoc see:
@param
@returns
@type
Applied changes:
Dev: fix JSDoc annotated
typein@paramand@returnsAll changes done via Regex replacements:
Find:
@returnReplace:
@returnsFind:
(@param|@returns) array($| )Replace:
$1 {Array}$2Find:
(@param|@returns) (.+\|)array($| )Replace:
$1 {$2Array}$3Find:
(@param|@returns) bool($| )Replace:
$1 {boolean}$2Find:
(@param|@returns) DOMElement($| )Replace:
$1 {Element}$2Find:
(@param|@returns) function($| )Replace:
$1 {Function}$2Find:
(@param|@returns) integer($| )Replace:
$1 {int}$2Find:
(@param|@returns) mixed($| )Replace:
$1 {\*}$2Find:
(@param|@returns) ((?:boolean|int|float|null|number|string|Array|Element|Function|Object)(?:\|(?:boolean|int|float|null|number|string|Array|Element|Function|Object))*)($| )Replace:
$1 {$2}$3Find:
@returns (Tracker(?:\[\])?)($| )Replace:
@returns {$1}$2Dev: fix JSDoc annotated
@paramand@returnstatementsManually fix:
@paramused instead of@returnsReview