-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔥 Remove redundant import and export
- Loading branch information
kghugo
committed
Aug 4, 2020
1 parent
8444cd4
commit 1289fdd
Showing
2 changed files
with
14 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,51 @@ | ||
const { | ||
options | ||
} = require('../index.js') | ||
|
||
const chalk = require('chalk'); | ||
const chalk = require('chalk') | ||
|
||
const hasWrappedInRFS = (decl) => /^rfs/g.test(decl.value) | ||
|
||
const isIncluded = (decl, inclusionRules) => { | ||
if (inclusionRules.includes('*')) { | ||
return true; | ||
return true | ||
} | ||
|
||
return inclusionRules.some(unit => RegExp(unit).test(decl)); | ||
return inclusionRules.some(unit => RegExp(unit).test(decl)) | ||
} | ||
|
||
const log = (msg, msgType) => { | ||
switch (msgType) { | ||
case 'success': | ||
console.log(chalk.green(msg)) | ||
break; | ||
break | ||
|
||
case 'error': | ||
console.log(chalk.red(msg)) | ||
break; | ||
break | ||
default: | ||
|
||
} | ||
} | ||
|
||
const shouldBeTransformed = (decl, options) => { | ||
|
||
if (hasWrappedInRFS(decl)) { | ||
return false | ||
} | ||
|
||
const inclusionRules = [ options.includedRules, options.includedSelectors, options.includedUnits] | ||
const exclusionRules = [ options.excludedRules, options.excludedSelectors, options.excludedUnits] | ||
const inclusionRules = [options.includedRules, options.includedSelectors, options.includedUnits] | ||
const exclusionRules = [options.excludedRules, options.excludedSelectors, options.excludedUnits] | ||
const validationValues = [decl.prop, decl.parent.selector, decl.value] | ||
|
||
for(const [index, value] of validationValues.entries() ){ | ||
if(! isIncluded(value, inclusionRules[index]) || isIncluded(value, exclusionRules[index]) ){ | ||
for (const [index, value] of validationValues.entries()) { | ||
if (!isIncluded(value, inclusionRules[index]) || isIncluded(value, exclusionRules[index])) { | ||
log(`${decl.parent.selector}{ ${decl.prop}: ${decl.value} } has been excluded`, 'error') | ||
return false | ||
} | ||
} | ||
|
||
log(`${decl.parent.selector}{ ${decl.prop}: ${decl.value} } has been wrapped with rfs()`, 'success') | ||
|
||
return true | ||
} | ||
|
||
module.exports = { | ||
hasWrappedInRFS, | ||
isIncluded, | ||
filterIdenticalValues, | ||
shouldBeTransformed | ||
} |