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

Code before:
                const engine = new FlatESLint({ cwd: getPath() });

                assert.strictEqual(await engine.isPathIgnored("bar.js"), true);
                assert.strictEqual(await engine.isPathIgnored("subdir/bar.js"), false);
            });

            it("'lintFiles()' should not verify 'foo.js' and '/bar.js'.", async () => {
                const engine = new FlatESLint({ cwd: getPath() });
                const filePaths = (await engine.lintFiles("**/*.js"))
                    .map(r => r.filePath)
                    .sort();

                assert.deepStrictEqual(filePaths, [
                    path.join(getPath(), "baz.js"),
                    path.join(getPath(), "eslint.config.js"),
                    path.join(getPath(), "subdir/bar.js"),
                    path.join(getPath(), "subdir/baz.js")
                ]);
            });
        });

        describe("ignores can unignore '/node_modules/foo'.", () => {

            const { prepare, cleanup, getPath } = createCustomTeardown({
                cwd: `${root}-unignores`,
                files: {
                    "eslint.config.js": `module.exports = {
                        ignores: ["!**/node_modules/foo/**"]
                    };`,
                    "node_modules/foo/index.js": "",
                    "node_modules/foo/.dot.js": "",
                    "node_modules/bar/index.js": "",
                    "foo.js": ""
                }
            });

            beforeEach(prepare);
            afterEach(cleanup);

            it("'isPathIgnored()' should return 'false' for 'node_modules/foo/index.js'.", async () => {
                const engine = new FlatESLint({ cwd: getPath() });

                assert.strictEqual(await engine.isPathIgnored("node_modules/foo/index.js"), false);
            });

            it("'isPathIgnored()' should return 'false' for 'node_modules/foo/.dot.js'.", async () => {
                const engine = new FlatESLint({ cwd: getPath() });

                assert.strictEqual(await engine.isPathIgnored("node_modules/foo/.dot.js"), false);
            });


Review comment (suggestion):
Seems like there was some timing issues where just `root` was colliding due to Mocha running some tests in parallel, so I made them unique.

Code after:
                const engine = new FlatESLint({ cwd: getPath() });

                assert.strictEqual(await engine.isPathIgnored("bar.js"), true);
                assert.strictEqual(await engine.isPathIgnored("subdir/bar.js"), false);
            });

            it("'lintFiles()' should not verify 'foo.js' and '/bar.js'.", async () => {
                const engine = new FlatESLint({ cwd: getPath() });
                const filePaths = (await engine.lintFiles("**/*.js"))
                    .map(r => r.filePath)
                    .sort();

                assert.deepStrictEqual(filePaths, [
                    path.join(getPath(), "baz.js"),
                    path.join(getPath(), "eslint.config.js"),
                    path.join(getPath(), "subdir/bar.js"),
                    path.join(getPath(), "subdir/baz.js")
                ]);
            });
        });


        describe("ignores can unignore '/node_modules/foo'.", () => {

            const { prepare, cleanup, getPath } = createCustomTeardown({
                cwd: `${root}-unignores`,
                files: {
                    "eslint.config.js": `module.exports = {
                        ignores: ["!**/node_modules/foo"]
                    };`,
                    "node_modules/foo/index.js": "",
                    "node_modules/foo/.dot.js": "",
                    "node_modules/bar/index.js": "",
                    "foo.js": ""
                }
            });

            beforeEach(prepare);
            afterEach(cleanup);

            it("'isPathIgnored()' should return 'false' for 'node_modules/foo/index.js'.", async () => {
                const engine = new FlatESLint({ cwd: getPath() });

                assert.strictEqual(await engine.isPathIgnored("node_modules/foo/index.js"), false);
            });

            it("'isPathIgnored()' should return 'false' for 'node_modules/foo/.dot.js'.", async () => {
                const engine = new FlatESLint({ cwd: getPath() });

                assert.strictEqual(await engine.isPathIgnored("node_modules/foo/.dot.js"), false);
            });