@prettier/plugin-pug
Advanced tools
Comparing version
@@ -1,12 +0,45 @@ | ||
import type { Parser, Plugin, Printer, RequiredOptions, SupportLanguage, SupportOptions } from 'prettier'; | ||
export declare const plugin: Plugin; | ||
export declare const languages: SupportLanguage[] | undefined; | ||
export declare const parsers: { | ||
import { Plugin, SupportLanguage, Parser, Printer, SupportOptions, RequiredOptions } from 'prettier'; | ||
import { Token } from 'pug-lexer'; | ||
declare enum LogLevel { | ||
DEBUG = "debug", | ||
LOG = "log", | ||
INFO = "info", | ||
WARN = "warn", | ||
ERROR = "error", | ||
OFF = "off" | ||
} | ||
type ILogger = Pick<typeof console, 'debug' | 'log' | 'info' | 'warn' | 'error'>; | ||
declare class Logger implements ILogger { | ||
private readonly logger; | ||
private level; | ||
constructor(logger?: ILogger, level?: LogLevel); | ||
static isSupportedLogLevel(value: any): value is LogLevel; | ||
setLogLevel(level: LogLevel): void; | ||
isDebugEnabled(): boolean; | ||
debug(message?: unknown, ...optionalParams: any[]): void; | ||
log(message?: unknown, ...optionalParams: any[]): void; | ||
info(message?: unknown, ...optionalParams: any[]): void; | ||
warn(message?: unknown, ...optionalParams: any[]): void; | ||
error(message?: unknown, ...optionalParams: any[]): void; | ||
private message; | ||
} | ||
declare function createLogger(logger?: ILogger): Logger; | ||
declare const logger: Logger; | ||
interface AstPathStackEntry { | ||
content: string; | ||
tokens: Token[]; | ||
} | ||
declare const plugin: Plugin<AstPathStackEntry>; | ||
declare const languages: SupportLanguage[] | undefined; | ||
declare const parsers: { | ||
[parserName: string]: Parser; | ||
} | undefined; | ||
export declare const printers: { | ||
declare const printers: { | ||
[astFormat: string]: Printer; | ||
} | undefined; | ||
export declare const options: SupportOptions | undefined; | ||
export declare const defaultOptions: Partial<RequiredOptions> | undefined; | ||
export { ILogger, LogLevel, Logger, createLogger, logger } from './logger'; | ||
declare const options: SupportOptions | undefined; | ||
declare const defaultOptions: Partial<RequiredOptions> | undefined; | ||
export { ILogger, LogLevel, Logger, createLogger, defaultOptions, languages, logger, options, parsers, plugin, printers }; |
@@ -1,90 +0,63 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.logger = exports.createLogger = exports.Logger = exports.LogLevel = exports.defaultOptions = exports.options = exports.printers = exports.parsers = exports.languages = exports.plugin = void 0; | ||
const pug_lexer_1 = __importDefault(require("pug-lexer")); | ||
const logger_1 = require("./logger"); | ||
const options_1 = require("./options"); | ||
const converge_1 = require("./options/converge"); | ||
const printer_1 = require("./printer"); | ||
exports.plugin = { | ||
languages: [ | ||
{ | ||
name: 'Pug', | ||
parsers: ['pug'], | ||
tmScope: 'text.jade', | ||
aceMode: 'jade', | ||
codemirrorMode: 'pug', | ||
codemirrorMimeType: 'text/x-pug', | ||
extensions: ['.jade', '.pug'], | ||
linguistLanguageId: 179, | ||
vscodeLanguageIds: ['jade', 'pug'], | ||
}, | ||
], | ||
parsers: { | ||
pug: { | ||
parse(text, parsers, options) { | ||
logger_1.logger.debug('[parsers:pug:parse]:', { text }); | ||
let trimmedAndAlignedContent = text.replace(/^\s*\n/, ''); | ||
const contentIndentation = /^\s*/.exec(trimmedAndAlignedContent); | ||
if (contentIndentation?.[0]) { | ||
const contentIndentationRegex = new RegExp(`(^|\\n)${contentIndentation[0]}`, 'g'); | ||
trimmedAndAlignedContent = trimmedAndAlignedContent.replace(contentIndentationRegex, '$1'); | ||
} | ||
const content = trimmedAndAlignedContent; | ||
const tokens = (0, pug_lexer_1.default)(content); | ||
return { content, tokens }; | ||
}, | ||
astFormat: 'pug-ast', | ||
hasPragma(text) { | ||
return (text.startsWith('//- @prettier\n') || text.startsWith('//- @format\n')); | ||
}, | ||
locStart(node) { | ||
logger_1.logger.debug('[parsers:pug:locStart]:', { node }); | ||
return 0; | ||
}, | ||
locEnd(node) { | ||
logger_1.logger.debug('[parsers:pug:locEnd]:', { node }); | ||
return 0; | ||
}, | ||
preprocess(text, options) { | ||
logger_1.logger.debug('[parsers:pug:preprocess]:', { text }); | ||
return text; | ||
}, | ||
}, | ||
}, | ||
printers: { | ||
'pug-ast': { | ||
print(path, options, print) { | ||
const entry = path.stack[0]; | ||
const { content, tokens } = entry; | ||
const pugOptions = (0, converge_1.convergeOptions)(options); | ||
const printer = new printer_1.PugPrinter(content, tokens, pugOptions); | ||
const result = printer.build(); | ||
logger_1.logger.debug('[printers:pug-ast:print]:', result); | ||
return result; | ||
}, | ||
embed(path, print, textToDoc, options) { | ||
return null; | ||
}, | ||
insertPragma(text) { | ||
return `//- @prettier\n${text}`; | ||
}, | ||
}, | ||
}, | ||
options: options_1.options, | ||
defaultOptions: {}, | ||
}; | ||
exports.languages = exports.plugin.languages; | ||
exports.parsers = exports.plugin.parsers; | ||
exports.printers = exports.plugin.printers; | ||
exports.options = exports.plugin.options; | ||
exports.defaultOptions = exports.plugin.defaultOptions; | ||
var logger_2 = require("./logger"); | ||
Object.defineProperty(exports, "LogLevel", { enumerable: true, get: function () { return logger_2.LogLevel; } }); | ||
Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return logger_2.Logger; } }); | ||
Object.defineProperty(exports, "createLogger", { enumerable: true, get: function () { return logger_2.createLogger; } }); | ||
Object.defineProperty(exports, "logger", { enumerable: true, get: function () { return logger_2.logger; } }); | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7O0FBYUEsMERBQTRCO0FBQzVCLHFDQUFrQztBQUVsQyx1Q0FBa0Q7QUFDbEQsaURBQXFEO0FBRXJELHVDQUF1QztBQVMxQixRQUFBLE1BQU0sR0FBVztJQUM1QixTQUFTLEVBQUU7UUFDVDtZQUNFLElBQUksRUFBRSxLQUFLO1lBQ1gsT0FBTyxFQUFFLENBQUMsS0FBSyxDQUFDO1lBQ2hCLE9BQU8sRUFBRSxXQUFXO1lBQ3BCLE9BQU8sRUFBRSxNQUFNO1lBQ2YsY0FBYyxFQUFFLEtBQUs7WUFDckIsa0JBQWtCLEVBQUUsWUFBWTtZQUNoQyxVQUFVLEVBQUUsQ0FBQyxPQUFPLEVBQUUsTUFBTSxDQUFDO1lBQzdCLGtCQUFrQixFQUFFLEdBQUc7WUFDdkIsaUJBQWlCLEVBQUUsQ0FBQyxNQUFNLEVBQUUsS0FBSyxDQUFDO1NBQ25DO0tBQ0Y7SUFFRCxPQUFPLEVBQUU7UUFDUCxHQUFHLEVBQUU7WUFDSCxLQUFLLENBQ0gsSUFBWSxFQUNaLE9BQXlDLEVBQ3pDLE9BQXNCO2dCQUV0QixlQUFNLENBQUMsS0FBSyxDQUFDLHNCQUFzQixFQUFFLEVBQUUsSUFBSSxFQUFFLENBQUMsQ0FBQztnQkFFL0MsSUFBSSx3QkFBd0IsR0FBVyxJQUFJLENBQUMsT0FBTyxDQUFDLFFBQVEsRUFBRSxFQUFFLENBQUMsQ0FBQztnQkFDbEUsTUFBTSxrQkFBa0IsR0FBMkIsTUFBTSxDQUFDLElBQUksQ0FDNUQsd0JBQXdCLENBQ3pCLENBQUM7Z0JBQ0YsSUFBSSxrQkFBa0IsRUFBRSxDQUFDLENBQUMsQ0FBQyxFQUFFO29CQUMzQixNQUFNLHVCQUF1QixHQUFXLElBQUksTUFBTSxDQUNoRCxVQUFVLGtCQUFrQixDQUFDLENBQUMsQ0FBQyxFQUFFLEVBQ2pDLEdBQUcsQ0FDSixDQUFDO29CQUNGLHdCQUF3QixHQUFHLHdCQUF3QixDQUFDLE9BQU8sQ0FDekQsdUJBQXVCLEVBQ3ZCLElBQUksQ0FDTCxDQUFDO2lCQUNIO2dCQUNELE1BQU0sT0FBTyxHQUFXLHdCQUF3QixDQUFDO2dCQUVqRCxNQUFNLE1BQU0sR0FBWSxJQUFBLG1CQUFHLEVBQUMsT0FBTyxDQUFDLENBQUM7Z0JBSXJDLE9BQU8sRUFBRSxPQUFPLEVBQUUsTUFBTSxFQUFFLENBQUM7WUFDN0IsQ0FBQztZQUNELFNBQVMsRUFBRSxTQUFTO1lBQ3BCLFNBQVMsQ0FBQyxJQUFZO2dCQUNwQixPQUFPLENBQ0wsSUFBSSxDQUFDLFVBQVUsQ0FBQyxpQkFBaUIsQ0FBQyxJQUFJLElBQUksQ0FBQyxVQUFVLENBQUMsZUFBZSxDQUFDLENBQ3ZFLENBQUM7WUFDSixDQUFDO1lBQ0QsUUFBUSxDQUFDLElBQWE7Z0JBQ3BCLGVBQU0sQ0FBQyxLQUFLLENBQUMseUJBQXlCLEVBQUUsRUFBRSxJQUFJLEVBQUUsQ0FBQyxDQUFDO2dCQUNsRCxPQUFPLENBQUMsQ0FBQztZQUNYLENBQUM7WUFDRCxNQUFNLENBQUMsSUFBYTtnQkFDbEIsZUFBTSxDQUFDLEtBQUssQ0FBQyx1QkFBdUIsRUFBRSxFQUFFLElBQUksRUFBRSxDQUFDLENBQUM7Z0JBQ2hELE9BQU8sQ0FBQyxDQUFDO1lBQ1gsQ0FBQztZQUNELFVBQVUsQ0FBQyxJQUFZLEVBQUUsT0FBc0I7Z0JBQzdDLGVBQU0sQ0FBQyxLQUFLLENBQUMsMkJBQTJCLEVBQUUsRUFBRSxJQUFJLEVBQUUsQ0FBQyxDQUFDO2dCQUNwRCxPQUFPLElBQUksQ0FBQztZQUNkLENBQUM7U0FDRjtLQUNGO0lBQ0QsUUFBUSxFQUFFO1FBQ1IsU0FBUyxFQUFFO1lBQ1QsS0FBSyxDQUNILElBQWEsRUFDYixPQUF5QyxFQUN6QyxLQUE2QjtnQkFFN0IsTUFBTSxLQUFLLEdBQXNCLElBQUksQ0FBQyxLQUFLLENBQUMsQ0FBQyxDQUFDLENBQUM7Z0JBQy9DLE1BQU0sRUFBRSxPQUFPLEVBQUUsTUFBTSxFQUFFLEdBQUcsS0FBSyxDQUFDO2dCQUNsQyxNQUFNLFVBQVUsR0FBc0IsSUFBQSwwQkFBZSxFQUFDLE9BQU8sQ0FBQyxDQUFDO2dCQUMvRCxNQUFNLE9BQU8sR0FBZSxJQUFJLG9CQUFVLENBQUMsT0FBTyxFQUFFLE1BQU0sRUFBRSxVQUFVLENBQUMsQ0FBQztnQkFDeEUsTUFBTSxNQUFNLEdBQVcsT0FBTyxDQUFDLEtBQUssRUFBRSxDQUFDO2dCQUN2QyxlQUFNLENBQUMsS0FBSyxDQUFDLDJCQUEyQixFQUFFLE1BQU0sQ0FBQyxDQUFDO2dCQUNsRCxPQUFPLE1BQU0sQ0FBQztZQUNoQixDQUFDO1lBQ0QsS0FBSyxDQUNILElBQWEsRUFDYixLQUE2QixFQUM3QixTQUFrRCxFQUNsRCxPQUFzQjtnQkFHdEIsT0FBTyxJQUFJLENBQUM7WUFDZCxDQUFDO1lBQ0QsWUFBWSxDQUFDLElBQVk7Z0JBQ3ZCLE9BQU8sa0JBQWtCLElBQUksRUFBRSxDQUFDO1lBQ2xDLENBQUM7U0FDRjtLQUNGO0lBRUQsT0FBTyxFQUFFLGlCQUFVO0lBQ25CLGNBQWMsRUFBRSxFQUFFO0NBQ25CLENBQUM7QUFHVyxRQUFBLFNBQVMsR0FBa0MsY0FBTSxDQUFDLFNBQVMsQ0FBQztBQUU1RCxRQUFBLE9BQU8sR0FDbEIsY0FBTSxDQUFDLE9BQU8sQ0FBQztBQUVKLFFBQUEsUUFBUSxHQUNuQixjQUFNLENBQUMsUUFBUSxDQUFDO0FBRUwsUUFBQSxPQUFPLEdBQStCLGNBQU0sQ0FBQyxPQUFPLENBQUM7QUFFckQsUUFBQSxjQUFjLEdBQ3pCLGNBQU0sQ0FBQyxjQUFjLENBQUM7QUFFeEIsbUNBQTJFO0FBQXpELGtHQUFBLFFBQVEsT0FBQTtBQUFFLGdHQUFBLE1BQU0sT0FBQTtBQUFFLHNHQUFBLFlBQVksT0FBQTtBQUFFLGdHQUFBLE1BQU0sT0FBQSJ9 | ||
import Rt from"pug-lexer";var I=(s=>(s.DEBUG="debug",s.LOG="log",s.INFO="info",s.WARN="warn",s.ERROR="error",s.OFF="off",s))(I||{}),P=class{constructor(t=console,e="info"){this.logger=t;this.level=e}static isSupportedLogLevel(t){return typeof t=="string"&&(t==="debug"||t==="log"||t==="info"||t==="warn"||t==="error"||t==="off")}setLogLevel(t){this.level=t}isDebugEnabled(){return this.level<="debug"}debug(t,...e){this.message("debug",t,...e)}log(t,...e){this.message("log",t,...e)}info(t,...e){this.message("info",t,...e)}warn(t,...e){this.message("warn",t,...e)}error(t,...e){this.message("error",t,...e)}message(t,e,...i){this.level!=="off"&&this.level<=t&&t!=="off"&&this.logger[t](e,...i)}};function E(r=console){return new P(r)}var p=E(console);process.env.NODE_ENV==="test"&&p.setLogLevel("debug");var y=process.env.PRETTIER_PLUGIN_PUG_LOG_LEVEL;y&&(y=y.toLowerCase(),P.isSupportedLogLevel(y)&&p.setLogLevel(y));var c="Pug";var O={category:c,type:"path",array:!0,default:[{value:[]}],description:""},L={...O,description:"Define a list of patterns for attributes that are sorted to the beginning."},_={...O,description:"Define a list of patterns for attributes that are sorted at the end."},C={category:c,type:"choice",default:"as-is",description:"Change how the attributes between _beginning_ and _end_ should be sorted.",choices:[{value:"asc",description:"Sort middle attributes ascending."},{value:"desc",description:"Sort middle attributes descending."},{value:"as-is",description:"Middle attributes are leave untouched."}]};var R={category:c,type:"int",default:-1,description:"The line length where Prettier will try wrap.",range:{start:-1,end:1/0,step:1}},N={category:c,type:"choice",default:null,description:"",choices:[{value:null,description:"Use `singleQuote` value."},{value:!0,description:"Use single quotes instead of double quotes."},{value:"true",description:"Use single quotes instead of double quotes."},{value:!1,description:"Use double quotes instead of double quotes."}]},U={category:c,type:"int",default:-1,description:"Number of spaces per indentation level.",range:{start:-1,end:1/0,step:1}},$={category:c,type:"choice",default:null,description:"",choices:[{value:null,description:"Use `useTabs` value."},{value:!0,description:"Indent with tabs instead of spaces."},{value:"true",description:"Indent with tabs instead of spaces."},{value:!1,description:"Indent with spaces instead of tabs."}]},B={category:c,type:"choice",default:null,description:"",choices:[{value:null,description:"Use `bracketSpacing` value."},{value:!0,description:"Print spaces between brackets."},{value:"true",description:"Print spaces between brackets."},{value:!1,description:"Do not print spaces between brackets."}]},G={category:c,type:"choice",default:null,description:"",choices:[{value:null,description:"Use `bracketSpacing` value."},{value:!0,description:"Print semicolons."},{value:"true",description:"Print semicolons."},{value:!1,description:"Do not print semicolons, except at the beginning of lines which may need them."}]},W={category:c,type:"choice",default:null,description:"Include parentheses around a sole arrow function parameter.",choices:[{value:null,description:"Use `arrowParens` value."},{value:"always",description:"Always add parens. Example: `(x) => x`"},{value:"avoid",description:"Omit parens when possible. Example: `x => x`"}]},F={category:c,type:"choice",default:null,description:"Determines position of closing bracket which wraps attributes.",choices:[{value:null,description:"Use `bracketSameLine` value."},{value:!0,description:` | ||
Closing bracket remains with last attribute's line. | ||
Example: | ||
input( | ||
type='text', | ||
value='my_value', | ||
name='my_name', | ||
alt='my_alt', | ||
autocomplete='on') | ||
`},{value:"true",description:` | ||
Closing bracket remains with last attribute's line. | ||
Example: | ||
input( | ||
type='text', | ||
value='my_value', | ||
name='my_name', | ||
alt='my_alt', | ||
autocomplete='on') | ||
`},{value:!1,description:` | ||
Closing bracket ends with a new line. | ||
Example: | ||
input( | ||
type='text', | ||
value='my_value', | ||
name='my_name', | ||
alt='my_alt', | ||
autocomplete='on' | ||
) | ||
`}]};var D={category:c,type:"choice",default:"as-is",description:"Change behavior of boolean attributes.",choices:[{value:"as-is",description:"Nothing is changed."},{value:"none",description:"Every attribute with empty quotes will have them removed."},{value:"all",description:"Every boolean attribute will be expressed with empty quotes."}]},Q={category:c,type:"path",default:[{value:[]}],array:!0,description:'Define a list of patterns for attributes that will be forced to have empty quotes even with "none" selected.'};var j={category:c,type:"choice",default:"always",description:"Change when attributes are separated by commas in tags.",choices:[{value:"always",description:'Always separate attributes with commas. Example: `button(type="submit", (click)="play()", disabled)`'},{value:"as-needed",description:'Only add commas between attributes where required. Example: `button(type="submit", (click)="play()" disabled)`'},{value:"none",description:'Never add commas between attributes. Example: `button(type="submit" @click="play()" :style="style" disabled)`'}]};function V(r){switch(r){case"always":case"as-needed":case"none":return r}throw new Error(`Invalid option for pugAttributeSeparator. Found '${r}'. Possible options: 'always', 'as-needed' or 'none'`)}var M={category:c,type:"choice",default:"before-attributes",description:"Define where classes be placed.",choices:[{value:"before-attributes",description:"Forces all valid class literals to be placed before attributes."},{value:"after-attributes",description:"Forces all valid class literals to be placed after attributes."}]};var q={category:c,type:"choice",default:"literal",description:"Define how classes should be formatted.",choices:[{value:"literal",description:"Forces all valid classes to be printed as literals."},{value:"attribute",description:"Forces all valid classes to be printed in class attribute."},{value:"as-is",description:"Disables class formatting."}]};var Y={category:c,type:"choice",default:"keep-all",description:"Change behavior of spaces within comments.",choices:[{value:"keep-all",description:"Keep all spaces within comments. Example: `// this is a comment`"},{value:"keep-leading",description:"Keep leading spaces within comments. Example: `// this is a comment`"},{value:"trim-all",description:"Trim all spaces within comments. Example: `// this is a comment`"}]};function A(r,t,e=!1){switch(t){case"keep-leading":{let i="",n=0;for(n;n<r.length&&r[n]===" ";n++)i+=" ";return i+=r.slice(n).trim().replace(/\s\s+/g," "),i}case"trim-all":{let i=r.trim();return i=i.replace(/\s\s+/g," "),!e&&r[0]===" "&&(i=` ${i}`),i}case"keep-all":default:return r}}var H={category:c,type:"boolean",default:!1,description:"Include `div` tag when followed by literal class or id syntax"};var K={category:c,type:"choice",default:"auto",description:"Define which framework is used in the project.",choices:[{value:"auto",description:"Try to identify used framework, if there is one."},{value:"vue",description:"Uses Vue.js."},{value:"svelte",description:"Uses Svelte."},{value:"angular",description:"Uses Angular."}]};var z={category:c,type:"choice",default:"literal",description:"Define how the id should be formatted.",choices:[{value:"literal",description:"Forces all valid ids to be printed as literals."},{value:"as-is",description:"Disables id formatting."}]};var J={category:c,type:"boolean",default:!1,description:"Preserve attribute brackets."};var Z={category:c,type:"boolean",default:!1,description:"Indent pug in template tags in single file components such as from vue or svelte."};var X={category:c,type:"int",default:-1,description:"The maximum amount of attributes that an element can appear with on one line before it gets wrapped.",range:{start:-1,end:1/0,step:1}},tt={category:c,type:"path",default:"",description:"Regex pattern to match attributes against that should always trigger wrapping."};var et={pugPrintWidth:R,pugSingleQuote:N,pugTabWidth:U,pugUseTabs:$,pugBracketSpacing:B,pugArrowParens:W,pugSemi:G,pugBracketSameLine:F,pugAttributeSeparator:j,pugCommentPreserveSpaces:Y,pugSortAttributes:C,pugSortAttributesBeginning:L,pugSortAttributesEnd:_,pugWrapAttributesThreshold:X,pugWrapAttributesPattern:tt,pugEmptyAttributes:D,pugClassNotation:q,pugIdNotation:z,pugClassLocation:M,pugExplicitDiv:H,pugEmptyAttributesForceQuotes:Q,pugSingleFileComponentIndentation:Z,pugFramework:K,pugPreserveAttributeBrackets:J};function it(r){return{printWidth:r.printWidth,pugPrintWidth:r.pugPrintWidth!==-1?r.pugPrintWidth:r.printWidth,singleQuote:r.singleQuote,pugSingleQuote:r.pugSingleQuote??r.singleQuote,tabWidth:r.tabWidth,pugTabWidth:r.pugTabWidth!==-1?r.pugTabWidth:r.tabWidth,useTabs:r.useTabs??!1,pugUseTabs:r.pugUseTabs??r.useTabs??!1,bracketSpacing:r.bracketSpacing,pugBracketSpacing:r.pugBracketSpacing??r.bracketSpacing,arrowParens:r.arrowParens,pugArrowParens:r.pugArrowParens??r.arrowParens,semi:r.semi,pugSemi:r.pugSemi??r.semi,bracketSameLine:r.bracketSameLine,pugBracketSameLine:r.pugBracketSameLine??r.bracketSameLine,pugAttributeSeparator:r.pugAttributeSeparator,pugCommentPreserveSpaces:r.pugCommentPreserveSpaces,pugSortAttributes:r.pugSortAttributes,pugSortAttributesBeginning:r.pugSortAttributesBeginning,pugSortAttributesEnd:r.pugSortAttributesEnd,pugWrapAttributesThreshold:r.pugWrapAttributesThreshold,pugWrapAttributesPattern:r.pugWrapAttributesPattern,pugClassNotation:r.pugClassNotation,pugIdNotation:r.pugIdNotation,pugClassLocation:r.pugClassLocation,pugEmptyAttributes:r.pugEmptyAttributes,pugEmptyAttributesForceQuotes:r.pugEmptyAttributesForceQuotes,pugSingleFileComponentIndentation:r.pugSingleFileComponentIndentation&&r.__embeddedInHtml===!0,pugFramework:r.pugFramework,pugExplicitDiv:r.pugExplicitDiv,pugPreserveAttributeBrackets:r.pugPreserveAttributeBrackets}}import{types as Ct}from"node:util";import{format as f}from"prettier";var rt={"<!doctype html>":"doctype html",'<?xml version="1.0" encoding="utf-8" ?>':"doctype xml",'<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">':"doctype transitional",'<!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd">':"doctype strict",'<!doctype html public "-//w3c//dtd xhtml 1.0 frameset//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-frameset.dtd">':"doctype frameset",'<!doctype html public "-//w3c//dtd xhtml 1.1//en" "http://www.w3.org/tr/xhtml11/dtd/xhtml11.dtd">':"doctype 1.1",'<!doctype html public "-//w3c//dtd xhtml basic 1.1//en" "http://www.w3.org/tr/xhtml-basic/xhtml-basic11.dtd">':"doctype basic",'<!doctype html public "-//wapforum//dtd xhtml mobile 1.2//en" "http://www.openmobilealliance.org/tech/dtd/xhtml-mobile12.dtd">':"doctype mobile",'<!doctype plist public "-//apple//dtd plist 1.0//en" "http://www.apple.com/dtds/propertylist-1.0.dtd">':"doctype plist"};function nt(r,t,e,i,n){let o=i.map(u=>new RegExp(u)).reverse(),s=n.map(u=>new RegExp(u)),a=r.name,l=t.name;if(o.length>0){let u=o.findIndex(d=>d.test(a)),h=o.findIndex(d=>d.test(l)),g=u-h;if(g>0)return-1;if(g<0)return 1}if(s.length>0){let u=s.findIndex(d=>d.test(a)),h=s.findIndex(d=>d.test(l)),g=u-h;if(g>0)return 1;if(g<0)return-1}switch(e){case"asc":{if(a>l)return 1;if(a<l)return-1;break}case"desc":{if(a>l)return-1;if(a<l)return 1;break}}return 0}function It(r,t){let e=r.map((i,n)=>[i,n]);return e.sort((i,n)=>{let o=t(i[0],n[0]);return o!==0?o:i[1]-n[1]}),e.map(([i])=>i)}function st(r,t,e,i){let n=r.slice(0,t),o=r.slice(e),s=r.slice(t,e),a=It(s,i);return[...n,...a,...o]}var Et=[!0,'""',"''"];function ot(r,t,e){let{val:i,name:n}=r;if(e.map(a=>new RegExp(a)).some(a=>a.test(n))){r.val===!0&&(r.val='""');return}if(!(t==="as-is"||!Et.includes(i)))switch(t){case"all":{r.val===!0&&(r.val='""');break}case"none":{(r.val==='""'||r.val==="''")&&(r.val=!0);break}}}function at(r,t){for(let e=t-1;e>=0;e--){let i=r[e];if(!i)return;if(i.type==="tag")return i}}function lt(r,t){for(let e=t-1;e>0;e--){let i=r[e];if(!i||i.type==="start-attributes")return;if(i.type==="attribute"&&i.name!=="class"&&i.name!=="id")return i}}function pt(r,t){for(let e=t-1;e>0;e--){let i=r[e];if(!i||i.type==="start-attributes"||i.type==="tag")return;if(i.type==="attribute"&&i.name==="type")return i}}function T(r){return r.includes(` | ||
`)?r.split(` | ||
`).map(t=>t.trim()).map(t=>(t[0]==="."?"":" ")+t).join("").trim():r}function ut(r,t){return r==="style"&&m(t)}function k(r,t,e,i=0){return r.startsWith(t,i)&&r.endsWith(e,r.length-i)}function m(r){return/^(["'`])(.*)\1$/.test(r)?!new RegExp(`${r[0]}(?<!\\\\${r[0]})`).test(r.slice(1,-1)):!1}function ct(r){return/^`[\s\S]*`$/.test(r)&&r.includes("${")}function gt(r){return/^`[\s\S]*`$/m.test(r)&&r.includes(` | ||
`)}function b(r,t,[e,i]=["{{","}}"]){return r?`${e} ${t} ${i}`:`${e}${t}${i}`}function S(r,t,e=!1){let i=t==='"'?"'":'"',n=r.replace(/\\([\s\S])|(['"])/g,(o,s,a)=>s===i?s:a===t?`\\${a}`:a||(e&&/^[^\\nrvtbfux\r\n\u2028\u2029"'0-7]$/.test(s)?s:`\\${s}`));return t+n+t}function w(r,t,e,i){let n=r.indexOf(t),o=r.indexOf(e),s=r.indexOf("`");return n>=0&&o>=0&&o>n&&(s<0||n<s)?(i.log({code:r,quotes:t,otherQuotes:e,q1:n,q2:o,qb:s}),!0):!1}function ht(){try{let r=Object.keys(process.env).filter(t=>t.startsWith("npm_package_")).filter(t=>/(dev)?[Dd]ependencies_+/.test(t));if(r.some(t=>t.includes("vue")&&!t.includes("vuepress")))return"vue";if(r.some(t=>t.includes("svelte")))return"svelte";if(r.some(t=>t.includes("angular")))return"angular"}catch{return"auto"}return"auto"}function dt(r){return r.length>=3&&r[0]==="["&&r[r.length-1]==="]"}function mt(r){return r.length>=3&&r[0]==="("&&r[r.length-1]===")"}function ft(r){return r.length>=2&&r[0]==="*"}function bt(r){return r.length>=5&&m(r)&&k(r,"{{","}}",1)&&!r.includes("{{",3)}var Ot=/\+(json|yaml)$/i,Lt=/(^("|'|`))|(("|'|`)$)/g,_t=new Map([["application/ecmascript","babel"],["application/javascript","babel"],["application/json","json"],["text/ecmascript","babel"],["text/javascript","babel"],["text/markdown","markdown"],["text/typescript","typescript"],["module","babel"]]);function Tt(r){if(!r)return"babel";let t=r.val;if(typeof t!="string")return;let e=t.replace(Lt,"");if(!e)return"babel";let i=Ot.exec(e);return i?i[1]:_t.get(e)}function yt(r){return r.length>=3&&m(r)&&k(r,"{","}",1)&&!r.includes("{",2)}function Pt(r){return/^(v-on:|@).*/.test(r)}function vt(r){return/^((v-(bind|slot))?:|v-(model|slot|if|for|else-if|text|html|t)|#).*/.test(r)}function kt(r,t){return r==="v-for"&&t.includes("of")}function St(r){return r==="v-bind"}function xt(r){return r==="v-on"}function At(r){return r.startsWith("v-")}var x=class{constructor(t,e,i){this.content=t;this.tokens=e;this.options=i;this.indentString=i.pugUseTabs?" ":" ".repeat(i.pugTabWidth),i.pugSingleFileComponentIndentation&&this.indentLevel++,this.framework=i.pugFramework!=="auto"?i.pugFramework:ht(),this.quotes=this.options.pugSingleQuote?"'":'"',this.otherQuotes=this.options.pugSingleQuote?'"':"'";let n=V(i.pugAttributeSeparator);this.alwaysUseAttributeSeparator=n==="always",this.neverUseAttributeSeparator=n==="none";let o=i.pugWrapAttributesPattern;this.wrapAttributesPattern=o?new RegExp(o):null,this.codeInterpolationOptions={semi:i.pugSemi??i.semi,singleQuote:i.pugSingleQuote??i.singleQuote,bracketSpacing:i.pugBracketSpacing??i.bracketSpacing,arrowParens:i.pugArrowParens??i.arrowParens,printWidth:9e3,endOfLine:"lf",useTabs:i.pugUseTabs??i.useTabs,tabWidth:i.pugTabWidth??i.tabWidth,bracketSameLine:i.pugBracketSameLine??i.bracketSameLine}}result="";currentIndex=-1;currentLineLength=0;indentString;indentLevel=0;framework="auto";quotes;otherQuotes;alwaysUseAttributeSeparator;neverUseAttributeSeparator;wrapAttributesPattern;codeInterpolationOptions;currentTagPosition=0;possibleIdPosition=0;possibleClassPosition=0;previousAttributeRemapped=!1;wrapAttributes=!1;pipelessText=!1;pipelessComment=!1;currentlyInPugInterpolation=!1;classLiteralToAttribute=[];classLiteralAfterAttributes=[];get computedIndent(){var t;switch((t=this.previousToken)==null?void 0:t.type){case"newline":case"outdent":return this.indentString.repeat(this.indentLevel);case"indent":return this.indentString;case"start-pug-interpolation":return""}return this.options.pugSingleFileComponentIndentation?this.indentString:""}get previousToken(){return this.tokens[this.currentIndex-1]}get nextToken(){return this.tokens[this.currentIndex+1]}async build(){var i,n;p.isDebugEnabled()&&p.debug("[PugPrinter]:",JSON.stringify(this.tokens));let t=[];if(((i=this.tokens[0])==null?void 0:i.type)==="text")t.push("| ");else if(((n=this.tokens[0])==null?void 0:n.type)==="eos")return"";let e=this.getNextToken();for(;e;){p.debug("[PugPrinter]:",JSON.stringify(e));try{switch(e.type){case"attribute":case"class":case"end-attributes":case"id":case"eos":this.result=t.join(""),await this[e.type](e),t.length=0,t.push(this.result);break;case"tag":case"start-attributes":case"interpolation":case"call":case":":this.result=t.join("");default:{if(typeof this[e.type]!="function")throw new Error("Unhandled token: "+JSON.stringify(e));t.push(await this[e.type](e));break}}}catch(o){throw new Error(o)}e=this.getNextToken()}return t.join("")}getNextToken(){return this.currentIndex++,this.tokens[this.currentIndex]??null}quoteString(t){return`${this.quotes}${t}${this.quotes}`}checkTokenType(t,e,i=!1){return!!t&&e.includes(t.type)!==i}tokenNeedsSeparator(t){return this.neverUseAttributeSeparator?!1:this.alwaysUseAttributeSeparator||/^(\(|\[|:).*/.test(t.name)}getUnformattedContentLines(t,e){let{start:i}=t.loc,{end:n}=e.loc,o=this.content.split(/\r\n|\n|\r/),s=i.line-1,a=n.line-1,l=[],u=o[s];u!==void 0&&l.push(u.slice(i.column-1));for(let g=s+1;g<a;g++){let d=o[g];d!==void 0&&l.push(d)}let h=o[a];return h!==void 0&&l.push(h.slice(0,n.column-1)),l}replaceTagWithLiteralIfPossible(t,e){if(this.options.pugExplicitDiv)return;let i=Math.max(this.possibleIdPosition,this.possibleClassPosition),n=this.result.slice(this.currentTagPosition,i),o=n.replace(t,e);if(o!==n){let s=this.result.slice(0,this.currentTagPosition),a=this.result.slice(i);this.result=`${s}${o}${a}`;let l=n.length-o.length;this.possibleIdPosition-=l,this.possibleClassPosition-=l}}async frameworkFormat(t){let e={...this.codeInterpolationOptions,singleQuote:this.options.singleQuote};switch(this.framework){case"angular":e.parser="__ng_interpolation";break;case"svelte":case"vue":default:e.parser="babel",e.semi=!1}let i=await f(t,e);return i[0]===";"&&(i=i.slice(1)),i}async formatText(t){let e="";for(;t;){let i=t.indexOf("{{");if(i!==-1){e+=t.slice(0,i),t=t.slice(i+2);let n=t.indexOf("}}");if(n!==-1){let o=t.slice(0,n);try{if(w(o,this.quotes,this.otherQuotes,p)){p.warn("The following expression could not be formatted correctly. Please try to fix it yourself and if there is a problem, please open a bug issue:",o),e+=b(this.options.pugBracketSpacing,o),t=t.slice(n+2);continue}else o=await this.frameworkFormat(o)}catch(s){typeof s=="string"?s.includes("Unexpected token Lexer Error")?s.includes("Unexpected character [`]")||p.debug("[PugPrinter:formatText]: Using fallback strategy"):s.includes("Bindings cannot contain assignments")?p.warn("[PugPrinter:formatText]: Bindings should not contain assignments:",`code: \`${o.trim()}\``):s.includes("Unexpected token '('")?this.framework!=="vue"&&p.warn("[PugPrinter:formatText]: Found unexpected token `(`.",`code: \`${o.trim()}\``):s.includes("Missing expected `)`")?this.framework!=="vue"&&p.warn("[PugPrinter:formatText]: Missing expected `)`.",`code: \`${o.trim()}\``):s.includes("Missing expected `:`")?this.framework!=="vue"&&p.warn("[PugPrinter:formatText]: Missing expected `:`.",`code: \`${o.trim()}\``):p.warn("[PugPrinter:formatText]: ",s):p.warn("[PugPrinter:formatText]: ",s);try{o=await f(o,{parser:"babel",...this.codeInterpolationOptions,semi:!1}),o[0]===";"&&(o=o.slice(1))}catch(a){p.warn(a)}}o=T(o),e+=b(this.options.pugBracketSpacing,o),t=t.slice(n+2)}else e+="{{",e+=t,t=""}else{let n=t.indexOf("{");if(this.options.pugFramework==="svelte"&&n!==-1){e+=t.slice(0,n),t=t.slice(n+1);let o=t.indexOf("}");if(o!==-1){let s=t.slice(0,o);try{if(w(s,this.quotes,this.otherQuotes,p)){p.warn("The following expression could not be formatted correctly. Please try to fix it yourself and if there is a problem, please open a bug issue:",s),e+=b(this.options.pugBracketSpacing,s),t=t.slice(o+1);continue}else s=await this.frameworkFormat(s)}catch(a){p.warn("[PugPrinter:formatText]: ",a);try{s=await f(s,{parser:"babel",...this.codeInterpolationOptions,semi:!1}),s[0]===";"&&(s=s.slice(1))}catch(l){p.warn(l)}}s=T(s),e+=b(this.options.pugBracketSpacing,s,["{","}"]),t=t.slice(o+1)}else e+="{",e+=t,t=""}else e+=t,t=""}}return e}async formatDelegatePrettier(t,e,i={}){let{trimTrailingSemicolon:n=!1,trimLeadingSemicolon:o=!0}=i;t=t.trim();let s={...this.codeInterpolationOptions},a=m(t);return a&&(s.singleQuote=!this.options.pugSingleQuote,t=t.slice(1,-1)),t=await f(t,{parser:e,...s}),this.quotes==='"'?t=t.replace(/"/g,'\\"'):t=t.replace(/'/g,"\\'"),t=T(t),n&&t[t.length-1]===";"&&(t=t.slice(0,-1)),o&&t[0]===";"&&(t=t.slice(1)),a?this.quoteString(t):t}async formatStyleAttribute(t){return this.formatDelegatePrettier(t,"css",{trimTrailingSemicolon:!0})}async formatVueEventBinding(t){return this.formatDelegatePrettier(t,"__vue_event_binding",{trimTrailingSemicolon:!0})}async formatVueExpression(t){return this.formatDelegatePrettier(t,"__vue_expression")}async formatAngularBinding(t){return this.formatDelegatePrettier(t,"__ng_binding")}async formatAngularAction(t){return this.formatDelegatePrettier(t,"__ng_action")}async formatAngularDirective(t){return this.formatDelegatePrettier(t,"__ng_directive")}async formatFrameworkInterpolation(t,e,[i,n]){if(t=t.slice(1,-1),t=t.slice(i.length,-n.length),t=t.trim(),t.includes(`\\${this.otherQuotes}`))p.warn("The following expression could not be formatted correctly. Please try to fix it yourself and if there is a problem, please open a bug issue:",t);else{let o={...this.codeInterpolationOptions,singleQuote:!this.options.pugSingleQuote};try{t=await f(t,{parser:e,...o})}catch{p.warn("The following expression could not be formatted correctly. Please try to fix it yourself and if there is a problem, please open a bug issue:",t)}t=T(t)}return t=b(this.options.pugBracketSpacing,t,[i,n]),this.quoteString(t)}async formatAngularInterpolation(t){return this.formatFrameworkInterpolation(t,"__ng_interpolation",["{{","}}"])}async formatSvelteInterpolation(t){return this.formatFrameworkInterpolation(t,"__ng_interpolation",["{","}"])}tag(t){let e=t.val;e==="div"&&!this.options.pugExplicitDiv&&this.nextToken&&(this.nextToken.type==="class"&&this.options.pugClassLocation==="before-attributes"||this.nextToken.type==="id")&&(e=""),this.currentLineLength+=e.length;let i=`${this.computedIndent}${e}`;return p.debug("tag",{result:i,val:t.val,length:t.val.length},this.currentLineLength),this.currentTagPosition=this.result.length+this.computedIndent.length,this.possibleIdPosition=this.result.length+i.length,this.possibleClassPosition=this.result.length+i.length,i}"start-attributes"(t){var i,n,o;let e="";if(((i=this.nextToken)==null?void 0:i.type)==="attribute"){this.previousAttributeRemapped=!1,this.possibleClassPosition=this.result.length,e="(",p.debug(this.currentLineLength);let s=this.nextToken,a=this.currentIndex+1,l=!1,u=0;for(;s.type==="attribute";){switch(!this.currentlyInPugInterpolation&&!this.wrapAttributes&&((n=this.wrapAttributesPattern)!=null&&n.test(s.name))&&(this.wrapAttributes=!0),s.name){case"class":case"id":{l=!0;let h=s.val.toString();m(h)&&(this.currentLineLength-=2),this.currentLineLength+=1+h.length,p.debug({tokenName:s.name,length:s.name.length},this.currentLineLength);break}default:{this.currentLineLength+=s.name.length,u>0&&(this.currentLineLength+=1,this.tokenNeedsSeparator(s)&&(this.currentLineLength+=1)),p.debug({tokenName:s.name,length:s.name.length},this.currentLineLength);let h=s.val.toString();h.length>0&&h!=="true"&&(this.currentLineLength+=1+h.length,p.debug({tokenVal:h,length:h.length},this.currentLineLength)),u++;break}}s=this.tokens[++a]}if(p.debug("after token",this.currentLineLength),l&&((o=this.previousToken)==null?void 0:o.type)==="tag"&&this.previousToken.val==="div"&&!this.options.pugExplicitDiv&&(this.currentLineLength-=3),u>0&&(this.currentLineLength+=2),this.options.pugClassLocation==="after-attributes"){let h=a,g=this.tokens[++h];for(;g.type==="class";){let d=g.val.toString();this.currentLineLength+=1+d.length,p.debug({tokenVal:d,length:d.length},this.currentLineLength),g=this.tokens[++h]}}if(p.debug("final line length",{currentLineLength:this.currentLineLength}),!this.currentlyInPugInterpolation&&!this.wrapAttributes&&(this.currentLineLength>this.options.pugPrintWidth||this.options.pugWrapAttributesThreshold>=0&&u>this.options.pugWrapAttributesThreshold)&&(this.wrapAttributes=!0),this.options.pugSortAttributes!=="as-is"||this.options.pugSortAttributesEnd.length>0||this.options.pugSortAttributesBeginning.length>0){let h=this.tokens.indexOf(t),g=a;g-h>2&&(this.tokens=st(this.tokens,h+1,g,(d,wt)=>nt(d,wt,this.options.pugSortAttributes,this.options.pugSortAttributesBeginning,this.options.pugSortAttributesEnd)))}}return e}async attribute(t){var i;if(ot(t,this.options.pugEmptyAttributes,this.options.pugEmptyAttributesForceQuotes),typeof t.val=="string"&&m(t.val)&&t.val[0]!=="`"){if(t.name==="class"&&this.options.pugClassNotation==="literal"){let o=t.val.slice(1,-1).trim().split(/\s+/),s=[],a=[],l=/^-?[_a-zA-Z]+[_a-zA-Z0-9-]*$/;for(let u of o)l.test(u)?this.options.pugClassLocation==="after-attributes"?this.classLiteralAfterAttributes.push(u):a.push(u):s.push(u);if(a.length>0){let u=this.possibleClassPosition;this.result=[this.result.slice(0,u),".",a.join("."),this.result.slice(u)].join(""),this.possibleClassPosition+=1+a.join(".").length,this.options.pugClassLocation==="before-attributes"&&this.replaceTagWithLiteralIfPossible(/div\./,".")}if(s.length>0)t.val=S(s.join(" "),this.quotes),this.previousAttributeRemapped=!1;else{this.previousAttributeRemapped=!0;return}}else if(t.name==="id"&&this.options.pugIdNotation!=="as-is"){let n=t.val;if(n=n.slice(1,-1),n=n.trim(),!/^-?[_a-zA-Z]+[_a-zA-Z0-9-]*$/.test(n)){n=S(n,this.quotes),this.result+="id",t.mustEscape===!1&&(this.result+="!"),this.result+=`=${n}`;return}let s=this.possibleIdPosition,a=`#${n}`;this.result=[this.result.slice(0,s),a,this.result.slice(s)].join(""),this.possibleClassPosition+=a.length,this.replaceTagWithLiteralIfPossible(/div#/,"#"),this.previousAttributeRemapped=!0;return}}let e=lt(this.tokens,this.currentIndex);if(((i=this.previousToken)==null?void 0:i.type)==="attribute"&&(!this.previousAttributeRemapped||e)&&(this.tokenNeedsSeparator(t)&&(this.result+=","),this.wrapAttributes||(this.result+=" ")),this.previousAttributeRemapped=!1,this.wrapAttributes&&(this.result+=` | ||
`,this.result+=this.indentString.repeat(this.indentLevel+1)),this.result+=`${t.name}`,typeof t.val=="boolean")t.val!==!0&&(this.result+=`=${t.val}`);else if(t.name==="class"&&this.options.pugClassNotation==="attribute"){let o=(m(t.val)?t.val.slice(1,-1).trim():t.val).split(/\s+/);if(this.classLiteralToAttribute.length)for(let s=this.classLiteralToAttribute.length-1;s>-1;s--){let a=this.classLiteralToAttribute.splice(s,1)[0];a&&o.unshift(a)}this.result+=`=${m(t.val)?this.quoteString(o.join(" ")):o.join(" ")}`}else{let n=t.val;if(!gt(n)){if(!ct(n))if(kt(t.name,n))n=await this.formatDelegatePrettier(n,"vue");else if(vt(t.name))n=await this.formatVueExpression(n);else if(Pt(t.name))n=await this.formatVueEventBinding(n);else if(this.framework==="vue"&&At(t.name))n=await this.formatVueExpression(n);else if(St(t.name))n=await this.formatDelegatePrettier(n,"__js_expression");else if(xt(t.name))n=await this.formatDelegatePrettier(n,"__js_expression");else if(dt(t.name))n=await this.formatAngularBinding(n);else if(mt(t.name))n=await this.formatAngularAction(n);else if(ft(t.name))n=await this.formatAngularDirective(n);else if(bt(n))n=await this.formatAngularInterpolation(n);else if(yt(n))n=await this.formatSvelteInterpolation(n);else if(ut(t.name,t.val))n=await this.formatStyleAttribute(n);else{let o=n.trimEnd();if(m(o))n=S(o.slice(1,-1),this.quotes);else{if(n==="true")return;if(t.mustEscape){n=await f(n,{parser:"__js_expression",...this.codeInterpolationOptions});let s=n.split(` | ||
`),a=this.wrapAttributes?this.indentLevel+1:this.indentLevel;if(s.length>1){n=s[0]??"";for(let l=1;l<s.length;l++)n+=` | ||
`,n+=this.indentString.repeat(a),n+=s[l]}}else n=n.trim(),n=n.replace(/\s\s+/g," "),n[0]==="{"&&n[1]===" "&&(n=`{${n.slice(2,n.length)}`)}}}t.mustEscape===!1&&(this.result+="!"),this.result+=`=${n}`}}"end-attributes"(t){var e,i,n,o,s,a,l;if(this.wrapAttributes&&this.result[this.result.length-1]!=="("&&(this.options.pugBracketSameLine||(this.result+=` | ||
`),this.result+=this.indentString.repeat(this.indentLevel)),this.wrapAttributes=!1,this.classLiteralToAttribute.length){((e=this.previousToken)==null?void 0:e.type)==="start-attributes"?this.result+="(":((i=this.previousToken)==null?void 0:i.type)==="attribute"&&(this.result+=" ");let u=this.classLiteralToAttribute.splice(0,this.classLiteralToAttribute.length);this.result+=`class=${this.quoteString(u.join(" "))}`,((n=this.previousToken)==null?void 0:n.type)==="start-attributes"&&(this.result+=")")}if(this.result[this.result.length-1]==="("?this.result=this.result.slice(0,-1):((o=this.previousToken)==null?void 0:o.type)==="attribute"?(this.options.pugBracketSameLine&&(this.result=this.result.trimEnd()),this.result+=")"):this.options.pugPreserveAttributeBrackets&&((s=this.previousToken)==null?void 0:s.type)==="start-attributes"&&(this.result+="()"),this.result[this.result.length-1]===")"&&this.classLiteralAfterAttributes.length>0){let u=this.classLiteralAfterAttributes.splice(0,this.classLiteralAfterAttributes.length);this.result+=`.${u.join(".")}`}this.options.pugClassLocation==="after-attributes"&&(this.possibleClassPosition=this.result.length),(((a=this.nextToken)==null?void 0:a.type)==="text"||((l=this.nextToken)==null?void 0:l.type)==="path")&&(this.result+=" ")}indent(t){let e=` | ||
${this.indentString.repeat(this.indentLevel)}`;return this.indentLevel++,this.currentLineLength=e.length-1+1+this.options.pugTabWidth,p.debug("indent",{result:e,indentLevel:this.indentLevel,pugTabWidth:this.options.pugTabWidth},this.currentLineLength),e}outdent(t){let e="";return this.previousToken&&this.previousToken.type!=="outdent"&&(t.loc.start.line-this.previousToken.loc.end.line>1&&(e+=` | ||
`),e+=` | ||
`),this.indentLevel--,this.currentLineLength=1+this.indentString.repeat(this.indentLevel).length,p.debug("outdent",{result:e,indentLevel:this.indentLevel},this.currentLineLength),e}class(t){var e,i,n,o,s;if(this.options.pugClassNotation==="attribute"){if(this.classLiteralToAttribute.push(t.val),((e=this.previousToken)==null?void 0:e.type)!=="tag"&&((i=this.previousToken)==null?void 0:i.type)!=="class"&&(this.result+=`${this.computedIndent}div`),this.nextToken&&["text","newline","indent","outdent","eos"].includes(this.nextToken.type)){let a=this.classLiteralToAttribute.splice(0,this.classLiteralToAttribute.length);this.result+=`(class=${this.quoteString(a.join(" "))})`,this.nextToken.type==="text"&&(this.result+=" ")}}else{let a=`.${t.val}`;switch(this.currentLineLength+=a.length,p.debug("before class",{result:this.result,val:a,length:a.length,previousToken:this.previousToken},this.currentLineLength),(n=this.previousToken)==null?void 0:n.type){case void 0:case"newline":case"outdent":case"indent":{let l=this.options.pugExplicitDiv||this.options.pugClassLocation==="after-attributes"?"div":"",u=`${this.computedIndent}${l}`;this.options.pugClassLocation==="after-attributes"?this.classLiteralAfterAttributes.push(a.slice(1)):u+=a,this.currentLineLength+=l.length,this.possibleIdPosition=this.result.length+this.computedIndent.length+l.length,this.result+=u,this.possibleClassPosition=this.result.length;break}case"end-attributes":{let l=this.result.slice(0,this.possibleClassPosition);this.result=[l,a,this.result.slice(this.possibleClassPosition)].join(""),this.possibleClassPosition+=a.length;break}default:{if(this.options.pugClassLocation==="after-attributes")this.classLiteralAfterAttributes.push(a.slice(1));else{let l=this.result.slice(0,this.possibleClassPosition);this.result=[l,a,this.result.slice(this.possibleClassPosition)].join(""),this.possibleClassPosition+=a.length}break}}if(this.options.pugClassLocation==="after-attributes"&&this.classLiteralAfterAttributes.length>0){let l=this.result.slice(0,this.possibleClassPosition);if(["text","newline","indent","outdent","eos","code",":",void 0].includes((o=this.nextToken)==null?void 0:o.type)){let u=this.classLiteralAfterAttributes.splice(0,this.classLiteralAfterAttributes.length);l+="."+u.join(".")}this.result=[l,this.result.slice(this.possibleClassPosition)].join(""),this.possibleClassPosition=this.result.length,this.replaceTagWithLiteralIfPossible(/div\./,".")}p.debug("after class",{result:this.result,val:a,length:a.length},this.currentLineLength),((s=this.nextToken)==null?void 0:s.type)==="text"&&!/^\s+$/.test(this.nextToken.val)&&(this.currentLineLength+=1,this.result+=" ")}}eos(t){for(;this.result[this.result.length-1]===` | ||
`;)this.result=this.result.slice(0,-1);this.result+=` | ||
`}comment(t){var i;let e=this.computedIndent;if(/^ prettier-ignore($|[: ])/.test(t.val)){let n=this.getNextToken();if(n){let o=n.type==="newline",s=0;for(;n;){let{type:a}=n;if(a==="newline"&&s===0)if(o)o=!1;else break;else if(a==="indent")s++;else if(a==="outdent"){if(s--,s<=0){s<0&&this.indentLevel--;break}}else if(a==="eos")break;n=this.getNextToken()}if(n){let a=this.getUnformattedContentLines(t,n),l=a.pop();l!==void 0&&a.push(l.trimEnd()),e+=a.join(` | ||
`),n.type==="eos"&&(e+=` | ||
`)}}}else this.checkTokenType(this.previousToken,["newline","indent","outdent"],!0)&&(e+=" "),e+="//",t.buffer||(e+="-"),e+=A(t.val,this.options.pugCommentPreserveSpaces),((i=this.nextToken)==null?void 0:i.type)==="start-pipeless-text"&&(this.pipelessComment=!0);return e}newline(t){let e="";return this.previousToken&&t.loc.start.line-this.previousToken.loc.end.line>1&&(e+=` | ||
`),e+=` | ||
`,this.currentLineLength=1+this.indentString.repeat(this.indentLevel).length,p.debug("newline",{result:e,indentLevel:this.indentLevel},this.currentLineLength),e}async text(t){var s,a,l,u,h;let e="",i=t.val,n=!1,o=i[i.length-1]===" "&&!/^\s+$/.test(i);if(this.pipelessText){switch((s=this.previousToken)==null?void 0:s.type){case"newline":i.trim().length>0&&(e+=this.indentString.repeat(this.indentLevel+1));break;case"start-pipeless-text":e+=this.indentString;break}this.pipelessComment&&(i=A(i,this.options.pugCommentPreserveSpaces,!0))}else{if(this.nextToken&&o)switch(this.nextToken.type){case"interpolated-code":case"start-pug-interpolation":n=!0;break}switch(i=i.replace(/\s\s+/g," "),(a=this.previousToken)==null?void 0:a.type){case"newline":e+=this.indentString.repeat(this.indentLevel),/^ .+$/.test(i)&&(e+=`| | ||
`,e+=this.indentString.repeat(this.indentLevel)),e+="|",(/.*\S.*/.test(t.val)||((l=this.nextToken)==null?void 0:l.type)==="start-pug-interpolation")&&(e+=" ");break;case"indent":case"outdent":e+=this.computedIndent,/^ .+$/.test(i)&&(e+=`| | ||
`,e+=this.indentString.repeat(this.indentLevel)),e+="|",/.*\S.*/.test(t.val)&&(e+=" ");break;case"interpolated-code":case"end-pug-interpolation":/^ .+$/.test(i)||i===" "?e+=" ":/^.+ $/.test(i)&&(n=!0);break}i=i.trim(),i=await this.formatText(i),i=i.replace(/#(\{|\[)/g,"\\#$1")}return this.checkTokenType(this.previousToken,["tag","id","interpolation","call","&attributes","filter"])&&(i.length===0&&((u=this.nextToken)==null?void 0:u.type)==="indent"?o=!1:i=` ${i}`),e+=i,n&&(e+=" "),o&&((h=this.nextToken)==null?void 0:h.type)==="indent"&&(e+=` | ||
`+this.indentString.repeat(this.indentLevel+1)+"|"),e}"interpolated-code"(t){var i;let e="";switch((i=this.previousToken)==null?void 0:i.type){case"tag":case"class":case"id":case"end-attributes":e=" ";break;case"start-pug-interpolation":e="| ";break;case"indent":case"newline":case"outdent":e=this.computedIndent,e+=this.pipelessText?this.indentString:"| ";break}return e+=t.mustEscape?"#":"!",e+=b(this.options.pugBracketSpacing,t.val.trim(),["{","}"]),e}async code(t){let e=this.computedIndent;!t.mustEscape&&t.buffer&&(e+="!"),e+=t.buffer?"=":"-";let i=this.options.pugSemi;i&&(t.mustEscape||t.buffer)&&(i=!1);let n=t.val;try{let o=n;n=await f(n,{parser:"babel",...this.codeInterpolationOptions,semi:i,endOfLine:"lf"}),n=n.slice(0,-1),n[0]===";"&&(n=n.slice(1)),n.includes(` | ||
`)&&(n=o)}catch(o){p.warn("[PugPrinter]:",o)}return e+=` ${n}`,e}id(t){var i;let e=`#${t.val}`;switch(this.currentLineLength+=e.length,(i=this.previousToken)==null?void 0:i.type){case void 0:case"newline":case"outdent":case"indent":{let n=this.options.pugExplicitDiv?"div":"",o=`${this.computedIndent}${n}${e}`;this.currentLineLength+=n.length,this.result+=o,this.possibleClassPosition=this.result.length;break}default:{let n=this.result.slice(0,this.possibleIdPosition);this.possibleClassPosition+=e.length,this.result=[n,e,this.result.slice(this.possibleIdPosition)].join("");break}}}async"start-pipeless-text"(t){var i;this.pipelessText=!0;let e=` | ||
${this.indentString.repeat(this.indentLevel)}`;if(((i=this.previousToken)==null?void 0:i.type)==="dot"){let n=at(this.tokens,this.currentIndex),o;switch(n==null?void 0:n.val){case"script":o=Tt(pt(this.tokens,this.currentIndex));break;case"style":o="css";break;default:break}if(o){let s=this.currentIndex+1,a=this.tokens[s],l="",u=!1;for(;a&&(a==null?void 0:a.type)!=="end-pipeless-text";){switch(a.type){case"text":l+=a.val;break;case"newline":l+=` | ||
`;break;case"interpolated-code":u=!0,l+=a.mustEscape?"#":"!",l+=`{${a.val}}`;break;default:p.warn("[PugPrinter:start-pipeless-text]:","Unhandled token for pipeless script tag:",JSON.stringify(a));break}s++,a=this.tokens[s]}try{e=await f(l,{parser:o,...this.codeInterpolationOptions})}catch(g){if(!u)throw p.error(g),g;let d=["[PugPrinter:start-pipeless-text]:","The following expression could not be formatted correctly.","This is likely a syntax error or an issue caused by the missing execution context.","If you think this is a bug, please open a bug issue."];d.push(` | ||
code: \`${l.trim()}\``),d.push(` | ||
You used interpolated code in your pipeless script tag, so you may ignore this warning.`),Ct.isNativeError(g)?d.push(` | ||
Found ${o} ${g.name}: ${g.message}.`):(p.debug("typeof error:",typeof g),d.push(` | ||
Unexpected error for parser ${o}.`,g)),p.warn(...d),e=l}e=e.trimEnd();let h=this.indentString.repeat(this.indentLevel+1);e=e.split(` | ||
`).map(g=>g?h+g:"").join(` | ||
`),e=` | ||
${e}`,a=this.tokens[s-1],(a==null?void 0:a.type)==="text"&&a.val===""&&(e+=` | ||
`),this.currentIndex=s-1}}return e}"end-pipeless-text"(t){return this.pipelessText=!1,this.pipelessComment=!1,""}doctype(t){let e=`${this.computedIndent}doctype`;return t.val&&(e+=` ${t.val}`),e}dot(t){return"."}block(t){let e=`${this.computedIndent}block `;return t.mode!=="replace"&&(e+=`${t.mode} `),e+=t.val,e}extends(t){return`${this.options.pugSingleFileComponentIndentation?this.indentString:""}extends `}path(t){let e="";return this.checkTokenType(this.previousToken,["include","filter"])&&(e+=" "),e+=t.val,e}"start-pug-interpolation"(t){var i,n;let e="";return((i=this.tokens[this.currentIndex-2])==null?void 0:i.type)==="newline"&&((n=this.previousToken)==null?void 0:n.type)==="text"&&this.previousToken.val.trim().length===0&&(e+=this.indentString.repeat(this.indentLevel+1)),this.currentlyInPugInterpolation=!0,e+="#[",e}"end-pug-interpolation"(t){return this.currentlyInPugInterpolation=!1,"]"}interpolation(t){let e=`${this.computedIndent}#{${t.val}}`;return this.currentLineLength+=e.length,this.possibleIdPosition=this.result.length+e.length,this.possibleClassPosition=this.result.length+e.length,e}include(t){return`${this.computedIndent}include`}filter(t){return`${this.computedIndent}:${t.val}`}call(t){let e=`${this.computedIndent}+${t.val}`,i=t.args;return i&&(i=i.trim(),i=i.replace(/\s\s+/g," "),e+=`(${i})`),this.currentLineLength+=e.length,this.possibleIdPosition=this.result.length+e.length,this.possibleClassPosition=this.result.length+e.length,e}mixin(t){let e=`${this.computedIndent}mixin ${t.val}`,i=t.args;return i&&(i=i.trim(),i=i.replace(/\s\s+/g," "),e+=`(${i})`),e}if(t){let e=this.computedIndent,i=/^!\((.*)\)$/.exec(t.val);return p.debug("[PugPrinter]:",i),e+=i?`unless ${i[1]}`:`if ${t.val}`,e}"mixin-block"(t){return`${this.computedIndent}block`}else(t){return`${this.computedIndent}else`}"&attributes"(t){let e=`&attributes(${t.val})`;return this.currentLineLength+=e.length,e}"text-html"(t){let e=/^<(.*?)>(.*)<\/(.*?)>$/.exec(t.val);if(p.debug("[PugPrinter]:",e),e)return`${this.computedIndent}${e[1]} ${e[2]}`;let i=Object.entries(rt).find(([n])=>n===t.val.toLowerCase());return i?`${this.computedIndent}${i[1]}`:`${this.computedIndent}${t.val}`}each(t){let e=`${this.computedIndent}each ${t.val}`;return t.key!==null&&(e+=`, ${t.key}`),e+=` in ${t.code}`,e}async eachOf(t){let e=t.value.trim();e=await f(e,{parser:"babel",...this.codeInterpolationOptions,semi:!1}),e[0]===";"&&(e=e.slice(1)),e=T(e);let i=t.code.trim();return`${this.computedIndent}each ${e} of ${i}`}while(t){return`${this.computedIndent}while ${t.val}`}case(t){return`${this.computedIndent}case ${t.val}`}when(t){return`${this.computedIndent}when ${t.val}`}":"(t){return this.possibleIdPosition=this.result.length+2,this.possibleClassPosition=this.result.length+2,": "}default(t){return`${this.computedIndent}default`}"else-if"(t){return`${this.computedIndent}else if ${t.val}`}blockcode(t){return`${this.computedIndent}-`}yield(t){return`${this.computedIndent}yield`}slash(t){var i;let e="/";return((i=this.nextToken)==null?void 0:i.type)==="text"&&(e+=" "),e}};var v={languages:[{name:"Pug",parsers:["pug"],tmScope:"text.jade",aceMode:"jade",codemirrorMode:"pug",codemirrorMimeType:"text/x-pug",extensions:[".jade",".pug"],linguistLanguageId:179,vscodeLanguageIds:["jade","pug"]}],parsers:{pug:{parse(r,t){p.debug("[parsers:pug:parse]:",{text:r});let e=r.replace(/^\s*\n/,""),i=/^\s*/.exec(e);if(i!=null&&i[0]){let s=new RegExp(`(^|\\n)${i[0]}`,"g");e=e.replace(s,"$1")}let n=e,o=Rt(n);return{content:n,tokens:o}},astFormat:"pug-ast",hasPragma(r){return r.startsWith(`//- @prettier | ||
`)||r.startsWith(`//- @format | ||
`)},locStart(r){return p.debug("[parsers:pug:locStart]:",{node:r}),0},locEnd(r){return p.debug("[parsers:pug:locEnd]:",{node:r}),0},preprocess(r,t){return p.debug("[parsers:pug:preprocess]:",{text:r}),r}}},printers:{"pug-ast":{async print(r,t){let e=r.stack[0],{content:i,tokens:n}=e,o=it(t),a=await new x(i,n,o).build();return p.debug("[printers:pug-ast:print]:",a),a},insertPragma(r){return`//- @prettier | ||
${r}`}}},options:et,defaultOptions:{}},Xe=v.languages,ti=v.parsers,ei=v.printers,ii=v.options,ri=v.defaultOptions;export{I as LogLevel,P as Logger,E as createLogger,ri as defaultOptions,Xe as languages,p as logger,ii as options,ti as parsers,v as plugin,ei as printers}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@prettier/plugin-pug", | ||
"version": "2.5.2", | ||
"version": "3.0.0", | ||
"description": "Prettier Pug Plugin", | ||
"main": "dist/index.js", | ||
"scripts": { | ||
"clean": "rimraf coverage .eslintcache dist junit.xml docs/.vitepress/dist pnpm-lock.yaml node_modules", | ||
"build:clean": "rimraf dist", | ||
"build:code": "tsc --project tsconfig.build.json", | ||
"build:code": "tsup-node", | ||
"build": "run-s build:clean build:code", | ||
@@ -22,2 +21,16 @@ "docs:build": "vitepress build docs", | ||
}, | ||
"type": "module", | ||
"main": "dist/index.js", | ||
"module": "dist/index.js", | ||
"exports": { | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/index.js" | ||
}, | ||
"./src/*": { | ||
"types": "./src/*.d.ts", | ||
"default": "./src/*.ts" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"keywords": [ | ||
@@ -60,6 +73,5 @@ "pug", | ||
"devDependencies": { | ||
"@types/node": "~20.4.4", | ||
"@types/prettier": "~2.7.3", | ||
"@typescript-eslint/eslint-plugin": "~6.1.0", | ||
"@typescript-eslint/parser": "~6.1.0", | ||
"@types/node": "~20.4.5", | ||
"@typescript-eslint/eslint-plugin": "~6.2.0", | ||
"@typescript-eslint/parser": "~6.2.0", | ||
"@vitest/coverage-v8": "~0.33.0", | ||
@@ -73,10 +85,11 @@ "benchmark": "~2.1.4", | ||
"eslint-plugin-jsdoc": "~46.4.4", | ||
"eslint-plugin-prettier": "~4.2.1", | ||
"eslint-plugin-prettier": "~5.0.0", | ||
"eslint-plugin-spellcheck": "~0.0.20", | ||
"npm-run-all": "~4.1.5", | ||
"prettier": "2.8.8", | ||
"prettier": "3.0.0", | ||
"prettier-plugin-organize-imports": "~3.2.3", | ||
"rimraf": "~5.0.1", | ||
"tsup": "~7.1.0", | ||
"typescript": "~5.1.6", | ||
"vite": "~4.4.6", | ||
"vite": "~4.4.7", | ||
"vitepress": "1.0.0-beta.6", | ||
@@ -86,5 +99,5 @@ "vitest": "~0.33.0" | ||
"peerDependencies": { | ||
"prettier": "^2.3.0" | ||
"prettier": "^3.0.0" | ||
}, | ||
"packageManager": "pnpm@8.6.9", | ||
"packageManager": "pnpm@8.6.10", | ||
"engines": { | ||
@@ -91,0 +104,0 @@ "node": "^16.13.0 || >=18.0.0", |
import type { | ||
AstPath, | ||
Doc, | ||
Options, | ||
Parser, | ||
@@ -29,3 +26,3 @@ ParserOptions, | ||
/** The plugin object that is picked up by prettier. */ | ||
export const plugin: Plugin = { | ||
export const plugin: Plugin<AstPathStackEntry> = { | ||
languages: [ | ||
@@ -47,7 +44,3 @@ { | ||
pug: { | ||
parse( | ||
text: string, | ||
parsers: { [parserName: string]: Parser }, | ||
options: ParserOptions, | ||
): AstPathStackEntry { | ||
parse(text, options) { | ||
logger.debug('[parsers:pug:parse]:', { text }); | ||
@@ -77,4 +70,6 @@ | ||
}, | ||
astFormat: 'pug-ast', | ||
hasPragma(text: string): boolean { | ||
hasPragma(text) { | ||
return ( | ||
@@ -84,11 +79,14 @@ text.startsWith('//- @prettier\n') || text.startsWith('//- @format\n') | ||
}, | ||
locStart(node: unknown): number { | ||
locStart(node) { | ||
logger.debug('[parsers:pug:locStart]:', { node }); | ||
return 0; | ||
}, | ||
locEnd(node: unknown): number { | ||
locEnd(node) { | ||
logger.debug('[parsers:pug:locEnd]:', { node }); | ||
return 0; | ||
}, | ||
preprocess(text: string, options: ParserOptions): string { | ||
preprocess(text, options) { | ||
logger.debug('[parsers:pug:preprocess]:', { text }); | ||
@@ -101,24 +99,13 @@ return text; | ||
'pug-ast': { | ||
print( | ||
path: AstPath, | ||
options: ParserOptions & PugParserOptions, | ||
print: (path: AstPath) => Doc, | ||
): Doc { | ||
const entry: AstPathStackEntry = path.stack[0]; | ||
// @ts-expect-error: Prettier allow it to be async if we don't do recursively print | ||
async print(path, options: ParserOptions & PugParserOptions) { | ||
const entry: AstPathStackEntry = path.stack[0]!; | ||
const { content, tokens } = entry; | ||
const pugOptions: PugPrinterOptions = convergeOptions(options); | ||
const printer: PugPrinter = new PugPrinter(content, tokens, pugOptions); | ||
const result: string = printer.build(); | ||
const result: string = await printer.build(); | ||
logger.debug('[printers:pug-ast:print]:', result); | ||
return result; | ||
}, | ||
embed( | ||
path: AstPath, | ||
print: (path: AstPath) => Doc, | ||
textToDoc: (text: string, options: Options) => Doc, | ||
options: ParserOptions, | ||
): Doc | null { | ||
// logger.debug('[printers:pug-ast:embed]:', JSON.stringify(path, undefined, 2)); | ||
return null; | ||
}, | ||
insertPragma(text: string): string { | ||
@@ -125,0 +112,0 @@ return `//- @prettier\n${text}`; |
@@ -5,3 +5,3 @@ import type { ChoiceSupportOption, PathArraySupportOption } from 'prettier'; | ||
const pugSortAttributesOption: PathArraySupportOption = { | ||
since: '1.7.0', | ||
// since: '1.7.0', | ||
category: CATEGORY_PUG, | ||
@@ -31,3 +31,3 @@ type: 'path', | ||
{ | ||
since: '1.8.0', | ||
// since: '1.8.0', | ||
category: CATEGORY_PUG, | ||
@@ -34,0 +34,0 @@ type: 'choice', |
@@ -6,3 +6,3 @@ import type { ChoiceSupportOption, IntSupportOption } from 'prettier'; | ||
export const PUG_PRINT_WIDTH_OPTION: IntSupportOption = { | ||
since: '1.6.0', | ||
// since: '1.6.0', | ||
category: CATEGORY_PUG, | ||
@@ -19,3 +19,3 @@ type: 'int', | ||
> = { | ||
since: '1.6.0', | ||
// since: '1.6.0', | ||
category: CATEGORY_PUG, | ||
@@ -48,3 +48,3 @@ type: 'choice', | ||
export const PUG_TAB_WIDTH_OPTION: IntSupportOption = { | ||
since: '1.6.0', | ||
// since: '1.6.0', | ||
category: CATEGORY_PUG, | ||
@@ -60,3 +60,3 @@ type: 'int', | ||
{ | ||
since: '1.6.0', | ||
// since: '1.6.0', | ||
category: CATEGORY_PUG, | ||
@@ -91,3 +91,3 @@ type: 'choice', | ||
> = { | ||
since: '1.6.0', | ||
// since: '1.6.0', | ||
category: CATEGORY_PUG, | ||
@@ -120,3 +120,3 @@ type: 'choice', | ||
export const PUG_SEMI_OPTION: ChoiceSupportOption<boolean | 'true' | null> = { | ||
since: '1.6.0', | ||
// since: '1.6.0', | ||
category: CATEGORY_PUG, | ||
@@ -151,3 +151,3 @@ type: 'choice', | ||
{ | ||
since: '1.7.0', | ||
// since: '1.7.0', | ||
category: CATEGORY_PUG, | ||
@@ -180,3 +180,3 @@ type: 'choice', | ||
> = { | ||
since: '1.17.0', | ||
// since: '1.17.0', | ||
category: CATEGORY_PUG, | ||
@@ -183,0 +183,0 @@ type: 'choice', |
@@ -24,4 +24,4 @@ import type { ParserOptions } from 'prettier'; | ||
options.pugTabWidth !== -1 ? options.pugTabWidth : options.tabWidth, | ||
useTabs: options.useTabs, | ||
pugUseTabs: options.pugUseTabs ?? options.useTabs, | ||
useTabs: options.useTabs ?? false, | ||
pugUseTabs: options.pugUseTabs ?? options.useTabs ?? false, | ||
bracketSpacing: options.bracketSpacing, | ||
@@ -28,0 +28,0 @@ pugBracketSpacing: options.pugBracketSpacing ?? options.bracketSpacing, |
@@ -8,3 +8,3 @@ import type { ChoiceSupportOption, PathArraySupportOption } from 'prettier'; | ||
{ | ||
since: '1.10.0', | ||
// since: '1.10.0', | ||
category: CATEGORY_PUG, | ||
@@ -35,3 +35,3 @@ type: 'choice', | ||
{ | ||
since: '1.10.0', | ||
// since: '1.10.0', | ||
category: CATEGORY_PUG, | ||
@@ -38,0 +38,0 @@ type: 'path', |
@@ -7,3 +7,3 @@ import type { ChoiceSupportOption } from 'prettier'; | ||
{ | ||
since: '1.6.0', | ||
// since: '1.6.0', | ||
category: CATEGORY_PUG, | ||
@@ -10,0 +10,0 @@ type: 'choice', |
@@ -6,3 +6,3 @@ import type { ChoiceSupportOption } from 'prettier'; | ||
export const PUG_CLASS_LOCATION: ChoiceSupportOption = { | ||
since: '1.19.0', | ||
// since: '1.19.0', | ||
category: CATEGORY_PUG, | ||
@@ -9,0 +9,0 @@ type: 'choice', |
@@ -6,3 +6,3 @@ import type { ChoiceSupportOption } from 'prettier'; | ||
export const PUG_CLASS_NOTATION: ChoiceSupportOption = { | ||
since: '1.13.0', | ||
// since: '1.13.0', | ||
category: CATEGORY_PUG, | ||
@@ -9,0 +9,0 @@ type: 'choice', |
@@ -7,3 +7,3 @@ import type { ChoiceSupportOption } from 'prettier'; | ||
{ | ||
since: '1.6.0', | ||
// since: '1.6.0', | ||
category: CATEGORY_PUG, | ||
@@ -10,0 +10,0 @@ type: 'choice', |
@@ -6,3 +6,3 @@ import type { BooleanSupportOption } from 'prettier'; | ||
export const PUG_EXPLICIT_DIV: BooleanSupportOption = { | ||
since: '1.16.0', | ||
// since: '1.16.0', | ||
category: CATEGORY_PUG, | ||
@@ -9,0 +9,0 @@ type: 'boolean', |
@@ -6,3 +6,3 @@ import type { ChoiceSupportOption } from 'prettier'; | ||
export const PUG_FRAMEWORK: ChoiceSupportOption<PugFramework> = { | ||
since: '1.14.0', | ||
// since: '1.14.0', | ||
category: CATEGORY_PUG, | ||
@@ -9,0 +9,0 @@ type: 'choice', |
@@ -6,3 +6,3 @@ import type { ChoiceSupportOption } from 'prettier'; | ||
export const PUG_ID_NOTATION: ChoiceSupportOption = { | ||
since: '1.13.0', | ||
// since: '1.13.0', | ||
category: CATEGORY_PUG, | ||
@@ -9,0 +9,0 @@ type: 'choice', |
@@ -6,3 +6,3 @@ import type { BooleanSupportOption } from 'prettier'; | ||
export const PUG_PRESERVE_ATTRIBUTE_BRACKETS: BooleanSupportOption = { | ||
since: '2.2.0', | ||
// since: '2.2.0', | ||
category: CATEGORY_PUG, | ||
@@ -9,0 +9,0 @@ type: 'boolean', |
@@ -6,3 +6,3 @@ import type { BooleanSupportOption } from 'prettier'; | ||
export const PUG_SINGLE_FILE_COMPONENT_INDENTATION: BooleanSupportOption = { | ||
since: '1.9.0', | ||
// since: '1.9.0', | ||
category: CATEGORY_PUG, | ||
@@ -9,0 +9,0 @@ type: 'boolean', |
@@ -6,3 +6,3 @@ import type { IntSupportOption, PathSupportOption } from 'prettier'; | ||
export const PUG_WRAP_ATTRIBUTES_THRESHOLD: IntSupportOption = { | ||
since: '1.8.0', | ||
// since: '1.8.0', | ||
category: CATEGORY_PUG, | ||
@@ -18,3 +18,3 @@ type: 'int', | ||
export const PUG_WRAP_ATTRIBUTES_PATTERN: PathSupportOption = { | ||
since: '1.8.0', | ||
// since: '1.8.0', | ||
category: CATEGORY_PUG, | ||
@@ -21,0 +21,0 @@ type: 'path', |
{ | ||
"compilerOptions": { | ||
"target": "ES2022", | ||
"module": "CommonJS", | ||
"moduleResolution": "node", | ||
"module": "ESNext", | ||
"moduleResolution": "Node", | ||
"strict": true, | ||
@@ -7,0 +7,0 @@ "noEmit": true, |
Sorry, the diff of this file is too big to display
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Yes
NaN348967
-2.08%37
-60.22%4144
-38.82%2
100%3
Infinity%