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

Code before:
            it("should ignore a local config file", async () => {
                const filePath = getFixturePath("eslintrc", "quotes.js");
                const exit = await cli.execute(`--no-eslintrc --no-ignore ${filePath}`, null, false);

                assert.isTrue(log.info.notCalled);
                assert.strictEqual(exit, 0);
            });
        });

        describe("when using an eslintrc config file", () => {

            let processStub;

            beforeEach(() => {
                processStub = sinon.stub(process, "emitWarning");
            });

            afterEach(() => {
                processStub.restore();
            });

            it("should emit deprecation warning", async () => {
                const configPath = getFixturePath(".eslintrc");
                const filePath = getFixturePath("passing.js");

                await cli.execute(`--config ${configPath} ${filePath}`, null, false);

                assert.strictEqual(processStub.callCount, 1, "calls `process.emitWarning()` once");
                assert.strictEqual(processStub.getCall(0).args[1], "ESLintRCWarning");
            });
        });

        describe("when executing without no-eslintrc flag", () => {
            it("should load a local config file", async () => {
                const filePath = getFixturePath("eslintrc", "quotes.js");
                const exit = await cli.execute(`--no-ignore ${filePath}`, null, false);

                assert.isTrue(log.info.calledOnce);
                assert.strictEqual(exit, 1);
            });
        });

        describe("when executing without env flag", () => {
            it("should not define environment-specific globals", async () => {
                const files = [
                    getFixturePath("globals-browser.js"),
                    getFixturePath("globals-node.js")
                ];

                await cli.execute(`--no-eslintrc --config ./packages/js/src/configs/eslint-recommended.js --no-ignore ${files.join(" ")}`, null, false);


Review comment (suggestion):
After these changes, `npm test` will be logging more than 100 deprecation warnings until we drop eslintrc in v10.

Can we avoid that?

`allowFlatConfig = false` is passed only from tests, so we could update the condition in `lib/cli.js` to avoid logging warnings while running tests:

```diff
-if (!usingFlatConfig) {
+if (allowFlatConfig && !usingFlatConfig) {
    process.emitWarning("You are using an eslintrc configuration file, which is deprecated and support will be removed in v10.0.0. Please migrate to an eslint.config.js file. See https://eslint.org/docs/latest/use/configure/migration-guide for details.", "ESLintRCWarning");
}
```

Then, we could update this test this way to make it work:

```suggestion
                const localCLI = proxyquire("../../lib/cli", {
                    "./eslint/flat-eslint": { shouldUseFlatConfig: () => Promise.resolve(false) }
                });

                await localCLI.execute(`--config ${configPath} ${filePath}`);
```

Or, perhaps even better, merge this test into the [test for `ESLINT_USE_FLAT_CONFIG=false`](https://github.com/eslint/eslint/blob/fffca5c362bcd205dbf79d1bb52834f8a98fc6bd/tests/lib/cli.js#L163-L170) as that's anyway the most realistic test:

```diff
it(`should not use it when ESLINT_USE_FLAT_CONFIG=false even if an eslint.config.js is present:${configType}`, async () => {
    process.env.ESLINT_USE_FLAT_CONFIG = "false";
    process.cwd = getFixturePath;

    const exitCode = await cli.execute(`--no-ignore --ext .js ${getFixturePath("files")}`, null, useFlatConfig);

    assert.strictEqual(exitCode, 0);

+   if (useFlatConfig) {
+       assert.strictEqual(processStub.callCount, 1, "calls `process.emitWarning()` once");
+       assert.strictEqual(processStub.getCall(0).args[1], "ESLintRCWarning");
+   }
});
```

That would leave `npm test` with zero eslintrc deprecation warnings (assuming https://github.com/eslint/eslint/pull/17797 will be merged; those tests pass `allowFlatConfig = true` but mistakenly still work in eslintc mode, so they're mistakenly logging deprecation warnings).

Code after:
        });

        // ---------
    });


    describe("when given a config file", () => {
        it("should load the specified config file", async () => {
            const configPath = getFixturePath("eslint.config.js");
            const filePath = getFixturePath("passing.js");

            await cli.execute(`--config ${configPath} ${filePath}`);
        });
    });


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

        describe("Environments", () => {

            describe("when given a config with environment set to browser", () => {
                it("should execute without any errors", async () => {
                    const configPath = getFixturePath("configurations", "env-browser.json");
                    const filePath = getFixturePath("globals-browser.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 Node.js", () => {
                it("should execute without any errors", async () => {
                    const configPath = getFixturePath("configurations", "env-node.json");
                    const filePath = getFixturePath("globals-node.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 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);