Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> # Conflicts: # tests/format/js/deferred-import-evaluation/__snapshots__/format.test.js.snap
39 lines
917 B
JavaScript
39 lines
917 B
JavaScript
import { shouldDisable } from "./failed-format-tests.js";
|
|
import { isErrorTest, isLanguage } from "./utilities.js";
|
|
|
|
function getParsers(dirname, parsers) {
|
|
const allParsers = [...parsers];
|
|
const addParsers = isErrorTest(dirname)
|
|
? () => {}
|
|
: (...parsers) => {
|
|
for (const parser of parsers) {
|
|
if (!allParsers.includes(parser) && !shouldDisable(dirname, parser)) {
|
|
allParsers.push(parser);
|
|
}
|
|
}
|
|
};
|
|
|
|
if (
|
|
parsers.includes("babel") &&
|
|
(isLanguage(dirname, "js") || isLanguage(dirname, "jsx"))
|
|
) {
|
|
addParsers("acorn", "espree", "meriyah", "oxc", "yuku");
|
|
}
|
|
|
|
if (parsers.includes("typescript")) {
|
|
addParsers("babel-ts", "oxc-ts", "yuku-ts");
|
|
}
|
|
|
|
if (parsers.includes("flow")) {
|
|
addParsers("hermes");
|
|
}
|
|
|
|
if (parsers.includes("babel")) {
|
|
addParsers("__babel_estree");
|
|
}
|
|
|
|
return allParsers;
|
|
}
|
|
|
|
export { getParsers };
|