digitalbazaar / eslint-config-digitalbazaar

BSD 3-Clause "New" or "Revised" License
2 stars 1 forks source link

Add a common jsdoc typedefs file to project #29

Open aljones15 opened 4 years ago

aljones15 commented 4 years ago

We have plenty of common types across projects such as

  1. integer
  2. RFC3349Date
  3. JSON-LD

etc.

This is a proposal to add a common set of jsdoc @typedef to this file so we can use say something like this:

/**
   * A number with no fractional component.
   *
   * @see https://en.wikipedia.org/wiki/Integer
   * @typedef {number} integer
   */

/**
 * An RFC3349 Date.
 *
 * @see https://tools.ietf.org/html/rfc3349
 * @example 2020-02-03T15:09:01.023Z
 * @example new Date().toISOString()
 * @typedef {string} RFC3349Date
*/

in our projects and the linter and jsdoc documentation would be able to find it. This would result in more informative documentation for developers and more readable types in JsDoc comments.

By requiring this file in a .eslintrc.js file the linter will see it and jsdoc should see it if required.

P.S. this is not an immediate project, but rather something to consider when we have more time to pursue it.

davidlehn commented 4 years ago

Seems like common jsdoc snippets would be in a jsdoc package rather than an eslint one.

aljones15 commented 4 years ago

Seems like common jsdoc snippets would be in a jsdoc package rather than an eslint one.

The linter does need them, but yeah we might consider something like digitalbazaar-common-jsdoc with common documentation types for things we use. Also do not create a repo for this yet as for some reason requiring the definitions is flaky for me (sometimes the linter sees the definitions and sometimes it does not) so until I can even get jsdoc and the linter to reliably share definitions no reason for a repo.