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

Allow empty groups #208

Merged
merged 3 commits into from
Mar 5, 2024
Merged

Conversation

james-nash
Copy link
Contributor

@james-nash james-nash commented Mar 5, 2024

Changes

Makes the parser log a warning instead of an error when it encounters an empty group. Closes #206.

How to Review

Refer to the discussion in #206 for the rationale behind this change in behaviour.

I added a regression test that fails without this fix and passes with it. However, I'm not sure if the expect(tokens.length).toBe(0) line is really needed, as getTokens() already has an expect() assertion to check that there were no parsing errors. It felt a bit weird having a test without an expect() in it though, so I added that. Happy to remove it, if you think that's cleaner / clearer.

Since this is a bug fix, I've classed it as a patch change in the changeset.

Copy link

changeset-bot bot commented Mar 5, 2024

🦋 Changeset detected

Latest commit: 029a160

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cobalt-ui/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

"@cobalt-ui/core": patch
---

Allows DTCG files to contain empty groups. Previously they would cause a parsing error, now only a warning will be logged.
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍 Perfect! Agreed this should just be a patch.

@@ -42,6 +42,15 @@ describe('5. Group', () => {
const tokens = getTokens(json);
expect(tokens.find((t) => t.id === 'color.blue')!.$type).toBe('color');
});

test('allow empty', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice test!

@drwpow
Copy link
Collaborator

drwpow commented Mar 5, 2024

This is great, thank you! After this merges, changeset will ship it to npm. 🎉

@drwpow drwpow merged commit 12f4127 into terrazzoapp:main Mar 5, 2024
7 checks passed
@github-actions github-actions bot mentioned this pull request Mar 5, 2024
@james-nash
Copy link
Contributor Author

Hurray! Thanks for the quick review & release. Much appreciated.

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.

Allow empty groups?
2 participants