Skip to content
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

Split regex and extend tests #18

Merged
merged 4 commits into from
Sep 4, 2024
Merged

Split regex and extend tests #18

merged 4 commits into from
Sep 4, 2024

Conversation

fregante
Copy link
Collaborator

@fregante fregante commented Sep 4, 2024

Splitting the regex makes it much easier to edit.

If this isn't well-liked, I propose one of:

  • Have a build (even manual) so that you can edit this version but ship a regex literal
  • Use snapshots so that the full readable regex appears somewhere on the repo

'foo/...#123',
'#123',
'#999',
Copy link
Collaborator Author

@fregante fregante Sep 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side note: The tests are really hard to parse when one is missing, the whole "diff" breaks and it's not really clear what's - and what's +.

This is why I changes a couple to avoid the repetitive 123

I'll look for an alternative later maybe.

Edit: done: #19

index.js Outdated
export default function issueRegex() {
return /(?<!\w)(?:(?<organization>[a-z\d](?:[a-z\d-]{0,37}[a-z\d])?)\/(?<repository>[\w.-]{1,100}))?(?<!(?:\/\.{1,2}))#(?<issueNumber>[1-9]\d{0,9})\b/gi;
return new RegExp(
`${initialDelimiter}(?:${organization}\\/${repository})?${reservedRepository}#${issueNumber}\\b`,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick, but this could be a top-level string variable.

@sindresorhus
Copy link
Owner

This looks fine to me.

@fregante
Copy link
Collaborator Author

fregante commented Sep 4, 2024

By the way I may have found some bugs while reworking the tests, so if you do your Node 18 / dependency update commit I’ll follow up with the test updates. #16 would have to wait.

@sindresorhus sindresorhus merged commit 4fe4297 into main Sep 4, 2024
2 checks passed
@sindresorhus sindresorhus deleted the split-regex branch September 4, 2024 17:48
@sindresorhus
Copy link
Owner

so if you do your Node 18

Are we planning any other breaking changes? If not, I don't see the strong need to do a major update just for Node.js 18.

@fregante
Copy link
Collaborator Author

fregante commented Sep 5, 2024

Just this: https://github.com/xojs/xo/releases/tag/v0.57.0

But the solution is to stay on XO 0.56

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants