diff --git a/.eslintrc b/.eslintrc index 238612fbd..10b89fb05 100644 --- a/.eslintrc +++ b/.eslintrc @@ -9,6 +9,7 @@ "extends": ["eslint-config-postcss", "prettier"], "plugins": ["prettier"], "rules": { + "no-unused-vars": [2, {"args": "all", "argsIgnorePattern": "^_"}], "prettier/prettier": [ "error", { diff --git a/__tests__/resolveConfig.test.js b/__tests__/resolveConfig.test.js index 1a44a54b1..927ed2338 100644 --- a/__tests__/resolveConfig.test.js +++ b/__tests__/resolveConfig.test.js @@ -1249,8 +1249,8 @@ test('more than two config objects can be resolved', () => { customBackgroundOne: '#bada55', }, textDecorationColor: { - orange: 'orange' - } + orange: 'orange', + }, }, }, } @@ -1270,7 +1270,7 @@ test('more than two config objects can be resolved', () => { backgroundColor: { customBackgroundTwo: '#facade', }, - textDecorationColor: theme => theme('colors') + textDecorationColor: theme => theme('colors'), }, }, } @@ -1292,7 +1292,7 @@ test('more than two config objects can be resolved', () => { }), textDecorationColor: { lime: 'lime', - } + }, }, }, } @@ -1316,12 +1316,7 @@ test('more than two config objects can be resolved', () => { }, } - const result = resolveConfig([ - firstConfig, - secondConfig, - thirdConfig, - defaultConfig - ]) + const result = resolveConfig([firstConfig, secondConfig, thirdConfig, defaultConfig]) expect(result).toEqual({ prefix: '-', @@ -1363,4 +1358,4 @@ test('more than two config objects can be resolved', () => { backgroundColor: ['responsive', 'hover', 'focus'], }, }) -}) \ No newline at end of file +}) diff --git a/src/lib/substituteTailwindAtRules.js b/src/lib/substituteTailwindAtRules.js index 3aa181d29..6ceb38aa1 100644 --- a/src/lib/substituteTailwindAtRules.js +++ b/src/lib/substituteTailwindAtRules.js @@ -8,7 +8,7 @@ function updateSource(nodes, source) { } export default function( - config, + _config, { base: pluginBase, components: pluginComponents, utilities: pluginUtilities } ) { return function(css) { diff --git a/src/util/resolveConfig.js b/src/util/resolveConfig.js index 9d5274525..cbf2f93d3 100644 --- a/src/util/resolveConfig.js +++ b/src/util/resolveConfig.js @@ -1,11 +1,10 @@ import some from 'lodash/some' import mergeWith from 'lodash/mergeWith' -import assignWith from 'lodash/assignWith' import isFunction from 'lodash/isFunction' import isUndefined from 'lodash/isUndefined' import defaults from 'lodash/defaults' import map from 'lodash/map' -import reduce from 'lodash/reduce' +import get from 'lodash/get' import toPath from 'lodash/toPath' import negateValue from './negateValue' @@ -28,29 +27,30 @@ function value(valueToResolve, ...args) { } function mergeThemes(themes) { - const theme = (({ extend, ...t }) => t)(themes.reduce((merged, t) => { - return defaults(merged, t) - }, {})) - - // In order to resolve n config objects, we combine all of their `extend` properties - // into arrays instead of objects so they aren't overridden. - const extend = themes.reduce((merged, { extend }) => { - return mergeWith(merged, extend, (mergedValue, extendValue) => { - if (isUndefined(mergedValue)) { - return [extendValue] - } - - if (Array.isArray(mergedValue)) { - return [...mergedValue, extendValue] - } - - return [mergedValue, extendValue] - }) - }, {}) + const theme = (({ extend: _, ...t }) => t)( + themes.reduce((merged, t) => { + return defaults(merged, t) + }, {}) + ) return { ...theme, - extend, + + // In order to resolve n config objects, we combine all of their `extend` properties + // into arrays instead of objects so they aren't overridden. + extend: themes.reduce((merged, { extend }) => { + return mergeWith(merged, extend, (mergedValue, extendValue) => { + if (isUndefined(mergedValue)) { + return [extendValue] + } + + if (Array.isArray(mergedValue)) { + return [...mergedValue, extendValue] + } + + return [mergedValue, extendValue] + }) + }, {}), } } @@ -97,7 +97,10 @@ function resolveFunctionKeys(object) { export default function resolveConfig(configs) { return defaults( { - theme: resolveFunctionKeys(mergeExtensions(mergeThemes(map(configs, 'theme')))), + // Need to get a default empty object if the config has no theme + theme: resolveFunctionKeys( + mergeExtensions(mergeThemes(map(configs, t => get(t, 'theme', {})))) + ), variants: (firstVariants => { return Array.isArray(firstVariants) ? firstVariants