-
-
Notifications
You must be signed in to change notification settings - Fork 947
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
Add autofix to media-feature-range-operator-space-before #3618
Add autofix to media-feature-range-operator-space-before #3618
Conversation
result, | ||
ruleName | ||
if (fixOperatorIndices.length) { | ||
let params = atRule.raws.params |
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.
As far as I can see there is no params
in raws
: http://api.postcss.org/Node.html#raws
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.
However, in fact, it seems to exist.
You can try it below.
http://astexplorer.net/#/gist/3596e8f68b84c0dc6d9d69866d5fa505/7716a73333c0e9b54eed5997ff4887eec16ab87c
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.
Is there any difference between getting / setting node.params
and node.raws.params.raw
?
If there is no difference I think it'd be better to use documented parameters.
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.
node.raws.params.raw
to be create if comments get in. In this case, node.params
will not contain comment data.
I tried finding but I do not know the existence of the document yet. . .
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.
Got it. Thank you!
? atRule.raws.params.raw | ||
: atRule.params; | ||
fixOperatorIndices | ||
.sort((a, b) => a - b) |
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'd replace .sort((a, b) => a - b).reverse()
with .sort((a, b) => b - a)
.
@@ -26,26 +26,54 @@ const rule = function(expectation) { | |||
} | |||
|
|||
root.walkAtRules(/^media$/i, atRule => { | |||
const fixOperatorIndices = []; | |||
findMediaOperator(atRule, checkBeforeOperator); |
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.
The whole process is not very obvious. You declare array -> call findMediaOperator
with callback that could be executed several times and that mutates array of indices.
Maybe instead of this you can create a new function that will fix spacing. And you will run this function from checkBeforeOperator
.
What do you think?
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 that is good. I will fix it the next time I can work.
…ged to fix callback call
@boccob |
|
closes #3580
if use the
--fix
option, to remove whitespace at the end of each line.ex.
option:
always
code:
@media (width<600px) {}
fixed:
@media (width <600px) {}
option:
never
code:
@media (width < 600px) {}
fixed:
@media (width< 600px) {}