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

Code before:

        it("should be a function", () => {
            assert.isFunction(api.loadESLint);
        });

        it("should return a Promise", () => {
            assert.instanceOf(api.loadESLint(), Promise);
        });

        it("should return FlatESLint when useFlatConfig is true", async () => {
            assert.strictEqual(await api.loadESLint({ useFlatConfig: true }), FlatESLint);
        });

        it("should return ESLint when useFlatConfig is false", async () => {
            assert.strictEqual(await api.loadESLint({ useFlatConfig: false }), api.ESLint);
        });

        it("should return FlatESLint when useFlatConfig is not provided because we have eslint.config.js", async () => {
            assert.strictEqual(await api.loadESLint(), FlatESLint);
        });

        it("should return ESLint when useFlatConfig is not provided because we have .eslintrc.cjs", async () => {
            assert.strictEqual(await api.loadESLint({
                cwd: "./tests/fixtures/config-file/cjs"
            }), FlatESLint);
        });

        it("should return ESLint when useFlatConfig is not provided and ESLINT_USE_FLAT_CONFIG is false", async () => {
            process.env.ESLINT_USE_FLAT_CONFIG = "false";
            assert.strictEqual(await api.loadESLint(), api.ESLint);
        });

        it("should return FlatESLint when useFlatConfig is not provided and ESLINT_USE_FLAT_CONFIG is true", async () => {
            process.env.ESLINT_USE_FLAT_CONFIG = "true";
            assert.strictEqual(await api.loadESLint(), FlatESLint);
        });

    });

});


Review comment (suggestion):
According to its title, this test expects `ESLint`, but checks if `FlatESLint` was returned? Also, the presence of `.eslintrc.cjs` doesn't affect the logic.

Perhaps we want to test something like this:

```suggestion
        it("should return ESLint when useFlatConfig is not provided and there is no eslint.config.js", async () => {
            assert.strictEqual(await api.loadESLint({
                cwd: os.tmpdir()
            }), api.ESLint);
        });
```

Code after:
        });

        it("should be a function", () => {
            assert.isFunction(api.loadESLint);
        });

        it("should return a Promise", () => {
            assert.instanceOf(api.loadESLint(), Promise);
        });

        it("should return FlatESLint when useFlatConfig is true", async () => {
            assert.strictEqual(await api.loadESLint({ useFlatConfig: true }), FlatESLint);
        });

        it("should return ESLint when useFlatConfig is false", async () => {
            assert.strictEqual(await api.loadESLint({ useFlatConfig: false }), api.ESLint);
        });

        it("should return FlatESLint when useFlatConfig is not provided because we have eslint.config.js", async () => {
            assert.strictEqual(await api.loadESLint(), FlatESLint);
        });

        it("should return ESLint when useFlatConfig is not provided and there is no eslint.config.js", async () => {
            assert.strictEqual(await api.loadESLint({
                cwd: os.tmpdir()
            }), api.ESLint);
        });

        it("should return ESLint when useFlatConfig is not provided and ESLINT_USE_FLAT_CONFIG is false", async () => {
            process.env.ESLINT_USE_FLAT_CONFIG = "false";
            assert.strictEqual(await api.loadESLint(), api.ESLint);
        });

        it("should return FlatESLint when useFlatConfig is not provided and ESLINT_USE_FLAT_CONFIG is true", async () => {
            process.env.ESLINT_USE_FLAT_CONFIG = "true";
            assert.strictEqual(await api.loadESLint(), FlatESLint);
        });

    });

});