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

Code before:
                assert(!await engine.isPathIgnored(getFixturePath("ignored-paths", "foo.cjs")), "foo.cjs should not be ignored");
                assert(!await engine.isPathIgnored(getFixturePath("ignored-paths", "foo/bar.cjs")), "foo/bar.cjs should not be ignored");
                assert(!await engine.isPathIgnored(getFixturePath("ignored-paths", "foo/bar/baz.cjs")), "foo/bar/baz.cjs should not be ignored");
            });
        });

        describe("with config ignores ignorePatterns option", () => {
            it("should return false for ignored file when unignored with ignore pattern", async () => {
                const cwd = getFixturePath("ignored-paths");
                const engine = new ESLint({
                    overrideConfigFile: getFixturePath("eslint.config-with-ignores2.js"),
                    ignorePatterns: ["!undef.js"],
                    cwd
                });

                assert(!await engine.isPathIgnored(getFixturePath("ignored-paths", "undef.js")));
            });
        });

        it("should throw if non-string value is given to 'filePath' parameter", async () => {
            const eslint = new ESLint();

            await assert.rejects(() => eslint.isPathIgnored(null), /'filePath' must be a non-empty string/u);
        });

        it("should warn if .eslintignore file is present", async () => {
            const cwd = getFixturePath("ignored-paths");

            sinon.restore();
            const processStub = sinon.stub(process, "emitWarning");

            // eslint-disable-next-line no-new -- for testing purpose only
            new ESLint({ cwd });

            assert.strictEqual(processStub.callCount, 1, "calls `process.emitWarning()` once");
            assert.strictEqual(processStub.getCall(0).args[0], "The \".eslintignore\" file is no longer supported. Switch to using the \"ignores\" property in \"eslint.config.js\": https://eslint.org/docs/latest/use/configure/migration-guide#ignoring-files");
            assert.strictEqual(processStub.getCall(0).args[1], "ESLintIgnoreWarning");

            processStub.restore();
        });
    });

    describe("loadFormatter()", () => {
        it("should return a formatter object when a bundled formatter is requested", async () => {
            const engine = new ESLint();
            const formatter = await engine.loadFormatter("json");

            assert.strictEqual(typeof formatter, "object");
            assert.strictEqual(typeof formatter.format, "function");
        });


Review comment (refactor):
This is in `describe()` for the `ESLint#isPathIgnored()` method.

```
  ESLint
    isPathIgnored
      √ should warn if .eslintignore file is present
```

 Since we are testing a warning emitted from the constructor, I think we should move this into `describe("ESLint constructor function", () => { ... })`.

Code after:
                const engine = new ESLint({ ignorePatterns: ["failing.js"], cwd });

                assert(!await engine.isPathIgnored(getFixturePath("ignored-paths", "unignored.js")));
            });

            it("two globstar '**' ignore pattern should ignore files in nested directories", async () => {
                const cwd = getFixturePath("ignored-paths");
                const engine = new ESLint({
                    overrideConfigFile: true,
                    ignorePatterns: ["**/*.js"],
                    cwd
                });

                assert(await engine.isPathIgnored(getFixturePath("ignored-paths", "foo.js")), "foo.js should be ignored");
                assert(await engine.isPathIgnored(getFixturePath("ignored-paths", "foo/bar.js")), "foo/bar.js should be ignored");
                assert(await engine.isPathIgnored(getFixturePath("ignored-paths", "foo/bar/baz.js")), "foo/bar/baz.js");
                assert(!await engine.isPathIgnored(getFixturePath("ignored-paths", "foo.cjs")), "foo.cjs should not be ignored");
                assert(!await engine.isPathIgnored(getFixturePath("ignored-paths", "foo/bar.cjs")), "foo/bar.cjs should not be ignored");
                assert(!await engine.isPathIgnored(getFixturePath("ignored-paths", "foo/bar/baz.cjs")), "foo/bar/baz.cjs should not be ignored");
            });
        });

        describe("with config ignores ignorePatterns option", () => {
            it("should return false for ignored file when unignored with ignore pattern", async () => {
                const cwd = getFixturePath("ignored-paths");
                const engine = new ESLint({
                    overrideConfigFile: getFixturePath("eslint.config-with-ignores2.js"),
                    ignorePatterns: ["!undef.js"],
                    cwd
                });

                assert(!await engine.isPathIgnored(getFixturePath("ignored-paths", "undef.js")));
            });
        });

        it("should throw if non-string value is given to 'filePath' parameter", async () => {
            const eslint = new ESLint();

            await assert.rejects(() => eslint.isPathIgnored(null), /'filePath' must be a non-empty string/u);
        });
    });

    describe("loadFormatter()", () => {
        it("should return a formatter object when a bundled formatter is requested", async () => {
            const engine = new ESLint();
            const formatter = await engine.loadFormatter("json");

            assert.strictEqual(typeof formatter, "object");
            assert.strictEqual(typeof formatter.format, "function");
        });