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

Trailing commas added to generated modes #56

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

yescorp
Copy link
Collaborator

@yescorp yescorp commented Apr 10, 2023

No description provided.

@@ -67,7 +71,7 @@ export function generateMode(
code += `${k}: ${JSON.stringify(v)}`;
}

if (i < arr.length - 1) {
if (i < arr.length) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we just drop the condition?

Comment on lines 61 to 65
if (arr.length != 0) {
code += `${k}: [${arr.join(",")},]`;
break;
}
code += `${k}: []`;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (arr.length != 0) {
code += `${k}: [${arr.join(",")},]`;
break;
}
code += `${k}: []`;
if (arr.length === 0) {
code += `${k}: []`;
break;
}
code += `${k}: [${arr.join(",")},]`;

"void",
"while",
"with",
"yield"
Copy link
Contributor

Choose a reason for hiding this comment

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

Not complete yet.

Copy link
Contributor

Choose a reason for hiding this comment

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

Keywords are dumped with JSON.stringify() which does not add trailing commas. We need a replacement to it that does. There must be 3rd party packages for this. This may also reduce special cases elsewhere, like arr.length === 0 in variants.

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