Skip to content

feat: biomejs 2 migration #1874

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

Merged
merged 5 commits into from
Jun 18, 2025
Merged

feat: biomejs 2 migration #1874

merged 5 commits into from
Jun 18, 2025

Conversation

setchy
Copy link
Member

@setchy setchy commented Jun 17, 2025

Biome v2 just launched - https://biomejs.dev/blog/biome-v2/

This PR migrates cdxgen to biome2 using their migration cli.

In addition, I have configured the organize import action to group imports into node, packages, all other, separated by a new line

Signed-off-by: Adam Setch <adam.setch@outlook.com>
@setchy setchy requested a review from prabhu as a code owner June 17, 2025 16:53
@setchy setchy added the dependency Dependency updates label Jun 17, 2025
Signed-off-by: Adam Setch <adam.setch@outlook.com>
@prabhu prabhu requested review from malice00 and removed request for prabhu June 17, 2025 17:06
setchy added 2 commits June 17, 2025 15:01
Signed-off-by: Adam Setch <adam.setch@outlook.com>
Signed-off-by: Adam Setch <adam.setch@outlook.com>
@malice00
Copy link
Collaborator

Thanks for the PR!

Comment on lines 8452 to 8454
...statement.matchAll(/\${?([^:\/\\}]+)}?/g),
...statement.matchAll(/\${?([^:/\\}]+)}?/g),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are you sure this shouldn't be escaped?

Comment on lines 9015 to 9017
const separatorRegex = /[@#:\/]/;
const separatorRegex = /[@#:/]/;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here...

Comment on lines 9165 to 9167
if (l.match(/^[^\s\/]+\/\S+/)) {
if (l.match(/^[^\s/]+\/\S+/)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

And again

Comment on lines 9397 to 9399
versionStr = versionStr.replace(/[\[\]]/g, "");
versionStr = versionStr.replace(/[[\]]/g, "");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Another one

Copy link
Collaborator

Choose a reason for hiding this comment

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

as per chatgpt first one is correct.

The first one is the correct (and idiomatic) way to strip literal [ and ] characters:

versionStr = versionStr.replace(/[\[\]]/g, "");

Why?
	•	Inside a character class [...], you need to escape both [ and ] so the engine doesn’t treat them as the class delimiters.
	•	[\[\]] defines “match either \[ (literal [) or \] (literal ]).”
	•	The alternate /[[\]]/ is confusing to read (and could be rejected by some engines), since the unescaped [ at the start of the class looks like it’d open a nested class.

Stick with /[\[\]]/g.

@setchy
Copy link
Member Author

setchy commented Jun 17, 2025

@malice00 - all of those regex changes you spotted where from biome applying it's auto linting/formatter fixes.

@prabhu
Copy link
Collaborator

prabhu commented Jun 17, 2025

@setchy can we ignore those regex auto-linting rules? We don't have time to test across ecosystems and there is a risk these could create regressions.

Signed-off-by: Adam Setch <adam.setch@outlook.com>
@setchy
Copy link
Member Author

setchy commented Jun 17, 2025

@setchy can we ignore those regex auto-linting rules? We don't have time to test across ecosystems and there is a risk these could create regressions.

Yes, i have pushed an update which disables the noUselessEscapeInRegex rule

@malice00
Copy link
Collaborator

OK, finally all actions are green! Merging now. 😄

@malice00 malice00 merged commit 4971490 into CycloneDX:master Jun 18, 2025
80 of 81 checks passed
import {
CARGO_CMD,
DEBUG_MODE,
DOTNET_CMD,
GCC_CMD,
GO_CMD,
getJavaCommand,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is an interesting decision to sort ignoring the case.

@@ -5,7 +5,11 @@
"packageManager": "yarn@4.0.0-rc.50",
"type": "module",
"license": "MIT",
"workspaces": ["app", "edge", "scripts"],
"workspaces": [
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is fine, but can we exclude biome from touching the test data?

@prabhu
Copy link
Collaborator

prabhu commented Jun 18, 2025

@setchy, wdyt about ignoring test and contrib folders in biome?

@setchy
Copy link
Member Author

setchy commented Jun 18, 2025

@setchy, wdyt about ignoring test and contrib folders in biome?

Personally I'd want all files in a repository to apply the same formatter and linter rules

@prabhu
Copy link
Collaborator

prabhu commented Jun 18, 2025

Interesting. ok, let's keep as-is and revisit incase it breaks any tests or cause confusion.

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

Successfully merging this pull request may close these issues.

3 participants