Skip to content

Conversation

rr-it
Copy link
Contributor

@rr-it rr-it commented May 17, 2023

Description:

Some functions are already somehow annotated via JSDoc. But the syntax especially for type does 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 type in @param and @returns

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


Dev: fix JSDoc annotated @param and @return statements

Manually fix:

  • missing/wrong name of parameter
  • @param used instead of @returns

Review

@michalkleiner michalkleiner changed the title Dev: Tracker - fix syntax of JSDoc annotation @param/@returns to enable type hinting in IDE Fix syntax of JSDoc annotations @param/@returns to enable type hinting in IDE May 18, 2023
@michalkleiner
Copy link
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.

@michalkleiner
Copy link
Contributor

Can you please commit the minified version of piwik.js as well? Some tests fail because of the minified version not matching the source.

@rr-it
Copy link
Contributor Author

rr-it commented May 19, 2023

@michalkleiner Minified tracker js added.

rr-it added 3 commits May 31, 2023 14:45
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`
@rr-it rr-it force-pushed the dev/jsdoc-param-types-syntax branch from 30258ec to 58a6847 Compare May 31, 2023 12:48
Copy link
Member

@sgiehl sgiehl left a comment

Choose a reason for hiding this comment

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

looks good to me as well. relevant tests seem to be passing

@sgiehl sgiehl merged commit 4de4ddc into matomo-org:5.x-dev Jun 1, 2023
@sgiehl sgiehl added this to the 5.0.0 milestone Jun 1, 2023
@sgiehl sgiehl added c: Tests & QA For issues related to automated tests or making it easier to QA & test issues. Easier debugging For issues that make troubleshooting issues for developers easier. labels Jun 1, 2023
@rr-it rr-it deleted the dev/jsdoc-param-types-syntax branch June 5, 2023 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Tests & QA For issues related to automated tests or making it easier to QA & test issues. Easier debugging For issues that make troubleshooting issues for developers easier.
Development

Successfully merging this pull request may close these issues.

3 participants