WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.47k stars 4.18k forks source link

@wordpress/eslint-plugin dependencies on other eslint plugins should be peer dependencies #39810

Open anomiex opened 2 years ago

anomiex commented 2 years ago

What problem does this address?

Having these other plugins as dependencies of @wordpress/eslint-plugin only works due to npm/yarn/pnpm "hoisting" dependencies. If this hoisting does not happen (e.g. with yarn's PnP or pnpm configured to disable the default compatibility hoisting that's intended to support broken dependencies like this), eslint does not find the depended plugins.

If a package such as @rushstack/eslint-patch is used to improve eslint's plugin loading, we can easily run into the opposite problem: if plugins used by @wordpress/eslint-plugin are also used directly, we can easily wind up with a version conflict (for example, if the local config uses eslint-plugin-prettier 4.0.0 while @wordpress/eslint-plugin is still depending on ^3.3.0).

What is your proposed solution?

Change these dependencies into peer dependencies with appropriate ranges (preferably >= rather than ^), as recommended by Eslint for sharable configs.

gziolo commented 2 years ago

What is your proposed solution?

Change these dependencies into peer dependencies with appropriate ranges (preferably >= rather than ^), as recommended by Eslint for sharable configs.

Yes, it makes sense to follow the recommendation. We probably need to switch to npm 8/yarn/pnpm first or list them explicitly in Gutenberg to ensure that those dependencies get installed with npm 6.