-
Notifications
You must be signed in to change notification settings - Fork 61
Plugin doesn't return messages or warnings for undefined variable usage #31
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
Comments
Hey @tbremer, sorry for the late reply 😔 We currently only warn you about undefined variable usage when composing other CSS variables if there isn't a fallback provided.
:root {
/* `--bar` isn't defined */
--foo: var(--bar);
/* `--qwer` isn't defined but we have a fallback so no warning will be added */
--asdf: var(--qwer, #f00);
} var postcss = require('postcss');
var readFile = require('fs').readFileSync;
var css = readFile('./input.css');
postcss([require('postcss-css-variables')])
.process(css)
.then(function(results) {
console.log('messages', results.messages);
console.log('warnings', results.warnings());
console.log(results.css);
}); Result:
But I can't remember on a decision either way for or against adding a warning for undefined usage on the substitutions on regular properties. Adding this in would probably be good though. Adding this functionality is easy as passing in the postcss-css-variables/index.js Line 237 in 4265ae7
resolveDecl(decl, map, opts.preserve, logResolveValueResult); @tbremer Care to make a PR? |
Where can I find this output if I'm using gulp? All I see is indexOf errors with no trace. |
@stephenway |
Would be nice to have that. Don't want to have 'undefined' properties in my distribution bundle by accident. |
That is still the issue. Warnings still are not displayed. |
@MadLittleMods postcss-reporter doesn't show any warnings in case of undefined variables |
Can confirm, this postcss-reporter doesn't show any errors. It looks like I've made a PR: |
Hi, the warning about using CSS vars without fallback can be disabled? |
@ronaiza-cardoso I don't think there is configurable a way in the plugin itself to disable. But this may work for you: https://stackoverflow.com/a/38914354/796832 |
I am coming up with an issue that when I have declarations with a missing or non-existent variable the CSS returns
undefined
(which is expected) however no warnings or messages coming through to the result…here is a gist that contains a rudimentary setup.if you pull down that gist and run
node index.js
you will see the compiled CSS compiles with anundefined
butresults.messages
&results.warnings()
both return blank.Please let me know if I can help in anyway! 🍻
The text was updated successfully, but these errors were encountered: