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

Add throwWhenCannotReduce option #20

Merged
merged 1 commit into from Jan 7, 2016

Conversation

jamiebuilds
Copy link
Contributor

Resolves #19

@@ -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,
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

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

@jamiebuilds
Copy link
Contributor Author

Done

@MoOx
Copy link
Contributor

MoOx commented Jan 7, 2016

👍

MoOx added a commit that referenced this pull request Jan 7, 2016
@MoOx MoOx merged commit 4dcfeea into postcss:master Jan 7, 2016
@MoOx
Copy link
Contributor

MoOx commented Jan 7, 2016

Released as 5.1.0

@jamiebuilds jamiebuilds deleted the throwWhenCannotReduce branch January 7, 2016 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants