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

Code before:
            });

            const results = await engine.lintText("new require('hi')");
            const rulesMeta = engine.getRulesMetaForResults(results);

            assert.strictEqual(rulesMeta.semi, coreRules.get("semi").meta);
            assert.strictEqual(rulesMeta.quotes, coreRules.get("quotes").meta);
            assert.strictEqual(
                rulesMeta["n/no-new-require"],
                nodePlugin.rules["no-new-require"].meta
            );
        });

        it("should ignore messages not related to a rule", async () => {
            const engine = new FlatESLint({
                overrideConfigFile: true,
                overrideConfig: { rules: { "no-var": "warn" } },
                reportUnusedDisableDirectives: "warn"
            });

            const results = [
                ...await engine.lintText("syntax error"),
                ...await engine.lintText("// eslint-disable-line no-var"),
                ...await engine.lintText("", { filePath: "/.ignored.js", warnIgnored: true })
            ];
            const rulesMeta = engine.getRulesMetaForResults(results);

            assert.deepStrictEqual(rulesMeta, {});
        });

        it("should return a non-empty value if some of the messages are related to a rule", async () => {
            const engine = new FlatESLint({
                overrideConfigFile: true,
                overrideConfig: { rules: { "no-var": "warn" } },
                reportUnusedDisableDirectives: "warn"
            });

            const results = await engine.lintText("// eslint-disable-line no-var\nvar foo;");
            const rulesMeta = engine.getRulesMetaForResults(results);

            assert.deepStrictEqual(rulesMeta, { "no-var": coreRules.get("no-var").meta });
        });
    });

    describe("outputFixes()", () => {
        afterEach(() => {
            sinon.verifyAndRestore();
        });

        it("should call fs.writeFile() for each result with output", async () => {
            const fakeFS = {

Review comment (suggestion):
This is not exactly the intended use of `getRulesMetaForResults`. It should be given a return value of `lintFiles()`/`lintText()`. I think the test would be more representative if we call `getRulesMetaForResults()` three times, once for each call of `lintText()`.

(the same for `eslint.js` tests)

Code after:
                    }
                }
            });

            const results = await engine.lintText("new require('hi')");
            const rulesMeta = engine.getRulesMetaForResults(results);

            assert.strictEqual(rulesMeta.semi, coreRules.get("semi").meta);
            assert.strictEqual(rulesMeta.quotes, coreRules.get("quotes").meta);
            assert.strictEqual(
                rulesMeta["n/no-new-require"],
                nodePlugin.rules["no-new-require"].meta
            );
        });

        it("should ignore messages not related to a rule", async () => {
            const engine = new FlatESLint({
                overrideConfigFile: true,
                ignorePatterns: "ignored.js",
                overrideConfig: {
                    rules: {
                        "no-var": "warn"
                    }
                },
                reportUnusedDisableDirectives: "warn"
            });

            {
                const results = await engine.lintText("syntax error");
                const rulesMeta = engine.getRulesMetaForResults(results);

                assert.deepStrictEqual(rulesMeta, {});
            }
            {
                const results = await engine.lintText("// eslint-disable-line no-var");
                const rulesMeta = engine.getRulesMetaForResults(results);

                assert.deepStrictEqual(rulesMeta, {});
            }
            {
                const results = await engine.lintText("", { filePath: "ignored.js", warnIgnored: true });
                const rulesMeta = engine.getRulesMetaForResults(results);

                assert.deepStrictEqual(rulesMeta, {});
            }
        });

        it("should return a non-empty value if some of the messages are related to a rule", async () => {
            const engine = new FlatESLint({
                overrideConfigFile: true,
                overrideConfig: { rules: { "no-var": "warn" } },