Skip to content

Update the lint:jsdoc configuration to be compatible with ESLint v10 - #13237

Open
afercia wants to merge 3 commits into
WordPress:trunkfrom
afercia:fix/lint-jsdoc
Open

Update the lint:jsdoc configuration to be compatible with ESLint v10#13237
afercia wants to merge 3 commits into
WordPress:trunkfrom
afercia:fix/lint-jsdoc

Conversation

@afercia

@afercia afercia commented Aug 22, 2026

Copy link
Copy Markdown
Member

Trac ticket: https://core.trac.wordpress.org/ticket/65939

Use of AI Tools

  • Run npm install && npm run lint:jsdoc
  • Observe the scripts reports JSDoc errors and warnings, as exepcted.

Important: compare the new ruleset with the previous one. The Core ruleset is minimal and only checks a very few rules while the one in Gutenberg checks for way more ones. For now, I tried to replicate the 'minimal' configuration that was used in Core.

AI assistance: Yes
Tool(s): GitHub Copilot
Model(s): Claude Haiku 4.5
Used for: Configuration of the rules to match the previous ones. Final implementation was reviewed by me.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props afercia.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@afercia

afercia commented Aug 22, 2026

Copy link
Copy Markdown
Member Author

Note, for history: the lint:jsdoc script in Core broke when the ESLint version used in @wordpress/scripts was upgraded to version 10 in the Gutenberg repository.

@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@ciampo ciampo left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for noticing the issue and working on a fix 🙏

I had a quick look and triggered an AI-assisted code review, sharing my findings here.

The current green checks do not exercise the behavior changed here. The JavaScript coding-standards workflow runs npm run grunt jshint, not npm run lint:jsdoc, so CI can stay green if the command hangs, loads the wrong config, accepts legacy-invalid JSDoc, or fixes unrelated directives.

Could we add a small fixture-based check that proves the command completes, selects the flat config, enforces the agreed legacy rules, and leaves non-Javadoc lint directives unchanged? A controlled fixture is preferable to asserting the current repository-wide error count.

Also cc @manzoorwanijk as the author of the related Gutenberg change.

And cc @aduth , too

Comment thread .eslintrc-jsdoc.js
Comment on lines +19 to +81
// Type validation with exemptTagContexts to allow flexible type formats
// This avoids enforcing type normalization (Object→object) preferences
'jsdoc/check-types': [ 'error', {
noDefaults: true,
exemptTagContexts: [
{ tag: 'param', types: true },
{ tag: 'return', types: true },
{ tag: 'returns', types: true },
{ tag: 'type', types: true },
{ tag: 'typedef', types: true },
{ tag: 'property', types: true },
{ tag: 'arg', types: true },
{ tag: 'argument', types: true },
],
} ],

// NOTE: check-tag-names is DISABLED because eslint-plugin-jsdoc enforces
// opposite tag preferences (return→returns) than the original valid-jsdoc
// (which preferred returns→return). Disabling avoids ~1600 false positives.
'jsdoc/check-tag-names': 'off',

// Disable all other jsdoc rules to match minimal original requirements
'jsdoc/check-indentation': 'off',
'jsdoc/check-line-alignment': 'off',
'jsdoc/check-property-names': 'off',
'jsdoc/check-syntax': 'off',
'jsdoc/check-template-names': 'off',
'jsdoc/check-values': 'off',
'jsdoc/convert-to-jsdoc-comments': 'off',
'jsdoc/empty-tags': 'off',
'jsdoc/implements-on-classes': 'off',
'jsdoc/match-description': 'off',
'jsdoc/multiline-blocks': 'off',
'jsdoc/no-bad-blocks': 'off',
'jsdoc/no-defaults': 'off',
'jsdoc/no-types': 'off',
'jsdoc/require-asterisk-prefix': 'off',
'jsdoc/require-description': 'off',
'jsdoc/require-description-complete-sentence': 'off',
'jsdoc/require-example': 'off',
'jsdoc/require-file-overview': 'off',
'jsdoc/require-hyphen-before-param-description': 'off',
'jsdoc/require-jsdoc': 'off',
'jsdoc/require-param': 'off',
'jsdoc/require-param-description': 'off',
'jsdoc/require-param-name': 'off',
'jsdoc/require-param-type': 'off',
'jsdoc/require-property': 'off',
'jsdoc/require-property-description': 'off',
'jsdoc/require-property-name': 'off',
'jsdoc/require-property-type': 'off',
'jsdoc/require-returns': 'off',
'jsdoc/require-returns-check': 'off',
'jsdoc/require-returns-description': 'off',
'jsdoc/require-returns-type': 'off',
'jsdoc/require-throws': 'off',
'jsdoc/require-yields': 'off',
'jsdoc/require-yields-check': 'off',
'jsdoc/sort-tags': 'off',
'jsdoc/tag-lines': 'off',
'jsdoc/text-escaping': 'off',
'jsdoc/valid-types': 'off',
},

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not preserve the old valid-jsdoc behavior described by the ticket and this config. The new rules exempt the common JSDoc tags from type checks, disable tag-name checks, and disable required parameter/return type and return-description checks.

I ran one fixture against ESLint 8.57.1 with the exact old config, then against ESLint 10 with this PR's config. @arg {int}, @returns {String} without a description, and missing parameter/return types produced six errors before and zero after. Nonconforming docblocks will therefore pass after this migration.

Could we map the old prefer, preferType, required-type, and return-description behavior to eslint-plugin-jsdoc, then add parity fixtures for those cases? The current Gutenberg JSDoc config confirms the supported pattern: use settings.jsdoc.tagNamePreference and preferredTypes with check-tag-names, check-types, and the applicable required-type/description rules.

Verification detail

The old config reported:

  • missing return description;
  • @arg instead of @param;
  • int instead of number;
  • @returns instead of @return;
  • String instead of string;
  • missing type braces.

The PR config exited successfully with no diagnostics for the same source.

Comment thread eslint.config.js
Comment on lines +12 to +37
module.exports = [
...jsdocConfig,
{
ignores: [
'build/**',
'**/build/**',
'node_modules/**',
'tests/**',
'vendor/**',
'tools/**',
'jsdoc/**',
'artifacts/**',
'coverage/**',
'.cache/**',
'src/wp-includes/blocks/**/*.js',
'src/wp-includes/blocks/**/*.js.map',
'src/wp-content/themes/**',
'src/wp-content/plugins/**',
'src/wp-content/mu-plugins/**',
'src/wp-content/upgrade/**',
'src/wp-content/uploads/**',
'src/js/_enqueues/vendor/**',
'src/wp-admin/js/**',
'src/wp-includes/js/**',
],
},

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dedicated JSDoc commands still process unrelated inline ESLint configuration. At this head, npm run lint:jsdoc reports five eslint-env errors and three unused-disable warnings outside JSDoc. More importantly, --fix-dry-run shows that lint:jsdoc:fix removes existing // eslint-disable-line complexity comments from src/js/_enqueues/wp/code-editor.js because the minimal config does not enable complexity.

That means a JSDoc fixer can change suppressions that belong to another lint pass. Could this config disable unrelated inline-config processing, for example with linterOptions.noInlineConfig: true after confirming that no JSDoc-specific inline suppressions are required? The pinned tree contains no JSDoc-specific ESLint disable comments, and the equivalent --no-inline-config probe removed these unrelated diagnostics.

Verification detail

The exact-head run completed with 40 diagnostics: 37 errors and 3 warnings. Five errors were for unsupported eslint-env comments, and all three warnings were unrelated unused disables. ESLint documents both behaviors in its flat-config migration guide and linter options reference.

@afercia afercia mentioned this pull request Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants