diff options
author | XhmikosR <xhmikosr@gmail.com> | 2022-03-25 17:36:56 +0300 |
---|---|---|
committer | XhmikosR <xhmikosr@gmail.com> | 2022-03-25 17:36:56 +0300 |
commit | 0d0f98d57184072680e8c6ec6510d33891b1da3a (patch) | |
tree | 45a97610a441e2f9c92a22a712ffa65761692a8d | |
parent | 82bf74aaaa51c0ae3c080f6976de1e7a20e9cb44 (diff) |
lib/rfs.js: throw a TypeError if options are invalid
-rw-r--r-- | lib/rfs.js | 10 |
1 files changed, 3 insertions, 7 deletions
@@ -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`.'); } } |