Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/rfs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXhmikosR <xhmikosr@gmail.com>2021-08-04 09:58:12 +0300
committerGitHub <noreply@github.com>2021-08-04 09:58:12 +0300
commit3fa5796687b872a7cb0e5cf86d743896e6abfbe2 (patch)
treed7dd82c9c96dbbbcf6e844fa9e3c43635df112f5
parent31780a461fb1ad0c6e9a43b315eb47e8f801cfcb (diff)
Switch to using for...of (#414)
-rw-r--r--lib/rfs.js6
-rw-r--r--package.json1
-rw-r--r--postcss.js8
-rw-r--r--test/test.js8
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);
-});
+}