2026-01-25 10:30:19 +08:00
|
|
|
import path from "node:path";
|
2026-01-25 20:48:49 +08:00
|
|
|
import { FORMAT_TEST_DIRECTORY } from "./constants.js";
|
2026-01-25 10:30:19 +08:00
|
|
|
|
|
|
|
|
// TODO: these test files need fix
|
|
|
|
|
const unstableTests = new Map(
|
|
|
|
|
[
|
2026-06-03 07:24:36 +08:00
|
|
|
[
|
|
|
|
|
"js/ignore/semi/class-expression-decorator.js",
|
|
|
|
|
(options) => options.semi === false,
|
|
|
|
|
],
|
2026-01-29 20:27:28 +08:00
|
|
|
["js/ignore/semi/head-ignored.js", (options) => options.semi === false],
|
2026-01-25 10:30:19 +08:00
|
|
|
"js/comments/return-statement.js",
|
|
|
|
|
"flow/hook/declare-hook.js",
|
|
|
|
|
"flow/hook/hook-type-annotation.js",
|
2026-06-22 17:44:23 -07:00
|
|
|
"flow/comments/type_annotations.js",
|
2026-01-25 10:30:19 +08:00
|
|
|
"typescript/prettier-ignore/mapped-types.ts",
|
|
|
|
|
"typescript/prettier-ignore/issue-14238.ts",
|
2026-01-31 01:26:45 +08:00
|
|
|
"js/for-of-statement/comments.js",
|
2026-01-25 10:30:19 +08:00
|
|
|
"jsx/comments/in-attributes.js",
|
|
|
|
|
"typescript/import-type/long-module-name/long-module-name4.ts",
|
|
|
|
|
[
|
|
|
|
|
"typescript/method-chain/object/issue-17239.ts",
|
|
|
|
|
(options) => options.objectWrap !== "collapse",
|
|
|
|
|
],
|
|
|
|
|
"typescript/call/callee-comments.ts",
|
|
|
|
|
"typescript/as/comments/18160.ts",
|
2026-06-04 17:16:15 +08:00
|
|
|
"typescript/union/consistent-with-flow/single-type.ts",
|
2026-01-25 10:30:19 +08:00
|
|
|
].map((fixture) => {
|
|
|
|
|
const [file, isUnstable = () => true] = Array.isArray(fixture)
|
|
|
|
|
? fixture
|
|
|
|
|
: [fixture];
|
2026-01-25 20:48:49 +08:00
|
|
|
return [path.join(FORMAT_TEST_DIRECTORY, file), isUnstable];
|
2026-01-25 10:30:19 +08:00
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const unstableAstTests = new Map();
|
|
|
|
|
|
|
|
|
|
// These tests works on `babel`, `acorn`, `espree`, `oxc`, and `meriyah`
|
2026-01-27 22:41:29 +08:00
|
|
|
const commentClosureTypecaseTests = [
|
|
|
|
|
"js/comments-closure-typecast/",
|
|
|
|
|
"js/comments-closure-typecast/no-semi/",
|
|
|
|
|
];
|
2026-01-25 10:30:19 +08:00
|
|
|
|
|
|
|
|
const disabledTests = new Map(
|
|
|
|
|
Object.entries({
|
2026-07-29 22:39:32 +08:00
|
|
|
espree: commentClosureTypecaseTests,
|
|
|
|
|
acorn: [],
|
2026-07-29 22:10:20 +08:00
|
|
|
meriyah: [],
|
2026-07-29 22:39:32 +08:00
|
|
|
"babel-ts": [],
|
2026-01-25 10:30:19 +08:00
|
|
|
oxc: [],
|
2026-07-15 23:14:34 +08:00
|
|
|
"oxc-ts": [],
|
|
|
|
|
yuku: ["js/await-expression/await-with-parens.js"],
|
2026-08-25 02:56:47 +08:00
|
|
|
"yuku-ts": ["js/await-expression/await-with-parens.js"],
|
2026-01-25 10:30:19 +08:00
|
|
|
hermes: [
|
2026-08-15 16:57:54 +08:00
|
|
|
"js/await-expression/like-call.js", // Different result
|
|
|
|
|
"jsx/top-level-await/test.jsx",
|
2026-01-25 10:30:19 +08:00
|
|
|
],
|
|
|
|
|
flow: [
|
2026-07-15 23:14:34 +08:00
|
|
|
"js/decorators/member-expression.js", // Parsing to different ASTs
|
|
|
|
|
"js/await-expression/await-with-parens.js",
|
|
|
|
|
"js/await-expression/like-call.js",
|
2026-08-15 16:57:54 +08:00
|
|
|
"jsx/top-level-await/test.jsx",
|
2026-01-25 10:30:19 +08:00
|
|
|
],
|
2026-09-14 20:48:16 +08:00
|
|
|
"babel-flow": ["js/babel-plugins/flow-comments.js"],
|
2026-08-04 22:42:39 +08:00
|
|
|
typescript: [],
|
2026-06-01 10:18:29 +08:00
|
|
|
yaml: [
|
|
|
|
|
// Bug: https://github.com/eemeli/yaml/issues/646
|
|
|
|
|
"yaml/spec/spec-example-2-11-mapping-between-sequences.yml",
|
|
|
|
|
],
|
2026-01-25 10:30:19 +08:00
|
|
|
}).map(([parser, tests]) => [
|
|
|
|
|
parser,
|
2026-01-25 20:48:49 +08:00
|
|
|
new Set(tests.map((file) => path.join(FORMAT_TEST_DIRECTORY, file))),
|
2026-01-25 10:30:19 +08:00
|
|
|
]),
|
|
|
|
|
);
|
|
|
|
|
|
2026-01-25 20:48:49 +08:00
|
|
|
const isUnstable = (filepath, options) =>
|
|
|
|
|
unstableTests.get(filepath)?.(options);
|
2026-01-25 10:30:19 +08:00
|
|
|
|
2026-01-25 20:48:49 +08:00
|
|
|
const isAstUnstable = (filepath, options) =>
|
|
|
|
|
unstableAstTests.get(filepath)?.(options);
|
2026-01-25 10:30:19 +08:00
|
|
|
|
2026-01-25 20:48:49 +08:00
|
|
|
const shouldDisable = (directoryOrFile, parser) =>
|
|
|
|
|
disabledTests.get(parser)?.has(directoryOrFile);
|
2026-01-25 10:30:19 +08:00
|
|
|
|
|
|
|
|
export { isAstUnstable, isUnstable, shouldDisable };
|