Skip to content

Commit eb24d50

Browse files
committed
Fix style
1 parent e7b831f commit eb24d50

File tree

4 files changed

+33
-34
lines changed

4 files changed

+33
-34
lines changed

.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"extends": ["eslint-config-postcss", "prettier"],
1010
"plugins": ["prettier"],
1111
"rules": {
12+
"no-unused-vars": [2, {"args": "all", "argsIgnorePattern": "^_"}],
1213
"prettier/prettier": [
1314
"error",
1415
{

__tests__/resolveConfig.test.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,8 +1249,8 @@ test('more than two config objects can be resolved', () => {
12491249
customBackgroundOne: '#bada55',
12501250
},
12511251
textDecorationColor: {
1252-
orange: 'orange'
1253-
}
1252+
orange: 'orange',
1253+
},
12541254
},
12551255
},
12561256
}
@@ -1270,7 +1270,7 @@ test('more than two config objects can be resolved', () => {
12701270
backgroundColor: {
12711271
customBackgroundTwo: '#facade',
12721272
},
1273-
textDecorationColor: theme => theme('colors')
1273+
textDecorationColor: theme => theme('colors'),
12741274
},
12751275
},
12761276
}
@@ -1292,7 +1292,7 @@ test('more than two config objects can be resolved', () => {
12921292
}),
12931293
textDecorationColor: {
12941294
lime: 'lime',
1295-
}
1295+
},
12961296
},
12971297
},
12981298
}
@@ -1316,12 +1316,7 @@ test('more than two config objects can be resolved', () => {
13161316
},
13171317
}
13181318

1319-
const result = resolveConfig([
1320-
firstConfig,
1321-
secondConfig,
1322-
thirdConfig,
1323-
defaultConfig
1324-
])
1319+
const result = resolveConfig([firstConfig, secondConfig, thirdConfig, defaultConfig])
13251320

13261321
expect(result).toEqual({
13271322
prefix: '-',
@@ -1363,4 +1358,4 @@ test('more than two config objects can be resolved', () => {
13631358
backgroundColor: ['responsive', 'hover', 'focus'],
13641359
},
13651360
})
1366-
})
1361+
})

src/lib/substituteTailwindAtRules.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function updateSource(nodes, source) {
88
}
99

1010
export default function(
11-
config,
11+
_config,
1212
{ base: pluginBase, components: pluginComponents, utilities: pluginUtilities }
1313
) {
1414
return function(css) {

src/util/resolveConfig.js

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import some from 'lodash/some'
22
import mergeWith from 'lodash/mergeWith'
3-
import assignWith from 'lodash/assignWith'
43
import isFunction from 'lodash/isFunction'
54
import isUndefined from 'lodash/isUndefined'
65
import defaults from 'lodash/defaults'
76
import map from 'lodash/map'
8-
import reduce from 'lodash/reduce'
7+
import get from 'lodash/get'
98
import toPath from 'lodash/toPath'
109
import negateValue from './negateValue'
1110

@@ -28,29 +27,30 @@ function value(valueToResolve, ...args) {
2827
}
2928

3029
function mergeThemes(themes) {
31-
const theme = (({ extend, ...t }) => t)(themes.reduce((merged, t) => {
32-
return defaults(merged, t)
33-
}, {}))
30+
const theme = (({ extend: _, ...t }) => t)(
31+
themes.reduce((merged, t) => {
32+
return defaults(merged, t)
33+
}, {})
34+
)
3435

35-
// In order to resolve n config objects, we combine all of their `extend` properties
36-
// into arrays instead of objects so they aren't overridden.
37-
const extend = themes.reduce((merged, { extend }) => {
38-
return mergeWith(merged, extend, (mergedValue, extendValue) => {
39-
if (isUndefined(mergedValue)) {
40-
return [extendValue]
41-
}
36+
return {
37+
...theme,
4238

43-
if (Array.isArray(mergedValue)) {
44-
return [...mergedValue, extendValue]
45-
}
39+
// In order to resolve n config objects, we combine all of their `extend` properties
40+
// into arrays instead of objects so they aren't overridden.
41+
extend: themes.reduce((merged, { extend }) => {
42+
return mergeWith(merged, extend, (mergedValue, extendValue) => {
43+
if (isUndefined(mergedValue)) {
44+
return [extendValue]
45+
}
4646

47-
return [mergedValue, extendValue]
48-
})
49-
}, {})
47+
if (Array.isArray(mergedValue)) {
48+
return [...mergedValue, extendValue]
49+
}
5050

51-
return {
52-
...theme,
53-
extend,
51+
return [mergedValue, extendValue]
52+
})
53+
}, {}),
5454
}
5555
}
5656

@@ -97,7 +97,10 @@ function resolveFunctionKeys(object) {
9797
export default function resolveConfig(configs) {
9898
return defaults(
9999
{
100-
theme: resolveFunctionKeys(mergeExtensions(mergeThemes(map(configs, 'theme')))),
100+
// Need to get a default empty object if the config has no theme
101+
theme: resolveFunctionKeys(
102+
mergeExtensions(mergeThemes(map(configs, t => get(t, 'theme', {}))))
103+
),
101104
variants: (firstVariants => {
102105
return Array.isArray(firstVariants)
103106
? firstVariants

0 commit comments

Comments
 (0)