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

"ESLint couldn't find the plugin" notice loses a last character #13255

Closed
JoshuaKGoldberg opened this issue May 4, 2020 · 8 comments · Fixed by #13473
Closed

"ESLint couldn't find the plugin" notice loses a last character #13255

JoshuaKGoldberg opened this issue May 4, 2020 · 8 comments · Fixed by #13473
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion auto closed The bot closed this issue works as intended The behavior described in this issue is working correctly

Comments

@JoshuaKGoldberg
Copy link
Contributor

JoshuaKGoldberg commented May 4, 2020

Tell us about your environment

  • ESLint Version: 6.8.0
  • Node Version: 12.0.0
  • npm Version: 6.14.4

What parser (default, Babel-ESLint, etc.) are you using?

Not relevant, but "@typescript-eslint/parser"

Please show your full configuration:

Configuration
module.exports = {
  extends: [
    "plugin:eslint-config-prettier",
  ],
};

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

eslint --print-config ./eslintrc.js

What did you expect to happen?

The module name being reported as not existing should be ... eslint-config-prettier, I'm guessing?

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

Oops! Something went wrong! :(

ESLint: 6.8.0.

ESLint couldn't find the plugin "eslint-plugin-eslint-config-prettie".

(The package "eslint-plugin-eslint-config-prettie" was not found when loaded as a Node module from the directory "C:\Code\tslinttest".)

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

    npm install eslint-plugin-eslint-config-prettie@latest --save-dev

The plugin "eslint-plugin-eslint-config-prettie" was referenced from the config file in ".eslintrc.js".

If you still can't figure out the problem, please stop by https://gitter.im/eslint/eslint to chat with the team.

This issue split from: typescript-eslint/tslint-to-eslint-config#439.

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

I'd love to! 🤗

@JoshuaKGoldberg JoshuaKGoldberg added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels May 4, 2020
@yeonjuan
Copy link
Member

yeonjuan commented May 4, 2020

Hi @JoshuaKGoldberg :) Thanks for the reporting. 😀

It seems a bug to me; I agree that the error message should be improved

The module name being reported as not existing should be ... eslint-config-prettier, I'm guessing?

Maybe not, 🤔 because the actual reason is incorrect configuration.

"plugin:eslint-config-prettier",

The "plugin:xxx" means the use of exported configuration from other plugins.
so it should be consists of "plugin:" + {package name} + "/" + {configuration name}

The extends property value can consist of:

  • plugin:
  • the package name (from which you can omit the prefix, for example, react)
  • /
  • the configuration name (for example, recommended)

const slashIndex = extendName.lastIndexOf("/");

the problem is here. there is no '/' character in extendName so lastIndexOf return -1;

@yeonjuan yeonjuan added cli Relates to ESLint's command-line interface evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels May 4, 2020
@Vovch
Copy link

Vovch commented May 13, 2020

Hi, everyone!

Stumbled upon this issue in other person's code yesterday.

As a solution I might propose adding the next code:

if (slashIndex === -1) {
    const wrongConfigName = JSON.stringify(extendName).slice(1, -1);
    throw new Error(`'extends' requires a configuration name for '${wrongConfigName}', provided after '/' sign.`);
}

This way it is possible to also give an understandable error in some cases when the user mistakenly prints \ sign. E.g.:
Error: 'extends' requires a configuration name for 'plugin:prettier\recommended', provided after '/' sign.

instead of:
ecommende". because there is whitespace in the name. Please check your configuration and remove all whitespace from the plugin name.

@mysticatea
Copy link
Member

mysticatea commented May 13, 2020

Thank you for your report.

But it's not a bug. The plugin: specifier needs a plugin name and a config name: plugin:foo/bar. Here, the foo is a plugin name, it means loading eslint-plugin-foo, and the bar is a config name, it means using the require("eslint-plugin-foo").configs.foo config object.

A PR is welcome in order to print understandable error message in that case.

@mysticatea mysticatea added works as intended The behavior described in this issue is working correctly and removed bug ESLint is working incorrectly cli Relates to ESLint's command-line interface evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels May 13, 2020
@jaganathanb
Copy link

I faced same kind of issue but for @typescript-eslint/eslint-plugin. The surprising thing is that the issue is because of eslint-nullish-coalescing which changed the content of node_modules\.bin\eslint.cmd file to some thing like below.

@IF EXIST "%~dp0\node.exe" (
  "%~dp0\node.exe"  "%~dp0\..\eslint-nullish-coalescing\bin\eslint.js" %*
) ELSE (
  @SETLOCAL
  @SET PATHEXT=%PATHEXT:;.JS;=;%
  node  "%~dp0\..\eslint-nullish-coalescing\bin\eslint.js" %*
)

I installed eslint version 7 but the error message was showing up as 4.19.1 which the eslint-nullish-coalescing package version which is a fork of eslint.

Please check your eslint.cmd file's content.

Here is the stackoverflow post.

@cellog
Copy link

cellog commented Jun 24, 2020

this is working as intende? That seems like a bad desig. Tell people they used invalid syntax, don't just chop off the last characte.

@eslint-deprecated
Copy link

Unfortunately, it looks like there wasn't enough interest from the team
or community to implement this change. While we wish we'd be able to
accommodate everyone's requests, we do need to prioritize. We've found
that issues failing to reach accepted status after 21 days tend to
never be accepted, and as such, we close those issues.
This doesn't mean the idea isn't interesting or useful, just that it's
not something the team can commit to.

Thanks for contributing to ESLint and we appreciate your understanding.

@mdjermanovic
Copy link
Member

PR to print an appropriate error message in this case: #13473

@mdjermanovic
Copy link
Member

Fixed by #13473.

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Jan 23, 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 Jan 23, 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 auto closed The bot closed this issue works as intended The behavior described in this issue is working correctly
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants