Scripts: `wp-scripts lint-js` Breaks After v16.1.4 - gutenberg


After updating @wordpress/scripts from 16.1.4 to 17.0.0 or higher (currently at 18.0.0), the JS linter breaks with the following result:

$ wp-scripts lint-js

Oops! Something went wrong! :(

ESLint: 7.32.0

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/parser/tokenizers/description.js' is not defined by "exports" in /Users/dom/Projects/wp-scripts-lint-js-test-repo/node_modules/@es-joy/jsdoccomment/node_modules/comment-parser/package.json
    at throwExportsNotFound (internal/modules/esm/resolve.js:290:9)
    at packageExportsResolve (internal/modules/esm/resolve.js:513:3)
    at resolveExports (internal/modules/cjs/loader.js:437:36)
    at Function.Module._findPath (internal/modules/cjs/loader.js:477:31)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:872:27)
    at Function.Module._load (internal/modules/cjs/loader.js:730:27)
    at Module.require (internal/modules/cjs/loader.js:957:19)
    at require (/Users/dom/Projects/wp-scripts-lint-js-test-repo/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at Object.<anonymous> (/Users/dom/Projects/wp-scripts-lint-js-test-repo/node_modules/@es-joy/jsdoccomment/dist/index.cjs.cjs:7:28)
    at Module._compile (/Users/dom/Projects/wp-scripts-lint-js-test-repo/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
error Command failed with exit code 2.
info Visit for documentation about this command.

Upon initial investigation, I think the @wordpress/eslint-plugin/jsdoc preset may be causing this issue. It’s a part of @wordpress/eslint-plugin/recommended used by default in @wordpress/scripts’ ESLint config.

Step-by-step reproduction instructions

Clone the test repository, then run:

yarn format # works fine
yarn lint:js # will break

Screenshots, screen recording, code snippet

No response

Environment info

$ node -v

$ cat package.json | grep @wordpress/scripts
        "@wordpress/scripts": "18.0.0",

Gutenberg not installed.

The test repository also includes eslint-plugin-import, but that’s primarily to keep the project config as identical to the project config as possible.


  • [X] I have searched the existing issues.
  • [X] I have tested with all plugins deactivated except Gutenberg.
Asked Sep 29 '21 10:09
avatar porada

3 Answer:

@renatho — I can see you worked on #25300, which could be related to this issue. Any chance you could take a look?

Answered Aug 25 '21 at 12:47
avatar  of porada

Referencing eslint-plugin-jsdoc directly in the project’s package.json seems to be resolving the issue. It’s not ideal, though.

Answered Aug 25 '21 at 13:12
avatar  of porada

It seems there was an issue related to some version mismatch. In older versions, it was getting that tokenizer dependency like this:

Now it's getting the exported dependency from the package:

I believe just updating the eslint-plugin-jsdoc in Gutenberg should fix that.

Answered Aug 26 '21 at 19:01
avatar  of renatho