@@ -26,18 +26,19 @@ const typeToString = s =>
2626 . toLowerCase ( ) ;
2727
2828const types = [
29- "String" ,
30- "Array" ,
31- "Undefined" ,
32- "Boolean" ,
33- "Number" ,
34- "Function" ,
35- "Symbol" ,
36- "Object"
29+ 'String' ,
30+ 'Array' ,
31+ 'Undefined' ,
32+ 'Boolean' ,
33+ 'Number' ,
34+ 'Function' ,
35+ 'Symbol' ,
36+ 'Object' ,
37+ 'RegExp'
3738] ;
3839
3940const type = types . reduce ( ( acc , str ) => {
40- acc [ "is" + str ] = val => typeToString ( val ) === str . toLowerCase ( ) ;
41+ acc [ 'is' + str ] = val => typeToString ( val ) === str . toLowerCase ( ) ;
4142 return acc ;
4243} , { } ) ;
4344
@@ -75,7 +76,8 @@ function createUnitRegex(customUnitList, unitList) {
7576 if ( unitList . length === 0 ) {
7677 // Empty unitList means no units should be processed
7778 filteredUnits = [ ] ;
78- } else {
79+ }
80+ else {
7981 const satisfyUnitList = createUnitListMatcher ( unitList ) ;
8082 filteredUnits = filteredUnits . filter ( unit => satisfyUnitList ( unit ) ) ;
8183 }
@@ -135,12 +137,12 @@ function toFixed(number, precision) {
135137}
136138
137139function blacklistedSelector ( blacklist , selector ) {
138- if ( typeof selector !== " string" ) {
140+ if ( typeof selector !== ' string' ) {
139141 return ;
140142 }
141143
142144 return blacklist . some ( regex => {
143- if ( typeof regex === " string" ) {
145+ if ( typeof regex === ' string' ) {
144146 return selector . indexOf ( regex ) !== - 1 ;
145147 }
146148
@@ -149,7 +151,7 @@ function blacklistedSelector(blacklist, selector) {
149151}
150152
151153function createPropListMatcher ( propList ) {
152- const hasWild = propList . indexOf ( "*" ) > - 1 ;
154+ const hasWild = propList . indexOf ( '*' ) > - 1 ;
153155 const matchAll = hasWild && propList . length === 1 ;
154156 const lists = {
155157 exact : filterPropList . exact ( propList ) ,
@@ -196,7 +198,7 @@ function createPropListMatcher(propList) {
196198}
197199
198200function createUnitListMatcher ( unitList ) {
199- const hasWild = unitList . indexOf ( "*" ) > - 1 ;
201+ const hasWild = unitList . indexOf ( '*' ) > - 1 ;
200202 const matchAll = hasWild && unitList . length === 1 ;
201203 const lists = {
202204 exact : filterPropList . exact ( unitList ) ,
@@ -254,7 +256,7 @@ module.exports = (options = {}) => {
254256 const unitRegex = createUnitRegex ( customUnitList , unitList ) ;
255257
256258 return {
257- postcssPlugin : " postcss-unit-processor" ,
259+ postcssPlugin : ' postcss-unit-processor' ,
258260
259261 Once ( css ) {
260262 const filePath = css . source . input . file ;
@@ -263,11 +265,12 @@ module.exports = (options = {}) => {
263265 exclude &&
264266 filePath &&
265267 ( ( type . isFunction ( exclude ) && exclude ( filePath ) ) ||
266- ( type . isString ( exclude ) && filePath . indexOf ( exclude ) !== - 1 ) ||
267- filePath . match ( exclude ) !== null )
268+ ( type . isString ( exclude ) && filePath . indexOf ( exclude ) !== - 1 ) ||
269+ ( type . isRegExp ( exclude ) && filePath . match ( exclude ) !== null ) )
268270 ) {
269271 isExcludeFile = true ;
270- } else {
272+ }
273+ else {
271274 isExcludeFile = false ;
272275 }
273276
@@ -312,7 +315,7 @@ module.exports = (options = {}) => {
312315
313316 unitRegex . lastIndex = 0 ;
314317
315- if ( opts . mediaQuery && atRule . name === " media" ) {
318+ if ( opts . mediaQuery && atRule . name === ' media' ) {
316319 if ( atRule . __unitProcessorFinished === true || ! unitRegex . test ( atRule . params ) ) {
317320 return ;
318321 }
0 commit comments