eslint: CLIEngine addPlugin function not working

Tell us about your environment

  • ESLint Version: 6.0.1
  • Node Version: 12.4.0
  • npm Version: 6.9.0

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

Please show your full configuration:

Configuration
{
    "parserOptions": {
        "ecmaFeatures": {
            "jsx": true
        }
    },
    "globals": {
        "createReactClass": true
    },
    "plugins": ["react"],
    "extends": ["plugin:react/recommended"],
    "rules": {
        "react/jsx-wrap-multilines": [
            "error", {
                "declaration": "parens-new-line",
                "assignment": "parens-new-line",
                "return": "parens-new-line",
                "arrow": "parens-new-line",
                "condition": "parens-new-line",
                "logical": "parens-new-line",
                "prop": "parens-new-line"
            }
        ]
    }
}

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

I’m trying to merge a PR that updates our ESLint dependency from 5.x to 6.x. However, a test that adds react-eslint-plugin and formats React does not pass. If I add it via the plugins string array in the CLIEngine options it runs. PR I’m referring to is: https://github.com/Unibeautify/beautifier-eslint/pull/142.

I tried debugging, and the best I can tell additionalPluginPool isn’t used in the relevant functions (mainly executeOnText()).

      const cliOptions: CLIOptions = {
        baseConfig: {
          extends: extendsToAdd,
          globals: globals,
        },
        fix: true,
        parserOptions: parseOpts,
        rules: finalOptions,
        useEslintrc: false,
      };
      const cli: CLIEngine = new CLIEngine(cliOptions);
      cli.addPlugin("react", reactPlugin.package);
      const report: LintReport = cli.executeOnText(text);
      const result: LintResult = report.results[0];

What did you expect to happen? The plugin be used when added via addPlugin

What actually happened? Please include the actual, raw output from ESLint. I don’t see it using the plugin.

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

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 21 (11 by maintainers)

Most upvoted comments

Yeah, to me this doesn’t make much sense. The point of addPlugin(), at least from the documentation, is to dynamically load a plugin to the CLIEngine without the need for the plugins property. At the very least it should have been documented as a breaking change with v6 despite it not working as designed prior.