Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugins that are a dependency to a config package that aren't hoisted can't be loaded #13500

Closed
freaktechnik opened this issue Jul 17, 2020 · 2 comments
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion core Relates to ESLint's core APIs and features evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion

Comments

@freaktechnik
Copy link

freaktechnik commented Jul 17, 2020

Tell us about your environment

Environment Info:

Node version: v13.11.0
npm version: v6.14.5
Local ESLint version: v7.4.0 (Currently used)
Global ESLint version: Not found

What parser (default, Babel-ESLint, etc.) are you using? I think default, but not relevant.

Please show your full configuration:

https://github.com/freaktechnik/transifex-loader/blob/master/src/.eslintrc.json

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

Run eslint (npx eslint or npm run lint:js in that project).

What did you expect to happen?

Eslint to happily lint the project.

What actually happened? Please include the actual, raw output from ESLint.

eslint:config-array-factory Loaded: @freaktechnik/eslint-config-webpack@7.2.0 (/home/martin/dev/transifex-loader/node_modules/@freaktechnik/eslint-config-webpack/index.js) +1ms
  eslint:config-array-factory Loading JS config file: /home/martin/dev/transifex-loader/node_modules/@freaktechnik/eslint-config-webpack/index.js +0ms
  eslint:config-array-factory Loading {extends:"plugin:import/errors"} relative to /home/martin/dev/transifex-loader/node_modules/@freaktechnik/eslint-config-webpack/index.js +0ms
  eslint:config-array-factory Loading plugin "import" from /home/martin/dev/transifex-loader/node_modules/@freaktechnik/eslint-config-webpack/index.js +0ms
  eslint:config-array-factory Failed to load plugin 'import' declared in 'src/.eslintrc.json » @freaktechnik/eslint-config-webpack'. +1ms

Oops! Something went wrong! :(

ESLint: 7.4.0

ESLint couldn't find the plugin "eslint-plugin-import".

(The package "eslint-plugin-import" was not found when loaded as a Node module from the directory "/home/martin/dev/transifex-loader".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

    npm install eslint-plugin-import@latest --save-dev

The plugin "eslint-plugin-import" was referenced from the config file in "src/.eslintrc.json » @freaktechnik/eslint-config-webpack".

Having plugins as dependencies of configs is working fine - in fact eslint happily loads a bunch of them before this. However, those plugins were all hoisted, this plugin is not. It is in /home/martin/dev/transifex-loader/node_modules/@freaktechnik/eslint-config-webpack/node_modules/eslint-plugin-import.

In order for the non-hoisted plugin to work

return this._loadConfigData({
...ctx,
filePath,
name: `${ctx.name} » ${request}`
});
would have to set pluginBasePath to the dirname of the config. I've verified that that makes everything work as expected. However that might break configs that expect their extends/plugins to be peer dependencies, I guess?

Are you willing to submit a pull request to fix this bug?

Sure, if this behavior is deemed incorrect (which I hope it is, since it makes eslint configs much more useful and not accidentally broken in a weird edge case). However I would need guidance toward how to/what to test.

@freaktechnik freaktechnik added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Jul 17, 2020
@mdjermanovic mdjermanovic added core Relates to ESLint's core APIs and features evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Jul 27, 2020
@mdjermanovic
Copy link
Member

Hi @freaktechnik, thanks for the issue.

I think this is a duplicate of #3458.

In short, having plugin as a dependency of a shareable config might work well in some cases, but it isn't actually supported. End users should install the plugin as a dev dependency. An alternative at the moment is to create a plugin instead of the shareable config, as described in #3458 (comment).

This will be changed in some of the future versions, per eslint/rfcs#9. With the new configuration file format, shareable configs will be able to specify plugins as direct dependencies.

@mdjermanovic
Copy link
Member

I'm closing this since it isn't a bug with the actual configuration system. Per our documentation about shareable configs, end-users of a shareable config are required to specifiy all plugins as dev-dependecies:

If your shareable config depends on a plugin, you should also specify it as a peerDependency (plugins will be loaded relative to the end user's project, so the end user is required to install the plugins they need).

We are working on a new configuration file format that will support plugins as dependencies in shareable configs.

You can follow the implementation progress here: #13481

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 7, 2021
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion core Relates to ESLint's core APIs and features evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion
Projects
None yet
Development

No branches or pull requests

2 participants