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

Code before:
                    const legacyProcessor = defineProcessor(${/<script lang="(\w*)">\n([\s\S]+?)\n<\/script>/gu}, true);
                    exports.processors = {
                        "html": { ...processor, supportsAutofix: true },
                        "non-fixable": processor,
                        "legacy": legacyProcessor
                    };
                `,
                "test.md": unIndent`
                    \`\`\`js
                    console.log("hello")
                    \`\`\`
                    \`\`\`html
                    <div>Hello</div>
                    <script lang="js">
                        console.log("hello")
                    </script>
                    <script lang="ts">
                        console.log("hello")
                    </script>
                    \`\`\`
                `
            };

            // unique directory for each test to avoid quirky disk-cleanup errors
            let id;

            beforeEach(() => (id = Date.now().toString()));

            /*
             * `fs.rmdir(path, { recursive: true })` is deprecated and will be removed.
             * Use `fs.rm(path, { recursive: true })` instead.
             * When supporting Node.js 14.14.0+, the compatibility condition can be removed for `fs.rmdir`.
             */
            if (typeof fsp.rm === "function") {
                afterEach(async () => fsp.rm(root, { recursive: true, force: true }));
            } else {
                afterEach(async () => fsp.rmdir(root, { recursive: true, force: true }));
            }

            it("should lint only JavaScript blocks.", async () => {
                const teardown = createCustomTeardown({
                    cwd: path.join(root, id),
                    files: {
                        ...commonFiles,
                        "eslint.config.js": `module.exports = [
                            {
                                plugins: {
                                    markdown: require("eslint-plugin-markdown"),
                                    html: require("eslint-plugin-html")
                                }
                            },

Review comment (bug):
Only this test was failing before the code change. The others represent behavior that was valid both before and after the change.

Code after:
                                }
                            },
                            {
                                files: ["**/*.ts"]
                            }
                        ]
                    });
                    const [result] = await eslint.lintText(text, { filePath: "foo.md" });

                    assert.strictEqual(result.messages.length, 4);
                    assert.strictEqual(result.messages[0].ruleId, "no-undef");
                    assert.match(result.messages[0].message, /foo_js/u);
                    assert.strictEqual(result.messages[0].line, 2);
                    assert.strictEqual(result.messages[1].ruleId, "no-undef");
                    assert.match(result.messages[1].message, /foo_ts/u);
                    assert.strictEqual(result.messages[1].line, 6);
                    assert.strictEqual(result.messages[2].ruleId, "no-undef");
                    assert.match(result.messages[2].message, /foo_cjs/u);
                    assert.strictEqual(result.messages[2].line, 10);
                    assert.strictEqual(result.messages[3].ruleId, "no-undef");
                    assert.match(result.messages[3].message, /foo_mjs/u);
                    assert.strictEqual(result.messages[3].line, 14);
                });

                // https://github.com/eslint/eslint/issues/18493
                it("should silently skip virtual files that match only universal patterns", async () => {
                    eslint = new ESLint({
                        overrideConfigFile: true,
                        overrideConfig: [
                            pluginConfig,
                            {
                                files: ["**/*"],
                                rules: {
                                    "no-undef": 2
                                }
                            }
                        ]
                    });
                    const [result] = await eslint.lintText(text, { filePath: "foo.md" });

                    assert.strictEqual(result.messages.length, 3);
                    assert.strictEqual(result.messages[0].ruleId, "no-undef");
                    assert.match(result.messages[0].message, /foo_js/u);
                    assert.strictEqual(result.messages[0].line, 2);
                    assert.strictEqual(result.messages[1].ruleId, "no-undef");
                    assert.match(result.messages[1].message, /foo_cjs/u);
                    assert.strictEqual(result.messages[1].line, 10);
                    assert.strictEqual(result.messages[2].ruleId, "no-undef");
                    assert.match(result.messages[2].message, /foo_mjs/u);
                    assert.strictEqual(result.messages[2].line, 14);
                });