Problem/Motivation

Drupal's ESLint configuration, which contrib projects are also encouraged to use, uses the valid-jsdoc rule, which has been deprecated.

The ESLint team recommends using eslint-plugin-jsdoc instead.

Proposed resolution

Stop using the valid-jsdoc rule in Drupal's ESLint configuration. Begin using eslint-plugin-jsdoc instead. For now, configure eslint-plugin-jsdoc similarly to how the valid-jsdoc is configured now, to minimize rework. In the future, consider using more features from eslint-plugin-jsdoc, as it is quite a bit more powerful than the valid-jsdoc rule.

Remaining tasks

Update to latest eslint-plugin-jsdoc.
Any changes needed for Nodejs 20 .

User interface changes

API changes

Data model changes

Issue fork drupal-3269001

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

john.karahalis created an issue. See original summary.

john.karahalis’s picture

Issue summary: View changes
john.karahalis’s picture

Title: ESLint: Replace valid-jsdoc rule with eslint-plugin-json » ESLint: Replace valid-jsdoc rule with eslint-plugin-jsdoc
john.karahalis’s picture

Issue summary: View changes
quietone’s picture

Title: ESLint: Replace valid-jsdoc rule with eslint-plugin-jsdoc » Replace valid-jsdoc rule with eslint-plugin-jsdoc for eslint
Project: Coding Standards » Drupal core
Version: » 11.x-dev
Component: Coding Standards » javascript
Category: Bug report » Task
Issue summary: View changes

Changing to a different package is an issue for core, so changing project.

tom konda made their first commit to this issue’s fork.

tom konda’s picture

Status: Active » Needs work

I try to replace valid-jsdoc rule with eslint-plugin-jsdoc and work well.
The /core/.eslintrc.json file is enabled settings that is written in eslint-plugin-jsdoc's document.

Note: Warnings from eslint-plugin-jsdoc much increase than from valid-jsdoc.

valid-jsdoc eslint-plugin-jsdoc
64 warnings 808 warnings

tom konda’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Needs work

Seems latest version is 54.1 can we use that one.

If you are another contributor eager to jump in, please allow the previous poster(s) at least 48 hours to respond to feedback first, so they have the opportunity to finish what they started!

tom konda’s picture

I commit eslint-plugin-jsdoc 54.1 but CI is failed because of invalid RegExp flag 'v'.
This error is not occurred Node.js v20.19.3 on my local environment.

smustgrave’s picture

This a new rule from jsdoc that was introduced? Js is not my best

tom konda’s picture

This 'v' flag was introduced ES2024 not jsdoc plugin.
According to MDN document, this v flag works Node.js 20 environment so I suppose run Node.js 18 on CI server but running environment is not logged on pipeline.

tom konda’s picture

I suppose run Node.js 18 on CI server but running environment is not logged on pipeline.

I confirmed Gitlab CI server was running Node v18.20.8.
https://git.drupalcode.org/issue/drupal-3546517/-/jobs/6938346

tom konda’s picture

Status: Needs work » Needs review

CI problem is fixed. #3553354: Update nodejs to v20
ESLint job works correctly.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Seems like a good replacement, leaning on the pipeline passing with the removal of "valid-jsdoc": from eslintrc.json. May be worth follow ups to address some of the rules being added. But definitely out of scope for here.

quietone’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Needs work
Issue tags: +Coding standards

Thanks for working to get Drupal off deprecated code. I read https://eslint.org/docs/latest/rules/valid-jsdoc and https://www.npmjs.com/package/eslint-plugin-jsdoc#user-content-eslint-pl... and these changes look correct to me. But I am not fluent in JavaScript.

There is a new release of eslint-plugin-jsdoc and core testing is using Nodejs 20 now. So setting to needs work for those.

tobiasb made their first commit to this issue’s fork.

tobiasb’s picture

Status: Needs work » Needs review

Bump to latest version and add the config changes also in .eslintrc.legacy.json.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

LGTM

  • nod_ committed 256c05ea on 11.3.x
    task: #3269001 Replace valid-jsdoc rule with eslint-plugin-jsdoc for...
nod_’s picture

Version: 11.x-dev » 11.3.x-dev
Status: Reviewed & tested by the community » Fixed

There was a new version like an hour ago, but let's get using this plugin for now it's up to date enough for our purpose.

Committed and pushed 703e5d41895 to 11.x and 256c05ea65a to 11.3.x. Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • nod_ committed 703e5d41 on 11.x
    task: #3269001 Replace valid-jsdoc rule with eslint-plugin-jsdoc for...
nod_’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

longwave’s picture

Issue tags: +11.3.0 release notes

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

nicrodgers’s picture

Running in to problems running eslint after updating to 11.3. Looks like eslint-plugin-jsdoc requires eslint 9, but core is supposed to still be on 8 https://www.drupal.org/project/drupal/issues/3440225

So with eslint 8, running npm install complains that eslint-plugin-jsdoc can't be installed.

I couldn't find anything in the release notes about this change either - what do we need to do?

tom konda’s picture

@nicrodgers

I tried npm install with npm 10.8.2 and Node v20.19.5, ESLint 8.57.1 was installed.
Accroding to the eslint-plugin-jsdoc's package.json on v61.2.1, this plugin has ESLint 7, 8 or 9 as peerDependency so ESLint 9 is not requirement.