Fix css-modules composes breaking with long line width (#2190)

* fix(css): css-modules composes breaking

* refactor(css): to use removeLines in case of composes
master
suǝʞǝǝpʇ 2017-06-19 11:41:10 +02:00 committed by Christopher Chedeau
parent 3769cbe5bb
commit 16db5971f0
4 changed files with 26 additions and 1 deletions

View File

@ -10,6 +10,9 @@ const softline = docBuilders.softline;
const group = docBuilders.group;
const indent = docBuilders.indent;
const docUtils = require("./doc-utils");
const removeLines = docUtils.removeLines;
function genericPrint(path, options, print) {
const n = path.getValue();
@ -69,13 +72,19 @@ function genericPrint(path, options, print) {
n.value.group.type === "value-value" &&
n.value.group.group.type === "value-func" &&
n.value.group.group.value === "extend";
const isComposed =
n.value.type === "value-root" &&
n.value.group.type === "value-value" &&
n.prop === "composes";
return concat([
n.raws.before.replace(/[\s;]/g, ""),
n.prop,
":",
isValueExtend ? "" : " ",
path.call(print, "value"),
isComposed
? removeLines(path.call(print, "value"))
: path.call(print, "value"),
n.important ? " !important" : "",
n.nodes
? concat([

View File

@ -0,0 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`composes.css 1`] = `
.reference {
composes: selector from "a/long/file/path/exceeding/the/maximum/length/forcing/a/line-wrap/file.css";
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.reference {
composes: selector from "a/long/file/path/exceeding/the/maximum/length/forcing/a/line-wrap/file.css";
}
`;

View File

@ -0,0 +1,3 @@
.reference {
composes: selector from "a/long/file/path/exceeding/the/maximum/length/forcing/a/line-wrap/file.css";
}

View File

@ -0,0 +1 @@
run_spec(__dirname, { parser: "postcss" });