From cf5dec976ae6a1088431c8f630e4031f1f5e32f4 Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Tue, 16 Jun 2026 03:55:19 +0800 Subject: [PATCH] Enable `unicorn/no-duplicate-loops` rule (#19370) --- eslint.config.js | 1 - src/language-js/print/template-literal.js | 8 ++++++-- website/playground/PrettierFormat.js | 8 +++++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 3639ae8ff..1c91c4aa8 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -322,7 +322,6 @@ const configs = [ "unicorn/prefer-unicode-code-point-escapes": "off", "unicorn/no-negated-array-predicate": "off", "unicorn/no-break-in-nested-loop": "off", - "unicorn/no-duplicate-loops": "off", "unicorn/no-declarations-before-early-exit": "off", "unicorn/no-negated-comparison": "off", "unicorn/prefer-early-return": "off", diff --git a/src/language-js/print/template-literal.js b/src/language-js/print/template-literal.js index b63ab19f5..dbb668b1c 100644 --- a/src/language-js/print/template-literal.js +++ b/src/language-js/print/template-literal.js @@ -136,8 +136,12 @@ function printJestEachTemplateLiteral(path, options, print) { { cells: headerNames }, ...tableBody.filter((row) => row.cells.length > 0), ]; - for (const { cells } of table.filter((row) => !row.hasLineBreak)) { - for (const [index, cell] of cells.entries()) { + for (const row of table) { + if (row.hasLineBreak) { + continue; + } + + for (const [index, cell] of row.cells.entries()) { maxColumnWidths[index] = Math.max( maxColumnWidths[index], getStringWidth(cell), diff --git a/website/playground/PrettierFormat.js b/website/playground/PrettierFormat.js index 21bc77b68..1275436ad 100644 --- a/website/playground/PrettierFormat.js +++ b/website/playground/PrettierFormat.js @@ -30,9 +30,11 @@ function setup(props, { slots }) { // Should not trigger format when these changes const ignoredKeys = new Set(["showSidebar", "showInput"]); - for (const key of Object.keys(settings).filter( - (key) => !ignoredKeys.has(key), - )) { + for (const key of Object.keys(settings)) { + if (ignoredKeys.has(key)) { + continue; + } + watch( () => settings[key], (newValue, oldValue) => {