eslint-plugin-jsdoc icon indicating copy to clipboard operation
eslint-plugin-jsdoc copied to clipboard

Options to validate descriptions more precisely based on the specific tag

Open brettz9 opened this issue 6 years ago • 4 comments

Note: This needs to be reviewed, as others not marked as such may have since been implemented.

This is a request for a rule to validate descriptions more precisely based on the tag.

While this would be a lot of work, here is one more immediate to-do:

  • [x] no-undefined-types might use the pattern of valid-types to check for types within tags recognized as having a type.
  • [ ] Handle assorted other tags in rules like require-description, require-description-complete-sentence, and especially match-description (see below)

Ported from https://github.com/eslint/eslint/issues/11043

When a JSDoc code comment has certain tags present elsewhere in a block (and which is not one of those covered by the function/class-based detection of the current behavior), a description that fails to match the regular expression of matchDescription (or equivalent separate config) should also be able to apply.

Note that some of these may now be possible in match-description, though perhaps these as possibilities may be made explicit there.

These tags should, as I see it, be comprised of:

  • [ ] Flagging an object of potentially broad purpose calling for a description @module, @mixin, @namespace, @external/@host
  • [ ] Though more specialized in some ways, @typedef, @event objects may also be of enough importance for a description
  • [ ] @interface if present should call for a description, particularly when within virtual comments where the lack of an associated function or class would necessitate its own warning
  • [ ] While these may or may not be of general interest, they are generic enough that they may merit requiring a description as well: @global, @kind and @type
  • [x] @variation, @version, and @since, though more concrete, typically are associated with documentation as well

Besides certain tags flagging the need for a description by their presence, certain other tags require a description and I think there should be an option for matchDescription to match within these tags.

  • [x] @summary and @file/@fileoverview/@overview, fields which are descriptive in content and broad in purpose
  • [x] While the current code checks classes, I'm not sure whether @classdesc can occur separately from a class, e.g., as its own separate comment, and if so, its text should also be queryable.
  • [x] Some additional fields, though fairly specialized, like @copyright, @example, @see, @todo also have descriptive text areas which should never or rarely be empty; @throws/@exception, @yields/@yield ~~and @property/@prop do likewise along with a possible type (and @property/@prop with a name as well)~~
  • [ ] @deprecated might be better filled (to point to a replacement)
  • [x] allows free form text but really shouldn't be empty (@throws, @exception)

Other tags may expect something additional and would be worthy of having a rule, but are less like "descriptions":

  • [ ] @author (with name and email; partly implemented but could allow checking against package.json contributors and author fields)
  • [x] a concrete technical name (@class (optional), @constructs (optional)); @event or @fires/@emits or @listens (<className>#[event:]<eventName>), @exports, @external/@host, @function (optional), @interface, @mixin, @requires
  • [x] a choice of names (@kind) #837
  • [x] a type @enum (optional), @implements; @package (for Closure only), @private (for Closure only), @protected (for Closure only); not @public or @static for Closure?; @throws/@exception, @type, @typedef (type and name path))
  • [x] a type and name (@constant/@const (optional), @member/@var, @module, @namespace)
  • [x] a name path (@alias, @augments/@extends, @borrows (namepath "as" namepath), @callback, @lends, @memberof, @mixes, @name, @see, @this, @tutorial)
  • [x] a value (@default/@defaultvalue) #473
  • [x] a version or identifier (@license, @since, @version)
  • [x] a status (@access (package|private|protected|public)
  • [ ] a link (@link/@linkcode/@linkplain)
  • [ ] inline identifier reference (block and inline @tutorial should point to config file tutorial IDs)

...and thus seem less like "descriptions" as per the rule name under discussion).

And a few seem they might benefit from insisting on no description as they don't seem to allow it:

  • [x] @abstract ,@async, @generator, @global, @hideconstructor, @ignore, @inheritdoc, @inner, @instance, @override, @readonly (and see access types above referencing Closure under types above)

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

brettz9 avatar May 16 '19 12:05 brettz9

as a matter of fact, using {@link myMethod} breaks if it references a method from another class and complains about the incorrect reference. Meanwhile, vscode's intellisense can read those statements just fine.

I'm using that a lot lately when I create helper methods to link back to the main method in the description part of the jsdoc

JoernBerkefeld avatar Jun 01 '23 08:06 JoernBerkefeld