Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"eslint-plugin-unicorn": "56.0.0",
"jiti": "2.3.3",
"npm-run-all2": "6.2.3",
"prettier": "3.3.3",
"prettier": "3.4.2",
"prettier-plugin-organize-imports": "4.1.0",
"prettier-plugin-packagejson": "2.5.3",
"rimraf": "6.0.1",
Expand Down
28 changes: 14 additions & 14 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions src/printer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,15 +266,15 @@
: null;

this.codeInterpolationOptions = {
semi: options.pugSemi ?? options.semi,

Check warning on line 269 in src/printer.ts

View workflow job for this annotation

GitHub Actions / Lint: node-20, ubuntu-latest

Unnecessary conditional, expected left-hand side of `??` operator to be possibly null or undefined
singleQuote: options.pugSingleQuote ?? options.singleQuote,

Check warning on line 270 in src/printer.ts

View workflow job for this annotation

GitHub Actions / Lint: node-20, ubuntu-latest

Unnecessary conditional, expected left-hand side of `??` operator to be possibly null or undefined
bracketSpacing: options.pugBracketSpacing ?? options.bracketSpacing,

Check warning on line 271 in src/printer.ts

View workflow job for this annotation

GitHub Actions / Lint: node-20, ubuntu-latest

Unnecessary conditional, expected left-hand side of `??` operator to be possibly null or undefined
arrowParens: options.pugArrowParens ?? options.arrowParens,

Check warning on line 272 in src/printer.ts

View workflow job for this annotation

GitHub Actions / Lint: node-20, ubuntu-latest

Unnecessary conditional, expected left-hand side of `??` operator to be possibly null or undefined
printWidth: 9000,
endOfLine: 'lf',
useTabs: options.pugUseTabs ?? options.useTabs,

Check warning on line 275 in src/printer.ts

View workflow job for this annotation

GitHub Actions / Lint: node-20, ubuntu-latest

Unnecessary conditional, expected left-hand side of `??` operator to be possibly null or undefined
tabWidth: options.pugTabWidth ?? options.tabWidth,

Check warning on line 276 in src/printer.ts

View workflow job for this annotation

GitHub Actions / Lint: node-20, ubuntu-latest

Unnecessary conditional, expected left-hand side of `??` operator to be possibly null or undefined
bracketSameLine: options.pugBracketSameLine ?? options.bracketSameLine,

Check warning on line 277 in src/printer.ts

View workflow job for this annotation

GitHub Actions / Lint: node-20, ubuntu-latest

Unnecessary conditional, expected left-hand side of `??` operator to be possibly null or undefined
};
}

Expand Down Expand Up @@ -324,7 +324,7 @@
*/
public async build(): Promise<string> {
if (logger.isDebugEnabled()) {
logger.debug('[PugPrinter]:', JSON.stringify(this.tokens));
logger.debug('[PugPrinter:build]:', JSON.stringify(this.tokens));
}

const results: string[] = [];
Expand All @@ -336,7 +336,7 @@

let token: Token | null = this.getNextToken();
while (token) {
logger.debug('[PugPrinter]:', JSON.stringify(token));
logger.debug('[PugPrinter:build]:', JSON.stringify(token));
try {
switch (token.type) {
case 'attribute':
Expand Down Expand Up @@ -691,7 +691,8 @@
val = await format(val, { parser, ...options });
val =
this.quotes === '"'
? val.replaceAll('"', '\\"')
? // Escape double quotes, but only if they are not already escaped
val.replaceAll(/(?<!\\)((?:\\\\)*)"/g, '$1\\"')
: val.replaceAll("'", "\\'");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is different about single quotes that they don't need the patch?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are by far to uncommon in that situation and if anybody encounters that, they should open a bug ticket / fix it via PR

val = unwrapLineFeeds(val);
if (trimTrailingSemicolon && val.at(-1) === ';') {
Expand Down
Loading