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
Browser prefix is operator #45
Conversation
211984e
to
58efda2
Compare
Update lesshint to work with shellscape/postcss-values-parser#45, which will return a number for +5 instead of an operator and a number. So, check both operators and numbers, ignore any numbers that don’t start with an operator (+-*/), allow the node to be the last node (no nextElement), and use a whitespace regex to check the none spacing instead of the exact value.
58efda2
to
75e946e
Compare
if ((!this.current.nodes.length || (this.current.last && this.current.last.type === 'operator')) && this.nextToken[0] === 'word') { | ||
return this.word(); | ||
} | ||
if (this.nextToken[0] === 'word') { |
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.
so why don't we want this parsed different in loose mode?
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.
Loose mode just means you aren’t compliant CSS, right? It doesn’t mean that this:
-16px -1px -1px 16px
…should be parsed as 3 operators and 4 numbers, it should be four numbers.
But, I mostly leave that question to you as the maintainer. Did I misunderstand that test?
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.
@jwilsson please weigh in here. I recall that we implemented loose mode specifically for less and scss. Will removing how this is processed in loose mode have negative consequences?
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 have a matching PR to update less here: lesshint/lesshint#458 (which will need to be updated to bump versions pending a release of this repo). I didn’t realize this was the parser for other things, @jwilsson LMK what else might need to be updated in the same manner as lesshint
, I’d prefer to rig up updates to all the repos as part of this review.
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.
Good to know. This might require a major version, as it's going to break some expected functionality.
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.
Yeah, the idea behind loose
mode was to target CSS-like languages (such as Less/SCSS).
I definitely think we should tag a major after this one is merged, I know that at least Prettier is using this library (and that's a pretty large project) so we probably wouldn't want to change the behaviour unexpectedly.
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.
Lemme see if I can loop those folks into this. I'll have to comb through the commits to figure out who that was, but we'll get this in once we get some more eyes on it.
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.
@evilebottnawi can you comment as to whether or not this will impact prettier?
@@ -209,15 +209,15 @@ describe('Parser → Number : Loose', () => { | |||
}, | |||
{ | |||
test: '5+5', | |||
expected: { value: '5', unit: '', length: 3 } | |||
expected: { value: '+5', unit: '', length: 2 } |
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.
@shellscape break, 5+5
should be as 5 + 5
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.
@evilebottnawi thanks for taking a look. can you elaborate? I'm not sure what you mean there.
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.
@shellscape It is difficult to say for sure, since we have rather complicated logic around +
, -
and
/
. I will test this branch tomorrow and leave feedback here 👍
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.
Thank you!
@shellscape also if it is major change, let's open issue for discussion before release. Some improvement for prettier will be great 👍 |
@evilebottnawi indeed. this would be a major version change. please do create an issue for discussing what you would like to see improved! |
@shellscape
- prop75: calc(100%+2px) calc(100% +2px) calc(100%+ 2px) calc(100% + 2px);
- prop76: calc(100%-2px) calc(100% -2px) calc(100%- 2px) calc(100% - 2px);
+ prop75: calc(100% +2px) calc(100% +2px) calc(100%+ 2px) calc(100% + 2px);
+ prop76: calc(100% -2px) calc(100% -2px) calc(100%- 2px) calc(100% - 2px);
- @mixin $(theme)-colors;
+ @mixin $(theme) -colors;
a {
prop57: round(1.5)+2 round(1.5) +2 round(1.5)+ 2 round(1.5) + 2;
prop58: 2+round(1.5) 2 +round(1.5) 2+ round(1.5) 2 + round(1.5);
prop59: (round(1.5)+2) (round(1.5) +2) (round(1.5)+ 2) (round(1.5) + 2);
prop60: (2+round(1.5)) (2 +round(1.5)) (2+ round(1.5)) (2 + round(1.5));
prop61: $width+2 $width +2 $width+ 2 $width + 2;
prop62: 2+$width 2 +$width 2+ $width 2 + $width;
prop63: ($width+2) ($width +2) ($width+ 2) ($width + 2);
prop64: (2+$width) (2 +$width) (2+ $width) (2 + $width);
prop65: @width+2 @width +2 @width+ 2 @width + 2;
} - prop57: round(1.5) + 2 round(1.5) + 2 round(1.5) + 2 round(1.5) + 2;
- prop58: 2 + round(1.5) 2 + round(1.5) 2 + round(1.5) 2 + round(1.5);
- prop59: (round(1.5) + 2) (round(1.5) + 2) (round(1.5) + 2) (round(1.5) + 2);
- prop60: (2 + round(1.5)) (2 + round(1.5)) (2 + round(1.5)) (2 + round(1.5));
- prop61: $width + 2 $width + 2 $width + 2 $width + 2;
- prop62: 2 + $width 2 + $width 2 + $width 2 + $width;
- prop63: ($width + 2) ($width + 2) ($width + 2) ($width + 2);
- prop64: (2 + $width) (2 + $width) (2 + $width) (2 + $width);
- prop65: @width+2 @width + 2 @width+ 2 @width + 2;
+ prop57: round(1.5) +2 round(1.5) +2 round(1.5) + 2 round(1.5) + 2;
+ prop58: 2 +round(1.5) 2 +round(1.5) 2 + round(1.5) 2 + round(1.5);
+ prop59: (round(1.5) +2) (round(1.5) +2) (round(1.5) + 2) (round(1.5) + 2);
+ prop60: (2 +round(1.5)) (2 +round(1.5)) (2 + round(1.5)) (2 + round(1.5));
+ prop61: $width +2 $width +2 $width + 2 $width + 2;
+ prop62: 2 +$width 2 +$width 2 + $width 2 + $width;
+ prop63: ($width +2) ($width +2) ($width + 2) ($width + 2);
+ prop64: (2 +$width) (2 +$width) (2 + $width) (2 + $width);
+ prop65: @width+2 @width +2 @width+ 2 @width + 2; From spec in short form:
I.e. - |
I think we should avoid behavior in this PR in loose mode, to allow reformat |
@evilebottnawi are your comments new requests/feedback in general for this module or do they pertain to this Pull Request? |
@shellscape to this |
@donotknow & @evilebottnawi can you two work through this so we can merge something that doesn't cause issues for other consumers (like prettier) but fixes the issue that lesshint is currently running into? |
@donotknow can we use this logic only in not |
This has been fixed in |
Which issue # if any, does this resolve?
#38
Please check one:
More information on my comment in the original issue #38 (comment).