diff --git a/dist/index.mjs b/dist/index.mjs index cb8c48252e7f..7767ef8d72bd 100644 --- a/dist/index.mjs +++ b/dist/index.mjs @@ -19352,7 +19352,9 @@ var core_options_evaluate_default = { "array": true, "default": [ { - "value": [] + "value": [ + "prettier-plugin-tailwindcss" + ] } ], "category": "Global", diff --git a/dist/standalone.js b/dist/standalone.js index 4bf381ceb76f..61d23570a436 100644 --- a/dist/standalone.js +++ b/dist/standalone.js @@ -22,7 +22,7 @@ Expected it to be ${n}.`}var St=class extends Error{name="InvalidDocError";const `||u==="\r"||u==="\u2028"||u==="\u2029")return t-1}else{if(u==="\r"&&e.charAt(t+1)===` `)return t+2;if(u===` `||u==="\r"||u==="\u2028"||u==="\u2029")return t+1}return t}var W=qu;function Xu(e,t,r={}){let n=S(e,r.backwards?t-1:t,r),u=W(e,n,r);return n!==u}var $=Xu;function Qu(e){return Array.isArray(e)&&e.length>0}var Yt=Qu;var tn=new Set(["tokens","comments","parent","enclosingNode","precedingNode","followingNode"]),Zu=e=>Object.keys(e).filter(t=>!tn.has(t));function ei(e){return e?t=>e(t,tn):Zu}var q=ei;function ti(e){let t=e.type||e.kind||"(unknown type)",r=String(e.name||e.id&&(typeof e.id=="object"?e.id.name:e.id)||e.key&&(typeof e.key=="object"?e.key.name:e.key)||e.value&&(typeof e.value=="object"?"":String(e.value))||e.operator||"");return r.length>20&&(r=r.slice(0,19)+"\u2026"),t+(r?" "+r:"")}function jt(e,t){(e.comments??(e.comments=[])).push(t),t.printed=!1,t.nodeDescription=ti(e)}function ue(e,t){t.leading=!0,t.trailing=!1,jt(e,t)}function re(e,t,r){t.leading=!1,t.trailing=!1,r&&(t.marker=r),jt(e,t)}function ie(e,t){t.leading=!1,t.trailing=!0,jt(e,t)}var Ht=new WeakMap;function ot(e,t){if(Ht.has(e))return Ht.get(e);let{printer:{getCommentChildNodes:r,canAttachComment:n,getVisitorKeys:u},locStart:i,locEnd:o}=t;if(!n)return[];let s=((r==null?void 0:r(e,t))??[...ge(e,{getVisitorKeys:q(u)})]).flatMap(a=>n(a)?[a]:ot(a,t));return s.sort((a,l)=>i(a)-i(l)||o(a)-o(l)),Ht.set(e,s),s}function nn(e,t,r,n){let{locStart:u,locEnd:i}=r,o=u(t),s=i(t),a=ot(e,r),l,D,p=0,f=a.length;for(;p>1,c=a[d],F=u(c),m=i(c);if(F<=o&&s<=m)return nn(c,t,r,c);if(m<=o){l=c,p=d+1;continue}if(s<=F){D=c,f=d;continue}throw new Error("Comment location overlaps with node location")}if((n==null?void 0:n.type)==="TemplateLiteral"){let{quasis:d}=n,c=$t(d,t,r);l&&$t(d,l,r)!==c&&(l=null),D&&$t(d,D,r)!==c&&(D=null)}return{enclosingNode:n,precedingNode:l,followingNode:D}}var Wt=()=>!1;function un(e,t){let{comments:r}=e;if(delete e.comments,!Yt(r)||!t.printer.canAttachComment)return;let n=[],{locStart:u,locEnd:i,printer:{experimentalFeatures:{avoidAstMutation:o=!1}={},handleComments:s={}},originalText:a}=t,{ownLine:l=Wt,endOfLine:D=Wt,remaining:p=Wt}=s,f=r.map((d,c)=>({...nn(e,d,t),comment:d,text:a,options:t,ast:e,isLastComment:r.length-1===c}));for(let[d,c]of f.entries()){let{comment:F,precedingNode:m,enclosingNode:h,followingNode:C,text:v,options:E,ast:g,isLastComment:j}=c;if(E.parser==="json"||E.parser==="json5"||E.parser==="jsonc"||E.parser==="__js_expression"||E.parser==="__ts_expression"||E.parser==="__vue_expression"||E.parser==="__vue_ts_expression"){if(u(F)-u(g)<=0){ue(g,F);continue}if(i(F)-i(g)>=0){ie(g,F);continue}}let b;if(o?b=[c]:(F.enclosingNode=h,F.precedingNode=m,F.followingNode=C,b=[F,v,E,g,j]),ri(v,E,f,d))F.placement="ownLine",l(...b)||(C?ue(C,F):m?ie(m,F):h?re(h,F):re(g,F));else if(ni(v,E,f,d))F.placement="endOfLine",D(...b)||(m?ie(m,F):C?ue(C,F):h?re(h,F):re(g,F));else if(F.placement="remaining",!p(...b))if(m&&C){let X=n.length;X>0&&n[X-1].followingNode!==C&&rn(n,E),n.push(c)}else m?ie(m,F):C?ue(C,F):h?re(h,F):re(g,F)}if(rn(n,t),!o)for(let d of r)delete d.precedingNode,delete d.enclosingNode,delete d.followingNode}var on=e=>!/[\S\n\u2028\u2029]/u.test(e);function ri(e,t,r,n){let{comment:u,precedingNode:i}=r[n],{locStart:o,locEnd:s}=t,a=o(u);if(i)for(let l=n-1;l>=0;l--){let{comment:D,precedingNode:p}=r[l];if(p!==i||!on(e.slice(s(D),a)))break;a=o(D)}return $(e,a,{backwards:!0})}function ni(e,t,r,n){let{comment:u,followingNode:i}=r[n],{locStart:o,locEnd:s}=t,a=s(u);if(i)for(let l=n+1;l0;--o){let{comment:l,precedingNode:D,followingNode:p}=e[o-1];Pe.strictEqual(D,n),Pe.strictEqual(p,u);let f=t.originalText.slice(t.locEnd(l),i);if(((a=(s=t.printer).isGap)==null?void 0:a.call(s,f,t))??/^[\s(]*$/u.test(f))i=t.locStart(l);else break}for(let[l,{comment:D}]of e.entries())l1&&l.comments.sort((D,p)=>t.locStart(D)-t.locStart(p));e.length=0}function $t(e,t,r){let n=r.locStart(t)-1;for(let u=1;u!n.has(a)).length===0)return{leading:"",trailing:""};let i=[],o=[],s;return e.each(()=>{let a=e.node;if(n!=null&&n.has(a))return;let{leading:l,trailing:D}=a;l?i.push(ii(e,t)):D&&(s=oi(e,t,s),o.push(s.doc))},"comments"),{leading:i,trailing:o}}function an(e,t,r){let{leading:n,trailing:u}=si(e,r);return!n&&!u?t:me(t,i=>[n,i,u])}function Dn(e){let{[Symbol.for("comments")]:t,[Symbol.for("printedComments")]:r}=e;for(let n of t){if(!n.printed&&!r.has(n))throw new Error('Comment "'+n.value.trim()+'" was not printed. Please report this error!');delete n.printed}}function ai(e){return()=>{}}var ln=ai;var Re=class extends Error{name="ConfigError"},Ye=class extends Error{name="UndefinedParserError"};var cn={cursorOffset:{category:"Special",type:"int",default:-1,range:{start:-1,end:1/0,step:1},description:"Print (to stderr) where a cursor at the given position would move to after formatting.",cliCategory:"Editor"},endOfLine:{category:"Global",type:"choice",default:"lf",description:"Which end of line characters to apply.",choices:[{value:"lf",description:"Line Feed only (\\n), common on Linux and macOS as well as inside git repos"},{value:"crlf",description:"Carriage Return + Line Feed characters (\\r\\n), common on Windows"},{value:"cr",description:"Carriage Return character only (\\r), used very rarely"},{value:"auto",description:`Maintain existing -(mixed values within one file are normalised by looking at what's used after the first line)`}]},filepath:{category:"Special",type:"path",description:"Specify the input filepath. This will be used to do parser inference.",cliName:"stdin-filepath",cliCategory:"Other",cliDescription:"Path to the file to pretend that stdin comes from."},insertPragma:{category:"Special",type:"boolean",default:!1,description:"Insert @format pragma into file's first docblock comment.",cliCategory:"Other"},parser:{category:"Global",type:"choice",default:void 0,description:"Which parser to use.",exception:e=>typeof e=="string"||typeof e=="function",choices:[{value:"flow",description:"Flow"},{value:"babel",description:"JavaScript"},{value:"babel-flow",description:"Flow"},{value:"babel-ts",description:"TypeScript"},{value:"typescript",description:"TypeScript"},{value:"acorn",description:"JavaScript"},{value:"espree",description:"JavaScript"},{value:"meriyah",description:"JavaScript"},{value:"css",description:"CSS"},{value:"less",description:"Less"},{value:"scss",description:"SCSS"},{value:"json",description:"JSON"},{value:"json5",description:"JSON5"},{value:"jsonc",description:"JSON with Comments"},{value:"json-stringify",description:"JSON.stringify"},{value:"graphql",description:"GraphQL"},{value:"markdown",description:"Markdown"},{value:"mdx",description:"MDX"},{value:"vue",description:"Vue"},{value:"yaml",description:"YAML"},{value:"glimmer",description:"Ember / Handlebars"},{value:"html",description:"HTML"},{value:"angular",description:"Angular"},{value:"lwc",description:"Lightning Web Components"}]},plugins:{type:"path",array:!0,default:[{value:[]}],category:"Global",description:"Add a plugin. Multiple plugins can be passed as separate `--plugin`s.",exception:e=>typeof e=="string"||typeof e=="object",cliName:"plugin",cliCategory:"Config"},printWidth:{category:"Global",type:"int",default:120,description:"The line length where Prettier will try wrap.",range:{start:0,end:1/0,step:1}},rangeEnd:{category:"Special",type:"int",default:1/0,range:{start:0,end:1/0,step:1},description:`Format code ending at a given character offset (exclusive). +(mixed values within one file are normalised by looking at what's used after the first line)`}]},filepath:{category:"Special",type:"path",description:"Specify the input filepath. This will be used to do parser inference.",cliName:"stdin-filepath",cliCategory:"Other",cliDescription:"Path to the file to pretend that stdin comes from."},insertPragma:{category:"Special",type:"boolean",default:!1,description:"Insert @format pragma into file's first docblock comment.",cliCategory:"Other"},parser:{category:"Global",type:"choice",default:void 0,description:"Which parser to use.",exception:e=>typeof e=="string"||typeof e=="function",choices:[{value:"flow",description:"Flow"},{value:"babel",description:"JavaScript"},{value:"babel-flow",description:"Flow"},{value:"babel-ts",description:"TypeScript"},{value:"typescript",description:"TypeScript"},{value:"acorn",description:"JavaScript"},{value:"espree",description:"JavaScript"},{value:"meriyah",description:"JavaScript"},{value:"css",description:"CSS"},{value:"less",description:"Less"},{value:"scss",description:"SCSS"},{value:"json",description:"JSON"},{value:"json5",description:"JSON5"},{value:"jsonc",description:"JSON with Comments"},{value:"json-stringify",description:"JSON.stringify"},{value:"graphql",description:"GraphQL"},{value:"markdown",description:"Markdown"},{value:"mdx",description:"MDX"},{value:"vue",description:"Vue"},{value:"yaml",description:"YAML"},{value:"glimmer",description:"Ember / Handlebars"},{value:"html",description:"HTML"},{value:"angular",description:"Angular"},{value:"lwc",description:"Lightning Web Components"}]},plugins:{type:"path",array:!0,default:[{value:["prettier-plugin-tailwindcss"]}],category:"Global",description:"Add a plugin. Multiple plugins can be passed as separate `--plugin`s.",exception:e=>typeof e=="string"||typeof e=="object",cliName:"plugin",cliCategory:"Config"},printWidth:{category:"Global",type:"int",default:120,description:"The line length where Prettier will try wrap.",range:{start:0,end:1/0,step:1}},rangeEnd:{category:"Special",type:"int",default:1/0,range:{start:0,end:1/0,step:1},description:`Format code ending at a given character offset (exclusive). The range will extend forwards to the end of the selected statement.`,cliCategory:"Editor"},rangeStart:{category:"Special",type:"int",default:0,range:{start:0,end:1/0,step:1},description:`Format code starting at a given character offset. The range will extend backwards to the start of the first line containing the selected statement.`,cliCategory:"Editor"},requirePragma:{category:"Special",type:"boolean",default:!1,description:`Require either '@prettier' or '@format' to be present in the file's first docblock comment in order for it to be formatted.`,cliCategory:"Other"},tabWidth:{type:"int",category:"Global",default:2,description:"Number of spaces per indentation level.",range:{start:0,end:1/0,step:1}},useTabs:{category:"Global",type:"boolean",default:!0,description:"Indent with tabs instead of spaces."},embeddedLanguageFormatting:{category:"Global",type:"choice",default:"auto",description:"Control how Prettier formats quoted code embedded in the file.",choices:[{value:"auto",description:"Format embedded code if Prettier can automatically identify it."},{value:"off",description:"Never automatically format embedded code."}]}};function st({plugins:e=[],showDeprecated:t=!1}={}){let r=e.flatMap(u=>u.languages??[]),n=[];for(let u of li(Object.assign({},...e.map(({options:i})=>i),cn)))!t&&u.deprecated||(Array.isArray(u.choices)&&(t||(u.choices=u.choices.filter(i=>!i.deprecated)),u.name==="parser"&&(u.choices=[...u.choices,...Di(u.choices,r,e)])),u.pluginDefaults=Object.fromEntries(e.filter(i=>{var o;return((o=i.defaultOptions)==null?void 0:o[u.name])!==void 0}).map(i=>[i.name,i.defaultOptions[u.name]])),n.push(u));return{languages:r,options:n}}function*Di(e,t,r){let n=new Set(e.map(u=>u.value));for(let u of t)if(u.parsers){for(let i of u.parsers)if(!n.has(i)){n.add(i);let o=r.find(a=>a.parsers&&Object.prototype.hasOwnProperty.call(a.parsers,i)),s=u.name;o!=null&&o.name&&(s+=` (plugin: ${o.name})`),yield{value:i,description:s}}}}function li(e){let t=[];for(let[r,n]of Object.entries(e)){let u={name:r,...n};Array.isArray(u.default)&&(u.default=y(!1,u.default,-1).value),t.push(u)}return t}var ci=e=>String(e).split(/[/\\]/u).pop();function fn(e,t){if(!t)return;let r=ci(t).toLowerCase();return e.find(({filenames:n})=>n==null?void 0:n.some(u=>u.toLowerCase()===r))??e.find(({extensions:n})=>n==null?void 0:n.some(u=>r.endsWith(u)))}function fi(e,t){if(t)return e.find(({name:r})=>r.toLowerCase()===t)??e.find(({aliases:r})=>r==null?void 0:r.includes(t))??e.find(({extensions:r})=>r==null?void 0:r.includes(`.${t}`))}function di(e,t){let r=e.plugins.flatMap(u=>u.languages??[]),n=fi(r,t.language)??fn(r,t.physicalFile)??fn(r,t.file)??(t.physicalFile,void 0);return n==null?void 0:n.parsers[0]}var dn=di;var oe={key:e=>/^[$_a-zA-Z][$_a-zA-Z0-9]*$/.test(e)?e:JSON.stringify(e),value(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(r=>oe.value(r)).join(", ")}]`;let t=Object.keys(e);return t.length===0?"{}":`{ ${t.map(r=>`${oe.key(r)}: ${oe.value(e[r])}`).join(", ")} }`},pair:({key:e,value:t})=>oe.value({[e]:t})};var Mt=Ue(at(),1),mn=(e,t,{descriptor:r})=>{let n=[`${Mt.default.yellow(typeof e=="string"?r.key(e):r.pair(e))} is deprecated`];return t&&n.push(`we now treat it as ${Mt.default.blue(typeof t=="string"?r.key(t):r.pair(t))}`),n.join("; ")+"."};var ce=Ue(at(),1);var Dt=Symbol.for("vnopts.VALUE_NOT_EXIST"),Ae=Symbol.for("vnopts.VALUE_UNCHANGED");var hn=" ".repeat(2),Cn=(e,t,r)=>{let{text:n,list:u}=r.normalizeExpectedResult(r.schemas[e].expected(r)),i=[];return n&&i.push(En(e,t,n,r.descriptor)),u&&i.push([En(e,t,u.title,r.descriptor)].concat(u.values.map(o=>gn(o,r.loggerPrintWidth))).join(` diff --git a/dist/standalone.mjs b/dist/standalone.mjs index 45f56d3c0c19..246bb01c96a6 100644 --- a/dist/standalone.mjs +++ b/dist/standalone.mjs @@ -22,7 +22,7 @@ Expected it to be ${n}.`}var St=class extends Error{name="InvalidDocError";const `||u==="\r"||u==="\u2028"||u==="\u2029")return t-1}else{if(u==="\r"&&e.charAt(t+1)===` `)return t+2;if(u===` `||u==="\r"||u==="\u2028"||u==="\u2029")return t+1}return t}var W=qu;function Xu(e,t,r={}){let n=S(e,r.backwards?t-1:t,r),u=W(e,n,r);return n!==u}var $=Xu;function Qu(e){return Array.isArray(e)&&e.length>0}var Yt=Qu;var tn=new Set(["tokens","comments","parent","enclosingNode","precedingNode","followingNode"]),Zu=e=>Object.keys(e).filter(t=>!tn.has(t));function ei(e){return e?t=>e(t,tn):Zu}var q=ei;function ti(e){let t=e.type||e.kind||"(unknown type)",r=String(e.name||e.id&&(typeof e.id=="object"?e.id.name:e.id)||e.key&&(typeof e.key=="object"?e.key.name:e.key)||e.value&&(typeof e.value=="object"?"":String(e.value))||e.operator||"");return r.length>20&&(r=r.slice(0,19)+"\u2026"),t+(r?" "+r:"")}function jt(e,t){(e.comments??(e.comments=[])).push(t),t.printed=!1,t.nodeDescription=ti(e)}function ue(e,t){t.leading=!0,t.trailing=!1,jt(e,t)}function re(e,t,r){t.leading=!1,t.trailing=!1,r&&(t.marker=r),jt(e,t)}function ie(e,t){t.leading=!1,t.trailing=!0,jt(e,t)}var Ht=new WeakMap;function it(e,t){if(Ht.has(e))return Ht.get(e);let{printer:{getCommentChildNodes:r,canAttachComment:n,getVisitorKeys:u},locStart:i,locEnd:o}=t;if(!n)return[];let s=((r==null?void 0:r(e,t))??[...ge(e,{getVisitorKeys:q(u)})]).flatMap(a=>n(a)?[a]:it(a,t));return s.sort((a,l)=>i(a)-i(l)||o(a)-o(l)),Ht.set(e,s),s}function nn(e,t,r,n){let{locStart:u,locEnd:i}=r,o=u(t),s=i(t),a=it(e,r),l,D,p=0,f=a.length;for(;p>1,c=a[d],F=u(c),m=i(c);if(F<=o&&s<=m)return nn(c,t,r,c);if(m<=o){l=c,p=d+1;continue}if(s<=F){D=c,f=d;continue}throw new Error("Comment location overlaps with node location")}if((n==null?void 0:n.type)==="TemplateLiteral"){let{quasis:d}=n,c=$t(d,t,r);l&&$t(d,l,r)!==c&&(l=null),D&&$t(d,D,r)!==c&&(D=null)}return{enclosingNode:n,precedingNode:l,followingNode:D}}var Wt=()=>!1;function un(e,t){let{comments:r}=e;if(delete e.comments,!Yt(r)||!t.printer.canAttachComment)return;let n=[],{locStart:u,locEnd:i,printer:{experimentalFeatures:{avoidAstMutation:o=!1}={},handleComments:s={}},originalText:a}=t,{ownLine:l=Wt,endOfLine:D=Wt,remaining:p=Wt}=s,f=r.map((d,c)=>({...nn(e,d,t),comment:d,text:a,options:t,ast:e,isLastComment:r.length-1===c}));for(let[d,c]of f.entries()){let{comment:F,precedingNode:m,enclosingNode:h,followingNode:C,text:v,options:E,ast:g,isLastComment:j}=c;if(E.parser==="json"||E.parser==="json5"||E.parser==="jsonc"||E.parser==="__js_expression"||E.parser==="__ts_expression"||E.parser==="__vue_expression"||E.parser==="__vue_ts_expression"){if(u(F)-u(g)<=0){ue(g,F);continue}if(i(F)-i(g)>=0){ie(g,F);continue}}let b;if(o?b=[c]:(F.enclosingNode=h,F.precedingNode=m,F.followingNode=C,b=[F,v,E,g,j]),ri(v,E,f,d))F.placement="ownLine",l(...b)||(C?ue(C,F):m?ie(m,F):h?re(h,F):re(g,F));else if(ni(v,E,f,d))F.placement="endOfLine",D(...b)||(m?ie(m,F):C?ue(C,F):h?re(h,F):re(g,F));else if(F.placement="remaining",!p(...b))if(m&&C){let X=n.length;X>0&&n[X-1].followingNode!==C&&rn(n,E),n.push(c)}else m?ie(m,F):C?ue(C,F):h?re(h,F):re(g,F)}if(rn(n,t),!o)for(let d of r)delete d.precedingNode,delete d.enclosingNode,delete d.followingNode}var on=e=>!/[\S\n\u2028\u2029]/u.test(e);function ri(e,t,r,n){let{comment:u,precedingNode:i}=r[n],{locStart:o,locEnd:s}=t,a=o(u);if(i)for(let l=n-1;l>=0;l--){let{comment:D,precedingNode:p}=r[l];if(p!==i||!on(e.slice(s(D),a)))break;a=o(D)}return $(e,a,{backwards:!0})}function ni(e,t,r,n){let{comment:u,followingNode:i}=r[n],{locStart:o,locEnd:s}=t,a=s(u);if(i)for(let l=n+1;l0;--o){let{comment:l,precedingNode:D,followingNode:p}=e[o-1];Pe.strictEqual(D,n),Pe.strictEqual(p,u);let f=t.originalText.slice(t.locEnd(l),i);if(((a=(s=t.printer).isGap)==null?void 0:a.call(s,f,t))??/^[\s(]*$/u.test(f))i=t.locStart(l);else break}for(let[l,{comment:D}]of e.entries())l1&&l.comments.sort((D,p)=>t.locStart(D)-t.locStart(p));e.length=0}function $t(e,t,r){let n=r.locStart(t)-1;for(let u=1;u!n.has(a)).length===0)return{leading:"",trailing:""};let i=[],o=[],s;return e.each(()=>{let a=e.node;if(n!=null&&n.has(a))return;let{leading:l,trailing:D}=a;l?i.push(ii(e,t)):D&&(s=oi(e,t,s),o.push(s.doc))},"comments"),{leading:i,trailing:o}}function an(e,t,r){let{leading:n,trailing:u}=si(e,r);return!n&&!u?t:me(t,i=>[n,i,u])}function Dn(e){let{[Symbol.for("comments")]:t,[Symbol.for("printedComments")]:r}=e;for(let n of t){if(!n.printed&&!r.has(n))throw new Error('Comment "'+n.value.trim()+'" was not printed. Please report this error!');delete n.printed}}function ai(e){return()=>{}}var ln=ai;var Re=class extends Error{name="ConfigError"},Ye=class extends Error{name="UndefinedParserError"};var cn={cursorOffset:{category:"Special",type:"int",default:-1,range:{start:-1,end:1/0,step:1},description:"Print (to stderr) where a cursor at the given position would move to after formatting.",cliCategory:"Editor"},endOfLine:{category:"Global",type:"choice",default:"lf",description:"Which end of line characters to apply.",choices:[{value:"lf",description:"Line Feed only (\\n), common on Linux and macOS as well as inside git repos"},{value:"crlf",description:"Carriage Return + Line Feed characters (\\r\\n), common on Windows"},{value:"cr",description:"Carriage Return character only (\\r), used very rarely"},{value:"auto",description:`Maintain existing -(mixed values within one file are normalised by looking at what's used after the first line)`}]},filepath:{category:"Special",type:"path",description:"Specify the input filepath. This will be used to do parser inference.",cliName:"stdin-filepath",cliCategory:"Other",cliDescription:"Path to the file to pretend that stdin comes from."},insertPragma:{category:"Special",type:"boolean",default:!1,description:"Insert @format pragma into file's first docblock comment.",cliCategory:"Other"},parser:{category:"Global",type:"choice",default:void 0,description:"Which parser to use.",exception:e=>typeof e=="string"||typeof e=="function",choices:[{value:"flow",description:"Flow"},{value:"babel",description:"JavaScript"},{value:"babel-flow",description:"Flow"},{value:"babel-ts",description:"TypeScript"},{value:"typescript",description:"TypeScript"},{value:"acorn",description:"JavaScript"},{value:"espree",description:"JavaScript"},{value:"meriyah",description:"JavaScript"},{value:"css",description:"CSS"},{value:"less",description:"Less"},{value:"scss",description:"SCSS"},{value:"json",description:"JSON"},{value:"json5",description:"JSON5"},{value:"jsonc",description:"JSON with Comments"},{value:"json-stringify",description:"JSON.stringify"},{value:"graphql",description:"GraphQL"},{value:"markdown",description:"Markdown"},{value:"mdx",description:"MDX"},{value:"vue",description:"Vue"},{value:"yaml",description:"YAML"},{value:"glimmer",description:"Ember / Handlebars"},{value:"html",description:"HTML"},{value:"angular",description:"Angular"},{value:"lwc",description:"Lightning Web Components"}]},plugins:{type:"path",array:!0,default:[{value:[]}],category:"Global",description:"Add a plugin. Multiple plugins can be passed as separate `--plugin`s.",exception:e=>typeof e=="string"||typeof e=="object",cliName:"plugin",cliCategory:"Config"},printWidth:{category:"Global",type:"int",default:120,description:"The line length where Prettier will try wrap.",range:{start:0,end:1/0,step:1}},rangeEnd:{category:"Special",type:"int",default:1/0,range:{start:0,end:1/0,step:1},description:`Format code ending at a given character offset (exclusive). +(mixed values within one file are normalised by looking at what's used after the first line)`}]},filepath:{category:"Special",type:"path",description:"Specify the input filepath. This will be used to do parser inference.",cliName:"stdin-filepath",cliCategory:"Other",cliDescription:"Path to the file to pretend that stdin comes from."},insertPragma:{category:"Special",type:"boolean",default:!1,description:"Insert @format pragma into file's first docblock comment.",cliCategory:"Other"},parser:{category:"Global",type:"choice",default:void 0,description:"Which parser to use.",exception:e=>typeof e=="string"||typeof e=="function",choices:[{value:"flow",description:"Flow"},{value:"babel",description:"JavaScript"},{value:"babel-flow",description:"Flow"},{value:"babel-ts",description:"TypeScript"},{value:"typescript",description:"TypeScript"},{value:"acorn",description:"JavaScript"},{value:"espree",description:"JavaScript"},{value:"meriyah",description:"JavaScript"},{value:"css",description:"CSS"},{value:"less",description:"Less"},{value:"scss",description:"SCSS"},{value:"json",description:"JSON"},{value:"json5",description:"JSON5"},{value:"jsonc",description:"JSON with Comments"},{value:"json-stringify",description:"JSON.stringify"},{value:"graphql",description:"GraphQL"},{value:"markdown",description:"Markdown"},{value:"mdx",description:"MDX"},{value:"vue",description:"Vue"},{value:"yaml",description:"YAML"},{value:"glimmer",description:"Ember / Handlebars"},{value:"html",description:"HTML"},{value:"angular",description:"Angular"},{value:"lwc",description:"Lightning Web Components"}]},plugins:{type:"path",array:!0,default:[{value:["prettier-plugin-tailwindcss"]}],category:"Global",description:"Add a plugin. Multiple plugins can be passed as separate `--plugin`s.",exception:e=>typeof e=="string"||typeof e=="object",cliName:"plugin",cliCategory:"Config"},printWidth:{category:"Global",type:"int",default:120,description:"The line length where Prettier will try wrap.",range:{start:0,end:1/0,step:1}},rangeEnd:{category:"Special",type:"int",default:1/0,range:{start:0,end:1/0,step:1},description:`Format code ending at a given character offset (exclusive). The range will extend forwards to the end of the selected statement.`,cliCategory:"Editor"},rangeStart:{category:"Special",type:"int",default:0,range:{start:0,end:1/0,step:1},description:`Format code starting at a given character offset. The range will extend backwards to the start of the first line containing the selected statement.`,cliCategory:"Editor"},requirePragma:{category:"Special",type:"boolean",default:!1,description:`Require either '@prettier' or '@format' to be present in the file's first docblock comment in order for it to be formatted.`,cliCategory:"Other"},tabWidth:{type:"int",category:"Global",default:2,description:"Number of spaces per indentation level.",range:{start:0,end:1/0,step:1}},useTabs:{category:"Global",type:"boolean",default:!0,description:"Indent with tabs instead of spaces."},embeddedLanguageFormatting:{category:"Global",type:"choice",default:"auto",description:"Control how Prettier formats quoted code embedded in the file.",choices:[{value:"auto",description:"Format embedded code if Prettier can automatically identify it."},{value:"off",description:"Never automatically format embedded code."}]}};function ot({plugins:e=[],showDeprecated:t=!1}={}){let r=e.flatMap(u=>u.languages??[]),n=[];for(let u of li(Object.assign({},...e.map(({options:i})=>i),cn)))!t&&u.deprecated||(Array.isArray(u.choices)&&(t||(u.choices=u.choices.filter(i=>!i.deprecated)),u.name==="parser"&&(u.choices=[...u.choices,...Di(u.choices,r,e)])),u.pluginDefaults=Object.fromEntries(e.filter(i=>{var o;return((o=i.defaultOptions)==null?void 0:o[u.name])!==void 0}).map(i=>[i.name,i.defaultOptions[u.name]])),n.push(u));return{languages:r,options:n}}function*Di(e,t,r){let n=new Set(e.map(u=>u.value));for(let u of t)if(u.parsers){for(let i of u.parsers)if(!n.has(i)){n.add(i);let o=r.find(a=>a.parsers&&Object.prototype.hasOwnProperty.call(a.parsers,i)),s=u.name;o!=null&&o.name&&(s+=` (plugin: ${o.name})`),yield{value:i,description:s}}}}function li(e){let t=[];for(let[r,n]of Object.entries(e)){let u={name:r,...n};Array.isArray(u.default)&&(u.default=y(!1,u.default,-1).value),t.push(u)}return t}var ci=e=>String(e).split(/[/\\]/u).pop();function fn(e,t){if(!t)return;let r=ci(t).toLowerCase();return e.find(({filenames:n})=>n==null?void 0:n.some(u=>u.toLowerCase()===r))??e.find(({extensions:n})=>n==null?void 0:n.some(u=>r.endsWith(u)))}function fi(e,t){if(t)return e.find(({name:r})=>r.toLowerCase()===t)??e.find(({aliases:r})=>r==null?void 0:r.includes(t))??e.find(({extensions:r})=>r==null?void 0:r.includes(`.${t}`))}function di(e,t){let r=e.plugins.flatMap(u=>u.languages??[]),n=fi(r,t.language)??fn(r,t.physicalFile)??fn(r,t.file)??(t.physicalFile,void 0);return n==null?void 0:n.parsers[0]}var dn=di;var oe={key:e=>/^[$_a-zA-Z][$_a-zA-Z0-9]*$/.test(e)?e:JSON.stringify(e),value(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(r=>oe.value(r)).join(", ")}]`;let t=Object.keys(e);return t.length===0?"{}":`{ ${t.map(r=>`${oe.key(r)}: ${oe.value(e[r])}`).join(", ")} }`},pair:({key:e,value:t})=>oe.value({[e]:t})};var Mt=Me(st(),1),mn=(e,t,{descriptor:r})=>{let n=[`${Mt.default.yellow(typeof e=="string"?r.key(e):r.pair(e))} is deprecated`];return t&&n.push(`we now treat it as ${Mt.default.blue(typeof t=="string"?r.key(t):r.pair(t))}`),n.join("; ")+"."};var ce=Me(st(),1);var at=Symbol.for("vnopts.VALUE_NOT_EXIST"),Ae=Symbol.for("vnopts.VALUE_UNCHANGED");var hn=" ".repeat(2),Cn=(e,t,r)=>{let{text:n,list:u}=r.normalizeExpectedResult(r.schemas[e].expected(r)),i=[];return n&&i.push(En(e,t,n,r.descriptor)),u&&i.push([En(e,t,u.title,r.descriptor)].concat(u.values.map(o=>gn(o,r.loggerPrintWidth))).join(` diff --git a/package-lock.json b/package-lock.json index 2583c1e6adfe..5970580509f7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -109,6 +109,7 @@ "postcss-selector-parser": "2.2.3", "postcss-values-parser": "2.0.1", "prettier": "3.3.3", + "prettier-plugin-tailwindcss": "^0.6.8", "pretty-bytes": "6.1.1", "regexp-util": "2.0.0", "remark-footnotes": "2.0.0", @@ -11374,6 +11375,85 @@ "url": "https://github.com/prettier/prettier?sponsor=1" } }, + "node_modules/prettier-plugin-tailwindcss": { + "version": "0.6.8", + "resolved": "https://registry.npmjs.org/prettier-plugin-tailwindcss/-/prettier-plugin-tailwindcss-0.6.8.tgz", + "integrity": "sha512-dGu3kdm7SXPkiW4nzeWKCl3uoImdd5CTZEJGxyypEPL37Wj0HT2pLqjrvSei1nTeuQfO4PUfjeW5cTUNRLZ4sA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.21.3" + }, + "peerDependencies": { + "@ianvs/prettier-plugin-sort-imports": "*", + "@prettier/plugin-pug": "*", + "@shopify/prettier-plugin-liquid": "*", + "@trivago/prettier-plugin-sort-imports": "*", + "@zackad/prettier-plugin-twig-melody": "*", + "prettier": "^3.0", + "prettier-plugin-astro": "*", + "prettier-plugin-css-order": "*", + "prettier-plugin-import-sort": "*", + "prettier-plugin-jsdoc": "*", + "prettier-plugin-marko": "*", + "prettier-plugin-multiline-arrays": "*", + "prettier-plugin-organize-attributes": "*", + "prettier-plugin-organize-imports": "*", + "prettier-plugin-sort-imports": "*", + "prettier-plugin-style-order": "*", + "prettier-plugin-svelte": "*" + }, + "peerDependenciesMeta": { + "@ianvs/prettier-plugin-sort-imports": { + "optional": true + }, + "@prettier/plugin-pug": { + "optional": true + }, + "@shopify/prettier-plugin-liquid": { + "optional": true + }, + "@trivago/prettier-plugin-sort-imports": { + "optional": true + }, + "@zackad/prettier-plugin-twig-melody": { + "optional": true + }, + "prettier-plugin-astro": { + "optional": true + }, + "prettier-plugin-css-order": { + "optional": true + }, + "prettier-plugin-import-sort": { + "optional": true + }, + "prettier-plugin-jsdoc": { + "optional": true + }, + "prettier-plugin-marko": { + "optional": true + }, + "prettier-plugin-multiline-arrays": { + "optional": true + }, + "prettier-plugin-organize-attributes": { + "optional": true + }, + "prettier-plugin-organize-imports": { + "optional": true + }, + "prettier-plugin-sort-imports": { + "optional": true + }, + "prettier-plugin-style-order": { + "optional": true + }, + "prettier-plugin-svelte": { + "optional": true + } + } + }, "node_modules/pretty-bytes": { "version": "6.1.1", "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-6.1.1.tgz", diff --git a/package.json b/package.json index f21c83418279..aa3466b0c1ad 100644 --- a/package.json +++ b/package.json @@ -29,18 +29,18 @@ "devDependencies": { "@angular/compiler": "18.2.6", "@babel/code-frame": "7.26.2", - "@babel/generator": "7.26.2", + "@babel/generator": "7.26.2", "@babel/parser": "7.26.2", "@babel/types": "7.26.0", - "@eslint/js": "9.13.0", + "@eslint/js": "9.13.0", "@glimmer/syntax": "0.92.3", "@prettier/is-es5-identifier-name": "0.2.0", "@prettier/parse-srcset": "3.1.0", - "@stylistic/eslint-plugin-js": "2.9.0", + "@stylistic/eslint-plugin-js": "2.9.0", "@types/eslint__js": "8.42.3", "@types/estree": "1.0.6", "@types/file-entry-cache": "5.0.4", - "@typescript-eslint/eslint-plugin": "8.10.0", + "@typescript-eslint/eslint-plugin": "8.10.0", "@typescript-eslint/typescript-estree": "8.10.0", "@typescript-eslint/visitor-keys": "8.10.0", "acorn": "8.14.0", @@ -68,16 +68,16 @@ "esbuild-plugins-node-modules-polyfill": "1.6.6", "esbuild-visualizer": "0.6.0", "escape-string-regexp": "5.0.0", - "eslint": "9.13.0", + "eslint": "9.13.0", "eslint-config-prettier": "9.1.0", "eslint-formatter-friendly": "7.0.0", - "eslint-plugin-compat": "6.0.1", + "eslint-plugin-compat": "6.0.1", "eslint-plugin-jest": "28.8.3", - "eslint-plugin-n": "17.11.1", - "eslint-plugin-react": "7.37.1", + "eslint-plugin-n": "17.11.1", + "eslint-plugin-react": "7.37.1", "eslint-plugin-regexp": "2.6.0", "eslint-plugin-simple-import-sort": "12.1.1", - "eslint-plugin-unicorn": "56.0.0", + "eslint-plugin-unicorn": "56.0.0", "esm-utils": "4.3.0", "espree": "10.3.0", "execa": "7.2.0", @@ -88,7 +88,7 @@ "flow-parser": "0.250.0", "get-east-asian-width": "1.3.0", "get-stdin": "9.0.0", - "globals": "15.11.0", + "globals": "15.11.0", "graphql": "16.9.0", "hermes-parser": "0.25.0", "html-element-attributes": "3.4.0", @@ -105,7 +105,7 @@ "jest-watch-typeahead": "2.2.2", "js-yaml": "4.1.0", "json5": "2.2.3", - "knip": "5.33.3", + "knip": "5.33.3", "leven": "4.0.0", "lines-and-columns": "2.0.4", "linguist-languages": "7.27.0", @@ -114,7 +114,7 @@ "micromatch": "4.0.8", "minimist": "1.2.8", "n-readlines": "1.0.1", - "npm-run-all2": "7.0.0", + "npm-run-all2": "7.0.0", "outdent": "0.8.0", "parse-json": "8.1.0", "postcss": "8.4.47", @@ -124,6 +124,7 @@ "postcss-selector-parser": "2.2.3", "postcss-values-parser": "2.0.1", "prettier": "3.3.3", + "prettier-plugin-tailwindcss": "^0.6.8", "pretty-bytes": "6.1.1", "regexp-util": "2.0.0", "remark-footnotes": "2.0.0", diff --git a/scripts/build/build-javascript-module.js b/scripts/build/build-javascript-module.js index 26a02642f8d5..1d9a5ceb072b 100644 --- a/scripts/build/build-javascript-module.js +++ b/scripts/build/build-javascript-module.js @@ -241,7 +241,7 @@ function getEsbuildOptions({ file, files, cliOptions }) { external: ["pnpapi", ...(buildOptions.external ?? [])], // Disable esbuild auto discover `tsconfig.json` file tsconfigRaw: JSON.stringify({}), - target: [...(buildOptions.target ?? ["node14"])], + target: [...(buildOptions.target ?? ["node16"])], logLevel: "error", format: file.output.format, outfile: path.join(DIST_DIR, cliOptions.saveAs ?? file.output.file), diff --git a/src/main/core-options.evaluate.js b/src/main/core-options.evaluate.js index aa497eaf5c07..55db6caff37b 100644 --- a/src/main/core-options.evaluate.js +++ b/src/main/core-options.evaluate.js @@ -133,7 +133,7 @@ const options = { plugins: { type: "path", array: true, - default: [{ value: [] }], + default: [{ value: ["prettier-plugin-tailwindcss"] }], category: CATEGORY_GLOBAL, description: "Add a plugin. Multiple plugins can be passed as separate `--plugin`s.", diff --git a/src/main/plugins/load-plugin.js b/src/main/plugins/load-plugin.js index fb189c62f2f6..5ca9454244d4 100644 --- a/src/main/plugins/load-plugin.js +++ b/src/main/plugins/load-plugin.js @@ -1,8 +1,12 @@ import path from "node:path"; import { pathToFileURL } from "node:url"; +import * as prettierPluginTailwindcss from "prettier-plugin-tailwindcss"; import importFromDirectory from "../../utils/import-from-directory.js"; async function importPlugin(name, cwd) { + if (name === "prettier-plugin-tailwindcss") { + return prettierPluginTailwindcss; + } if (path.isAbsolute(name)) { return import(pathToFileURL(name).href); }