Skip to content

Comparison with deprecated JSdoc related ESLint rules

Brett Zamir edited this page May 24, 2019 · 38 revisions

ESLint has end-of-lifed their jsdoc support and are recommending eslint-plugin-jsdoc as a replacement: https://eslint.org/blog/2018/11/jsdoc-end-of-life

JSDoc features deprecated by ESLint

Deprecated JSDoc component eslint-plugin-jsdoc replacement or tracking issue
"Maintaining the Doctrine JSDoc comment parser" jsdoctypeparser (complete)
"The require-jsdoc rule" require-jsdoc #162 (complete)
"The valid-jsdoc rule" #107; see also tables below (complete)
"The SourceCode#getJSDocComment method" #189 (to overcome its planned removal). (complete)

Equivalents for valid-jsdoc features

Number Feature from valid-jsdoc rule Replacement within eslint-plugin-jsdoc or tracking issue Notes
1 "missing return tag: @return or @returns" require-returns
2 "missing ... return type" require-returns-type
3 "missing ... return description" require-returns-description
4 Requiring return statement upon use of @return(s) tag require-returns-check Behavior not in feature summary but was referenced in documentation code comment
5 "missing parameter tag: @arg, @argument, or @param" require-param
6 "missing parameter ... type" require-param-type
7 "missing parameter ... description" require-param-description
8 "inconsistent order of parameter names in a comment compared to the function or method" check-param-names
9 "syntax error" valid-types We should examine source or tests to see other implications (Examined and missing subfeatures added)

The "correct" code comments for valid-jsdoc also mention some specific behavior pertaining to these features:

Tag Behavior eslint-plugin-jsdoc equivalent or tracking issue
@returns "@constructor tag allows missing @returns tag" (#1 above) require-returns (since v4.8.1)
@returns "class constructor allows missing @returns tag" (#1 above) require-returns (since v4.8.1)
@returns "@override tag allows missing ... @returns tags" (#1 above) require-returns (since v4.8.1)
@returns "@abstract tag allows @returns tag without return statement" (#4 above) Supported automatically in require-returns-check
@param "@override tag allows missing @param ... tags" (#5 above) Supported by require-param with settings.jsdoc.allowOverrideWithoutParam

Finally, this large rule had a number of options we have implemented now in our own code base:

Option Accepted types Replacement within eslint-plugin-jsdoc or tracking issue
"prefer" object (item to replace keyed to replacement) check-tag-names with settings.jsdoc.tagNamePreference
"preferType" object (item to replace keyed to replacement) check-types can, in conjunction with settings.jsdoc.preferredTypes, be used to arbitrarily remap to preferred types (or also forbid types); #107
"requireReturn" boolean require-returns
"requireReturnType" boolean require-returns-type
"matchDescription" string (regular expression) require-description-complete-sentence and newline-after-description can handle subsets of this, but matchDescription, in allowing a custom regular expression, is more flexible and powerful (unless paragraph parsing is needed). Implemented as jsdoc/match-description rule (in #107)
"requireParamDescription" boolean require-param-description
"requireReturnDescription" boolean require-returns-description
"requireParamType" boolean require-param-type
Clone this wiki locally