-
-
Notifications
You must be signed in to change notification settings - Fork 930
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 @import
tests for max-line-length
rule
#2221
Changes from 3 commits
480c3fc
926e35e
fdbd4fa
eed5b50
0467c96
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 |
---|---|---|
|
@@ -11765,169 +11765,169 @@ Array [ | |
"text": "Expected line length to be no more than 20 characters (max-line-length)", | ||
}, | ||
Object { | ||
"column": 5, | ||
"line": 146, | ||
"column": 25, | ||
"line": 145, | ||
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. Something seems wrong with this system test. Am I right that these line numbers do not correspond with lines in 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. Trying to wrap my head around this and it's not going so well 😏 Currently in https://github.com/stylelint/stylelint/blob/master/system-tests/005/stylesheet.css#L146
Once applying the changes in this PR the above warning for line 146 is no longer reported in the test snapshot but a new one is, line 149 with It appears that there are numerous cases of the above, the only sane piece of data I've been able to extract thus far is that both before and after this PR there are a total of 84 Line numbers, are at best a crap shoot 🎲 If anyone else in @stylelint/core can make any sense of this it'd be appreciated 😄 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. There's something going on here, but I'm not sure what. If I can reproduce a smaller test case I'll post it up. 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. One possability is that Jest is serializing the Unconfirmed at this stage though, need to read more docs and or code to confirm. 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 this is the problem: #2286 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. @m-allanson I actually didn't even get to the stage of checking if the column number was correct, I've only really tested line numbers, and it's been clear that the line numbers referenced are not 20 characters in length (based on this PRs settings) Edit: I've just read the Extra example in the #2286 issue in that multiple errors can be reported for a single line rather, let's get that fixed and test the results 👍 p.s. Great sleuthing @m-allanson 🔍 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. @ntwb Yeah it's a funny one - the incorrect column numbers can compound and spill over into incorrect line numbers too. I added an extra example to the bottom of the issue to demonstrate. |
||
"rule": "max-line-length", | ||
"severity": "error", | ||
"text": "Expected line length to be no more than 20 characters (max-line-length)", | ||
}, | ||
Object { | ||
"column": 3, | ||
"line": 150, | ||
"column": 2, | ||
"line": 149, | ||
"rule": "max-line-length", | ||
"severity": "error", | ||
"text": "Expected line length to be no more than 20 characters (max-line-length)", | ||
}, | ||
Object { | ||
"column": 10, | ||
"column": 3, | ||
"line": 152, | ||
"rule": "max-line-length", | ||
"severity": "error", | ||
"text": "Expected line length to be no more than 20 characters (max-line-length)", | ||
}, | ||
Object { | ||
"column": 35, | ||
"column": 28, | ||
"line": 153, | ||
"rule": "max-line-length", | ||
"severity": "error", | ||
"text": "Expected line length to be no more than 20 characters (max-line-length)", | ||
}, | ||
Object { | ||
"column": 16, | ||
"column": 9, | ||
"line": 156, | ||
"rule": "max-line-length", | ||
"severity": "error", | ||
"text": "Expected line length to be no more than 20 characters (max-line-length)", | ||
}, | ||
Object { | ||
"column": 10, | ||
"column": 3, | ||
"line": 160, | ||
"rule": "max-line-length", | ||
"severity": "error", | ||
"text": "Expected line length to be no more than 20 characters (max-line-length)", | ||
}, | ||
Object { | ||
"column": 6, | ||
"line": 162, | ||
"column": 3, | ||
"line": 161, | ||
"rule": "max-line-length", | ||
"severity": "error", | ||
"text": "Expected line length to be no more than 20 characters (max-line-length)", | ||
}, | ||
Object { | ||
"column": 19, | ||
"column": 12, | ||
"line": 173, | ||
"rule": "max-line-length", | ||
"severity": "error", | ||
"text": "Expected line length to be no more than 20 characters (max-line-length)", | ||
}, | ||
Object { | ||
"column": 3, | ||
"line": 175, | ||
"column": 15, | ||
"line": 174, | ||
"rule": "max-line-length", | ||
"severity": "error", | ||
"text": "Expected line length to be no more than 20 characters (max-line-length)", | ||
}, | ||
Object { | ||
"column": 10, | ||
"column": 3, | ||
"line": 177, | ||
"rule": "max-line-length", | ||
"severity": "error", | ||
"text": "Expected line length to be no more than 20 characters (max-line-length)", | ||
}, | ||
Object { | ||
"column": 5, | ||
"line": 179, | ||
"column": 7, | ||
"line": 178, | ||
"rule": "max-line-length", | ||
"severity": "error", | ||
"text": "Expected line length to be no more than 20 characters (max-line-length)", | ||
}, | ||
Object { | ||
"column": 5, | ||
"line": 183, | ||
"column": 7, | ||
"line": 182, | ||
"rule": "max-line-length", | ||
"severity": "error", | ||
"text": "Expected line length to be no more than 20 characters (max-line-length)", | ||
}, | ||
Object { | ||
"column": 6, | ||
"line": 195, | ||
"column": 3, | ||
"line": 194, | ||
"rule": "max-line-length", | ||
"severity": "error", | ||
"text": "Expected line length to be no more than 20 characters (max-line-length)", | ||
}, | ||
Object { | ||
"column": 10, | ||
"column": 3, | ||
"line": 202, | ||
"rule": "max-line-length", | ||
"severity": "error", | ||
"text": "Expected line length to be no more than 20 characters (max-line-length)", | ||
}, | ||
Object { | ||
"column": 9, | ||
"column": 2, | ||
"line": 207, | ||
"rule": "max-line-length", | ||
"severity": "error", | ||
"text": "Expected line length to be no more than 20 characters (max-line-length)", | ||
}, | ||
Object { | ||
"column": 8, | ||
"column": 1, | ||
"line": 211, | ||
"rule": "max-line-length", | ||
"severity": "error", | ||
"text": "Expected line length to be no more than 20 characters (max-line-length)", | ||
}, | ||
Object { | ||
"column": 1, | ||
"line": 220, | ||
"column": 21, | ||
"line": 218, | ||
"rule": "max-line-length", | ||
"severity": "error", | ||
"text": "Expected line length to be no more than 20 characters (max-line-length)", | ||
}, | ||
Object { | ||
"column": 2, | ||
"line": 224, | ||
"column": 15, | ||
"line": 223, | ||
"rule": "max-line-length", | ||
"severity": "error", | ||
"text": "Expected line length to be no more than 20 characters (max-line-length)", | ||
}, | ||
Object { | ||
"column": 23, | ||
"column": 16, | ||
"line": 225, | ||
"rule": "max-line-length", | ||
"severity": "error", | ||
"text": "Expected line length to be no more than 20 characters (max-line-length)", | ||
}, | ||
Object { | ||
"column": 7, | ||
"line": 232, | ||
"column": 4, | ||
"line": 231, | ||
"rule": "max-line-length", | ||
"severity": "error", | ||
"text": "Expected line length to be no more than 20 characters (max-line-length)", | ||
}, | ||
Object { | ||
"column": 14, | ||
"column": 7, | ||
"line": 235, | ||
"rule": "max-line-length", | ||
"severity": "error", | ||
"text": "Expected line length to be no more than 20 characters (max-line-length)", | ||
}, | ||
Object { | ||
"column": 2, | ||
"line": 238, | ||
"column": 14, | ||
"line": 237, | ||
"rule": "max-line-length", | ||
"severity": "error", | ||
"text": "Expected line length to be no more than 20 characters (max-line-length)", | ||
}, | ||
Object { | ||
"column": 6, | ||
"line": 241, | ||
"column": 1, | ||
"line": 240, | ||
"rule": "max-line-length", | ||
"severity": "error", | ||
"text": "Expected line length to be no more than 20 characters (max-line-length)", | ||
}, | ||
Object { | ||
"column": 1, | ||
"line": 244, | ||
"column": 22, | ||
"line": 243, | ||
"rule": "max-line-length", | ||
"severity": "error", | ||
"text": "Expected line length to be no more than 20 characters (max-line-length)", | ||
|
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.
Unfortunately, I do not think this regexp is exact enough. for example,
@import 'svg-something<id="horse">';
will become@important ">';
, right?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.
Thanks @davidtheclark, I think what I have is OK (for my sanity I use http://regexr.com/ to test/explain regexes). There is probably room for improvement as I'm not the greatest regex architect.
Using
\@import\s+['"].*['"]
and replacing with@import
With this string:
@import 'svg-something<id="horse">';
Results in
@import ;
(There is a single space between thet
and;
)I've added a test to accept that the length of this
@import 'svg-something<id=\"horse\">' projection;
string is 20 characters or under, stripping'svg-something<id=\"horse\">'
leaves@import projection;
which is exactly 20 characters in length.I've also added a failing test using
@import 'svg-something<id=\"horse\">' screens, tv;
which once stripping'svg-something<id=\"horse\">'
leaves@import screens, tv;
which is 21 characters in length.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.
Ooooo, I think my misunderstanding was in forgetting that the
*
is non-greedy by default, so the last['"]
will match the last possible quotation mark instead of first one it finds. You're right: carry on!