Update postcss-less to v3#6981
Conversation
| @KeepDetachedRuleset(); | ||
|
|
||
| &: EXTEND(.Keep ALL); | ||
| &:EXTEND(.Keep ALL); |
There was a problem hiding this comment.
Anyone know what is this? space matters?
There was a problem hiding this comment.
I think I added this test case when I added support for lowercasing of stuff back in the day. Testing on http://lesscss.org/less-preview/, uppercase EXTEND does not appear to be valid Less. So it’s a weird test case. &:extend(.Keep ALL) seems to be valid syntax, while &: extend(.Keep ALL) is a syntax error.
There was a problem hiding this comment.
My guess is that the input should be changed to &:extend(.Keep ALL) and the output should be the same (&:extend(.Keep ALL)).
873ea31 to
754c3cc
Compare
|
Also feel free to switch to the |
754c3cc to
6b3456c
Compare
| @KeepDetachedRuleset(); | ||
|
|
||
| &:EXTEND(.Keep ALL); | ||
| &:extend(.Keep ALL); |
There was a problem hiding this comment.
we should keep EXTEND as is
.bucket {
tr { // nested ruleset with target selector
color: blue;
}
}
.some-class:extend(.bucket tr) {}->
.bucket tr,
.some-class {
color: blue;
}But:
.bucket {
tr { // nested ruleset with target selector
color: blue;
}
}
.some-class:EXTEND(.bucket tr) {}->
.bucket tr {
color: blue;
}| @KeepDetachedRuleset(); | ||
|
|
||
| &: EXTEND(.Keep ALL); | ||
| &:extend(.Keep ALL); |
|
ready for review |
|
Prettier pr-6981 --parser lessInput: @selectors: blue, green, red;
each(@selectors, {
.sel-@{value} {
a: b;
}
});Output: @selectors: blue, green, red;
@each (@selectors, {.sel- @{value} {a: b;}}) ;
|
|
looking into this, different |
ace46c2 to
7b4cf56
Compare
|
@thorn0 add a test for it, print as it is, maybe we can make it pretty later, I guess ugly is better than broken. this PR only update this module |
|
Prettier pr-6981 --parser lessInput: @selectors: blue, green, red;
each(@selectors, {
.sel-@{value} {
a: b;
}
});Output: @selectors: blue, green, red;
each(@selectors, {
.sel-@{value} {
a: b;
}
});
|
|
@fisker 👍 I'm okay with whatever you decide as long as the output stays valid. First correctness, then aesthetics. |
|
#5420 is not a parser error now, but selectors assigned to a variable (docs) get corrupted by whitespace inserted after colons. Prettier pr-6981 --parser lessInput: @selector: &:not([type='file']):not([type='checkbox']):not([type='radio']):not([type='range']):not([type='hidden']);
Output: @selector: &: not([type= "file" ]): not([type= "checkbox" ]):
not([type= "radio" ]): not([type= "range" ]): not([type= "hidden" ]);
|
|
variable support selector, maybe we need do a |
alexander-akait
left a comment
There was a problem hiding this comment.
Many problems, we should fix it
| : "", | ||
| isTemplatePlaceholderNodeWithoutSemiColon ? "" : ";" | ||
| ]); | ||
| } |
There was a problem hiding this comment.
Each node.mixin/node.function/node.variable should be:
if (isLessParser) {
if (node.mixin) { /* ... */ }
if (node.function) { /* ... */ }
}
It is better for performance and other parsers can potentially have same properties
There was a problem hiding this comment.
Please add isLessParser check here
There was a problem hiding this comment.
In fact we can't use options.parser === "less", since we has parser=css also use less parser, so I use options.parser !== "scss" in this commit
What do you think? or maybe options.parser === "less" || options.parser === "csss"?
There was a problem hiding this comment.
To be honestly we should throw error on less syntax when developer set css parser. What about change the options.parser value change when we switch on other syntax?
There was a problem hiding this comment.
Maybe we can do this later in a seperate PR, shall we?
There was a problem hiding this comment.
Yes, don't forget open new issue after merge, anyway let's encapsulate logic in one util function isLessParser, it is allow to fix problem in one places
| " {", | ||
| node.selector && | ||
| node.selector.type === "selector-unknown" && | ||
| node.selector.value.endsWith("\n") |
There was a problem hiding this comment.
Is is bad idea use node.selector.value.endsWith("\n")
| if (node.raws.inline || node.inline) { | ||
| const needBreakAfter = !( | ||
| node.source.input.css.split("\n")[node.source.end.line] || "" | ||
| ).trim(); | ||
| return concat([ | ||
| "//", | ||
| node.raws.left + rawText, | ||
| needBreakAfter ? "\n" : "" | ||
| ]); |
There was a problem hiding this comment.
"\n"? We should use prettier builders
node.source.input.css should be never used
this place is very bad, need rewrite this
| // last line has inline comment | ||
| if (/\/\//.test(selector.split("\n").pop())) { | ||
| value += "\n"; | ||
| } |
There was a problem hiding this comment.
Why? Using \n break code for developers who using CRLF
|
|
||
| // Less variable | ||
| if (node.variable) { | ||
| delete node.params; |
There was a problem hiding this comment.
variable, use value property
| // Missing whitespace between variable and colon | ||
| if ( | ||
| ["page", "nest"].indexOf(node.name) === -1 && | ||
| node.params && | ||
| node.params[0] === ":" | ||
| ) { | ||
| node.variable = true; | ||
| node.value = parseValue(node.params.slice(1)); | ||
| } |
|
|
||
| if (node.type === "css-atrule") { | ||
| // mixin | ||
| if (node.mixin) { |
There was a problem hiding this comment.
isLessParser && node.mixin
| } | ||
|
|
||
| // Whitespace between variable and colon | ||
| if (node.name.indexOf(":") !== -1 && !node.params) { |
There was a problem hiding this comment.
We should improve this check, Scss allow to use : in interpolations and can't have params, so this invalid
|
Please reduce using regexps, it is always bad, if you don't have enough information on node, please open issue in postcss-less instead using hacks |
@foo : bar;what do we do? |
|
@fisker if less support that, we should open issue and fix problem in parser |
|
@evilebottnawi shellscape/postcss-less#101 (comment) It was fixed in 2, but changed again in 3 with breaking change shellscape/postcss-less#113 , I don't think they are going to parse it |
|
@fisker we should investigate how Less interpreted this, if parser don't parse that propertly we can't update parser until it will be fixed |
|
I'm no Less expert, but it seems to be valid on http://lesscss.org/less-preview/ @foo : bar;
a {
color: @foo;
}becomes: a {
color: bar;
} |
|
@fisker it is mean we can't update parser while it is not fixed |
|
But it works! Prettier pr-6981 --parser lessInput: @foo : bar;Output: @foo: bar;
|
0ed4d5c to
73e7ba7
Compare
docs/directory)changelog_unreleased/*/pr-XXXX.mdfile followingchangelog_unreleased/TEMPLATE.md.✨Try the playground for this PR✨