From 3fa5796687b872a7cb0e5cf86d743896e6abfbe2 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Wed, 4 Aug 2021 09:58:12 +0300 Subject: Switch to using for...of (#414) --- lib/rfs.js | 6 ++++-- package.json | 1 - postcss.js | 8 ++++---- test/test.js | 8 ++++---- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/rfs.js b/lib/rfs.js index 7ffb235..850c93f 100644 --- a/lib/rfs.js +++ b/lib/rfs.js @@ -81,7 +81,9 @@ module.exports = class { return; } - node.nodes.filter(node => node.type === 'word').forEach(node => { + const wordNodes = node.nodes.filter(node => node.type === 'word'); + + for (const node of wordNodes) { node.value = node.value.replace(/^(-?\d*\.?\d+)(.*)/g, (match, value, unit) => { value = Number.parseFloat(value); @@ -116,7 +118,7 @@ module.exports = class { return `calc(-${this.toFixed(baseValue, this.opts.unitPrecision)}${this.opts.unit} - ${this.toFixed(diff * 100 / this.opts.breakpoint, this.opts.unitPrecision)}${viewportUnit})`; }); - }); + } // Now we will transform the existing rgba() function node // into a word node with the hex value diff --git a/package.json b/package.json index a356317..477c781 100644 --- a/package.json +++ b/package.json @@ -101,7 +101,6 @@ "after" ], "promise/prefer-await-to-then": "off", - "unicorn/no-array-for-each": "off", "unicorn/prefer-module": "off", "unicorn/prevent-abbreviations": "off" } diff --git a/postcss.js b/postcss.js index 0ef2e7b..9f44ea8 100644 --- a/postcss.js +++ b/postcss.js @@ -123,16 +123,16 @@ module.exports = postcss.plugin('postcss-rfs', opts => { const fluidMediaQuery = mediaQuery.clone(); - mediaQueryRules.forEach(mediaQueryRule => { + for (const mediaQueryRule of mediaQueryRules) { fluidMediaQuery.append(mediaQueryRule); - }); + } parent.insertAfter(rule, fluidMediaQuery); if (extraBlocks.length > 0) { - extraBlocks.forEach(disableBlock => { + for (const disableBlock of extraBlocks) { parent.insertAfter(rule, disableBlock); - }); + } } if (removeRule) { diff --git a/test/test.js b/test/test.js index 419b3fb..2708ab8 100644 --- a/test/test.js +++ b/test/test.js @@ -17,7 +17,7 @@ const styles = [ function doTest(style) { describe(style, () => { - tests.forEach(test => { + for (const test of tests) { it(test.name, done => { const generated = result[style.toLowerCase()](test.id); const expected = result.expected(test.id); @@ -34,10 +34,10 @@ function doTest(style) { done(); } }); - }); + } }); } -styles.forEach(style => { +for (const style of styles) { doTest(style); -}); +} -- cgit v1.2.3