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

Options to validate descriptions more precisely based on the specific tag #233

Open
15 of 24 tasks
brettz9 opened this issue May 16, 2019 · 1 comment
Open
15 of 24 tasks

Comments

@brettz9
Copy link
Collaborator

brettz9 commented May 16, 2019

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:

  • 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 eslint/eslint#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
  • @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.

  • @summary and @file/@fileoverview/@overview, fields which are descriptive in content and broad in purpose
  • 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.
  • 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)
  • 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)
  • 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
  • a choice of names (@kind) feat(check-values): add checking of kind #837
  • 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))
  • a type and name (@constant/@const (optional), @member/@var, @module, @namespace)
  • a name path (@alias, @augments/@extends, @borrows (namepath "as" namepath), @callback, @lends, @memberof, @mixes, @name, @see, @this, @tutorial)
  • a value (@default/@defaultvalue) Lint default param/property values and @default/@defaultvalue #473
  • a version or identifier (@license, @since, @version)
  • 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:

  • @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 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Feb 12, 2022
gajus#233

1. Make `constructs` disallow type (but optional name)
2. Require namepath and disallow type for `emits`;
3. Disallow type on `exports` except in closure/permissive modes;
4. Disallow type on `external` and `host`
5. Disallow type on `fires` but require name
6. Specify name as optional but type required on `function`
7. `listens`: should not have a type but must have a name
8. Make `miixin` name optional but disallow type
9. `requires` must have name but not have a type
10. `exports` must have a name in jsdoc mode
11. `interface`: disallow type
@JoernBerkefeld
Copy link

JoernBerkefeld commented Jun 1, 2023

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

brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Jun 1, 2023
…ore desc-like tags by default; check non-empty tags; gajus#233
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Jun 2, 2023
…ore desc-like tags by default; check non-empty tags; gajus#233
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Jun 3, 2023
…ore desc-like tags by default; check non-empty tags; gajus#233
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Jun 4, 2023
…ore desc-like tags by default; check non-empty tags; gajus#233
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Jun 25, 2023
…ore desc-like tags by default; check non-empty tags; gajus#233
brettz9 added a commit that referenced this issue Jun 25, 2023
…ore desc-like tags by default; check non-empty tags; #233
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants