Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

prettier-plugin-jsdoc

Package Overview
Dependencies
Maintainers
1
Versions
105
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prettier-plugin-jsdoc - npm Package Compare versions

Comparing version
1.3.2
to
1.3.3
+7
-0
CHANGELOG.md

@@ -5,2 +5,9 @@ # Changelog

### [1.3.3](https://github.com/hosseinmd/prettier-plugin-jsdoc/compare/v1.3.2...v1.3.3) (2025-07-01)
### Bug Fixes
* add compatibility with prettier v3.6.0 ([#246](https://github.com/hosseinmd/prettier-plugin-jsdoc/issues/246)) ([a50b62e](https://github.com/hosseinmd/prettier-plugin-jsdoc/commit/a50b62e931c736d9408723f2959b1b5d137dbbed))
### [1.3.1](https://github.com/hosseinmd/prettier-plugin-jsdoc/compare/v1.3.0...v1.3.1) (2025-01-03)

@@ -7,0 +14,0 @@

+5
-2

@@ -51,3 +51,2 @@ import prettier from "prettier";

readonly choices: {
since?: string | undefined;
value: any;

@@ -113,3 +112,2 @@ description: string;

readonly choices: {
since?: string | undefined;
value: any;

@@ -137,2 +135,3 @@ description: string;

hasPragma?: ((text: string) => boolean) | undefined;
hasIgnorePragma?: ((text: string) => boolean) | undefined;
locStart: (node: any) => number;

@@ -146,2 +145,3 @@ locEnd: (node: any) => number;

hasPragma?: ((text: string) => boolean) | undefined;
hasIgnorePragma?: ((text: string) => boolean) | undefined;
locStart: (node: any) => number;

@@ -155,2 +155,3 @@ locEnd: (node: any) => number;

hasPragma?: ((text: string) => boolean) | undefined;
hasIgnorePragma?: ((text: string) => boolean) | undefined;
locStart: (node: any) => number;

@@ -164,2 +165,3 @@ locEnd: (node: any) => number;

hasPragma?: ((text: string) => boolean) | undefined;
hasIgnorePragma?: ((text: string) => boolean) | undefined;
locStart: (node: any) => number;

@@ -174,2 +176,3 @@ locEnd: (node: any) => number;

hasPragma?: ((text: string) => boolean) | undefined;
hasIgnorePragma?: ((text: string) => boolean) | undefined;
locStart: (node: any) => number;

@@ -176,0 +179,0 @@ locEnd: (node: any) => number;

@@ -55,3 +55,2 @@ import { getParser } from "./parser.js";

{
since: "1.1.0",
value: "singleLine",

@@ -61,3 +60,2 @@ description: `Should compact single line comment, if possible`,

{
since: "1.1.0",
value: "multiline",

@@ -67,3 +65,2 @@ description: `Should compact multi line comment`,

{
since: "1.1.0",
value: "keep",

@@ -131,3 +128,2 @@ description: `Should keep original line comment`,

{
since: "0.3.39",
value: "greedy",

@@ -134,0 +130,0 @@ description: `Lines wrap as soon as they reach the print width`,

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('comment-parser'), require('prettier'), require('binary-searching'), require('mdast-util-from-markdown'), require('prettier/plugins/babel'), require('prettier/plugins/flow'), require('prettier/plugins/typescript')) :
typeof define === 'function' && define.amd ? define(['exports', 'comment-parser', 'prettier', 'binary-searching', 'mdast-util-from-markdown', 'prettier/plugins/babel', 'prettier/plugins/flow', 'prettier/plugins/typescript'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.sayHello = {}, global.commentParser, global.prettier, global.BSearch, global.mdastUtilFromMarkdown, global.parserBabel, global.parserFlow, global.parserTypescript));
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.sayHello = {}, global.commentParser, global.prettier, null, global.mdastUtilFromMarkdown, global.parserBabel, global.parserFlow, global.parserTypescript));
})(this, (function (exports, commentParser, prettier, BSearch, mdastUtilFromMarkdown, parserBabel, parserFlow, parserTypescript) { 'use strict';

@@ -9,3 +9,2 @@

var BSearch__default = /*#__PURE__*/_interopDefaultLegacy(BSearch);
var parserBabel__default = /*#__PURE__*/_interopDefaultLegacy(parserBabel);

@@ -331,12 +330,2 @@ var parserFlow__default = /*#__PURE__*/_interopDefaultLegacy(parserFlow);

}
function findTokenIndex(tokens, token) {
return BSearch__default["default"].eq(tokens, token, (a, b) => {
if (a.loc.start.line === b.loc.start.line) {
return a.loc.start.column - b.loc.start.column;
}
else {
return a.loc.start.line - b.loc.start.line;
}
});
}
async function formatCode(result, beginningSpace, options) {

@@ -380,2 +369,4 @@ const { printWidth, jsdocKeepUnParseAbleExampleIndent } = options;

return (typeof plugin === "object" &&
plugin !== null &&
!(plugin instanceof URL) &&
plugin.name &&

@@ -759,4 +750,3 @@ plugin.parsers &&

return;
const tokenIndex = findTokenIndex(ast.tokens, comment);
const paramsOrder = getParamsOrders(ast, tokenIndex);
const paramsOrder = getParamsOrders(text, comment);
const originalValue = comment.value;

@@ -1029,56 +1019,58 @@ comment.value = comment.value.replace(/^([*]+)/g, "*");

}
function getParamsOrders(ast, tokenIndex) {
let params;
function getParamsOrders(text, comment) {
try {
const nextTokenType = ast.tokens[tokenIndex + 1]?.type;
if (typeof nextTokenType !== "object") {
return undefined;
const lines = text.split("\n");
let commentEnd = 0;
for (let i = 0; i < comment.loc.end.line - 1; i++) {
commentEnd += lines[i].length + 1;
}
if (nextTokenType.label === "function") {
let openedParenthesesCount = 1;
const tokensAfterComment = ast.tokens.slice(tokenIndex + 4);
const endIndex = tokensAfterComment.findIndex(({ type }) => {
if (typeof type === "string") {
return false;
}
else if (type.label === "(") {
openedParenthesesCount++;
}
else if (type.label === ")") {
openedParenthesesCount--;
}
return openedParenthesesCount === 0;
});
params = tokensAfterComment.slice(0, endIndex + 1);
commentEnd += comment.loc.end.column;
const textAfterComment = text.slice(commentEnd);
const functionMatch = textAfterComment.match(/^\s*function\s+\w*\s*\(([^)]*)\)/);
if (functionMatch) {
const paramsString = functionMatch[1];
const params = paramsString
.split(",")
.map((param) => {
const trimmed = param.trim();
const colonIndex = trimmed.indexOf(":");
const paramName = colonIndex > -1 ? trimmed.slice(0, colonIndex) : trimmed;
return paramName.split(/\s+/)[0].replace(/[{}[\]]/g, "");
})
.filter((param) => param && param !== "...");
return params;
}
if (nextTokenType.label === "const") {
let openedParenthesesCount = 1;
let tokensAfterComment = ast.tokens.slice(tokenIndex + 1);
const firstParenthesesIndex = tokensAfterComment.findIndex(({ type }) => typeof type === "object" && type.label === "(");
tokensAfterComment = tokensAfterComment.slice(firstParenthesesIndex + 1);
const endIndex = tokensAfterComment.findIndex(({ type }) => {
if (typeof type === "string") {
return false;
}
else if (type.label === "(") {
openedParenthesesCount++;
}
else if (type.label === ")") {
openedParenthesesCount--;
}
return openedParenthesesCount === 0;
});
const arrowItem = tokensAfterComment[endIndex + 1];
if (typeof arrowItem?.type === "object" &&
arrowItem.type.label === "=>") {
params = tokensAfterComment.slice(0, endIndex + 1);
}
const arrowMatch = textAfterComment.match(/^\s*(?:const|let|var)\s+\w+\s*=\s*\(([^)]*)\)\s*=>/);
if (arrowMatch) {
const paramsString = arrowMatch[1];
const params = paramsString
.split(",")
.map((param) => {
const trimmed = param.trim();
const colonIndex = trimmed.indexOf(":");
const paramName = colonIndex > -1 ? trimmed.slice(0, colonIndex) : trimmed;
return paramName.split(/\s+/)[0].replace(/[{}[\]]/g, "");
})
.filter((param) => param && param !== "...");
return params;
}
return params
?.filter(({ type }) => typeof type === "object" && type.label === "name")
.map(({ value }) => value);
const methodMatch = textAfterComment.match(/^\s*(\w+)\s*\(([^)]*)\)/);
if (methodMatch) {
const paramsString = methodMatch[2];
const params = paramsString
.split(",")
.map((param) => {
const trimmed = param.trim();
const colonIndex = trimmed.indexOf(":");
const paramName = colonIndex > -1 ? trimmed.slice(0, colonIndex) : trimmed;
return paramName.split(/\s+/)[0].replace(/[{}[\]]/g, "");
})
.filter((param) => param && param !== "...");
return params;
}
return undefined;
}
catch {
catch (error) {
return undefined;
}
return;
}

@@ -1188,3 +1180,2 @@ function addDefaultValueToDescription(tag) {

{
since: "1.1.0",
value: "singleLine",

@@ -1194,3 +1185,2 @@ description: `Should compact single line comment, if possible`,

{
since: "1.1.0",
value: "multiline",

@@ -1200,3 +1190,2 @@ description: `Should compact multi line comment`,

{
since: "1.1.0",
value: "keep",

@@ -1264,3 +1253,2 @@ description: `Should keep original line comment`,

{
since: "0.3.39",
value: "greedy",

@@ -1267,0 +1255,0 @@ description: `Lines wrap as soon as they reach the print width`,

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("comment-parser"),require("prettier"),require("binary-searching"),require("mdast-util-from-markdown"),require("prettier/plugins/babel"),require("prettier/plugins/flow"),require("prettier/plugins/typescript")):"function"==typeof define&&define.amd?define(["exports","comment-parser","prettier","binary-searching","mdast-util-from-markdown","prettier/plugins/babel","prettier/plugins/flow","prettier/plugins/typescript"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).sayHello={},e.commentParser,e.prettier,e.BSearch,e.mdastUtilFromMarkdown,e.parserBabel,e.parserFlow,e.parserTypescript)}(this,(function(e,t,n,r,a,s,i,o){"use strict";function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=c(r),p=c(s),d=c(i),u=c(o);const g="abstract",f="borrows",m="callback",h="category",y="class",j="constant",b="default",$="defaultValue",w="deprecated",S="description",v="example",x="extends",W="external",k="file",D="fires",L="function",P="ignore",T="license",C="member",A="memberof",O="module",E="namespace",F="overload",I="override",M="param",_="privateRemarks",z="property",R="remarks",q="returns",U="since",K="throws",V="todo",G="type",B="typedef",H="satisfies",J="yields",N={tag:"this_is_for_space",name:"",optional:!1,type:"",description:"",source:[],problems:[]},Y={arg:M,argument:M,const:j,constructor:y,desc:S,emits:D,examples:v,exception:K,fileoverview:k,func:L,host:W,method:L,overview:k,params:M,prop:z,return:q,var:C,virtual:g,yield:J,hidden:P},Q=[b,$],X=[f,h,w,S,v,x,T,O,E,F,I,_,R,q,U,K,V,J,k,...Q],Z=[f,f,w,S,v,P,T,O,E,F,I,_,R,U,V,k],ee=[f,...Q,A,O,"see"],te=[f,h,S,v,_,R,U,V],ne=[x,M,z,q,K,G,H,B,J],re=[m,B],ae=[...re,G,z,M,q,J,K],se={[R]:1,[_]:2,providesModule:3,[O]:4,[T]:5,flow:6,async:7,private:8,[P]:9,[A]:10,version:11,[k]:12,author:13,[w]:14,[U]:15,[h]:16,[S]:17,[v]:18,[g]:19,augments:20,[j]:21,[b]:22,[$]:23,[W]:24,[F]:25,[D]:26,template:27,typeParam:28,[L]:29,[E]:30,[f]:31,[y]:32,[x]:33,[C]:34,[B]:35,[G]:36,[H]:37,[z]:38,[m]:39,[M]:40,[J]:41,[q]:42,[K]:43,other:44,see:45,[V]:46};function ie(e,t){return(e.match(new RegExp(t,"g"))||[]).length}function oe(e){return e?e.match(/^https?:\/\//i)?e:e.startsWith("- ")?e.slice(0,2)+oe(e.slice(2)):e[0].toUpperCase()+e.slice(1):e}async function ce(e,t,r){const{printWidth:a,jsdocKeepUnParseAbleExampleIndent:s}=r;e.split("\n").slice(1).every((e=>!e.trim()||e.startsWith(t)))&&(e=e.replace(new RegExp(`\n${t.replace(/[\t]/g,"[\\t]")}`,"g"),"\n"));try{let s="";const i=a-4;s=e.trim().startsWith("{")?await n.format(e||"",{...r,parser:"json",printWidth:i}):await n.format(e||"",{...r,printWidth:i}),e=s.replace(/(^|\n)/g,`\n${t}`)}catch(n){e=(e=`\n${e.split("\n").map((e=>`${t}${s?e:e.trim()}`)).join("\n")}\n`).replace(/^\n[\s]+\n/g,"\n")}return e}const le=(e,t)=>{const n=t.plugins.find((t=>"object"==typeof t&&t.name&&t.parsers&&t.parsers.hasOwnProperty(e)));return!n||"prettier-plugin-jsdoc"===n.name||n.parsers?.hasOwnProperty("jsdoc-parser")?void 0:n.parsers?.[e]},pe=e=>Q.includes(e),de="2@^5!~#sdE!_TABLE";async function ue(e,t,r,s){if(!t)return t;const{printWidth:i}=r,{tagStringLength:o=0,beginningSpace:c}=s,l=[...(t=(t=t.replace(/^(\d+)[-][\s|]+/g,"$1. ")).replace(/\n+(\s*\d+)[-][\s]+/g,"\n$1. ")).matchAll(/```\S*?\n[\s\S]+?```/gm),...t.matchAll(/^\r?\n^(?:(?:(?:[ ]{4}|\t).*(?:\r?\n|$))+)/gm)],p=[];t=t.replace(/((\n|^)\|[\s\S]*?)((\n[^|])|$)/g,((e,t,n,r,a,s)=>{for(const t of l)if(void 0!==t.index&&t.index<=s+1&&s+e.length+1<=t.index+t[0].length)return e;return e=r?e.slice(0,-1):e,p.push(e),`\n\n${de}\n\n${r?r.slice(1):""}`})),r.jsdocCapitalizeDescription&&!ee.includes(e)&&(t=oe(t)),t=`${o?`${"!".repeat(o-1)}?`:""}${t.startsWith("```")?"\n":""}${t}`;let d=0;t=t.replace(new RegExp(`\\n[ ]{${c.length}}`,"g"),"\n");const u=a.fromMarkdown(t);let g=await async function t(a,s,o){return Array.isArray(a.children)?(await Promise.all(a.children.map((async(n,c)=>{switch(n.type){case"listItem":{let e=`\n${s}- `;if("number"==typeof a.start){const t=c+(a.start??1);e=`\n${s}${t}. `}const r=s+" ".repeat(e.length-1);return`${e}${(await t(n,r,a)).trim()}`}case"list":{let r="";return e!==S&&"root"===a.type&&c===a.children.length-1&&(r="\n"),`\n${await t(n,s,a)}${r}`}case"paragraph":{const a=await t(n,s,o);return n.costumeType===de?a:`\n\n${a.split("\\\n").map((t=>{const n=[];t=t.replace(/{@(link|linkcode|linkplain)[\s](([^{}])*)}/g,((e,t,r)=>(n.push(r),`{@${t}${"_".repeat(r.length)}}`))),t=t.replace(/\s+/g," "),r.jsdocCapitalizeDescription&&!ee.includes(e)&&(t=oe(t)),r.jsdocDescriptionWithDot&&(t=t.replace(/([\w\p{L}])$/u,"$1."));let a=function(e,t,n){let r=e.trim();if(!r)return r;let a="";for(;r.length>t;){let e=r.lastIndexOf(" ",r.startsWith("\n")?t+1:t);e<=n.length&&(e=r.indexOf(" ",n.length+1)),-1===e&&(e=r.length),a+=r.substring(0,e),r=r.substring(e+1),r&&(r=`${n}${r}`,r=`\n${r}`)}return a+=r,`${n}${a}`}(t,i,s);return a=a.replace(/{@(link|linkcode|linkplain)([_]+)}/g,((e,t,r)=>{const a=n[0];return a.length===r.length?(n.shift(),`{@${t} ${a}}`):e})),a})).join("\\\n")}`}case"strong":return`**${await t(n,s,a)}**`;case"emphasis":return`_${await t(n,s,a)}_`;case"heading":return`\n\n${s}${"#".repeat(n.depth)} ${await t(n,s,a)}`;case"link":case"image":return`[${await t(n,s,a)}](${n.url})`;case"linkReference":return`[${await t(n,s,a)}][${n.label}]`;case"definition":return`\n\n[${n.label}]: ${n.url}`;case"blockquote":return`\n\n> ${(await t(n,"",a)).trim().replace(/(\n+)/g,`$1${s}> `)}`}return t(n,s,a)})))).join(""):async function(e,t,a){if("inlineCode"===e.type)return`\`${e.value}\``;if("code"===e.type){let n=e.value||"",a=t;if(n)if(e.lang){const a=(e=>{switch(e){case"js":case"javascript":case"jsx":return["babel","babel-flow","vue"];case"ts":case"typescript":case"tsx":return["typescript","babel-ts","angular"];case"json":case"css":return["css"];case"less":return["less"];case"scss":return["scss"];case"html":return["html"];case"yaml":return["yaml"];default:return["babel"]}})(e.lang.toLowerCase()),s=a?.includes(r.parser)?r.parser:a?.[0]||e.lang;n=await ce(n,t,{...r,parser:s,jsdocKeepUnParseAbleExampleIndent:!0})}else r.jsdocPreferCodeFences||(a=t+" ".repeat(4)),n=await ce(n,a,{...r,jsdocKeepUnParseAbleExampleIndent:!0});const s=r.jsdocPreferCodeFences||!!e.lang;return n=s?n:n.trimEnd(),n?s?`\n\n${a}\`\`\`${e.lang||""}${n}\`\`\``:`\n${n}`:""}if(e.value===de&&(a&&(a.costumeType=de),p.length>0)){let a=p?.[d]||"";return d++,a&&(a=(await n.format(a,{...r,parser:"markdown"})).trim()),`${a?`\n\n${t}${a.split("\n").join(`\n${t}`)}`:e.value}`}return"break"===e.type?"\\\n":e.value||e.title||e.alt||""}(a,s,o)}(u,c,null);return g=g.replace(/^[\s\n]+/g,""),g=g.replace(/^([!]+\?)/g,""),g}const ge=async({name:e,description:t,type:n,tag:r},a,s,i,o,c,l)=>{let p="\n";if(r===N.tag)return p;const{printWidth:d,jsdocSpaces:u,jsdocVerticalAlignment:g,jsdocDescriptionTag:f,tsdoc:m,useTabs:h,tabWidth:y,jsdocSeparateTagGroups:j}=i,b=" ".repeat(u);let $=0,w=0,x=0,W=0;g&&ne.includes(r)&&(r?$+=o-r.length:o&&(W+=o+b.length),n?w+=c-n.length:c&&(W+=c+b.length),e?x+=l-e.length:l&&(W=l+b.length));const k=r!==S||f;if(k&&(p+=`@${r}${" ".repeat($||0)}`),n){p+=b+(()=>{if(!pe(r))return`{${n}}`;if("[]"===n)return"[ ]";if("{}"===n)return"{ }";return/^{.*[A-z0-9_]+ ?:.*}$/.test(n)?n.replace(/; ([A-z0-9_])/g,", $1"):n})()+" ".repeat(w)}if(e&&(p+=`${b}${e}${" ".repeat(x)}`),r!==v||m){if(t){let e="";if(k&&(p+=b+" ".repeat(W)),ee.includes(r)||!se[r])e=t;else{const[,n]=/^\s*(\S+)/.exec(t)||["",""],a=r===S||[v,R,_].includes(r)&&m?"":" ";e=r!==S&&p.length+n.length>d||[R,_].includes(r)?`\n${a}`+await ue(r,t,i,{beginningSpace:a}):await ue(r,t,i,{tagStringLength:p.length-1,beginningSpace:a})}j&&(e=e.trimEnd()),p+=e.startsWith("\n")?e.replace(/^\n[\s]+\n/g,"\n"):e.trimStart()}}else{const e=t.match(/<caption>([\s\S]*?)<\/caption>/i);e&&(t=t.replace(e[0],""),p=`${p} ${e[0]}`);const n=h?"\t":" ".repeat(y);p+=(await ce(t,n,i)).replace(new RegExp(`^\\n${n.replace(/[\t]/g,"[\\t]").replace(/[^S\r\n]/g,"[^S\\r\\n]")}\\n`),"").trimEnd()}return p+=function({tag:e,isEndTag:t}){return[S,v,V].includes(e)&&!t?"\n":""}({tag:r,isEndTag:a===s.length-1}),p},{name:fe,tag:me,type:he,description:ye}=t.tokenizers,je=(e,r)=>async function(a,s,i){let o=i??s;const c=(le(r,o)?.parse||e)(a,o);o={...o,printWidth:o.jsdocPrintWidth??o.printWidth};const p="auto"===o.endOfLine?function(e){const t={"\r":0,"\r\n":0,"\n":0},n=/\r\n?|\n/g;let r;for(;r=n.exec(e);)t[r[0]]++;const a=t["\r"],s=t["\r\n"],i=t["\n"],o=Math.max(a,s,i);return i===o?"lf":s===o?"crlf":"cr"}(a):o.endOfLine;return o={...o,endOfLine:"lf"},await Promise.all(c.comments.map((async e=>{if(!we(e))return;const r=(s=c.tokens,i=e,l.default.eq(s,i,((e,t)=>e.loc.start.line===t.loc.start.line?e.loc.start.column-t.loc.start.column:e.loc.start.line-t.loc.start.line)));var s,i;const d=function(e,t){let n;try{const r=e.tokens[t+1]?.type;if("object"!=typeof r)return;if("function"===r.label){let r=1;const a=e.tokens.slice(t+4),s=a.findIndex((({type:e})=>"string"!=typeof e&&("("===e.label?r++:")"===e.label&&r--,0===r)));n=a.slice(0,s+1)}if("const"===r.label){let r=1,a=e.tokens.slice(t+1);const s=a.findIndex((({type:e})=>"object"==typeof e&&"("===e.label));a=a.slice(s+1);const i=a.findIndex((({type:e})=>"string"!=typeof e&&("("===e.label?r++:")"===e.label&&r--,0===r))),o=a[i+1];"object"==typeof o?.type&&"=>"===o.type.label&&(n=a.slice(0,i+1))}return n?.filter((({type:e})=>"object"==typeof e&&"name"===e.label)).map((({value:e})=>e))}catch{}return}(c,r),u=e.value;e.value=e.value.replace(/^([*]+)/g,"*");const g=`/*${e.value.replace(/\r\n?/g,"\n")}*/`;if(!/^\/\*\*[\s\S]+?\*\/$/.test(g))return;const f=t.parse(g,{spacing:"preserve",tokenizers:[me(),e=>pe(e.tag)?e:he("preserve")(e),fe(),ye("preserve")]})[0];if(e.value="",!f)return;!function(e){e.tags=e.tags.map((({tag:e,type:t,name:n,description:r,default:a,...s})=>{e=e||"",t=t||"",n=n||"",r=r||"",a=a?.trim();const i=e.indexOf("{");-1!==i&&"}"===e[e.length-1]&&(t=e.slice(i+1,-1)+" "+t,e=e.slice(0,i));const o=(e=e.trim()).toLowerCase(),c=Se.findIndex((([e])=>e.toLowerCase()===o));return c>=0?e=Se[c][0]:o in Y&&(e=Y[o]),t=t.trim(),(n=n.trim())&&X.includes(e)&&(r=`${n} ${r}`,n=""),t&&Z.includes(e)&&(r=`{${t}} ${r}`,t=""),{tag:e,type:t,name:n,description:r,default:a,...s}}))}(f),function(e){let t=e.description||"";e.description="",e.tags=e.tags.filter((({description:e,tag:n})=>n.toLowerCase()!==S||(e.trim()&&(t+="\n\n"+e),!1))),t&&e.tags.unshift({tag:S,description:t,name:void 0,type:void 0,source:[],optional:!1,problems:[]})}(f);const m=function(e,t,n){const r=t.split(/\r\n?|\n/g)[e.loc.start.line-1];let a=0,s=0;for(let t=e.loc.start.column-1;t>=0;t--){const e=r[t];if(" "===e)a++;else{if("\t"!==e)break;s++}}return n.printWidth-(a+s*n.tabWidth)-" * ".length}(e,a,o);let h=0,y=0,j=0,b=f.tags.map((({type:e,optional:t,...n})=>(e&&(e=e.replace(/[=]$/,(()=>(t=!0,""))),e=function(e,t){const n=[];let r=e.replace(/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/g,(e=>(n.push(e),`String$${n.length-1}$`)));return r.includes("`")?e:(r=t(r),r.replace(/String\$(\d+)\$/g,((e,t)=>n[t])))}(e,(e=>{e=(e=(e=(e=e.trim()).replace(/\.</g,"<")).replace(/\*/g," any ")).replace(/^\?\s*(\w+)$/,"$1 | null").replace(/^(\w+)\s*\?$/,"$1 | null");let t=!0;for(;t;)t=!1,e=e.replace(/(^|[^$\w\xA0-\uFFFF])Array\s*<((?:[^<>=]|=>|=(?!>)|<(?:[^<>=]|=>|=(?!>))+>)+)>/g,((e,n,r)=>(t=!0,`${n}(${r})[]`)));return e}))),{...n,type:e,optional:t})));b=be(b,d,o),o.jsdocSeparateReturnsFromParam&&(b=b.flatMap(((e,t)=>e.tag===q&&b[t-1]?.tag===M?[N,e]:[e]))),o.jsdocAddDefaultToDescription&&(b=b.map(ve)),b=await Promise.all(b.map(xe).map((async({type:e,...t})=>(e&&(e=await async function(e,t){try{const r="type name = ";let a=e,s=!1;return a.startsWith("...")&&(s=!0,a=`(${a.slice(3)})[]`),a=await n.format(`${r}${a}`,{...t,parser:"typescript",plugins:[],filepath:"file.ts"}),a=a.slice(r.length),a=a.replace(/^\s*/g,"").replace(/[;\n]*$/g,"").replace(/^\|/g,"").trim(),s&&(a="..."+a.replace(/\[\s*\]$/,"")),a}catch(t){return e}}(e,{...o,printWidth:m})),{...t,type:e})))).then((e=>e.map((({type:e,name:t,description:n,tag:r,...a})=>(ne.includes(r)&&(h=Math.max(h,r.length),y=Math.max(y,e.length),j=Math.max(j,t.length)),{type:e,name:t,description:n,tag:r,...a}))))),o.jsdocSeparateTagGroups&&(b=b.flatMap(((e,t)=>{const n=b[t-1];return n&&n.tag!==S&&n.tag!==v&&n.tag!==N.tag&&e.tag!==N.tag&&n.tag!==e.tag?[N,e]:[e]})));const $=b.filter((({description:e,tag:t})=>!(!e&&te.includes(t))));for(const[t,n]of $.entries()){const r=await ge(n,t,$,{...o,printWidth:m},h,y,j);e.value+=r}e.value=e.value.trimEnd(),e.value&&(e.value=function(e,t,n){return"singleLine"===n.jsdocCommentLineStrategy&&0===ie(t.trim(),"\n")||"keep"===n.jsdocCommentLineStrategy&&0===ie(e,"\n")?`* ${t.trim()} `:`*${t.replace(/(\n(?!$))/g,"\n * ")}\n `}(u,e.value,o)),"cr"===p?e.value=e.value.replace(/\n/g,"\r"):"crlf"===p&&(e.value=e.value.replace(/\n/g,"\r\n"))}))),c.comments=c.comments.filter((e=>!(we(e)&&!e.value))),c};function be(e,t,n){let r=!1,a=!1;return e=e.reduce(((e,t)=>((0===e.length||re.includes(t.tag)&&r)&&(r=!1,e.push([])),ae.includes(t.tag)&&(r=!0),e[e.length-1].push(t),e)),[]).flatMap(((e,r,s)=>(e.sort(((e,r)=>{if(t&&t.length>1&&e.tag===M&&r.tag===M){const n=t.indexOf(e.name),a=t.indexOf(r.name);return n>-1&&a>-1?n-a:0}return $e(e.tag,n)-$e(r.tag,n)})),s.length-1!==r&&e.push(N),r>0&&e[0]?.tag&&!re.includes(e[0].tag)&&(a=!0),e))),a?be(e,t,n):e}function $e(e,t){if(e===S&&!t.jsdocDescriptionTag)return-1;let n;return n=void 0!==t.jsdocTagsOrder?.[e]?t.jsdocTagsOrder[e]:se[e],void 0===n?se.other:n}function we(e){return"CommentBlock"===e.type||"Block"===e.type}const Se=Object.entries(se);function ve(e){if(e.optional&&e.default){let{description:t}=e;return t=t.replace(/(?:\s*Default\s+is\s+`.*?`\.?)+/g,""),t&&!/[.\n]$/.test(t)&&(t+="."),t+=` Default is \`${e.default}\``,{...e,description:t.trim()}}return e}function xe({name:e,optional:t,default:n,tag:r,type:a,source:s,description:i,...o}){if(pe(r)){const t=(s.find((e=>e.source.includes(`@${r}`)))?.source||"").match(/@default(Value)? (\[.*]|{.*}|\(.*\)|'.*'|".*"|`.*`| \w+)( ((?!\*\/).+))?/),n=t?.[2]||"",o=t?.[4]||"";t&&(a=n,e="",i=o)}else t&&(e?e=n?`[${e}=${n}]`:`[${e}]`:a=`${a} | undefined`);return{...o,tag:r,name:e,description:i,optional:t,type:a,source:s,default:n}}const We={jsdocSpaces:{name:"jsdocSpaces",type:"int",category:"jsdoc",default:1,description:"How many spaces will be used to separate tag elements."},jsdocDescriptionWithDot:{name:"jsdocDescriptionWithDot",type:"boolean",category:"jsdoc",default:!1,description:"Should dot be inserted at the end of description"},jsdocDescriptionTag:{name:"jsdocDescriptionTag",type:"boolean",category:"jsdoc",default:!1,description:"Should description tag be used"},jsdocVerticalAlignment:{name:"jsdocVerticalAlignment",type:"boolean",category:"jsdoc",default:!1,description:"Should tags, types, names and description be aligned"},jsdocKeepUnParseAbleExampleIndent:{name:"jsdocKeepUnParseAbleExampleIndent",type:"boolean",category:"jsdoc",default:!1,description:"Should unParseAble example (pseudo code or no js code) keep its indentation"},jsdocSingleLineComment:{name:"jsdocSingleLineComment",type:"boolean",category:"jsdoc",deprecated:"use jsdocCommentLineStrategy instead will be remove on v2",default:!0,description:"Should compact single line comment"},jsdocCommentLineStrategy:{name:"jsdocCommentLineStrategy",type:"choice",choices:[{since:"1.1.0",value:"singleLine",description:"Should compact single line comment, if possible"},{since:"1.1.0",value:"multiline",description:"Should compact multi line comment"},{since:"1.1.0",value:"keep",description:"Should keep original line comment"}],category:"jsdoc",default:"singleLine",description:"How comments line should be"},jsdocSeparateReturnsFromParam:{name:"jsdocSeparateReturnsFromParam",type:"boolean",category:"jsdoc",default:!1,description:"Add an space between last @param and @returns"},jsdocSeparateTagGroups:{name:"jsdocSeparateTagGroups",type:"boolean",category:"jsdoc",default:!1,description:"Add an space between tag groups"},jsdocCapitalizeDescription:{name:"jsdocCapitalizeDescription",type:"boolean",category:"jsdoc",default:!0,description:"Should capitalize first letter of description"},tsdoc:{name:"tsdoc",type:"boolean",category:"jsdoc",default:!1,description:"Should format as tsdoc"},jsdocPrintWidth:{name:"jsdocPrintWidth",type:"int",category:"jsdoc",default:void 0,description:"If You don't set value to jsdocPrintWidth, the printWidth will be use as jsdocPrintWidth."},jsdocAddDefaultToDescription:{name:"jsdocAddDefaultToDescription",type:"boolean",category:"jsdoc",default:!0,description:"Add Default value of a param to end description"},jsdocPreferCodeFences:{name:"jsdocPreferCodeFences",type:"boolean",category:"jsdoc",default:!1,description:'Prefer to render code blocks using "fences" (triple backticks). If not set, blocks without a language tag will be rendered with a four space indentation.'},jsdocLineWrappingStyle:{name:"jsdocLineWrappingStyle",type:"choice",choices:[{since:"0.3.39",value:"greedy",description:"Lines wrap as soon as they reach the print width"}],category:"jsdoc",default:"greedy",description:"Strategy for wrapping lines for the given print width. More options may be added in the future."},jsdocTagsOrder:{name:"jsdocTagsOrder",type:"string",category:"jsdoc",default:void 0,description:"How many spaces will be used to separate tag elements."}},ke={jsdocSpaces:We.jsdocSpaces.default,jsdocPrintWidth:We.jsdocPrintWidth.default,jsdocDescriptionWithDot:We.jsdocDescriptionWithDot.default,jsdocDescriptionTag:We.jsdocDescriptionTag.default,jsdocVerticalAlignment:We.jsdocVerticalAlignment.default,jsdocKeepUnParseAbleExampleIndent:We.jsdocKeepUnParseAbleExampleIndent.default,jsdocSingleLineComment:We.jsdocSingleLineComment.default,jsdocCommentLineStrategy:We.jsdocCommentLineStrategy.default,jsdocSeparateReturnsFromParam:We.jsdocSeparateReturnsFromParam.default,jsdocSeparateTagGroups:We.jsdocSeparateTagGroups.default,jsdocCapitalizeDescription:We.jsdocCapitalizeDescription.default,jsdocAddDefaultToDescription:We.jsdocAddDefaultToDescription.default,jsdocPreferCodeFences:We.jsdocPreferCodeFences.default,tsdoc:We.tsdoc.default,jsdocLineWrappingStyle:We.jsdocLineWrappingStyle.default,jsdocTagsOrder:We.jsdocTagsOrder.default},De={get babel(){return Le(p.default.parsers.babel,"babel")},get"babel-flow"(){return Le(p.default.parsers["babel-flow"],"babel-flow")},get"babel-ts"(){return Le(p.default.parsers["babel-ts"],"babel-ts")},get flow(){return Le(d.default.parsers.flow,"flow")},get typescript(){return Le(u.default.parsers.typescript,"typescript")},get"jsdoc-parser"(){return Le(p.default.parsers["babel-ts"],"babel-ts")}};function Le(e,t){const n=je(e.parse,t),r=(s,i)=>{!function(e){e.jsdocTagsOrder&&(e.jsdocTagsOrder=JSON.parse(e.jsdocTagsOrder));if(e.jsdocCommentLineStrategy)return;e.jsdocSingleLineComment?e.jsdocCommentLineStrategy="singleLine":e.jsdocCommentLineStrategy="multiline"}(i);const o=le(t,i);if(!o)return e.preprocess?e.preprocess(s,i):s;const c=o.preprocess||e.preprocess;return Object.assign(a,{...a,...o,preprocess:r,parse:n}),c?c(s,i):s},a={...e,preprocess:r,parse:n};return a}e.defaultOptions=ke,e.options=We,e.parsers=De,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("comment-parser"),require("prettier"),require("binary-searching"),require("mdast-util-from-markdown"),require("prettier/plugins/babel"),require("prettier/plugins/flow"),require("prettier/plugins/typescript")):"function"==typeof define&&define.amd?define(["exports","comment-parser","prettier","binary-searching","mdast-util-from-markdown","prettier/plugins/babel","prettier/plugins/flow","prettier/plugins/typescript"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).sayHello={},e.commentParser,e.prettier,null,e.mdastUtilFromMarkdown,e.parserBabel,e.parserFlow,e.parserTypescript)}(this,(function(e,t,n,r,a,s,i,o){"use strict";function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=c(s),p=c(i),d=c(o);const u="abstract",g="borrows",m="callback",f="category",h="class",y="constant",j="default",$="defaultValue",b="deprecated",w="description",S="example",v="extends",x="external",L="file",W="fires",D="function",P="ignore",T="license",C="member",k="memberof",A="module",O="namespace",E="overload",F="override",I="param",M="privateRemarks",R="property",_="remarks",z="returns",U="since",q="throws",K="todo",V="type",G="typedef",B="satisfies",H="yields",J={tag:"this_is_for_space",name:"",optional:!1,type:"",description:"",source:[],problems:[]},N={arg:I,argument:I,const:y,constructor:h,desc:w,emits:W,examples:S,exception:q,fileoverview:L,func:D,host:x,method:D,overview:L,params:I,prop:R,return:z,var:C,virtual:u,yield:H,hidden:P},Y=[j,$],Q=[g,f,b,w,S,v,T,A,O,E,F,M,_,z,U,q,K,H,L,...Y],X=[g,g,b,w,S,P,T,A,O,E,F,M,_,U,K,L],Z=[g,...Y,k,A,"see"],ee=[g,f,w,S,M,_,U,K],te=[v,I,R,z,q,V,B,G,H],ne=[m,G],re=[...ne,V,R,I,z,H,q],ae={[_]:1,[M]:2,providesModule:3,[A]:4,[T]:5,flow:6,async:7,private:8,[P]:9,[k]:10,version:11,[L]:12,author:13,[b]:14,[U]:15,[f]:16,[w]:17,[S]:18,[u]:19,augments:20,[y]:21,[j]:22,[$]:23,[x]:24,[E]:25,[W]:26,template:27,typeParam:28,[D]:29,[O]:30,[g]:31,[h]:32,[v]:33,[C]:34,[G]:35,[V]:36,[B]:37,[R]:38,[m]:39,[I]:40,[H]:41,[z]:42,[q]:43,other:44,see:45,[K]:46};function se(e,t){return(e.match(new RegExp(t,"g"))||[]).length}function ie(e){return e?e.match(/^https?:\/\//i)?e:e.startsWith("- ")?e.slice(0,2)+ie(e.slice(2)):e[0].toUpperCase()+e.slice(1):e}async function oe(e,t,r){const{printWidth:a,jsdocKeepUnParseAbleExampleIndent:s}=r;e.split("\n").slice(1).every((e=>!e.trim()||e.startsWith(t)))&&(e=e.replace(new RegExp(`\n${t.replace(/[\t]/g,"[\\t]")}`,"g"),"\n"));try{let s="";const i=a-4;s=e.trim().startsWith("{")?await n.format(e||"",{...r,parser:"json",printWidth:i}):await n.format(e||"",{...r,printWidth:i}),e=s.replace(/(^|\n)/g,`\n${t}`)}catch(n){e=(e=`\n${e.split("\n").map((e=>`${t}${s?e:e.trim()}`)).join("\n")}\n`).replace(/^\n[\s]+\n/g,"\n")}return e}const ce=(e,t)=>{const n=t.plugins.find((t=>"object"==typeof t&&null!==t&&!(t instanceof URL)&&t.name&&t.parsers&&t.parsers.hasOwnProperty(e)));return!n||"prettier-plugin-jsdoc"===n.name||n.parsers?.hasOwnProperty("jsdoc-parser")?void 0:n.parsers?.[e]},le=e=>Y.includes(e),pe="2@^5!~#sdE!_TABLE";async function de(e,t,r,s){if(!t)return t;const{printWidth:i}=r,{tagStringLength:o=0,beginningSpace:c}=s,l=[...(t=(t=t.replace(/^(\d+)[-][\s|]+/g,"$1. ")).replace(/\n+(\s*\d+)[-][\s]+/g,"\n$1. ")).matchAll(/```\S*?\n[\s\S]+?```/gm),...t.matchAll(/^\r?\n^(?:(?:(?:[ ]{4}|\t).*(?:\r?\n|$))+)/gm)],p=[];t=t.replace(/((\n|^)\|[\s\S]*?)((\n[^|])|$)/g,((e,t,n,r,a,s)=>{for(const t of l)if(void 0!==t.index&&t.index<=s+1&&s+e.length+1<=t.index+t[0].length)return e;return e=r?e.slice(0,-1):e,p.push(e),`\n\n${pe}\n\n${r?r.slice(1):""}`})),r.jsdocCapitalizeDescription&&!Z.includes(e)&&(t=ie(t)),t=`${o?`${"!".repeat(o-1)}?`:""}${t.startsWith("```")?"\n":""}${t}`;let d=0;t=t.replace(new RegExp(`\\n[ ]{${c.length}}`,"g"),"\n");const u=a.fromMarkdown(t);let g=await async function t(a,s,o){return Array.isArray(a.children)?(await Promise.all(a.children.map((async(n,c)=>{switch(n.type){case"listItem":{let e=`\n${s}- `;if("number"==typeof a.start){const t=c+(a.start??1);e=`\n${s}${t}. `}const r=s+" ".repeat(e.length-1);return`${e}${(await t(n,r,a)).trim()}`}case"list":{let r="";return e!==w&&"root"===a.type&&c===a.children.length-1&&(r="\n"),`\n${await t(n,s,a)}${r}`}case"paragraph":{const a=await t(n,s,o);return n.costumeType===pe?a:`\n\n${a.split("\\\n").map((t=>{const n=[];t=t.replace(/{@(link|linkcode|linkplain)[\s](([^{}])*)}/g,((e,t,r)=>(n.push(r),`{@${t}${"_".repeat(r.length)}}`))),t=t.replace(/\s+/g," "),r.jsdocCapitalizeDescription&&!Z.includes(e)&&(t=ie(t)),r.jsdocDescriptionWithDot&&(t=t.replace(/([\w\p{L}])$/u,"$1."));let a=function(e,t,n){let r=e.trim();if(!r)return r;let a="";for(;r.length>t;){let e=r.lastIndexOf(" ",r.startsWith("\n")?t+1:t);e<=n.length&&(e=r.indexOf(" ",n.length+1)),-1===e&&(e=r.length),a+=r.substring(0,e),r=r.substring(e+1),r&&(r=`${n}${r}`,r=`\n${r}`)}return a+=r,`${n}${a}`}(t,i,s);return a=a.replace(/{@(link|linkcode|linkplain)([_]+)}/g,((e,t,r)=>{const a=n[0];return a.length===r.length?(n.shift(),`{@${t} ${a}}`):e})),a})).join("\\\n")}`}case"strong":return`**${await t(n,s,a)}**`;case"emphasis":return`_${await t(n,s,a)}_`;case"heading":return`\n\n${s}${"#".repeat(n.depth)} ${await t(n,s,a)}`;case"link":case"image":return`[${await t(n,s,a)}](${n.url})`;case"linkReference":return`[${await t(n,s,a)}][${n.label}]`;case"definition":return`\n\n[${n.label}]: ${n.url}`;case"blockquote":return`\n\n> ${(await t(n,"",a)).trim().replace(/(\n+)/g,`$1${s}> `)}`}return t(n,s,a)})))).join(""):async function(e,t,a){if("inlineCode"===e.type)return`\`${e.value}\``;if("code"===e.type){let n=e.value||"",a=t;if(n)if(e.lang){const a=(e=>{switch(e){case"js":case"javascript":case"jsx":return["babel","babel-flow","vue"];case"ts":case"typescript":case"tsx":return["typescript","babel-ts","angular"];case"json":case"css":return["css"];case"less":return["less"];case"scss":return["scss"];case"html":return["html"];case"yaml":return["yaml"];default:return["babel"]}})(e.lang.toLowerCase()),s=a?.includes(r.parser)?r.parser:a?.[0]||e.lang;n=await oe(n,t,{...r,parser:s,jsdocKeepUnParseAbleExampleIndent:!0})}else r.jsdocPreferCodeFences||(a=t+" ".repeat(4)),n=await oe(n,a,{...r,jsdocKeepUnParseAbleExampleIndent:!0});const s=r.jsdocPreferCodeFences||!!e.lang;return n=s?n:n.trimEnd(),n?s?`\n\n${a}\`\`\`${e.lang||""}${n}\`\`\``:`\n${n}`:""}if(e.value===pe&&(a&&(a.costumeType=pe),p.length>0)){let a=p?.[d]||"";return d++,a&&(a=(await n.format(a,{...r,parser:"markdown"})).trim()),`${a?`\n\n${t}${a.split("\n").join(`\n${t}`)}`:e.value}`}return"break"===e.type?"\\\n":e.value||e.title||e.alt||""}(a,s,o)}(u,c,null);return g=g.replace(/^[\s\n]+/g,""),g=g.replace(/^([!]+\?)/g,""),g}const ue=async({name:e,description:t,type:n,tag:r},a,s,i,o,c,l)=>{let p="\n";if(r===J.tag)return p;const{printWidth:d,jsdocSpaces:u,jsdocVerticalAlignment:g,jsdocDescriptionTag:m,tsdoc:f,useTabs:h,tabWidth:y,jsdocSeparateTagGroups:j}=i,$=" ".repeat(u);let b=0,v=0,x=0,L=0;g&&te.includes(r)&&(r?b+=o-r.length:o&&(L+=o+$.length),n?v+=c-n.length:c&&(L+=c+$.length),e?x+=l-e.length:l&&(L=l+$.length));const W=r!==w||m;if(W&&(p+=`@${r}${" ".repeat(b||0)}`),n){p+=$+(()=>{if(!le(r))return`{${n}}`;if("[]"===n)return"[ ]";if("{}"===n)return"{ }";return/^{.*[A-z0-9_]+ ?:.*}$/.test(n)?n.replace(/; ([A-z0-9_])/g,", $1"):n})()+" ".repeat(v)}if(e&&(p+=`${$}${e}${" ".repeat(x)}`),r!==S||f){if(t){let e="";if(W&&(p+=$+" ".repeat(L)),Z.includes(r)||!ae[r])e=t;else{const[,n]=/^\s*(\S+)/.exec(t)||["",""],a=r===w||[S,_,M].includes(r)&&f?"":" ";e=r!==w&&p.length+n.length>d||[_,M].includes(r)?`\n${a}`+await de(r,t,i,{beginningSpace:a}):await de(r,t,i,{tagStringLength:p.length-1,beginningSpace:a})}j&&(e=e.trimEnd()),p+=e.startsWith("\n")?e.replace(/^\n[\s]+\n/g,"\n"):e.trimStart()}}else{const e=t.match(/<caption>([\s\S]*?)<\/caption>/i);e&&(t=t.replace(e[0],""),p=`${p} ${e[0]}`);const n=h?"\t":" ".repeat(y);p+=(await oe(t,n,i)).replace(new RegExp(`^\\n${n.replace(/[\t]/g,"[\\t]").replace(/[^S\r\n]/g,"[^S\\r\\n]")}\\n`),"").trimEnd()}return p+=function({tag:e,isEndTag:t}){return[w,S,K].includes(e)&&!t?"\n":""}({tag:r,isEndTag:a===s.length-1}),p},{name:ge,tag:me,type:fe,description:he}=t.tokenizers,ye=(e,r)=>async function(a,s,i){let o=i??s;const c=(ce(r,o)?.parse||e)(a,o);o={...o,printWidth:o.jsdocPrintWidth??o.printWidth};const l="auto"===o.endOfLine?function(e){const t={"\r":0,"\r\n":0,"\n":0},n=/\r\n?|\n/g;let r;for(;r=n.exec(e);)t[r[0]]++;const a=t["\r"],s=t["\r\n"],i=t["\n"],o=Math.max(a,s,i);return i===o?"lf":s===o?"crlf":"cr"}(a):o.endOfLine;return o={...o,endOfLine:"lf"},await Promise.all(c.comments.map((async e=>{if(!be(e))return;const r=function(e,t){try{const n=e.split("\n");let r=0;for(let e=0;e<t.loc.end.line-1;e++)r+=n[e].length+1;r+=t.loc.end.column;const a=e.slice(r),s=a.match(/^\s*function\s+\w*\s*\(([^)]*)\)/);if(s){const e=s[1];return e.split(",").map((e=>{const t=e.trim(),n=t.indexOf(":");return(n>-1?t.slice(0,n):t).split(/\s+/)[0].replace(/[{}[\]]/g,"")})).filter((e=>e&&"..."!==e))}const i=a.match(/^\s*(?:const|let|var)\s+\w+\s*=\s*\(([^)]*)\)\s*=>/);if(i){const e=i[1];return e.split(",").map((e=>{const t=e.trim(),n=t.indexOf(":");return(n>-1?t.slice(0,n):t).split(/\s+/)[0].replace(/[{}[\]]/g,"")})).filter((e=>e&&"..."!==e))}const o=a.match(/^\s*(\w+)\s*\(([^)]*)\)/);if(o){const e=o[2];return e.split(",").map((e=>{const t=e.trim(),n=t.indexOf(":");return(n>-1?t.slice(0,n):t).split(/\s+/)[0].replace(/[{}[\]]/g,"")})).filter((e=>e&&"..."!==e))}return}catch(e){return}}(a,e),s=e.value;e.value=e.value.replace(/^([*]+)/g,"*");const i=`/*${e.value.replace(/\r\n?/g,"\n")}*/`;if(!/^\/\*\*[\s\S]+?\*\/$/.test(i))return;const c=t.parse(i,{spacing:"preserve",tokenizers:[me(),e=>le(e.tag)?e:fe("preserve")(e),ge(),he("preserve")]})[0];if(e.value="",!c)return;!function(e){e.tags=e.tags.map((({tag:e,type:t,name:n,description:r,default:a,...s})=>{e=e||"",t=t||"",n=n||"",r=r||"",a=a?.trim();const i=e.indexOf("{");-1!==i&&"}"===e[e.length-1]&&(t=e.slice(i+1,-1)+" "+t,e=e.slice(0,i));const o=(e=e.trim()).toLowerCase(),c=we.findIndex((([e])=>e.toLowerCase()===o));return c>=0?e=we[c][0]:o in N&&(e=N[o]),t=t.trim(),(n=n.trim())&&Q.includes(e)&&(r=`${n} ${r}`,n=""),t&&X.includes(e)&&(r=`{${t}} ${r}`,t=""),{tag:e,type:t,name:n,description:r,default:a,...s}}))}(c),function(e){let t=e.description||"";e.description="",e.tags=e.tags.filter((({description:e,tag:n})=>n.toLowerCase()!==w||(e.trim()&&(t+="\n\n"+e),!1))),t&&e.tags.unshift({tag:w,description:t,name:void 0,type:void 0,source:[],optional:!1,problems:[]})}(c);const p=function(e,t,n){const r=t.split(/\r\n?|\n/g)[e.loc.start.line-1];let a=0,s=0;for(let t=e.loc.start.column-1;t>=0;t--){const e=r[t];if(" "===e)a++;else{if("\t"!==e)break;s++}}return n.printWidth-(a+s*n.tabWidth)-" * ".length}(e,a,o);let d=0,u=0,g=0,m=c.tags.map((({type:e,optional:t,...n})=>(e&&(e=e.replace(/[=]$/,(()=>(t=!0,""))),e=function(e,t){const n=[];let r=e.replace(/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/g,(e=>(n.push(e),`String$${n.length-1}$`)));return r.includes("`")?e:(r=t(r),r.replace(/String\$(\d+)\$/g,((e,t)=>n[t])))}(e,(e=>{e=(e=(e=(e=e.trim()).replace(/\.</g,"<")).replace(/\*/g," any ")).replace(/^\?\s*(\w+)$/,"$1 | null").replace(/^(\w+)\s*\?$/,"$1 | null");let t=!0;for(;t;)t=!1,e=e.replace(/(^|[^$\w\xA0-\uFFFF])Array\s*<((?:[^<>=]|=>|=(?!>)|<(?:[^<>=]|=>|=(?!>))+>)+)>/g,((e,n,r)=>(t=!0,`${n}(${r})[]`)));return e}))),{...n,type:e,optional:t})));m=je(m,r,o),o.jsdocSeparateReturnsFromParam&&(m=m.flatMap(((e,t)=>e.tag===z&&m[t-1]?.tag===I?[J,e]:[e]))),o.jsdocAddDefaultToDescription&&(m=m.map(Se)),m=await Promise.all(m.map(ve).map((async({type:e,...t})=>(e&&(e=await async function(e,t){try{const r="type name = ";let a=e,s=!1;return a.startsWith("...")&&(s=!0,a=`(${a.slice(3)})[]`),a=await n.format(`${r}${a}`,{...t,parser:"typescript",plugins:[],filepath:"file.ts"}),a=a.slice(r.length),a=a.replace(/^\s*/g,"").replace(/[;\n]*$/g,"").replace(/^\|/g,"").trim(),s&&(a="..."+a.replace(/\[\s*\]$/,"")),a}catch(t){return e}}(e,{...o,printWidth:p})),{...t,type:e})))).then((e=>e.map((({type:e,name:t,description:n,tag:r,...a})=>(te.includes(r)&&(d=Math.max(d,r.length),u=Math.max(u,e.length),g=Math.max(g,t.length)),{type:e,name:t,description:n,tag:r,...a}))))),o.jsdocSeparateTagGroups&&(m=m.flatMap(((e,t)=>{const n=m[t-1];return n&&n.tag!==w&&n.tag!==S&&n.tag!==J.tag&&e.tag!==J.tag&&n.tag!==e.tag?[J,e]:[e]})));const f=m.filter((({description:e,tag:t})=>!(!e&&ee.includes(t))));for(const[t,n]of f.entries()){const r=await ue(n,t,f,{...o,printWidth:p},d,u,g);e.value+=r}e.value=e.value.trimEnd(),e.value&&(e.value=function(e,t,n){return"singleLine"===n.jsdocCommentLineStrategy&&0===se(t.trim(),"\n")||"keep"===n.jsdocCommentLineStrategy&&0===se(e,"\n")?`* ${t.trim()} `:`*${t.replace(/(\n(?!$))/g,"\n * ")}\n `}(s,e.value,o)),"cr"===l?e.value=e.value.replace(/\n/g,"\r"):"crlf"===l&&(e.value=e.value.replace(/\n/g,"\r\n"))}))),c.comments=c.comments.filter((e=>!(be(e)&&!e.value))),c};function je(e,t,n){let r=!1,a=!1;return e=e.reduce(((e,t)=>((0===e.length||ne.includes(t.tag)&&r)&&(r=!1,e.push([])),re.includes(t.tag)&&(r=!0),e[e.length-1].push(t),e)),[]).flatMap(((e,r,s)=>(e.sort(((e,r)=>{if(t&&t.length>1&&e.tag===I&&r.tag===I){const n=t.indexOf(e.name),a=t.indexOf(r.name);return n>-1&&a>-1?n-a:0}return $e(e.tag,n)-$e(r.tag,n)})),s.length-1!==r&&e.push(J),r>0&&e[0]?.tag&&!ne.includes(e[0].tag)&&(a=!0),e))),a?je(e,t,n):e}function $e(e,t){if(e===w&&!t.jsdocDescriptionTag)return-1;let n;return n=void 0!==t.jsdocTagsOrder?.[e]?t.jsdocTagsOrder[e]:ae[e],void 0===n?ae.other:n}function be(e){return"CommentBlock"===e.type||"Block"===e.type}const we=Object.entries(ae);function Se(e){if(e.optional&&e.default){let{description:t}=e;return t=t.replace(/(?:\s*Default\s+is\s+`.*?`\.?)+/g,""),t&&!/[.\n]$/.test(t)&&(t+="."),t+=` Default is \`${e.default}\``,{...e,description:t.trim()}}return e}function ve({name:e,optional:t,default:n,tag:r,type:a,source:s,description:i,...o}){if(le(r)){const t=(s.find((e=>e.source.includes(`@${r}`)))?.source||"").match(/@default(Value)? (\[.*]|{.*}|\(.*\)|'.*'|".*"|`.*`| \w+)( ((?!\*\/).+))?/),n=t?.[2]||"",o=t?.[4]||"";t&&(a=n,e="",i=o)}else t&&(e?e=n?`[${e}=${n}]`:`[${e}]`:a=`${a} | undefined`);return{...o,tag:r,name:e,description:i,optional:t,type:a,source:s,default:n}}const xe={jsdocSpaces:{name:"jsdocSpaces",type:"int",category:"jsdoc",default:1,description:"How many spaces will be used to separate tag elements."},jsdocDescriptionWithDot:{name:"jsdocDescriptionWithDot",type:"boolean",category:"jsdoc",default:!1,description:"Should dot be inserted at the end of description"},jsdocDescriptionTag:{name:"jsdocDescriptionTag",type:"boolean",category:"jsdoc",default:!1,description:"Should description tag be used"},jsdocVerticalAlignment:{name:"jsdocVerticalAlignment",type:"boolean",category:"jsdoc",default:!1,description:"Should tags, types, names and description be aligned"},jsdocKeepUnParseAbleExampleIndent:{name:"jsdocKeepUnParseAbleExampleIndent",type:"boolean",category:"jsdoc",default:!1,description:"Should unParseAble example (pseudo code or no js code) keep its indentation"},jsdocSingleLineComment:{name:"jsdocSingleLineComment",type:"boolean",category:"jsdoc",deprecated:"use jsdocCommentLineStrategy instead will be remove on v2",default:!0,description:"Should compact single line comment"},jsdocCommentLineStrategy:{name:"jsdocCommentLineStrategy",type:"choice",choices:[{value:"singleLine",description:"Should compact single line comment, if possible"},{value:"multiline",description:"Should compact multi line comment"},{value:"keep",description:"Should keep original line comment"}],category:"jsdoc",default:"singleLine",description:"How comments line should be"},jsdocSeparateReturnsFromParam:{name:"jsdocSeparateReturnsFromParam",type:"boolean",category:"jsdoc",default:!1,description:"Add an space between last @param and @returns"},jsdocSeparateTagGroups:{name:"jsdocSeparateTagGroups",type:"boolean",category:"jsdoc",default:!1,description:"Add an space between tag groups"},jsdocCapitalizeDescription:{name:"jsdocCapitalizeDescription",type:"boolean",category:"jsdoc",default:!0,description:"Should capitalize first letter of description"},tsdoc:{name:"tsdoc",type:"boolean",category:"jsdoc",default:!1,description:"Should format as tsdoc"},jsdocPrintWidth:{name:"jsdocPrintWidth",type:"int",category:"jsdoc",default:void 0,description:"If You don't set value to jsdocPrintWidth, the printWidth will be use as jsdocPrintWidth."},jsdocAddDefaultToDescription:{name:"jsdocAddDefaultToDescription",type:"boolean",category:"jsdoc",default:!0,description:"Add Default value of a param to end description"},jsdocPreferCodeFences:{name:"jsdocPreferCodeFences",type:"boolean",category:"jsdoc",default:!1,description:'Prefer to render code blocks using "fences" (triple backticks). If not set, blocks without a language tag will be rendered with a four space indentation.'},jsdocLineWrappingStyle:{name:"jsdocLineWrappingStyle",type:"choice",choices:[{value:"greedy",description:"Lines wrap as soon as they reach the print width"}],category:"jsdoc",default:"greedy",description:"Strategy for wrapping lines for the given print width. More options may be added in the future."},jsdocTagsOrder:{name:"jsdocTagsOrder",type:"string",category:"jsdoc",default:void 0,description:"How many spaces will be used to separate tag elements."}},Le={jsdocSpaces:xe.jsdocSpaces.default,jsdocPrintWidth:xe.jsdocPrintWidth.default,jsdocDescriptionWithDot:xe.jsdocDescriptionWithDot.default,jsdocDescriptionTag:xe.jsdocDescriptionTag.default,jsdocVerticalAlignment:xe.jsdocVerticalAlignment.default,jsdocKeepUnParseAbleExampleIndent:xe.jsdocKeepUnParseAbleExampleIndent.default,jsdocSingleLineComment:xe.jsdocSingleLineComment.default,jsdocCommentLineStrategy:xe.jsdocCommentLineStrategy.default,jsdocSeparateReturnsFromParam:xe.jsdocSeparateReturnsFromParam.default,jsdocSeparateTagGroups:xe.jsdocSeparateTagGroups.default,jsdocCapitalizeDescription:xe.jsdocCapitalizeDescription.default,jsdocAddDefaultToDescription:xe.jsdocAddDefaultToDescription.default,jsdocPreferCodeFences:xe.jsdocPreferCodeFences.default,tsdoc:xe.tsdoc.default,jsdocLineWrappingStyle:xe.jsdocLineWrappingStyle.default,jsdocTagsOrder:xe.jsdocTagsOrder.default},We={get babel(){return De(l.default.parsers.babel,"babel")},get"babel-flow"(){return De(l.default.parsers["babel-flow"],"babel-flow")},get"babel-ts"(){return De(l.default.parsers["babel-ts"],"babel-ts")},get flow(){return De(p.default.parsers.flow,"flow")},get typescript(){return De(d.default.parsers.typescript,"typescript")},get"jsdoc-parser"(){return De(l.default.parsers["babel-ts"],"babel-ts")}};function De(e,t){const n=ye(e.parse,t),r=(s,i)=>{!function(e){e.jsdocTagsOrder&&(e.jsdocTagsOrder=JSON.parse(e.jsdocTagsOrder));if(e.jsdocCommentLineStrategy)return;e.jsdocSingleLineComment?e.jsdocCommentLineStrategy="singleLine":e.jsdocCommentLineStrategy="multiline"}(i);const o=ce(t,i);if(!o)return e.preprocess?e.preprocess(s,i):s;const c=o.preprocess||e.preprocess;return Object.assign(a,{...a,...o,preprocess:r,parse:n}),c?c(s,i):s},a={...e,preprocess:r,parse:n};return a}e.defaultOptions=Le,e.options=xe,e.parsers=We,Object.defineProperty(e,"__esModule",{value:!0})}));
import { parse, tokenizers } from "comment-parser";
import { addStarsToTheBeginningOfTheLines, convertToModernType, formatType, detectEndOfLine, findTokenIndex, findPluginByParser, isDefaultTag, } from "./utils.js";
import { addStarsToTheBeginningOfTheLines, convertToModernType, formatType, detectEndOfLine, findPluginByParser, isDefaultTag, } from "./utils.js";
import { DESCRIPTION, PARAM, RETURNS, EXAMPLE } from "./tags.js";

@@ -21,4 +21,3 @@ import { TAGS_DESCRIPTION_NEEDED, TAGS_GROUP_HEAD, TAGS_GROUP_CONDITION, TAGS_NAMELESS, TAGS_ORDER, TAGS_SYNONYMS, TAGS_TYPELESS, TAGS_VERTICALLY_ALIGN_ABLE, } from "./roles.js";

return;
const tokenIndex = findTokenIndex(ast.tokens, comment);
const paramsOrder = getParamsOrders(ast, tokenIndex);
const paramsOrder = getParamsOrders(text, comment);
const originalValue = comment.value;

@@ -291,56 +290,58 @@ comment.value = comment.value.replace(/^([*]+)/g, "*");

}
function getParamsOrders(ast, tokenIndex) {
let params;
function getParamsOrders(text, comment) {
try {
const nextTokenType = ast.tokens[tokenIndex + 1]?.type;
if (typeof nextTokenType !== "object") {
return undefined;
const lines = text.split("\n");
let commentEnd = 0;
for (let i = 0; i < comment.loc.end.line - 1; i++) {
commentEnd += lines[i].length + 1;
}
if (nextTokenType.label === "function") {
let openedParenthesesCount = 1;
const tokensAfterComment = ast.tokens.slice(tokenIndex + 4);
const endIndex = tokensAfterComment.findIndex(({ type }) => {
if (typeof type === "string") {
return false;
}
else if (type.label === "(") {
openedParenthesesCount++;
}
else if (type.label === ")") {
openedParenthesesCount--;
}
return openedParenthesesCount === 0;
});
params = tokensAfterComment.slice(0, endIndex + 1);
commentEnd += comment.loc.end.column;
const textAfterComment = text.slice(commentEnd);
const functionMatch = textAfterComment.match(/^\s*function\s+\w*\s*\(([^)]*)\)/);
if (functionMatch) {
const paramsString = functionMatch[1];
const params = paramsString
.split(",")
.map((param) => {
const trimmed = param.trim();
const colonIndex = trimmed.indexOf(":");
const paramName = colonIndex > -1 ? trimmed.slice(0, colonIndex) : trimmed;
return paramName.split(/\s+/)[0].replace(/[{}[\]]/g, "");
})
.filter((param) => param && param !== "...");
return params;
}
if (nextTokenType.label === "const") {
let openedParenthesesCount = 1;
let tokensAfterComment = ast.tokens.slice(tokenIndex + 1);
const firstParenthesesIndex = tokensAfterComment.findIndex(({ type }) => typeof type === "object" && type.label === "(");
tokensAfterComment = tokensAfterComment.slice(firstParenthesesIndex + 1);
const endIndex = tokensAfterComment.findIndex(({ type }) => {
if (typeof type === "string") {
return false;
}
else if (type.label === "(") {
openedParenthesesCount++;
}
else if (type.label === ")") {
openedParenthesesCount--;
}
return openedParenthesesCount === 0;
});
const arrowItem = tokensAfterComment[endIndex + 1];
if (typeof arrowItem?.type === "object" &&
arrowItem.type.label === "=>") {
params = tokensAfterComment.slice(0, endIndex + 1);
}
const arrowMatch = textAfterComment.match(/^\s*(?:const|let|var)\s+\w+\s*=\s*\(([^)]*)\)\s*=>/);
if (arrowMatch) {
const paramsString = arrowMatch[1];
const params = paramsString
.split(",")
.map((param) => {
const trimmed = param.trim();
const colonIndex = trimmed.indexOf(":");
const paramName = colonIndex > -1 ? trimmed.slice(0, colonIndex) : trimmed;
return paramName.split(/\s+/)[0].replace(/[{}[\]]/g, "");
})
.filter((param) => param && param !== "...");
return params;
}
return params
?.filter(({ type }) => typeof type === "object" && type.label === "name")
.map(({ value }) => value);
const methodMatch = textAfterComment.match(/^\s*(\w+)\s*\(([^)]*)\)/);
if (methodMatch) {
const paramsString = methodMatch[2];
const params = paramsString
.split(",")
.map((param) => {
const trimmed = param.trim();
const colonIndex = trimmed.indexOf(":");
const paramName = colonIndex > -1 ? trimmed.slice(0, colonIndex) : trimmed;
return paramName.split(/\s+/)[0].replace(/[{}[\]]/g, "");
})
.filter((param) => param && param !== "...");
return params;
}
return undefined;
}
catch {
catch (error) {
return undefined;
}
return;
}

@@ -347,0 +348,0 @@ function addDefaultValueToDescription(tag) {

@@ -115,2 +115,5 @@ import { format } from "prettier";

function findTokenIndex(tokens, token) {
if (!Array.isArray(tokens) || tokens.length === 0) {
return -1;
}
return BSearch.eq(tokens, token, (a, b) => {

@@ -163,2 +166,4 @@ if (a.loc.start.line === b.loc.start.line) {

return (typeof plugin === "object" &&
plugin !== null &&
!(plugin instanceof URL) &&
plugin.name &&

@@ -165,0 +170,0 @@ plugin.parsers &&

{
"name": "prettier-plugin-jsdoc",
"version": "1.3.2",
"version": "1.3.3",
"description": "A Prettier plugin to format JSDoc comments.",

@@ -61,3 +61,3 @@ "private": false,

"jest-specific-snapshot": "^5.0.0",
"prettier": "^3.0.3",
"prettier": "^3.6.1",
"rollup": "^2.70.1",

@@ -64,0 +64,0 @@ "standard-version": "^9.3.2",

+97
-112
[![NPM](https://nodei.co/npm/prettier-plugin-jsdoc.png)](https://nodei.co/npm/prettier-plugin-jsdoc/)
[![install size](https://packagephobia.now.sh/badge?p=prettier-plugin-jsdoc)](https://packagephobia.now.sh/result?p=prettier-plugin-jsdoc)
[![dependencies](https://david-dm.org/hosseinmd/prettier-plugin-jsdoc.svg)](https://david-dm.org/hosseinmd/prettier-plugin-jsdoc.svg)
[![Installation size](https://packagephobia.now.sh/badge?p=prettier-plugin-jsdoc)](https://packagephobia.now.sh/result?p=prettier-plugin-jsdoc)
![Prettier Banner](https://raw.githubusercontent.com/prettier/prettier-logo/master/images/prettier-banner-light.png)
# prettier-plugin-jsdoc
Prettier plugin for format comment blocks and convert to standard
Match with Visual studio and other IDE which support jsdoc and comments as markdown.
Prettier plugin for formatting comment blocks and converting to a standard.
Match with Visual Studio Code and other IDEs that support JSDoc and comments as Markdown.
Many good examples of how this plugin work, are in tests directory.
Compare tests and their snapshot
Many good examples of how this plugin works are in the [`/tests`](/tests) directory.
Compare tests and their [snapshots](/tests//__snapshots__).
Configured with best practices of jsDoc style guides.
Configured with best practices of JSDoc style guides.
## TOC
## Contents
- [Installation](#Installation)
- [Examples](#Examples)
- [Links](#Links)
- [Options](#Options)
- [Support](#Support)
- [Installation](#installation)
- [Configuration](#configuration)
- [Ignore](#ignore)
- [Examples](#examples)
- [Options](#options)
- [Supported Prettier versions](#supported-prettier-versions)
- [Contributing](#contributing)
- [Links](#links)
- [Acknowledge](#acknowledge)
## Installation
1. Install and configure Prettier as usual
2. Install prettier-plugin-jsdoc
1. [Install](https://prettier.io/docs/en/install.html) and [configure](https://prettier.io/docs/en/configuration) Prettier
2. Install `prettier-plugin-jsdoc`:
```npm
npm i prettier-plugin-jsdoc --save
```sh
npm install prettier-plugin-jsdoc --save-dev
```
```yarn
yarn add prettier-plugin-jsdoc
```sh
yarn add prettier-plugin-jsdoc --dev
```
## Config
## Configuration
Set `prettier-plugin-jsdoc` to your plugins list.
Add `prettier-plugin-jsdoc` to your `plugins` list.
.prettierrc
`.prettierrc`:
```json
{
"plugins": ["prettier-plugin-jsdoc"],
};
"plugins": ["prettier-plugin-jsdoc"]
}
```
Prettier v3
`prettier.config.js`:
```json
{
"plugins": ["./node_modules/prettier-plugin-jsdoc/dist/index.js"]
};
```js
export default {
plugins: ["prettier-plugin-jsdoc"],
}
```
If you want ignore some type of files remove "prettier-plugin-jsdoc" from plugins or add empty plugins
If you want to ignore some types of files, use `overrides` with an empty `plugins`:
```.prettierrc.js
module.exports = {
"plugins": ["prettier-plugin-jsdoc"]
overrides: [
```json
{
"plugins": ["prettier-plugin-jsdoc"],
"overrides": [
{
files: '*.tsx',
options: {
"files": "*.tsx",
"options": {
"plugins": []
},
},
],
};
}
}
]
}
```

@@ -77,3 +78,3 @@

To ignore prettier use `/* */` or `//` instead of /\*\* \*/
To prevent Prettier from formatting, use `/* */` or `//` instead of /\*\* \*/, or see [Ignoring Code](https://prettier.io/docs/en/ignore#javascript).

@@ -91,3 +92,3 @@ ## Examples

Format to
Formats to:

@@ -99,3 +100,3 @@ ```js

#### React Component
#### React component

@@ -111,3 +112,3 @@ ```js

Format to
Formats to:

@@ -121,3 +122,3 @@ ```js

#### Typescript Objects
#### TypeScript objects

@@ -140,3 +141,3 @@ ```js

Format to
Format to:

@@ -159,3 +160,3 @@ ```js

Add code to example tag
Add code to `@examples` tag.

@@ -172,3 +173,3 @@ ```js

to
Formats to:

@@ -189,83 +190,67 @@ ```js

Description is formatting as Markdown, so you could use any features of Markdown on that. Like code tags ("```js"), header tags like "# AHeader" or other markdown features.
`@description` is formatted as Markdown so that you can use any features of Markdown on that.
Like code tags (` ```js `), header tags like `# Header`, or other Markdown features.
## Options
| Key | type | Default | description |
| :-------------------------------- | :-------------------------------- | :---------- | ----------------------------------------------------------------------------------------- |
| jsdocSpaces | Number | 1 |
| jsdocDescriptionWithDot | Boolean | false |
| jsdocDescriptionTag | Boolean | false |
| jsdocVerticalAlignment | Boolean | false |
| jsdocKeepUnParseAbleExampleIndent | Boolean | false |
| jsdocCommentLineStrategy | ("singleLine","multiline","keep") | "singleLine |
| jsdocCapitalizeDescription | Boolean | true |
| jsdocSeparateReturnsFromParam | Boolean | false | Add an space between last @param and @returns |
| jsdocSeparateTagGroups | Boolean | false | Add an space between tag groups |
| jsdocPreferCodeFences | Boolean | false | Always fence code blocks (surround them by triple backticks) |
| tsdoc | Boolean | false |
| jsdocPrintWidth | Number | undefined | If You don't set value to jsdocPrintWidth, the printWidth will be use as jsdocPrintWidth. |
| jsdocLineWrappingStyle | String | "greedy" | "greedy": Lines wrap as soon as they reach the print width |
| jsdocTagsOrder | String (object) | "undefined" | [Custom Tags Order](doc/CUSTOM_TAGS_ORDER.md) |
| Key | Type | Default | Description |
| :---------------------------------- | :-------------------------------- | :----------- | ----------------------------------------------------------------------------------------------- |
| `jsdocSpaces` | Number | 1 |
| `jsdocDescriptionWithDot` | Boolean | false |
| `jsdocDescriptionTag` | Boolean | false |
| `jsdocVerticalAlignment` | Boolean | false |
| `jsdocKeepUnParseAbleExampleIndent` | Boolean | false |
| `jsdocCommentLineStrategy` | ("singleLine","multiline","keep") | "singleLine" |
| `jsdocCapitalizeDescription` | Boolean | true |
| `jsdocSeparateReturnsFromParam` | Boolean | false | Adds a space between last `@param` and `@returns` |
| `jsdocSeparateTagGroups` | Boolean | false | Adds a space between tag groups |
| `jsdocPreferCodeFences` | Boolean | false | Always fence code blocks (surround them by triple backticks) |
| `tsdoc` | Boolean | false | See [TSDoc](#tsdoc) |
| `jsdocPrintWidth` | Number | undefined | If you don't set the value to `jsdocPrintWidth`, `printWidth` will be used as `jsdocPrintWidth` |
| `jsdocLineWrappingStyle` | String | "greedy" | "greedy": lines wrap as soon as they reach `printWidth` |
| `jsdocTagsOrder` | String (object) | undefined | See [Custom Tags Order](doc/CUSTOM_TAGS_ORDER.md) |
Full up to date list and description of options can be found in Prettier help. First install plugin then run Prettier with "--help" option.
### TSDoc
`$ prettier --help` # global installation
We hope to support the whole [TSDoc](https://tsdoc.org/).
If we missed something, please [create an issue](https://github.com/hosseinmd/prettier-plugin-jsdoc/issues/new).
`$ ./node_modules/.bin/prettier --help` # local installation
To enable, add:
## ESLint
Install [eslint-plugin-prettier](https://github.com/prettier/eslint-plugin-prettier)
```
$ yarn add eslint eslint-plugin-prettier
```
Then, in your .eslintrc.json:
```json
{
"plugins": ["prettier"],
"rules": {
"prettier/prettier": "error"
}
"tsdoc": true
}
```
## Tsdoc
## Supported Prettier versions
We hope to support whole tsdoc, if we missed somethings please create an issue.
| Plugin version | Prettier version |
| -------------- | ---------------- |
| 1.0.0+ | 3.0.0+ |
| 0.4.2 | 2.x+ |
```json
{
"tsdoc": true
};
```
## Contributing
## Contribute
1. Fork and clone the repository
2. [Install Yarn](https://yarnpkg.com/getting-started/install)
3. Install project dependencies:
```sh
yarn install
```
4. Make changes and make sure that tests pass:
```js
yarn run test
```
5. Update or add tests to your changes if needed
6. Create PR
1- Get a clone/fork of repo
2- Install yarn
3- Add your changes
4- Add a test to your change if needed
5- Create PR
This project extended from @gum3n worked project on GitLab.
## Links
[Prettier](https://prettier.io)
- [Prettier](https://prettier.io)
- [JSDoc](https://jsdoc.app)
[JSDoc](https://jsdoc.app)
## Acknowledge
## Supported prettier version
| version | prettier version |
| ------- | ---------------- |
| 1.0.0+ | 3.0.0+ |
| 0.4.2 | 2.x+ |
This project extended from the @gum3n worked project on GitLab.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet