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

Code before:
                }
            });

            beforeEach(prepare);
            afterEach(cleanup);

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

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

            it("'isPathIgnored()' should return 'true' for '/bar.js'.", async () => {
                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' with patterns ['!node_modules/', 'node_modules/*', '!node_modules/foo/'].", () => {

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


Review comment (bug):
question: why does it have a linting error here?  To me, seems it should be no errors reported: `foo.js` is an empty file, so there are no linting errors. am i missing something?


Code after:
                            },
                        },
                        {
                            ignores: ["**/*.json"],
                            rules: {
                                "no-unused-vars": "error",
                            },
                        },
                      ];`,
                    "foo.js": "",
                    "foo.json": ""
                }
            });

            beforeEach(prepare);
            afterEach(cleanup);

            it("should not add json files as lint targets", async () => {
                const engine = new FlatESLint({
                    cwd
                });

                const results = await engine.lintFiles("foo*");

                // should not lint `foo.json`
                assert.strictEqual(results.length, 1);
                assert.strictEqual(results[0].filePath, path.join(getPath(), "foo.js"));
            });
        });

    });

    describe("with ignores config", () => {
        const root = getFixturePath("cli-engine/ignore-patterns");

        describe("ignores can add an ignore pattern ('foo.js').", () => {
            const { prepare, cleanup, getPath } = createCustomTeardown({
                cwd: root,
                files: {
                    "eslint.config.js": `module.exports = {
                        ignores: ["**/foo.js"]
                    };`,
                    "foo.js": "",
                    "bar.js": "",
                    "subdir/foo.js": "",
                    "subdir/bar.js": ""
                }
            });

            beforeEach(prepare);
            afterEach(cleanup);