mirror of
https://github.com/hanzoai/babel.git
synced 2026-10-30 14:46:06 +00:00
* Attempt to fix #17331 * Split maybeParse * Apparently the async version of createConfigItem doesn't exist? * Add to mini-babel-core, and rename maybeParse to maybeParseSync and asyncMaybeParse to maybeParse * Use createConfigItemAsync * Hope this is sufficient for a test * Don't need an import * ope * review --------- Co-authored-by: Babel Bot <[email protected]>
63 lines
1.8 KiB
JavaScript
63 lines
1.8 KiB
JavaScript
import { ESLint } from "eslint";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
describe("Babel config files", () => {
|
|
it("works with babel.config.mjs - ESLint " + ESLint.version, async () => {
|
|
if (parseInt(ESLint.version, 10) >= 9) {
|
|
const engine = new ESLint({
|
|
ignore: false,
|
|
overrideConfigFile: fileURLToPath(
|
|
new URL(
|
|
"../fixtures/mjs-config-file/eslint.config.js",
|
|
import.meta.url,
|
|
),
|
|
),
|
|
});
|
|
// eslint-disable-next-line jest/no-conditional-expect
|
|
expect(
|
|
await engine.lintFiles([
|
|
fileURLToPath(
|
|
new URL("../fixtures/mjs-config-file/a.js", import.meta.url),
|
|
),
|
|
]),
|
|
).toMatchObject([{ errorCount: 0, messages: [] }]);
|
|
} else {
|
|
const engine = new ESLint({
|
|
ignore: false,
|
|
});
|
|
// eslint-disable-next-line jest/no-conditional-expect
|
|
expect(
|
|
await engine.lintFiles([
|
|
fileURLToPath(
|
|
new URL(
|
|
"../fixtures/mjs-config-file-eslint-8/a.js",
|
|
import.meta.url,
|
|
),
|
|
),
|
|
]),
|
|
).toMatchObject([{ errorCount: 0, messages: [] }]);
|
|
}
|
|
});
|
|
|
|
it("works with async-requiring ESM plugins", async () => {
|
|
const engine = new ESLint({
|
|
ignore: false,
|
|
overrideConfigFile: fileURLToPath(
|
|
new URL(
|
|
parseInt(ESLint.version, 10) >= 9
|
|
? "../fixtures/mjs-babel-plugin/eslint.config.js"
|
|
: "../fixtures/mjs-babel-plugin-eslint-8/.eslintrc.js",
|
|
import.meta.url,
|
|
),
|
|
),
|
|
});
|
|
expect(
|
|
await engine.lintFiles([
|
|
fileURLToPath(
|
|
new URL("../fixtures/mjs-babel-plugin/a.js", import.meta.url),
|
|
),
|
|
]),
|
|
).toMatchObject([{ errorCount: 0, messages: [] }]);
|
|
});
|
|
});
|