Skip to content

Do not append trailing spaces to JSDoc tags #1231

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 4 commits into from
Jul 21, 2023

Conversation

tkrotoff
Copy link
Contributor

@tkrotoff tkrotoff commented Jul 20, 2023

Before:

/**
 * A title <== Trailing space here
 * @description A description
 */

After:

/**
 * A title <== No trailing space
 * @description A description
 */

@changeset-bot
Copy link

changeset-bot bot commented Jul 20, 2023

🦋 Changeset detected

Latest commit: b3c3508

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

This PR includes changesets to release 1 package
Name Type
openapi-typescript 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

@tkrotoff tkrotoff force-pushed the remove-trailing-spaces branch from 7878da3 to 3a9b1bb Compare July 20, 2023 20:19
if (v.format) output.push(`Format: ${v.format} `);
if (v.title) output.push(v.title);
if (v.summary) output.push(v.summary);
if (v.format) output.push(`Format: ${v.format}`);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The comment function already does the job of adding a trailing space in case of a single-line comment

@tkrotoff tkrotoff marked this pull request as draft July 20, 2023 20:32
@tkrotoff tkrotoff marked this pull request as ready for review July 21, 2023 10:26
Copy link
Contributor

@drwpow drwpow left a comment

Choose a reason for hiding this comment

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

This is such a small detail but has a really big impact! Thank you for fixing this.

"lint": "run-p -s lint:*",
"lint:js": "eslint \"src/**/*.{js,ts}\"",
"lint:prettier": "prettier --check \"src/**/*\"",
"lint:js": "eslint 'src/**/*.{js,ts}'",
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
"lint:js": "eslint 'src/**/*.{js,ts}'",
"lint:js": "eslint \"src/**/*.{js,ts}\"",

We actually want to keep the escaped double quotes. Though *nix and mac users can run this just fine, IIRC Windows contributors run into problems with single quotes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is such a minor thing, I’ll revert this after merge, but won’t touch anything else. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry for that I always work on a UNIX OS and though the scripts without escaped quotes look nicer.

Copy link
Contributor

Choose a reason for hiding this comment

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

oh no worries at all. I did the same thing until I had Windows users complain 😛 (and I agree with you)

@@ -55,13 +55,13 @@ export function getSchemaObjectComment(v: CommentObject, indentLv?: number): str
const output: string[] = [];

// * Not JSDOC tags: [title, format]
if (v.title) output.push(`${v.title} `);
if (v.summary) output.push(`${v.summary} `);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think some of these string escapes mostly came from fields that could contain non-strings, but I think that was really only example. I don’t see the harm in removing the string escapes.

@@ -112,4 +112,60 @@ describe("utils", () => {
expect(escObjKey("_ref_")).toStrictEqual("_ref_");
});
});

describe("comment", () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Great tests 👏

@drwpow drwpow merged commit e1ce2d6 into openapi-ts:main Jul 21, 2023
@github-actions github-actions bot mentioned this pull request Jul 21, 2023
@tkrotoff tkrotoff deleted the remove-trailing-spaces branch July 21, 2023 16:16
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