Skip to content

Commit

Permalink
fix: add new line to unknown tag
Browse files Browse the repository at this point in the history
issue: #204
  • Loading branch information
hosseinmd committed Oct 3, 2023
1 parent 384709f commit cdbf931
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/stringify.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { Spec } from "comment-parser";
import { formatDescription, descriptionEndLine } from "./descriptionFormatter.js";
import {
formatDescription,
descriptionEndLine,
} from "./descriptionFormatter.js";
import {
DESCRIPTION,
EXAMPLE,
Expand Down Expand Up @@ -123,6 +126,8 @@ const stringify = async (
TAGS_PEV_FORMATE_DESCRIPTION.includes(tag) ||
!TAGS_ORDER.includes(tag)
) {
description = description.trimEnd();

// Avoid wrapping
descriptionString = description;
} else {
Expand Down
22 changes: 22 additions & 0 deletions tests/__snapshots__/tagGroup.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,25 @@ exports[`Tag group 1`] = `
*/
"
`;
exports[`space after unknownTag 1`] = `
"/**
* A description.
*
* @unknownTag A note.
*
* @see http://acme.com
*/
"
`;
exports[`space between note and see 1`] = `
"/**
* A description.
*
* @notDefinedTag A note.
*
* @see http://acme.com
*/
"
`;
53 changes: 53 additions & 0 deletions tests/tagGroup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,56 @@ test("Tag group", async () => {

expect(result).toMatchSnapshot();
});

test("space after unknownTag", async () => {
function _subject(str: string) {
return subject(str, {
arrowParens: "always",
bracketSameLine: false,
bracketSpacing: true,
embeddedLanguageFormatting: "auto",
endOfLine: "lf",
htmlWhitespaceSensitivity: "css",
insertPragma: false,
jsxSingleQuote: true,
printWidth: 180,
proseWrap: "preserve",
quoteProps: "preserve",
requirePragma: false,
semi: true,
singleAttributePerLine: false,
singleQuote: true,
tabWidth: 4,
trailingComma: "all",
useTabs: true,
vueIndentScriptAndStyle: true,

jsdocAddDefaultToDescription: false,
jsdocCapitalizeDescription: true,
jsdocDescriptionTag: false,
jsdocDescriptionWithDot: true,
jsdocKeepUnParseAbleExampleIndent: false,
jsdocLineWrappingStyle: "greedy",
jsdocPreferCodeFences: false,
jsdocPrintWidth: 120,
jsdocSeparateReturnsFromParam: false,
jsdocSeparateTagGroups: true,
jsdocSingleLineComment: false,
jsdocSpaces: 1,
jsdocVerticalAlignment: true,
tsdoc: false,
});
}
const result = await _subject(`
/**
*
* A description.
*
* @unknownTag A note.
*
* @see http://acme.com
*/
`);

expect(await _subject(await _subject(result))).toMatchSnapshot();
});

0 comments on commit cdbf931

Please sign in to comment.