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

Is JSDoc case sensitive? #1046

Closed
dandv opened this issue Jul 30, 2015 · 3 comments
Closed

Is JSDoc case sensitive? #1046

dandv opened this issue Jul 30, 2015 · 3 comments

Comments

@dandv
Copy link
Contributor

dandv commented Jul 30, 2015

Maybe this is a silly question, but a search for "case sensitive" in the repo doesn't reveal anything as of now. Same search on Google.

At http://usejsdoc.org/tags-type.html I see "number", "boolean", "string" and "Array".

At http://usejsdoc.org/tags-returns.html I see Titlecase: "Number", "Boolean", "Array".

@hegemonic
Copy link
Contributor

JSDoc doesn't care. It's up to the user's preference. I tend to use lowercase for primitive types (and function, for some reason) and uppercase for Array and Object.

In the future, please send this sort of question to the jsdoc-users mailing list. Thanks!

wmfgerrit pushed a commit to wikimedia/mediawiki-skins-MinervaNeue that referenced this issue Jul 10, 2018
From TypeScript's do's and don'ts:[0]

  Don’t ever use the types Number, String, Boolean, or Object. These
  types refer to non-primitive boxed objects that are almost never used
  appropriately in JavaScript code.

Although Minerva only uses JSDocs at this time which seemingly doesn't
care about casing[1], we should endeavor to use the proper return types.

This patch lowercases typing to indicate primitive / boxed type as
appropriate.[2] As a special case, function types are uppercased for
compatibility with TypeScript type checking.

Also, JQuery types are of type "JQuery". The global JQuery object's
identifier is "jQuery". This patch uppercases J's where appropriate.

Lastly, replace unsupported type "Integer" with "number" and a comment.

[0] https://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html#general-types

[1] jsdoc/jsdoc#1046 (comment)

[2] find resources tests -iname \*.js|
    xargs -rd\\n sed -ri '
      s%\{\s*(number|string|boolean|object|null|undefined)%{\L\1%gi;
      s%\{\s*function%{Function%g;
      s%\{\s*jquery%{JQuery%gi;
      s%\{\s*integer\s*\}%{number} An integer.%gi
    '

Change-Id: I6cbac15940e4501aee7ede8f421b77ffd027170d
wmfgerrit pushed a commit to wikimedia/mediawiki-skins that referenced this issue Jul 10, 2018
* Update MinervaNeue from branch 'master'
  to d5ae9915223ac70a78af7cdbd981ef6d69161e8e
  - Merge "Hygiene: update JSDoc boxed and JQuery types"
  - Hygiene: update JSDoc boxed and JQuery types
    
    From TypeScript's do's and don'ts:[0]
    
      Don’t ever use the types Number, String, Boolean, or Object. These
      types refer to non-primitive boxed objects that are almost never used
      appropriately in JavaScript code.
    
    Although Minerva only uses JSDocs at this time which seemingly doesn't
    care about casing[1], we should endeavor to use the proper return types.
    
    This patch lowercases typing to indicate primitive / boxed type as
    appropriate.[2] As a special case, function types are uppercased for
    compatibility with TypeScript type checking.
    
    Also, JQuery types are of type "JQuery". The global JQuery object's
    identifier is "jQuery". This patch uppercases J's where appropriate.
    
    Lastly, replace unsupported type "Integer" with "number" and a comment.
    
    [0] https://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html#general-types
    
    [1] jsdoc/jsdoc#1046 (comment)
    
    [2] find resources tests -iname \*.js|
        xargs -rd\\n sed -ri '
          s%\{\s*(number|string|boolean|object|null|undefined)%{\L\1%gi;
          s%\{\s*function%{Function%g;
          s%\{\s*jquery%{JQuery%gi;
          s%\{\s*integer\s*\}%{number} An integer.%gi
        '
    
    Change-Id: I6cbac15940e4501aee7ede8f421b77ffd027170d
wmfgerrit pushed a commit to wikimedia/mediawiki-extensions-Popups that referenced this issue Jul 18, 2018
Although Popups only uses JSDocs at this time which seemingly doesn't
care about casing[1], we should endeavor to use the proper return types.

This patch lowercases typing to indicate primitive / boxed type as
appropriate.[2] As a special case, function types are uppercased for
compatibility with TypeScript type checking.

Lastly, JQuery types are of type "JQuery". The global JQuery object's
identifier is "jQuery". This patch uppercases J's where appropriate.

[0] jsdoc/jsdoc#1046 (comment)

[1] find src tests -iname \*.js|
    xargs -rd\\n sed -ri '
      s%\{\s*([?!])?(number|string|boolean|null|undefined)%{\1\L\2%gi;
      s%\{\s*([?!])?(function|object)%{\1\u\2%gi;
      s%\{\s*([?!])?jquery%{\1JQuery%gi
    '

Change-Id: I771bdbb69dc978796a331998c0657622ac39c449
@dandv
Copy link
Contributor Author

dandv commented Jan 19, 2019

In the future, please send this sort of question to the jsdoc-users mailing list. Thanks!

Does the number of issues pointing to this one suggest that GitHub might have become a better place for similar questions than the jsdoc-users mailing list?

@shanimal
Copy link

shanimal commented Dec 13, 2019

I tend to use lowercase for primitive types

So does JSDocs...
https://jsdoc.app/tags-type.html

And typeof in javascript...

typeof true // "boolean"
typeof '' // "string"
typeof 4 // "number"
typeof undefined // "undefined"
typeof Symbol() // "symbol"
typeof function() {} // "function"

over-engineer added a commit to over-engineer/wp-cypress that referenced this issue Jan 16, 2023
- Some param types were starting with a lowercase letter (e.g. `string`), while others were starting with an uppercase letter (e.g. `String`). Switched all of them to lowercase for primitive types. Refer to jsdoc/jsdoc#1046 and https://jsdoc.app/tags-type.html (to see what JSDoc uses) for more information
- Fixed a few typos and minor grammar mistakes
- Fixed a few JSDoc params that were not matching the actual param name
- Some returns were using the `@return` tag, while others were using the `@returns` tag. Switched all of them to `@return` for consistency
- Some `@param`s were ending with a period, while others were not. Switched all of them to end with a period for consistency
- Made sure that all JSDoc comments include a `@return` tag (including `@return {void}` and `@return {Promise<void>}`
- Documented object structures were possible (e.g. `@return {Promise<{code: number, stdout: string, stderr: string}>}`)
- Expanded the documentation of functions like `exec()`, `run()`, etc., where their types could be confusing when you first come in the project
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants