UNPKG

@shufo/prettier-plugin-blade

Version:

- Automatically indent markup inside directives - Automatically add spacing to blade template markers - PHP 8 syntax support (null safe operator, named arguments) - Compliant to PSR-2 coding standard (PHP code inside directives) - Automatically sort Tailw

3 lines (2 loc) 4.12 kB
var d={tabWidth:4,printWidth:120,singleQuote:!0},c={wrapAttributes:{type:"string",category:"Blade",default:"auto",description:"The way to wrap attributes. [auto|force|force-aligned|force-expand-multiline|aligned-multiple|preserve|preserve-aligned]",since:"1.0.0"},wrapAttributesMinAttrs:{type:"int",category:"Blade",default:2,description:"Minimum number of html tag attributes for force wrap attribute options. Wrap the first attribute only if 'force-expand-multiline' is specified in wrap attributes",since:"1.11.0"},endWithNewLine:{type:"boolean",category:"Blade",default:!0,description:"End output with newline.",since:"1.0.0"},sortTailwindcssClasses:{type:"boolean",category:"Blade",default:!1,description:"Sort Tailwindcss classes automatically. This option respects `tailwind.config.js`.",since:"1.0.0"},tailwindcssConfigPath:{type:"string",category:"Blade",default:"",description:"Path to custom Tailwindcss config. This option is available only when `sortTailwindcssClasses` is present.",since:"1.5.7"},sortHtmlAttributes:{type:"string",category:"Blade",default:"none",description:"Sort HTML Attributes. [none|alphabetical|code-guide|idiomatic|vuejs|custom]",since:"1.5.0"},customHtmlAttributesOrder:{type:"string",category:"Blade",default:"",description:'Comma separated custom HTML attributes order. e.g. "id, aria-.+, class, src". To enable this you must specify sort html attributes option as `custom`. You can use regex for attribute names.',since:"1.8.0"},noPhpSyntaxCheck:{type:"boolean",category:"Blade",default:!1,description:"Disable PHP syntax checking",since:"1.7.0"},indentInnerHtml:{type:"boolean",category:"Blade",default:!1,description:"Indent <head> and <body> sections in html",since:"1.10.0"},extraLiners:{type:"string",category:"Blade",default:"head,body,/html",description:"Comma separated list of tags that should have an extra newline before them.",since:"1.10.0"},trailingCommaPHP:{type:"boolean",category:"Blade",default:!0,description:"If set to false, no trailing commas are printed for php expression.",since:"1.10.0"},phpVersion:{type:"string",category:"Blade",default:"8.4",description:"The version of PHP to use for formatting.",since:"1.13.0"},componentPrefix:{type:"string",category:"Blade",default:"x-,livewire:",description:"Comma separated list of component prefix use to preserve style in html attributes.",since:"1.15.0"}};function a(t){return Number.parseFloat(t)}import{resolveConfigFile as u}from"prettier";import{Formatter as m}from"blade-formatter";import i from"path";var s=async(t,r,e)=>{var n;let l=a(e.phpVersion),p={indentSize:e.tabWidth,wrapLineLength:e.printWidth,wrapAttributes:e.singleAttributePerLine?"force-expand-multiline":e.bracketSameLine?"force-aligned":e.wrapAttributes,wrapAttributesMinAttrs:e.wrapAttributesMinAttrs,endWithNewline:e.endWithNewline,useTabs:e.useTabs,sortTailwindcssClasses:e.sortTailwindcssClasses,tailwindcssConfigPath:await f(e.filepath,e.tailwindcssConfigPath),sortHtmlAttributes:e.sortHtmlAttributes,noMultipleEmptyLines:!0,noPhpSyntaxCheck:e.noPhpSyntaxCheck,noSingleQuote:!e.singleQuote,noTrailingCommaPhp:l<7.2||!e.trailingCommaPHP,customHtmlAttributesOrder:e.customHtmlAttributesOrder,indentInnerHtml:e.indentInnerHtml,componentPrefix:(n=e.componentPrefix)==null?void 0:n.split(","),extraLiners:e.extraLiners.split(","),phpVersion:e.phpVersion||"auto"};return{type:"blade-formatter",body:await new m(p).formatContent(t),end:t.length,source:t,start:0}};async function f(t,r){if(!r)return;if(i.isAbsolute(r??""))return r;let e=await u(t);return i.resolve(i.dirname(e??""),r??"")}var o=t=>{let r=t.getValue();switch(r.type){case"blade-formatter":return r.body}throw new Error(`Unknown node type: ${r.type}`)};var L=[{name:"Blade",parsers:["blade"],since:"1.0.0",extensions:[".blade.php"],tmScope:"source.blade.php",aceMode:"text",linguistLanguageId:33,vscodeLanguageIds:["blade"]}],B={blade:{parse:s,astFormat:"blade-format",locStart(t){return t.start},locEnd(t){return t.end}}},v={"blade-format":{print:o}};export{d as defaultOptions,L as languages,c as options,B as parsers,v as printers}; //# sourceMappingURL=index.js.map