Repository: eslint/eslint
File: tests/lib/cli.js (JavaScript)

Code before:
            describe("when given a config with environment set to Nashorn", () => {
                it("should execute without any errors", async () => {
                    const configPath = getFixturePath("configurations", "env-nashorn.json");
                    const filePath = getFixturePath("globals-nashorn.js");
                    const code = `--config ${configPath} ${filePath}`;

                    const exit = await cli.execute(code, null, false);

                    assert.strictEqual(exit, 0);
                });
            });

            describe("when given a config with environment set to WebExtensions", () => {
                it("should execute without any errors", async () => {
                    const configPath = getFixturePath("configurations", "env-webextensions.json");
                    const filePath = getFixturePath("globals-webextensions.js");
                    const code = `--config ${configPath} ${filePath}`;

                    const exit = await cli.execute(code, null, false);

                    assert.strictEqual(exit, 0);
                });
            });
        });

        describe("flat Only", () => {

            describe("`--plugin` option", () => {

                let originalCwd;

                beforeEach(() => {
                    originalCwd = process.cwd();
                    process.chdir(getFixturePath("plugins"));
                });

                afterEach(() => {
                    process.chdir(originalCwd);
                    originalCwd = void 0;
                });

                it("should load a plugin from a CommonJS package", async () => {
                    const code = "--plugin hello-cjs --rule 'hello-cjs/hello: error' ../files/*.js";

                    const exitCode = await cli.execute(code, null, true);

                    assert.strictEqual(exitCode, 1);
                    assert.ok(log.info.calledOnce);
                    assert.include(log.info.firstCall.firstArg, "Hello CommonJS!");
                });


Review comment (bug):
This was probably accidentally inserted in "eslintrc Only".

```
  cli
    eslintrc Only
      flat Only
        `--plugin` option
          √ should load a plugin from a CommonJS package (41ms)
          √ should load a plugin from an ESM package
          √ should load multiple plugins
          √ should resolve plugins specified with 'eslint-plugin-'
          √ should resolve plugins in the parent directory's node_module subdirectory
          √ should fail if a plugin is not found
          √ should fail if a plugin throws an error while loading
          √ should fail to load a plugin from a package without a default export
```

Code after:
            describe("when given a config with environment set to Nashorn", () => {
                it("should execute without any errors", async () => {
                    const configPath = getFixturePath("configurations", "env-nashorn.json");
                    const filePath = getFixturePath("globals-nashorn.js");
                    const code = `--config ${configPath} ${filePath}`;

                    const exit = await cli.execute(code, null, false);

                    assert.strictEqual(exit, 0);
                });
            });

            describe("when given a config with environment set to WebExtensions", () => {
                it("should execute without any errors", async () => {
                    const configPath = getFixturePath("configurations", "env-webextensions.json");
                    const filePath = getFixturePath("globals-webextensions.js");
                    const code = `--config ${configPath} ${filePath}`;

                    const exit = await cli.execute(code, null, false);

                    assert.strictEqual(exit, 0);
                });
            });
        });

        describe("when loading a custom rule", () => {
            it("should return an error when rule isn't found", async () => {
                const rulesPath = getFixturePath("rules", "wrong");
                const configPath = getFixturePath("rules", "eslint.json");
                const filePath = getFixturePath("rules", "test", "test-custom-rule.js");
                const code = `--rulesdir ${rulesPath} --config ${configPath} --no-ignore ${filePath}`;

                await stdAssert.rejects(async () => {
                    const exit = await cli.execute(code, null, false);

                    assert.strictEqual(exit, 2);
                }, /Error while loading rule 'custom-rule': Boom!/u);
            });

            it("should return a warning when rule is matched", async () => {
                const rulesPath = getFixturePath("rules");
                const configPath = getFixturePath("rules", "eslint.json");
                const filePath = getFixturePath("rules", "test", "test-custom-rule.js");
                const code = `--rulesdir ${rulesPath} --config ${configPath} --no-ignore ${filePath}`;

                await cli.execute(code, null, false);

                assert.isTrue(log.info.calledOnce);
                assert.isTrue(log.info.neverCalledWith(""));
            });