Skip to content

Commit

Permalink
Merge efc9ebb into fda5f4a
Browse files Browse the repository at this point in the history
  • Loading branch information
m4thieulavoie committed Sep 17, 2020
2 parents fda5f4a + efc9ebb commit 22e0245
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
"cssnano": "^4.0.0",
"jest": "^24.0.0",
"jsdoc-to-markdown": "^5.0.0",
"postcss": "^7.0.0",
"postcss": "^8.0.0",
"postcss-import": "^12.0.0",
"postcss-nested": "^4.0.0",
"postcss-nested": "^5.0.0",
"standard": "^12.0.0",
"standard-version": "6.0.0",
"sugarss": "^2.0.0"
Expand Down
6 changes: 1 addition & 5 deletions src/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,7 @@ const plugins = (config, file) => {
plugin = plugin.default
}

if (
// eslint-disable-next-line
!(typeof plugin === 'object' && Array.isArray(plugin.plugins) ||
typeof plugin === 'function')
) {
if (!!plugin.plugins && Array.isArray(plugin.plugins)) {
throw new TypeError(`Invalid PostCSS Plugin found at: plugins[${i}]\n\n(@${file})`)
}
})
Expand Down
17 changes: 15 additions & 2 deletions test/js.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const path = require('path')

const postcss = require('postcss')
const postcssrc = require('../src/index.js')
const loadPlugins = require('../src/plugins.js')

const { fixture, expected } = require('./utils.js')

Expand Down Expand Up @@ -35,7 +36,19 @@ describe('postcss.config.js - {Object} - Load Config', () => {
test('Sync', () => {
const config = postcssrc.sync(ctx, 'test/js/object')

expected(config)
expect(() => {
expected(config)
}).not.toThrowError()
})

test('Throw error if plugin has plugins too', () => {
expect(() => {
loadPlugins({
plugins: [{
plugins: ['postcssPlugin']
}]
}, undefined)
}).toThrowError()
})
})

Expand Down Expand Up @@ -85,7 +98,7 @@ describe('postcss.config.js - {Array} - Load Config', () => {

expect(config.plugins.length).toEqual(2)
expect(typeof config.plugins[0]).toBe('function')
expect(typeof config.plugins[1]).toBe('function')
expect(typeof config.plugins[1]).toBe('object')

expect(config.file)
.toEqual(path.resolve('test/js/array', 'postcss.config.js'))
Expand Down

0 comments on commit 22e0245

Please sign in to comment.