CSS: implement prettier-ignore (#2089)

* fix(css): implement prettier-ignore, fixes #2007

* refactor(css): move prettier-ignore to printNodeSequence
This commit is contained in:
Lucas Azzola authored and Christopher Chedeau committed 2017-06-10 07:45:59 -07:00
1 parent a9409f11e7
commit f7819d5695
3 files changed
+49 -1

No files matched your search

+17 -1
View File
@@ -337,7 +337,23 @@ function printNodeSequence(path, options, print) {
const parts = [];
let i = 0;
path.map(pathChild => {
parts.push(pathChild.call(print));
const prevNode = node.nodes[i - 1];
if (
prevNode &&
prevNode.type === "css-comment" &&
prevNode.text.trim() === "prettier-ignore"
) {
const childNode = pathChild.getValue();
parts.push(
options.originalText.slice(
util.locStart(childNode),
util.locEnd(childNode)
)
);
} else {
parts.push(pathChild.call(print));
}
if (i !== node.nodes.length - 1) {
if (
(node.nodes[i + 1].type === "css-comment" &&
@@ -67,6 +67,29 @@ div {
`;
exports[`prettier-ignore.css 1`] = `
// prettier-ignore
@blue: blue;
@black: darkgray;
foo {
/* prettier-ignore */
thing: foo;
-ms-thing: foo;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// prettier-ignore
@blue: blue;
@black: darkgray;
foo {
/* prettier-ignore */
thing: foo;
-ms-thing: foo;
}
`;
exports[`selector.css 1`] = `
.powerPathNavigator .helm button.pressedButton, /* pressed buttons */
.powerPathNavigator .helm button:active:not(.disabledButton),
+9
View File
@@ -0,0 +1,9 @@
// prettier-ignore
@blue: blue;
@black: darkgray;
foo {
/* prettier-ignore */
thing: foo;
-ms-thing: foo;
}