-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
Support negated ignore patterns #70
base: main
Are you sure you want to change the base?
Conversation
commit: |
oh, wow. first of all, thanks a lot for taking your time into implementing this, such a nice solution. how would patching picomatch work for users who download tinyglobby from npm? sadly, i don't think patching it is viable long term, but we can figure out something else or send a PR to picomatch |
Oh no, bad idea indeed, this wasn't my intention at all
Yes, this PR is mostly to keep the conversation going. And for you and others the ability to actually try it out e.g. when looking to migrate away from globby and see if this is a viable route. Would you be interested in this solution given that picomatch would accept my PR? Tbh I don't fancy publishing (and maintaining) a fork of picomatch, so I'm not sure what other options we have here. |
i think i'm fine with anything that doesn't involve patching, whether it is a picomatch PR or something more complex |
Sorry I phrased that poorly. With "this solution" I meant this PR without the patch part. Thanks! WIP. |
i think so? i think i can see some things that could be refactored (unsure though) and probably needs a small cleanup when that happens but other than that yes |
Here's the PR: micromatch/picomatch#137 |
39fe550
to
6d8fcbd
Compare
When this is ready we should test it against cspell to make sure we don't break it since it uses a negated ignore pattern and the behavior here will be changing |
6d8fcbd
to
b603afc
Compare
Rebased the changes in this PR on top of |
Since the picomatch repo doesn't seem to have a lot of motion anymore I'd be OK with using my fork unmatch (which is in this PR already).
Sometimes a fix means a breaking change, and that's OK? As long as we're clear about it. |
I'm not sure I like the idea of using a fork of picomatch. picomatch itself dedupes really well. If we use a fork then it won't dedupe. It might be interesting to try also supporting Node's built-in matcher as an optional second matcher since that doesn't add a dep and it will be in all LTS in April |
Forking is some sort of last resort. Rest assured I don't fancy it either, but I'm OK with maintaining it so users can enjoy tinyglobby to the greatest extend possible as I believe it's a great initiative. Then I guess the alternative is to be more transparent about the fact that tinyglobby isn't a drop-in replacement of globby. Would also love to start using tinyglobby in Knip and other projects, and I could imagine plenty of maintainers relying on globby to be in the same boat. Globby features the This PR with the fork does not even add support for
Do you think by relying on picomatch the situation will improve overall? Different users value different aspects.
Indeed, the Node.js built-in glob matcher has an Could easily agree using a fork is a price too high to pay. But then in the meantime, let's update the docs with the fact that tinyglobby does not have an option to respect |
Is this PR enough to use tinyglobby in knip? You need streaming support first, right? (#24). Perhaps we should focus there first as that's needed by multiple projects |
Tbh, the |
This isn't about Knip, but rather about whether tinyglobby wants to be a fully featured replacement for globby. Here's a GitHub Search to give a very rough idea of usage: https://github.com/search?q=globby+%22gitignore%3A+true%22+%28language%3ATypeScript+OR+language%3AJavaScript%29&type=code I appreciate the team has the information to decide on their own terms. My offer to maintain and improve the fork still stands whenever you might need it. |
So it's either:
|
I've filed an issue to discuss the gitignore issue: #92 |
Fixes #32
This PR adds support for negated ignore patterns. Please see #32 for more details and use cases.
This is a solution that should not impact performance at all if no negated ignore patterns are used. However, it does require a patched picomatch, and I'm not sure whether there's interest in a PR upstream. But before I'm even trying to go there I wanted to gauge interest here.
The idea/patch: we could leverage picomatch's
onIgnore
function to un-ignore if ignored matches also match a negated ignore pattern.The problem: it requires to un-ignore matches within picomatch and this is a relatively low-impact solution for picomatch, but I'm afraid even requiring an explicit
true
(orfalse
?) return value might still be a breaking change looking at the scale it's being used. Yet at the same time it could also actually mean a fix in certain cases and removing a major hurdle when looking to migrate from globby to tinyglobby.This PR still needs some work:
result.output
tounignoreMatcher
? I also sawresult.input
and I'm not sure about the difference.picomatch
when creatingunignoreMatcher
.