Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support for postcss 8 plugins #200

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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