Comparing version 0.6.8 to 0.6.9
@@ -50,14 +50,23 @@ // src/check.ts | ||
} from "@babel/parser"; | ||
function hasPlugin(plugins, plugin) { | ||
return plugins.some((p) => (Array.isArray(p) ? p[0] : p) === plugin); | ||
} | ||
function getParserOptions(lang, options = {}) { | ||
const plugins = [...options.plugins || []]; | ||
if (isTs(lang)) { | ||
plugins.push( | ||
lang === "dts" ? ["typescript", { dts: true }] : "typescript", | ||
["importAttributes", { deprecatedAssertSyntax: true }] | ||
); | ||
if (REGEX_LANG_JSX.test(lang)) | ||
if (!hasPlugin(plugins, "typescript")) { | ||
plugins.push( | ||
lang === "dts" ? ["typescript", { dts: true }] : "typescript" | ||
); | ||
} | ||
if (!hasPlugin(plugins, "decorators") && !hasPlugin(plugins, "decorators-legacy")) { | ||
plugins.push("decorators-legacy"); | ||
} | ||
if (!hasPlugin(plugins, "importAttributes") && !hasPlugin(plugins, "importAssertions")) { | ||
plugins.push(["importAttributes", { deprecatedAssertSyntax: true }]); | ||
} | ||
if (REGEX_LANG_JSX.test(lang) && !hasPlugin(plugins, "jsx")) { | ||
plugins.push("jsx"); | ||
if (!plugins.includes("decorators")) | ||
plugins.push("decorators-legacy"); | ||
} else { | ||
} | ||
} else if (!hasPlugin(plugins, "jsx")) { | ||
plugins.push("jsx"); | ||
@@ -64,0 +73,0 @@ } |
@@ -50,14 +50,23 @@ // src/check.ts | ||
} from "@babel/parser"; | ||
function hasPlugin(plugins, plugin) { | ||
return plugins.some((p) => (Array.isArray(p) ? p[0] : p) === plugin); | ||
} | ||
function getParserOptions(lang, options = {}) { | ||
const plugins = [...options.plugins || []]; | ||
if (isTs(lang)) { | ||
plugins.push( | ||
lang === "dts" ? ["typescript", { dts: true }] : "typescript", | ||
["importAttributes", { deprecatedAssertSyntax: true }] | ||
); | ||
if (REGEX_LANG_JSX.test(lang)) | ||
if (!hasPlugin(plugins, "typescript")) { | ||
plugins.push( | ||
lang === "dts" ? ["typescript", { dts: true }] : "typescript" | ||
); | ||
} | ||
if (!hasPlugin(plugins, "decorators") && !hasPlugin(plugins, "decorators-legacy")) { | ||
plugins.push("decorators-legacy"); | ||
} | ||
if (!hasPlugin(plugins, "importAttributes") && !hasPlugin(plugins, "importAssertions")) { | ||
plugins.push(["importAttributes", { deprecatedAssertSyntax: true }]); | ||
} | ||
if (REGEX_LANG_JSX.test(lang) && !hasPlugin(plugins, "jsx")) { | ||
plugins.push("jsx"); | ||
if (!plugins.includes("decorators")) | ||
plugins.push("decorators-legacy"); | ||
} else { | ||
} | ||
} else if (!hasPlugin(plugins, "jsx")) { | ||
plugins.push("jsx"); | ||
@@ -64,0 +73,0 @@ } |
{ | ||
"name": "ast-kit", | ||
"version": "0.6.8", | ||
"version": "0.6.9", | ||
"packageManager": "pnpm@8.6.0", | ||
@@ -5,0 +5,0 @@ "description": "AST Toolkit.", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57707
1600