-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Update postcss
to v8
#9209
Update postcss
to v8
#9209
Changes from all commits
3e8aa2f
44240c7
ddb1f9d
1c4b6cf
9561e8c
2d8e7f0
c819223
2cd7352
da347b0
fe29fd9
8927698
407ebc3
0377474
094ccca
77787ca
cb858a8
e20db21
c5e3bdd
b5804d5
a5351ba
9647897
efcbf22
b804345
9f93878
58f102d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#### Improve custom properties format (#9209 by @fisker) | ||
|
||
Thanks to [`PostCSS 8.0`](https://github.com/postcss/postcss/releases/tag/8.0.0), we can handle these edge cases on custom properties. | ||
|
||
<!-- prettier-ignore --> | ||
```css | ||
/* Input */ | ||
:root { | ||
--empty: ; | ||
--JSON: [1, "2", {"three": {"a":1}}, [4]]; | ||
--javascript: function(rule) { console.log(rule) }; | ||
} | ||
|
||
@supports (--element(".minwidth", { "minWidth": 300 })) { | ||
[--self] { | ||
background: greenyellow; | ||
} | ||
} | ||
|
||
/* Prettier stable */ | ||
SyntaxError: (postcss) CssSyntaxError Missed semicolon (3:20) | ||
1 | :root { | ||
2 | --empty: ; | ||
> 3 | --JSON: [1, "2", {"three": {"a":1}}, [4]]; | ||
| ^ | ||
4 | --javascript: function(rule) { console.log(rule) }; | ||
5 | } | ||
6 | | ||
|
||
/* Prettier master */ | ||
:root { | ||
--empty: ; | ||
--JSON: [1, "2", {"three": {"a": 1}}, [4]]; | ||
--javascript: function(rule) {console.log(rule)}; | ||
} | ||
|
||
@supports (--element(".minwidth", {"minWidth": 300})) { | ||
[--self] { | ||
background: greenyellow; | ||
} | ||
} | ||
``` |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -304,6 +304,44 @@ printWidth: 80 | |||
================================================================================ | ||||
`; | ||||
|
||||
exports[`custom-properties.css format 1`] = ` | ||||
====================================options===================================== | ||||
parsers: ["css"] | ||||
printWidth: 80 | ||||
| printWidth | ||||
=====================================input====================================== | ||||
/* comment 1 */ | ||||
:root { | ||||
/* comment 2 */ | ||||
--prop : { | ||||
/* comment 3 */ | ||||
color/* comment 4 */: /* comment 5 */#fff/* comment 6 */;/* comment 7 */ | ||||
/* comment 8 */ | ||||
font-size: 12px; | ||||
/* comment 9 */ | ||||
}; | ||||
/* comment 10 */ | ||||
} | ||||
/* comment 11 */ | ||||
|
||||
=====================================output===================================== | ||||
/* comment 1 */ | ||||
:root { | ||||
/* comment 2 */ | ||||
--prop: { | ||||
/* comment 3 */ | ||||
color/* comment 4 */: /* comment 5 */ #fff /* comment 6 */; /* comment 7 */ | ||||
/* comment 8 */ | ||||
font-size: 12px; | ||||
/* comment 9 */ | ||||
}; | ||||
/* comment 10 */ | ||||
} | ||||
/* comment 11 */ | ||||
|
||||
================================================================================ | ||||
`; | ||||
|
||||
exports[`declaration.css format 1`] = ` | ||||
====================================options===================================== | ||||
parsers: ["css"] | ||||
|
@@ -887,11 +925,11 @@ article /* comment 168 */ :--heading /* comment 169 */ + /* comment 170 */ p /* | |||
/* custom properties set & @apply rule */ | ||||
:root { | ||||
/* comments 192 */ | ||||
--centered /* comments 193 */ : /* comments 194 */ { | ||||
--centered/* comments 193 */ : /* comments 194 */ { | ||||
display: flex; | ||||
align-items: center; | ||||
justify-content: center; | ||||
} | ||||
}; | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Regression? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Acutally, I think it's bugfix.
The space before There is a space before, because we treat it as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And the test is added by you, the input has prettier/tests/css/comments/selectors.css Line 156 in e857c4e
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should print There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. scss (need test on less) supports nested declarations https://www.sassmeister.com/, so prefer keep it as is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The whole part after There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Starts with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It we have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, I'll change this case to let the value parse as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed, c5e3bdd. |
||||
} | ||||
|
||||
================================================================================ | ||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* comment 1 */ | ||
:root { | ||
/* comment 2 */ | ||
--prop : { | ||
/* comment 3 */ | ||
color/* comment 4 */: /* comment 5 */#fff/* comment 6 */;/* comment 7 */ | ||
/* comment 8 */ | ||
font-size: 12px; | ||
/* comment 9 */ | ||
}; | ||
/* comment 10 */ | ||
} | ||
/* comment 11 */ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`empty-props.css format 1`] = ` | ||
====================================options===================================== | ||
parsers: ["css"] | ||
printWidth: 80 | ||
| printWidth | ||
=====================================input====================================== | ||
:root { | ||
--empty:; | ||
--one-space: ; | ||
--two-space: ; | ||
--many-space: ; | ||
} | ||
|
||
=====================================output===================================== | ||
:root { | ||
--empty:; | ||
--one-space: ; | ||
--two-space: ; | ||
--many-space: ; | ||
} | ||
|
||
================================================================================ | ||
`; | ||
|
||
exports[`test.css format 1`] = ` | ||
====================================options===================================== | ||
parsers: ["css"] | ||
printWidth: 80 | ||
| printWidth | ||
=====================================input====================================== | ||
/* | ||
This test is copied from \`postcss@8\` release note | ||
|
||
https://github.com/postcss/postcss/releases/tag/8.0.0 | ||
*/ | ||
|
||
:root { | ||
--empty: ; | ||
--JSON: [1, "2", {"three": {"a":1}}, [4]]; | ||
--javascript: function(rule) { console.log(rule) }; | ||
} | ||
|
||
@supports (--element(".minwidth", { "minWidth": 300 })) { | ||
[--self] { | ||
background: greenyellow; | ||
} | ||
} | ||
|
||
=====================================output===================================== | ||
/* | ||
This test is copied from \`postcss@8\` release note | ||
|
||
https://github.com/postcss/postcss/releases/tag/8.0.0 | ||
*/ | ||
|
||
:root { | ||
--empty: ; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
So both should not be changed |
||
--JSON: [1, "2", {"three": {"a": 1}}, [4]]; | ||
--javascript: function(rule) {console.log(rule)}; | ||
} | ||
|
||
@supports (--element(".minwidth", {"minWidth": 300})) { | ||
[--self] { | ||
background: greenyellow; | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add |
||
|
||
================================================================================ | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
:root { | ||
--empty:; | ||
--one-space: ; | ||
--two-space: ; | ||
--many-space: ; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
run_spec(__dirname, ["css"]); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
This test is copied from `postcss@8` release note | ||
|
||
https://github.com/postcss/postcss/releases/tag/8.0.0 | ||
*/ | ||
|
||
:root { | ||
--empty: ; | ||
--JSON: [1, "2", {"three": {"a":1}}, [4]]; | ||
--javascript: function(rule) { console.log(rule) }; | ||
} | ||
|
||
@supports (--element(".minwidth", { "minWidth": 300 })) { | ||
[--self] { | ||
background: greenyellow; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should remove them in the future major release, it is invalid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to parse is as
value-unknown
, but seems it is a proposal, but abandonedhttp://tabatkins.github.io/specs/css-apply-rule/#defining
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but it is violate CSS spec, so prefer to avoid this, because it can break some future CSS features