diff options
-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`.'); } } |