Page MenuHomePhabricator

Fix eslint warnings in MediaWiki core related to JSDoc
Open, MediumPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Run npm test

What happens?:
Various eslint warnings relating to JSDoc

What should have happened instead?:

No warnings - either we should fix them, change the default eslintrc.json configuration or upstream changes to the eslint-wikimedia-plugin / https://www.npmjs.com/package/eslint-plugin-jsdoc

Software version (skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):

Event Timeline

Jdlrobson triaged this task as Medium priority.Feb 1 2024, 10:42 PM
Jdforrester-WMF renamed this task from Fix eslint warnings to Fix eslint warnings in MediaWiki core related to JSDoc.May 3 2024, 10:12 AM

Change #1027475 had a related patch set uploaded (by Siebrand; author: Siebrand):

[mediawiki/core@master] Fix a bunch of eslint warnings related to JSDoc

https://gerrit.wikimedia.org/r/1027475

Change #1027475 merged by jenkins-bot:

[mediawiki/core@master] Fix a bunch of eslint warnings related to JSDoc

https://gerrit.wikimedia.org/r/1027475

eslint jsdoc warnings in mediawiki core as of 2024-06-26 are below.

Some of these look fixable (such as missing @return and double @return).

Some of them look like false positives that we should perhaps write a patch to eslint-config-wikimedia to stop alerting for (the ones with tildes such as Syntax error in namepath: ~'wikipage.indicators')

novemlinguae@DESKTOP-J5KRKNI:~/mediawiki$ npm run lint

> lint
> grunt lint

Running "eslint:all" (eslint) task

/home/novemlinguae/mediawiki/resources/src/jquery/jquery.confirmable.js
  13:2  warning  Missing JSDoc @return declaration  jsdoc/require-returns

/home/novemlinguae/mediawiki/resources/src/jquery/jquery.makeCollapsible.js
  425:1  warning  Syntax error in namepath: ~'wikipage.collapsibleContent'  jsdoc/valid-types

/home/novemlinguae/mediawiki/resources/src/mediawiki.Upload.BookletLayout/BookletLayout.js
  338:2  warning  JSDoc @return declaration present but return expression not available in function  jsdoc/require-returns-check

/home/novemlinguae/mediawiki/resources/src/mediawiki.action.edit/edit.js
  12:1  warning  Syntax error in namepath: ~'wikipage.editform'  jsdoc/valid-types

/home/novemlinguae/mediawiki/resources/src/mediawiki.action/mediawiki.action.history.js
  11:1  warning  The type 'input' is undefined  jsdoc/no-undefined-types

/home/novemlinguae/mediawiki/resources/src/mediawiki.action/mediawiki.action.protect.js
  96:2  warning  JSDoc @return declaration present but return expression not available in function  jsdoc/require-returns-check

/home/novemlinguae/mediawiki/resources/src/mediawiki.action/mediawiki.action.view.postEdit.js
  21:1  warning  Syntax error in namepath: ~'postEdit'               jsdoc/valid-types
  36:1  warning  Syntax error in namepath: ~'postEdit.afterRemoval'  jsdoc/valid-types

/home/novemlinguae/mediawiki/resources/src/mediawiki.authenticationPopup/AuthPopup.js
  162:1  warning  Invalid JSDoc tag name "unstable"  jsdoc/check-tag-names

/home/novemlinguae/mediawiki/resources/src/mediawiki.authenticationPopup/index.js
  38:1  warning  The type 'userinfo' is undefined  jsdoc/no-undefined-types

/home/novemlinguae/mediawiki/resources/src/mediawiki.base/errorLogger.js
   8:1  warning  Syntax error in namepath: ~'global.error'  jsdoc/valid-types
  22:1  warning  Syntax error in namepath: ~'error.caught'  jsdoc/valid-types

/home/novemlinguae/mediawiki/resources/src/mediawiki.base/log.js
  14:1  warning  Found more than one @return declaration  jsdoc/require-returns
  14:1  warning  Found more than one @return declaration  jsdoc/require-returns-check

/home/novemlinguae/mediawiki/resources/src/mediawiki.base/mediawiki.base.js
  206:1  warning  The type 'mediawiki' is undefined  jsdoc/no-undefined-types
  232:1  warning  The type 'mediawiki' is undefined  jsdoc/no-undefined-types

/home/novemlinguae/mediawiki/resources/src/mediawiki.diff/inlineFormatToggle.js
  151:1  warning  Syntax error in namepath: ~'wikipage.diff.wikitextDiffBody'  jsdoc/valid-types
  163:1  warning  Syntax error in namepath: ~'wikipage.diff.diffTypeSwitch'    jsdoc/valid-types

/home/novemlinguae/mediawiki/resources/src/mediawiki.editRecovery/edit.js
  177:1  warning  Syntax error in namepath: ~'editRecovery.loadEnd'  jsdoc/valid-types

/home/novemlinguae/mediawiki/resources/src/mediawiki.htmlform/cond-state.js
  48:1  warning  Found more than one @return declaration  jsdoc/require-returns-check

/home/novemlinguae/mediawiki/resources/src/mediawiki.htmlform/htmlform.js
  5:1  warning  Syntax error in namepath: ~'htmlform.enhance'  jsdoc/valid-types

/home/novemlinguae/mediawiki/resources/src/mediawiki.inspect.js
   61:1  warning  The type 'mediawiki' is undefined        jsdoc/no-undefined-types
   91:1  warning  The type 'mediawiki' is undefined        jsdoc/no-undefined-types
  112:2  warning  Found more than one @return declaration  jsdoc/require-returns
  112:2  warning  Found more than one @return declaration  jsdoc/require-returns-check
  121:1  warning  The type 'mediawiki' is undefined        jsdoc/no-undefined-types
  152:1  warning  The type 'mediawiki' is undefined        jsdoc/no-undefined-types
  164:1  warning  The type 'mediawiki' is undefined        jsdoc/no-undefined-types
  175:1  warning  The type 'mediawiki' is undefined        jsdoc/no-undefined-types
  203:1  warning  The type 'mediawiki' is undefined        jsdoc/no-undefined-types

/home/novemlinguae/mediawiki/resources/src/mediawiki.jqueryMsg/mediawiki.jqueryMsg.js
  141:1  warning  Found more than one @return declaration  jsdoc/require-returns
  141:1  warning  Found more than one @return declaration  jsdoc/require-returns-check

/home/novemlinguae/mediawiki/resources/src/mediawiki.language.months/months.js
  44:1  warning  The type 'Months' is undefined  jsdoc/no-undefined-types

/home/novemlinguae/mediawiki/resources/src/mediawiki.notification.convertmessagebox.js
  13:1  warning  Syntax error in namepath: (require("mediawiki.notification.convertmessagebox"))  jsdoc/valid-types

/home/novemlinguae/mediawiki/resources/src/mediawiki.page.gallery.js
  21:1  warning  The type 'A' is undefined  jsdoc/no-undefined-types

/home/novemlinguae/mediawiki/resources/src/mediawiki.page.preview.js
  406:1  warning  Syntax error in namepath: ~'wikipage.tableOfContents'  jsdoc/valid-types

/home/novemlinguae/mediawiki/resources/src/mediawiki.page.ready/ready.js
   96:1  warning  Syntax error in namepath: ~'wikipage.indicators'  jsdoc/valid-types
  116:1  warning  Syntax error in namepath: ~'wikipage.content'     jsdoc/valid-types
  137:1  warning  Syntax error in namepath: ~'wikipage.categories'  jsdoc/valid-types
  153:1  warning  Syntax error in namepath: ~'wikipage.diff'        jsdoc/valid-types
  184:1  warning  Syntax error in namepath: ~'skin.logout'          jsdoc/valid-types

/home/novemlinguae/mediawiki/resources/src/mediawiki.page.watch.ajax/watch-ajax.js
  128:1  warning  Syntax error in namepath: ~'wikipage.watchlistChange'  jsdoc/valid-types

/home/novemlinguae/mediawiki/resources/src/mediawiki.rcfilters/Controller.js
  334:1  warning  Found more than one @return declaration                  jsdoc/require-returns
  334:1  warning  Found more than one @return declaration                  jsdoc/require-returns-check
  556:1  warning  Syntax error in namepath: ~'RcFilters.highlight.enable'  jsdoc/valid-types

/home/novemlinguae/mediawiki/resources/src/mediawiki.rcfilters/dm/FilterItem.js
   82:1  warning  Found more than one @return declaration  jsdoc/require-returns
   82:1  warning  Found more than one @return declaration  jsdoc/require-returns-check
  336:1  warning  The type 'update' is undefined           jsdoc/no-undefined-types
  352:1  warning  The type 'update' is undefined           jsdoc/no-undefined-types
  367:1  warning  The type 'update' is undefined           jsdoc/no-undefined-types

/home/novemlinguae/mediawiki/resources/src/mediawiki.rcfilters/dm/FiltersViewModel.js
  1200:1  warning  The type 'searchChange' is undefined  jsdoc/no-undefined-types

/home/novemlinguae/mediawiki/resources/src/mediawiki.rcfilters/mw.rcfilters.js
  178:1  warning  Syntax error in namepath: ~'structuredChangeFilters.ui.initialized'  jsdoc/valid-types

/home/novemlinguae/mediawiki/resources/src/mediawiki.rcfilters/ui/FilterTagMultiselectWidget.js
  402:1  warning  Syntax error in namepath: ~'RcFilters.popup.open'  jsdoc/valid-types

/home/novemlinguae/mediawiki/resources/src/mediawiki.rcfilters/ui/SaveFiltersPopupButtonWidget.js
  126:1  warning  JSDoc @return declaration present but return expression not available in function  jsdoc/require-returns-check

/home/novemlinguae/mediawiki/resources/src/mediawiki.rcfilters/ui/SavedLinksListItemWidget.js
  199:1  warning  JSDoc @return declaration present but return expression not available in function  jsdoc/require-returns-check

/home/novemlinguae/mediawiki/resources/src/mediawiki.router/router.js
  130:2  warning  Missing JSDoc @return declaration  jsdoc/require-returns

/home/novemlinguae/mediawiki/resources/src/mediawiki.searchSuggest/searchSuggest.js
  52:1  warning  The type 'ResponseMetaData' is undefined  jsdoc/no-undefined-types
  59:1  warning  The type 'ResponseFunction' is undefined  jsdoc/no-undefined-types

/home/novemlinguae/mediawiki/resources/src/mediawiki.special.apisandbox/apisandbox.js
  1320:2  warning  Found more than one @return declaration  jsdoc/require-returns
  1320:2  warning  Found more than one @return declaration  jsdoc/require-returns-check

/home/novemlinguae/mediawiki/resources/src/mediawiki.special.createaccount/HtmlformChecker.js
  53:1  warning  JSDoc @return declaration present but return expression not available in function  jsdoc/require-returns-check

/home/novemlinguae/mediawiki/resources/src/mediawiki.template.js
   26:1  warning  The type 'TemplateRenderer' is undefined         jsdoc/no-undefined-types
   40:1  warning  The type 'TemplateRenderFunction' is undefined   jsdoc/no-undefined-types
   45:1  warning  The type 'TemplateCompileFunction' is undefined  jsdoc/no-undefined-types
   61:1  warning  The type 'TemplateCompiler' is undefined         jsdoc/no-undefined-types
   88:1  warning  The type 'TemplateCompiler' is undefined         jsdoc/no-undefined-types
  107:1  warning  The type 'TemplateRenderer' is undefined         jsdoc/no-undefined-types
  125:1  warning  The type 'TemplateRenderer' is undefined         jsdoc/no-undefined-types
  149:1  warning  The type 'TemplateRenderer' is undefined         jsdoc/no-undefined-types

/home/novemlinguae/mediawiki/resources/src/mediawiki.util/util.js
  580:1  warning  Syntax error in namepath: ~'util.addPortlet'      jsdoc/valid-types
  748:1  warning  Syntax error in namepath: ~'util.addPortletLink'  jsdoc/valid-types

/home/novemlinguae/mediawiki/resources/src/mediawiki.widgets.datetime/CalendarWidget.js
  506:2  warning  JSDoc @return declaration present but return expression not available in function  jsdoc/require-returns-check

/home/novemlinguae/mediawiki/resources/src/mediawiki.widgets.datetime/DateTimeFormatter.js
  268:1  warning  The type 'FieldSpecificationObject' is undefined  jsdoc/no-undefined-types
  632:1  warning  The type 'CalendarGridData' is undefined          jsdoc/no-undefined-types

/home/novemlinguae/mediawiki/resources/src/mediawiki.widgets.datetime/DateTimeInputWidget.js
  603:2  warning  JSDoc @return declaration present but return expression not available in function  jsdoc/require-returns-check
  727:2  warning  JSDoc @return declaration present but return expression not available in function  jsdoc/require-returns-check

/home/novemlinguae/mediawiki/resources/src/mediawiki.widgets.datetime/DiscordianDateTimeFormatter.js
  74:1  warning  The type 'FieldSpecificationObject' is undefined  jsdoc/no-undefined-types

/home/novemlinguae/mediawiki/resources/src/mediawiki.widgets.datetime/ProlepticGregorianDateTimeFormatter.js
  306:1  warning  The type 'FieldSpecificationObject' is undefined  jsdoc/no-undefined-types

/home/novemlinguae/mediawiki/resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js
  566:2  warning  JSDoc @return declaration present but return expression not available in function  jsdoc/require-returns-check
  580:2  warning  JSDoc @return declaration present but return expression not available in function  jsdoc/require-returns-check

/home/novemlinguae/mediawiki/resources/src/mediawiki.widgets/mw.widgets.DateInputWidget.js
  529:2  warning  JSDoc @return declaration present but return expression not available in function  jsdoc/require-returns-check
  556:2  warning  JSDoc @return declaration present but return expression not available in function  jsdoc/require-returns-check
  570:2  warning  JSDoc @return declaration present but return expression not available in function  jsdoc/require-returns-check

/home/novemlinguae/mediawiki/resources/src/mediawiki.widgets/mw.widgets.NamespaceInputWidget.js
  50:1  warning  The type 'DropdownOptions' is undefined  jsdoc/no-undefined-types

/home/novemlinguae/mediawiki/resources/src/startup/mediawiki.loader.js
  61:1  warning  Syntax error in namepath: ~'resourceloader.exception'  jsdoc/valid-types

Double return statements kind of work in JSDoc. They render. Isn't very pretty though.

	 * @return {Object} Selector counts
	 * @return {number} return.selectors Total number of selectors
	 * @return {number} return.matched Number of matched selectors

image.png (529×496 px, 18 KB)

Do we want to convert this to 1 giant return statement to get rid of the JSDoc error?

	 * @return {Object} Selector counts. return.selectors {number} Total
	 * number of selectors. return.matched {number} Number of matched
	 * selectors

Or do we want to do something else (such as changing eslint-config-wikimedia to not warn for this, and changing jsdoc-wmf-theme to render this a bit more compact)?

Change #1050091 had a related patch set uploaded (by Novem Linguae; author: Novem Linguae):

[mediawiki/core@master] JSDoc: fix some eslint warnings

https://gerrit.wikimedia.org/r/1050091

@Novem_Linguae, regarding the double @return statements, we want to re-write these to use only one @return statement, but in a way that is more clear than combining the JSDuck return.[thing] statements into one line. I don't understand these well enough to give an exact example, but one way would be to use a @typedef to define an object with multiple properties.

Removing this from the scope of the MediaWiki core migration as we wrap up that project. We'll track this along with other docs improvements as part of MediaWiki-Documentation

Change #1050091 merged by jenkins-bot:

[mediawiki/core@master] JSDoc: fix some eslint warnings

https://gerrit.wikimedia.org/r/1050091