This release adds Node#replace()
shortcut and uses GNU style for syntax error messages.
Replace Nodes
@jonathanong suggested good shortcut to replace one node to another (or several other nodes). For example, you can write @import
loader:
css.eachAtRule(function (rule) {
if ( rule.name != 'import' ) return;
var file = readFileFromRule(rule);
var content = fs.readFileSync(file);
var root = postcss.parse(content, { from: file });
rule.replace(root);
});
GNU Style for Syntax Errors
Old PostCSS’s errors was like Can't parse CSS: Unexpected { in decls at line 2:1 in a.css
.
But GNU Coding Standards had good recommendations for syntax error messages. Rework, CoffeeScript and other tools already use it. Also some tools can find this format in output and they will open your text editor on this line.
PostCSS 2.2 now uses GNU style for syntax errors:
a.css:2:1 Unexpected { in decls
Also CssSyntaxError
now has reason
property to build your own error messages in end-user interfaces (in previous example it will be "Unexpected { in decls"
).
PostCSS Organization
PostCSS repository was moved to postcss GitHub organiztion, which will host official plugins.