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>2022-03-25 17:36:56 +0300
committerXhmikosR <xhmikosr@gmail.com>2022-03-25 17:36:56 +0300
commit0d0f98d57184072680e8c6ec6510d33891b1da3a (patch)
tree45a97610a441e2f9c92a22a712ffa65761692a8d
parent82bf74aaaa51c0ae3c080f6976de1e7a20e9cb44 (diff)
lib/rfs.js: throw a TypeError if options are invalid
-rw-r--r--lib/rfs.js10
1 files changed, 3 insertions, 7 deletions
diff --git a/lib/rfs.js b/lib/rfs.js
index a3e6d36..f76a835 100644
--- a/lib/rfs.js
+++ b/lib/rfs.js
@@ -3,10 +3,6 @@
const postcss = require('postcss');
const valueParser = require('postcss-value-parser');
-const BREAKPOINT_ERROR = 'breakpoint option is invalid, it should be set in `px`, `rem` or `em`.';
-const BREAKPOINT_UNIT_ERROR = 'breakpointUnit option is invalid, it should be `px`, `rem` or `em`.';
-const BASE_RFS_ERROR = 'baseValue option is invalid, it should be set in `px` or `rem`.';
-
const defaultOptions = {
baseValue: 20,
unit: 'rem',
@@ -31,7 +27,7 @@ module.exports = class {
} else if (this.opts.baseValue.endsWith('rem')) {
this.opts.baseValue = Number.parseFloat(this.opts.baseValue) * this.opts.remValue;
} else {
- console.error(BASE_RFS_ERROR);
+ throw new TypeError('`baseValue` option is invalid, it should be set in `px` or `rem`.');
}
}
@@ -41,12 +37,12 @@ module.exports = class {
} else if (this.opts.breakpoint.endsWith('em')) {
this.opts.breakpoint = Number.parseFloat(this.opts.breakpoint) * this.opts.remValue;
} else {
- console.error(BREAKPOINT_ERROR);
+ throw new TypeError('`breakpoint` option is invalid, it should be set in `px`, `rem` or `em`.');
}
}
if (!['px', 'rem', 'em'].includes(this.opts.breakpointUnit)) {
- console.error(BREAKPOINT_UNIT_ERROR);
+ throw new TypeError('`breakpointUnit` option is invalid, it should be `px`, `rem` or `em`.');
}
}