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
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:
- 3269001-replace-valid-jsdoc-rule
changes, plain diff MR !12497
Comments
Comment #2
john.karahalis commentedComment #3
john.karahalis commentedComment #4
john.karahalis commentedComment #5
quietone commentedChanging to a different package is an issue for core, so changing project.
Comment #7
tom kondaI 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.
Comment #9
tom kondaComment #10
smustgrave commentedSeems 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!
Comment #11
tom kondaI 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.
Comment #12
smustgrave commentedThis a new rule from jsdoc that was introduced? Js is not my best
Comment #13
tom kondaThis '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.
Comment #14
tom kondaI confirmed Gitlab CI server was running Node v18.20.8.
https://git.drupalcode.org/issue/drupal-3546517/-/jobs/6938346
Comment #15
tom kondaCI problem is fixed. #3553354: Update nodejs to v20
ESLint job works correctly.
Comment #16
smustgrave commentedSeems 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.
Comment #17
quietone commentedThanks 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.
Comment #19
tobiasbBump to latest version and add the config changes also in
.eslintrc.legacy.json.Comment #20
smustgrave commentedLGTM
Comment #23
nod_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!
Comment #26
nod_Comment #28
longwaveComment #30
nicrodgersRunning 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?
Comment #31
tom konda@nicrodgers
I tried
npm installwith 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.