Fix some unicorn/prefer-else-if violations (#19394)

This commit is contained in:
fisker Cheung authored and GitHub committed 2026-06-17 07:31:04 +08:00
1 parent e41cbf4594
commit bfe8858f5e
7 files changed
+8 -15

No files matched your search

+1
View File
@@ -330,6 +330,7 @@ const configs = [
"unicorn/prefer-global-number-constants": "off",
"unicorn/prefer-global-this": "off",
"unicorn/prefer-https": "off",
// TODO: Enable
"unicorn/prefer-else-if": "off",
"unicorn/prefer-includes-over-repeated-comparisons": "off",
"unicorn/prefer-minimal-ternary": "off",
+1 -3
View File
@@ -17,9 +17,7 @@ for (let i = 0; i < groupCount; i++) {
for (let i = 0; i < groupSize; i++) {
await format(sourceText, { parser: "typescript" });
}
}
if (method === "parallel") {
} else if (method === "parallel") {
await Promise.allSettled(
Array.from({ length: groupSize }, () =>
format(sourceText, { parser: "typescript" }),
+1 -3
View File
@@ -45,9 +45,7 @@ async function buildPlaygroundFiles(version) {
url.pathToFileURL(path.join(packagesDirectory, "prettier/standalone.mjs"))
);
versionData.version = prettierVersion;
}
if (version === "next") {
} else if (version === "next") {
packagesDirectory = DIST_DIR;
versionData.gitTree = await getGitTreeInformation();
if (IS_PULL_REQUEST) {
+1 -1
View File
@@ -166,7 +166,7 @@ function getEsbuildOptions({ packageConfig, file, cliOptions, buildOptions }) {
// Current version of `yaml` is not tree-shakable,
// but when we update it, we may reduce size,
// since the UMD version don't need expose `__parsePrettierYamlConfig`
if (buildOptions.format === "umd" && file.output === "plugins/yaml.js") {
else if (buildOptions.format === "umd" && file.output === "plugins/yaml.js") {
replaceModule.push({
module: path.join(sourceDirectory, file.input),
text: 'export * from "../language-yaml/index.js";',
+2 -4
View File
@@ -482,8 +482,7 @@ function replaceQuotesInInlineComments(text) {
case "url":
if (c === ")") {
state = "initial";
}
if (c === "\n" || c === "\r") {
} else if (c === "\n" || c === "\r") {
return text; // invalid input
}
if (c === "'") {
@@ -507,8 +506,7 @@ function replaceQuotesInInlineComments(text) {
case "comment-inline":
if (c === '"' || c === "'" || c === "*") {
inlineCommentContainsQuotes = true;
}
if (c === "\n" || c === "\r") {
} else if (c === "\n" || c === "\r") {
if (inlineCommentContainsQuotes) {
inlineCommentsToReplace.push([inlineCommentStartIndex, i]);
}
@@ -16,9 +16,7 @@ function cleanChainExpression(original, cloned) {
// We don't add parentheses to `(a?.b)?.c`
if (original.type === "ChainExpression") {
cleanEstreeChainExpression(cloned);
}
if (
} else if (
original.type === "OptionalMemberExpression" ||
original.type === "OptionalCallExpression"
) {
+1 -1
View File
@@ -34,7 +34,7 @@ function massageAstNode(original, cloned /* , parent */) {
}
// TODO: Fix this
if (original.chomping === "clip" || original.chomping === "strip") {
else if (original.chomping === "clip" || original.chomping === "strip") {
cloned.value = original.value.trimEnd();
}
break;