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-01-29 20:27:28 +08:00
|
|
|
[
|
|
|
|
|
"js/ignore/semi/class-expression-decorator.js",
|
|
|
|
|
(options) => options.semi === false,
|
|
|
|
|
],
|
|
|
|
|
["js/ignore/semi/head-ignored.js", (options) => options.semi === false],
|
2026-01-25 10:30:19 +08:00
|
|
|
"js/comments/return-statement.js",
|
|
|
|
|
"js/comments/tagged-template-literal.js",
|
|
|
|
|
[
|
|
|
|
|
"js/multiparser-markdown/codeblock.js",
|
|
|
|
|
(options) => options.proseWrap === "always",
|
|
|
|
|
],
|
|
|
|
|
"flow/hook/declare-hook.js",
|
|
|
|
|
"flow/hook/hook-type-annotation.js",
|
|
|
|
|
"typescript/prettier-ignore/mapped-types.ts",
|
|
|
|
|
"typescript/prettier-ignore/issue-14238.ts",
|
2026-01-31 01:26:45 +08:00
|
|
|
"js/for-of/comments.js",
|
2026-01-25 10:30:19 +08:00
|
|
|
"js/sequence-expression/parenthesized.js",
|
|
|
|
|
"typescript/satisfies-operators/comments-unstable.ts",
|
|
|
|
|
"jsx/comments/in-attributes.js",
|
|
|
|
|
"typescript/import-type/long-module-name/long-module-name4.ts",
|
|
|
|
|
// Unstable due to lack of indent information
|
|
|
|
|
"js/multiparser-comments/comment-inside.js",
|
|
|
|
|
[
|
|
|
|
|
"typescript/method-chain/object/issue-17239.ts",
|
|
|
|
|
(options) => options.objectWrap !== "collapse",
|
|
|
|
|
],
|
|
|
|
|
"typescript/call/callee-comments.ts",
|
|
|
|
|
"js/arrows/arrow-chain-with-trailing-comments.js",
|
|
|
|
|
"typescript/as/comments/18160.ts",
|
|
|
|
|
].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({
|
|
|
|
|
espree: [
|
|
|
|
|
...commentClosureTypecaseTests,
|
|
|
|
|
"js/explicit-resource-management/valid-await-using-asi-assignment.js",
|
|
|
|
|
],
|
|
|
|
|
acorn: [
|
|
|
|
|
"js/explicit-resource-management/valid-await-using-asi-assignment.js",
|
|
|
|
|
],
|
|
|
|
|
meriyah: [
|
|
|
|
|
// Parsing to different ASTs
|
|
|
|
|
"js/decorators/member-expression.js",
|
|
|
|
|
],
|
|
|
|
|
"babel-ts": [
|
|
|
|
|
"typescript/conformance/types/moduleDeclaration/kind-detection.ts",
|
|
|
|
|
// https://github.com/babel/babel/pull/17659
|
|
|
|
|
"typescript/conformance/internalModules/importDeclarations/circularImportAlias.ts",
|
|
|
|
|
"typescript/conformance/internalModules/importDeclarations/exportImportAlias.ts",
|
|
|
|
|
"typescript/conformance/internalModules/importDeclarations/importAliasIdentifiers.ts",
|
|
|
|
|
"typescript/conformance/internalModules/importDeclarations/shadowedInternalModule.ts",
|
|
|
|
|
"typescript/conformance/types/moduleDeclaration/moduleDeclaration.ts",
|
|
|
|
|
"typescript/conformance/types/ambient/ambientDeclarations.ts",
|
|
|
|
|
"typescript/compiler/declareDottedModuleName.ts",
|
|
|
|
|
"typescript/compiler/privacyGloImport.ts",
|
|
|
|
|
"typescript/declare/declare_module.ts",
|
|
|
|
|
"typescript/const/initializer-ambient-context.ts",
|
|
|
|
|
"typescript/keywords/keywords.ts",
|
|
|
|
|
"typescript/keywords/module.ts",
|
|
|
|
|
"typescript/module/global.ts",
|
|
|
|
|
"typescript/module/keyword.ts",
|
|
|
|
|
"typescript/module/module_nested.ts",
|
|
|
|
|
"typescript/custom/stability/moduleBlock.ts",
|
|
|
|
|
"typescript/interface2/module.ts",
|
|
|
|
|
"typescript/typescript-only/",
|
|
|
|
|
],
|
|
|
|
|
oxc: [],
|
|
|
|
|
"oxc-ts": ["typescript/typescript-only/"],
|
|
|
|
|
hermes: [
|
|
|
|
|
...commentClosureTypecaseTests,
|
|
|
|
|
|
|
|
|
|
// Not supported
|
|
|
|
|
"flow/comments/",
|
2026-01-25 11:23:53 +08:00
|
|
|
"flow/flow-repo/union_new/",
|
2026-01-25 10:30:19 +08:00
|
|
|
|
|
|
|
|
// Different result
|
|
|
|
|
"flow/hook/comments-before-arrow.js",
|
|
|
|
|
],
|
|
|
|
|
flow: [
|
|
|
|
|
// Parsing to different ASTs
|
|
|
|
|
"js/decorators/member-expression.js",
|
|
|
|
|
],
|
|
|
|
|
typescript: [
|
|
|
|
|
// https://github.com/typescript-eslint/typescript-eslint/issues/11389
|
|
|
|
|
"js/import/long-module-name/import-defer.js",
|
|
|
|
|
"js/import/long-module-name/import-source.js",
|
|
|
|
|
],
|
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 };
|