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
Fix up vendor regex for bootstrap #6410
Fix up vendor regex for bootstrap #6410
Conversation
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.
regexp looks accurate.
I don't know if matching across slashes is doing useful work for us though. bootstrap*/*.css
is a thing that exists out there, I found some in Blackbird that I guess slipped past the current regex. css under a "bootstrap" dir; some other files
Pinging you for review @Alhadis as our resident regex guru 🙇♂️ (no rush) |
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 don't believe that's correct or intended. This vendor rule should target bootstrap artefacts specifically (not entire directories).
IIRC, popular Bootstrap components like styled form components are often bundled alongside the core Bootstrap files themselves (so, stuff like bootstrap/components/datepicker/**/*.{css,js}
).
I could easily be wrong, however, as I've never actually used Bootstrap before (or anything resembling it). Ergo, I trust your familiarity with Bootstrap over mine.
That's true! Looking at the links that @jorendorff posted though, there is a real mix of original js/css content nested inside directories named I ended up proposing this change in part because the lookahead in this regex isn't very portable to linguist clones that are using different regex engines (and it's the only vendor regex that uses that lookahead). In investigating and writing some tests it then also seemed like the current regex was making some arbitrary choices as documented in the main PR description. I'm open to some further discussion here on how to best detect what is actually vendored twbs vs. what is code in a subdirectory of |
In that case, I'd replace
Unfortunately, no. It's impossible to distinguish vendored components from original (or heavily-modified) ones. There's really not much we can do, other than encourage authors to manually unvendor files on a case-by-case basis. |
We came up with replacing |
Ugh, did I really write
I think it's fine. 👍 I was about to suggest you use |
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.
@tclem yup, this looks good to me. I tend to merge PRs only close to when I make a release to keep changes to a minimum in the event there is a need for a quick patch fix release. I’m aiming for a new release early June once everything has settled down on GitHub.
The current regex for detecting if bootstrap is vendored is too broad and overly complicated (uses lookahead). I believe the intent is only to match bootstrap files (not entire directories), but I've written a few more test to demonstrate what should and should not be detected as vendored here.
The current regex looks like this:
(^|/)bootstrap([^/.]*)(?=\.).*\.(js|css|less|scss|styl)$
As written, this would be considered vendored:
bootstrap-1.4/misc/other/reset.css
But this would not:
bootstrap/misc/other/reset.css
I don't believe that's correct or intended. This vendor rule should target bootstrap artifacts specifically (not entire directories). Some history in #5745 and #5957.
The proposal is to only match on the filename (and allow filenames that include
.
).Checklist: