-
Notifications
You must be signed in to change notification settings - Fork 32
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
Add throwWhenCannotReduce option #20
Conversation
@@ -22,6 +26,11 @@ module.exports = postcss.plugin("postcss-calc", function(options) { | |||
helpers.try(function transformCSSCalc() { | |||
var value = reduceCSSCalc(decl.value, precision) | |||
|
|||
if (throwWhenCannotReduce && CONTAINS_CALC.test(value)) { | |||
throw decl.error("Could not reduce expression: " + decl.value, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about using postcss message api instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the API for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example of usage https://github.com/postcss/postcss-custom-properties/blob/master/index.js#L56-L59
You will need to add "result" as a second parameter here https://github.com/thejameskyle/postcss-calc/blob/2ca864fa70ce55956c2f5c5d3b1f0daee993786f/index.js#L19.
If you do that, please rename the option to "warnWhenCannotResolve" (since in this case it's full resolution that we are testing), add a note in the top of the CHANGELOG (something like Added: "warnWhenCannotResolve" option to warn when calc() are not reduced to a single value
) and document it in the README and we should be good to go 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is an example on how to test messages https://github.com/postcss/postcss-custom-properties/blob/master/test/index.js#L74-L80
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To see them, you can use postcss-reporter or postcss-browser-reporter
2ca864f
to
6000b05
Compare
Done |
👍 |
Released as 5.1.0 |
Resolves #19