From 89109a8f19e0dd6922d344481537fdfaf2cbe57b Mon Sep 17 00:00:00 2001 From: Cyril Mizzi Date: Mon, 26 Feb 2018 18:05:19 +0100 Subject: [PATCH] fixes style code --- __tests__/purgecssDefault.test.js | 13 ++++++------- src/index.js | 14 +++++++------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/__tests__/purgecssDefault.test.js b/__tests__/purgecssDefault.test.js index 09cd8110..a7b4efcd 100644 --- a/__tests__/purgecssDefault.test.js +++ b/__tests__/purgecssDefault.test.js @@ -357,23 +357,22 @@ describe('purge methods with raw content and default extractor with whitelisted .double-class {color: black;}` } ], - whitelistPatterns : [ + whitelistPatterns: [ { - pattern : /^double-class$/, - keepChildren : true - }, + pattern: /^double-class$/, + keepChildren: true + } ] }).purge()[0].css }) - it ('keeps double-class children', () => { + it('keeps double-class children', () => { expect(purgecssResult.includes('.double-class test')).toBe(true) expect(purgecssResult.includes('.double-class.red')).toBe(true) expect(purgecssResult.includes('.double-class > .first-class')).toBe(true) }) - it ('removes double-class--black class because of $', () => { + it('removes double-class--black class because of $', () => { expect(purgecssResult.includes('.double-class--black')).toBe(false) }) }) - diff --git a/src/index.js b/src/index.js index 03dfe087..6c380593 100644 --- a/src/index.js +++ b/src/index.js @@ -446,24 +446,24 @@ class Purgecss { getWhitelistedSelector(selector: string): Object { if (this.options.whitelist) { for (const item of this.options.whitelist) { - const isString = (typeof item === 'string') - const pattern = (isString) ? item : item.pattern + const isString = typeof item === 'string' + const pattern = isString ? item : item.pattern // Assert the pattern match the given selector if (pattern === selector) { - return (isString) ? { pattern : pattern } : item + return isString ? { pattern: pattern } : item } } } if (this.options.whitelistPatterns) { for (const item of this.options.whitelistPatterns) { - const isRegExp = (item instanceof RegExp) - const pattern = (isRegExp) ? item : item.pattern + const isRegExp = item instanceof RegExp + const pattern = isRegExp ? item : item.pattern // Assert the pattern match the given selector if (pattern.test(selector)) { - return (isRegExp) ? { pattern : pattern } : item + return isRegExp ? { pattern: pattern } : item } } } @@ -478,7 +478,7 @@ class Purgecss { */ hasSelectorKeepChildren(selector: string): Object { const whitelist = this.getWhitelistedSelector(selector) - return (whitelist.hasOwnProperty('keepChildren')) ? whitelist.keepChildren : false + return whitelist.hasOwnProperty('keepChildren') ? whitelist.keepChildren : false } }