diff --git a/eslint.config.js b/eslint.config.js index 2d4581598..ae21a8c7f 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -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", diff --git a/scripts/benchmark/bench.js b/scripts/benchmark/bench.js index d6869417e..6284c23c0 100644 --- a/scripts/benchmark/bench.js +++ b/scripts/benchmark/bench.js @@ -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" }), diff --git a/scripts/build-website.js b/scripts/build-website.js index d9e33dedd..c4d872684 100644 --- a/scripts/build-website.js +++ b/scripts/build-website.js @@ -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) { diff --git a/scripts/build/builders/javascript-module.js b/scripts/build/builders/javascript-module.js index af45eb45d..4c1b56673 100644 --- a/scripts/build/builders/javascript-module.js +++ b/scripts/build/builders/javascript-module.js @@ -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";', diff --git a/src/language-css/loc.js b/src/language-css/loc.js index 9dddc801e..db73dbede 100644 --- a/src/language-css/loc.js +++ b/src/language-css/loc.js @@ -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]); } diff --git a/src/language-js/massage-ast/chain-expression.js b/src/language-js/massage-ast/chain-expression.js index 7fc99a99a..556a14a74 100644 --- a/src/language-js/massage-ast/chain-expression.js +++ b/src/language-js/massage-ast/chain-expression.js @@ -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" ) { diff --git a/src/language-yaml/massage-ast/index.js b/src/language-yaml/massage-ast/index.js index 1fa1ae0ff..9613aa10b 100644 --- a/src/language-yaml/massage-ast/index.js +++ b/src/language-yaml/massage-ast/index.js @@ -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;