Conversation
Codecov Report
@@ Coverage Diff @@
## master #867 +/- ##
=======================================
Coverage 97.28% 97.28%
=======================================
Files 118 123 +5
Lines 3458 3539 +81
Branches 1040 1054 +14
=======================================
+ Hits 3364 3443 +79
- Misses 86 88 +2
Partials 8 8
Continue to review full report at Codecov.
|
packages/postcss-lowercase-text/src/__tests__/data/pseudo-elements.js
Outdated
Show resolved
Hide resolved
alexander-akait
left a comment
There was a problem hiding this comment.
Looks good, we need more improvement - let's do it
alexander-akait
left a comment
There was a problem hiding this comment.
Can we add more tests?
| run( | ||
| 'should not transform css variable declarations', | ||
| ':root { --BG-COLOR: coral; --TEXT-COLOR: RED;}', | ||
| ':root { --BG-COLOR: coral; --TEXT-COLOR: red;}' |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
they are css values, they can be transformed as well just like the rest of the values.
Like this
https://github.com/cssnano/cssnano/pull/867/files#diff-fe88a57283a0a1a5c792a3000e5badbaR43-R53
There was a problem hiding this comment.
I will read spec, maybe you are right
|
@evilebottnawi Can you please check this allowed transformation |
|
Need fix CI |
working on it |
57998c5 to
b1b0698
Compare
b6a1db5 to
af8a940
Compare
|
cc @evilebottnawi finally the CI is green. Can you review this. |
| '_processCSS.js', | ||
| '_processCss.js', | ||
| '_webpack.config.js', | ||
| 'packages/postcss-lowercase-text/src/__tests__/data/', |
There was a problem hiding this comment.
jest was running the test running in this directory as well as there is an .js file which is true for jest's default test file pattern. So I added them. this directory should not be tested as it has data only.
| "postcss-discard-duplicates": "^4.0.2", | ||
| "postcss-discard-empty": "^4.0.1", | ||
| "postcss-discard-overridden": "^4.0.1", | ||
| "postcss-lowercase-text": "*", |
There was a problem hiding this comment.
I didnt publish v1 . so it will through error if we build it locally. I will release it manually after merging of this.
| }, | ||
| "engines": { | ||
| "node": ">=10.13" | ||
| "node": ">=10.13.0" |
| @@ -1,5 +1,7 @@ | |||
| import processCss from './_processCss'; | |||
|
|
|||
| jest.setTimeout(30000); | |||
There was a problem hiding this comment.
Avoid it and use setupFilesAfterEnv https://jestjs.io/docs/en/jest-object#jestsettimeouttimeout
There was a problem hiding this comment.
ok cool, I will try this 👍
| '@MEDIA SCREEN and (min-width: 480px){}', | ||
| '@media screen and (min-width: 480px){}' | ||
| ); | ||
| }); |
There was a problem hiding this comment.
Please add test: @MEDIA SCREEN AND (MIN-WIDTH: 480PX) {}
| run( | ||
| 'should safely transform the @charset', | ||
| '@CHARSET "iso-8859-15";', | ||
| '@charset "iso-8859-15";' |
There was a problem hiding this comment.
Do not touch charset never, it should b always in lowercase, we should keep @CHARSET as is
There was a problem hiding this comment.
is it case sensitive?
| 'should transform the @import ', | ||
| `@IMPORT url("fineprint.css") print;@import url("bluish.css") speech;@ImPoRt 'custom.css';@import url("CHROME://communicator/SKIN/");@import "common.css" screen;`, | ||
| `@import url("fineprint.css") print;@import url("bluish.css") speech;@import 'custom.css';@import url("CHROME://communicator/SKIN/");@import "common.css" screen;` | ||
| ); |
There was a problem hiding this comment.
Please add test: @IMPORT URL("fineprint.css") PRINT;
| run( | ||
| 'should safely transform the @namespace', | ||
| '@NAMESPACE prefix url(http://www.w3.org/1999/xhtml);', | ||
| '@namespace prefix url(http://www.w3.org/1999/xhtml);' |
There was a problem hiding this comment.
Please add test @NAMESPACE SVG URL(http://www.w3.org/2000/svg);, SVG should be in uppercase (keep as is)
| run( | ||
| 'should safely transform the @supports ', | ||
| '@SUPPORTS (display: grid) {div {display: grid;}};@supports not (display: GRID) {div {float: right;}}', | ||
| '@supports (display: grid) {div {display: grid;}};@supports not (display: GRID) {div {float: right;}}' |
There was a problem hiding this comment.
Please add test: @SUPPORTS (DISPLAY: GRID) {}
| run( | ||
| 'should safely transform the @document ', | ||
| '@DOCUMENT URL("https://www.EXAMPLE.com/") {h1 {COLOR: green;}}', | ||
| '@document URL("https://www.EXAMPLE.com/") {h1 {color: green;}}' |
There was a problem hiding this comment.
URL should be lowercased
There was a problem hiding this comment.
@evilebottnawi, it will lowercase the argument ("https://www.EXAMPLE.com/") as well which is not saved as lowercasing anything after domain name in URLs are not safe.
postcss will parse URL("https://www.EXAMPLE.com/") whole as params so we cant lowercase only URL.
let me know what you think!
| run( | ||
| 'should safely transform the @page ', | ||
| '@PAGE {margin: 1cm;};@page :FIRST {margin: 2cm;}', | ||
| '@page {margin: 1cm;};@page :FIRST {margin: 2cm;}' |
There was a problem hiding this comment.
Please add test: @PAGE :FIRST (all should be lowercased)
| run( | ||
| 'should safely transform the @keyframes', | ||
| '@KEYFRAMES slidein {from {transform: translateX(0%);}};@KEYFRAMES important2 {FROM {TRANSFORM: translateX(0%);}}', | ||
| '@keyframes slidein {from {transform: translateX(0%);}};@keyframes important2 {from {transform: translateX(0%);}}' |
There was a problem hiding this comment.
Please add test - @KEYFRAMES SLIDEIN {}, SLIDEIN should not be lowercased (keep as is)
| }, | ||
| }; | ||
|
|
||
| export default pseudoElementsList; |
There was a problem hiding this comment.
Can we write a script and get it from mdn?
There was a problem hiding this comment.
I don't know of any API to request from MDN !
can you share any link.
| run( | ||
| 'should safely transform the CSS attribute Selectors to lowercase', | ||
| '[NAME="newname"]{border: 1px solid black;}', | ||
| '[name="newname"]{border: 1px solid black;}' |
There was a problem hiding this comment.
Please add tests:
A[HREF*="insensitive" I]->a[href*="insensitive" i]A[HREF*="insensitive" S]->a[href*="insensitive" s]
| run( | ||
| 'should safely transform the CSS attribute Selectors to lowercase', | ||
| '[NAME="newname"]{border: 1px solid black;}', | ||
| '[name="newname"]{border: 1px solid black;}' |
There was a problem hiding this comment.
Please add test: DIV:NOT([LANG])
| 'should safely transform the CSS attribute Selectors to lowercase', | ||
| '[NAME="newname"]{border: 1px solid black;}', | ||
| '[name="newname"]{border: 1px solid black;}' | ||
| ); |
There was a problem hiding this comment.
Please add test: LI[DATA-VALUE|="1900"], we should not lowercase DATA-VALUE (keep as is) because https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes
| run( | ||
| 'should not transform the CSS :active pseudo class Selectors to lowercase', | ||
| 'a:ACTIVE{border: 1px solid black;}', | ||
| 'a:ACTIVE{border: 1px solid black;}' |
There was a problem hiding this comment.
Why we do not lowercased?
| ); | ||
|
|
||
| run( | ||
| 'should safely transform the CSS nested classname Selectors to lowercase', |
| describe('transforming CSS units', () => { | ||
| run( | ||
| 'should safely transform the absolute units to lowercase : px', | ||
| 'classname{border: 1PX solid black;}', |
There was a problem hiding this comment.
change classname to .classname
| run( | ||
| 'should safely transform Property ', | ||
| ':root { --main-BG-color: coral;} .classname { color : RED; background-color: var(--main-BG-color);}', | ||
| ':root { --main-BG-color: coral;} .classname { color : red; background-color: var(--main-BG-color);}' |
There was a problem hiding this comment.
Please add test - background-color: VAR(--MY-VAR, VAR(--MY-BACKGROUND, PING));
There was a problem hiding this comment.
should PING be lowercased too ?
| let allAtRulesNames = []; // ignored list for transforming values | ||
| css.walkAtRules((rule) => { | ||
| const allowedTransformingTypes = Object.keys(atRulesTranformerMap); | ||
| const allowedTransformingTypeSet = new Set(allowedTransformingTypes); |
There was a problem hiding this comment.
No need initialize inside walk, it is reduce perf
| decl.prop = decl.prop.toLowerCase(); | ||
| } | ||
| // font-family is case sensitive prop, its value should be left as it is | ||
| if (decl.prop === 'font-family') { |
There was a problem hiding this comment.
We have many properties which we should lowercased
There was a problem hiding this comment.
can you name them ? may all font as well ?
| decl.value = valueParser(decl.value) | ||
| .walk((node) => { | ||
| i += 1; | ||
| if (node.type === 'word' && i === 1) { |
There was a problem hiding this comment.
Avoid using counter, need rewrite
Moved
postcss-lowercase-texttocssnano-preset-defaultUpdated few integration tests.