question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: `ESLint` class should not load plugins already defined in `plugins`

See original GitHub issue

Environment

Node version: v16.9.1 npm version: v7.9.0 Local ESLint version: v7.32.0 Global ESLint version: Not found Operating System: win32 10.0.19043

What parser are you using?

Default (Espree)

What did you do?

import {ESLint} from 'eslint'

new ESLint({
	baseConfig: {
		extends: [
			'plugin:foo/preset',
		],
	},
	plugins: {
		foo: {
			configs: {
				preset: {}
			}
		}
	}
})

What did you expect to happen?

No errors.

What actually happened?

The config-array-factory is trying to load the plugin that I’ve set in the plugins.

node:internal/modules/cjs/loader:933
  const err = new Error(message);
              ^

Error: Failed to load plugin 'foo' declared in 'BaseConfig': Cannot find module 'eslint-plugin-foo'
Require stack:
- CWD\__placeholder__.js
Referenced from: BaseConfig
	// ...

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

N/A

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
nzakascommented, Oct 1, 2021

I took a look at this and updating CLIEngine is probably the easiest way to fix this.

1reaction
mdjermanoviccommented, Sep 23, 2021

If we add plugins to the CLIEngine constructor, we can init additionalPluginPool with the plugin implementations, will it solve the problem?

I think something like that would work. In the current version, we are updating additionalPluginPool on the instance, but that’s too late for extends in baseConfig.

https://github.com/eslint/eslint/blob/e3cd1414489ceda460d593ac7e7b14f8ad45d4fc/lib/eslint/eslint.js#L435-L454

We could instead pass additionalPluginPool map to the constructor. CLIEngine is now an internal module, so new options on it wouldn’t be public.

Read more comments on GitHub >

github_iconTop Results From Across the Web

VSCode failed to load plugin cannot find module 'eslint- ...
i had the same issue. In your root workspace you have a .vscode folder with a settings.json . Add the following: { "eslint....
Read more >
Configuration Files - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
eslint-plugin-react
However, this is not recommended, and any plugins or shareable configs that you use must be installed locally in either case. Configuration. Use ......
Read more >
VS Code ESLint extension - Visual Studio Marketplace
If the folder doesn't provide one the extension looks for a global install version. If you haven't installed ESLint either locally or globally ......
Read more >
[eslint] failed to load plugin 'prettier' declared in '.eslintrc.json'
I got the exact same problem. I solved this issue by removing existing eslint-config-prettier and eslint-plugin-prettier from package.json.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found