@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.82 kB
JavaScript
;var b=Object.create;var a=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,P=Object.prototype.hasOwnProperty;var x=(t,r)=>{for(var e in r)a(t,e,{get:r[e],enumerable:!0})},l=(t,r,e,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of y(r))!P.call(t,i)&&i!==e&&a(t,i,{get:()=>r[i],enumerable:!(n=h(r,i))||n.enumerable});return t};var A=(t,r,e)=>(e=t!=null?b(w(t)):{},l(r||!t||!t.__esModule?a(e,"default",{value:t,enumerable:!0}):e,t)),C=t=>l(a({},"__esModule",{value:!0}),t);var v={};x(v,{defaultOptions:()=>p,languages:()=>H,options:()=>d,parsers:()=>L,printers:()=>B});module.exports=C(v);var p={tabWidth:4,printWidth:120,singleQuote:!0},d={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 c(t){return Number.parseFloat(t)}var u=require("prettier"),m=require("blade-formatter"),s=A(require("path"),1);var f=async(t,r,e)=>{var o;let n=c(e.phpVersion),i={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 T(e.filepath,e.tailwindcssConfigPath),sortHtmlAttributes:e.sortHtmlAttributes,noMultipleEmptyLines:!0,noPhpSyntaxCheck:e.noPhpSyntaxCheck,noSingleQuote:!e.singleQuote,noTrailingCommaPhp:n<7.2||!e.trailingCommaPHP,customHtmlAttributesOrder:e.customHtmlAttributesOrder,indentInnerHtml:e.indentInnerHtml,componentPrefix:(o=e.componentPrefix)==null?void 0:o.split(","),extraLiners:e.extraLiners.split(","),phpVersion:e.phpVersion||"auto"};return{type:"blade-formatter",body:await new m.Formatter(i).formatContent(t),end:t.length,source:t,start:0}};async function T(t,r){if(!r)return;if(s.default.isAbsolute(r??""))return r;let e=await(0,u.resolveConfigFile)(t);return s.default.resolve(s.default.dirname(e??""),r??"")}var g=t=>{let r=t.getValue();switch(r.type){case"blade-formatter":return r.body}throw new Error(`Unknown node type: ${r.type}`)};var H=[{name:"Blade",parsers:["blade"],since:"1.0.0",extensions:[".blade.php"],tmScope:"source.blade.php",aceMode:"text",linguistLanguageId:33,vscodeLanguageIds:["blade"]}],L={blade:{parse:f,astFormat:"blade-format",locStart(t){return t.start},locEnd(t){return t.end}}},B={"blade-format":{print:g}};0&&(module.exports={defaultOptions,languages,options,parsers,printers});
//# sourceMappingURL=index.cjs.map