hudochenkov / postcss-sorting

PostCSS plugin to keep rules and at-rules content in order.
MIT License
517 stars 31 forks source link

Make invalid config error messages more informative #65

Closed guilhermehn closed 7 years ago

guilhermehn commented 7 years ago

at-variables from stylelint-order is not considered a valid order value by lib/validateOptions.js.

Example

postcss.js

const fs = require('fs')
const postcss = require('postcss')
const sorting = require('postcss-sorting')

const config = {
    'order': [
        'at-variables'
    ]
}

fs.readFile('a.css', (err, css) => {
    postcss([ sorting(config) ])
        .process(css, { from: 'a.css', to: 'b.css' })
        .then(result => {
            fs.writeFile('b.css', result.css)
        })
})

a.css

body {
  color: #fff;
  font-size: 10px;
}

When I run $ node postcss.js the response is:

postcss-sorting: Invalid "order" option value

Is this intended behaviour?

hudochenkov commented 7 years ago

Yes, at-variables and less-mixins aren't supported in postcss-sorting. Even Less wasn't tested there. I'm not interested in working on Less support, but PRs are welcome.

guilhermehn commented 7 years ago

I do not need the Less support (who even uses Less these days?), but someone of my team just copy-pasted some predefined config when creating our shared stylelint-order config, which came with the at-variables value. We lost a good part of the day trying to figure out why the stylefmt was not working and just printing the error message.

It would be nice to at least have a friendlier error message, displaying invalid values that are present in the config.

hudochenkov commented 7 years ago

who even uses Less these days?

I was surprised by that too. I know Wikipedia developers use it.

It would be nice to at least have a friendlier error message, displaying invalid values that are present in the config.

Thank you for suggestion! I'll think how to make error messages more useful.

hudochenkov commented 7 years ago

Fixed in 3.0.2. Thank you for a suggestion.

guilhermehn commented 7 years ago

Thank you!