Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@prettier/plugin-pug

Package Overview
Dependencies
Maintainers
12
Versions
104
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prettier/plugin-pug - npm Package Compare versions

Comparing version 1.13.0 to 1.13.1

12

CHANGELOG.md
# Next
[diff](https://github.com/prettier/plugin-pug/compare/1.13.0...main)
[diff](https://github.com/prettier/plugin-pug/compare/1.13.1...main)
# 1.13.1
[diff](https://github.com/prettier/plugin-pug/compare/1.13.0...1.13.1)
- Set `prettier` peer dependency to `>= 2.1.0` ([#168])
- Handle error thrown by interpolated code in pipeless script tag ([#169])
[#168]: https://github.com/prettier/plugin-pug/issues/168
[#169]: https://github.com/prettier/plugin-pug/issues/169
# 1.13.0

@@ -6,0 +16,0 @@

18

package.json
{
"name": "@prettier/plugin-pug",
"version": "1.13.0",
"version": "1.13.1",
"description": "Prettier Pug Plugin",

@@ -39,11 +39,11 @@ "main": "dist/index.js",

"devDependencies": {
"@types/jest": "~26.0.15",
"@types/node": "~14.14.10",
"@types/jest": "~26.0.17",
"@types/node": "~14.14.11",
"@types/prettier": "~2.1.5",
"@typescript-eslint/eslint-plugin": "~4.8.2",
"@typescript-eslint/parser": "~4.8.2",
"@typescript-eslint/eslint-plugin": "~4.9.1",
"@typescript-eslint/parser": "~4.9.1",
"benchmark": "~2.1.4",
"eslint": "~7.14.0",
"eslint-config-prettier": "~6.15.0",
"eslint-plugin-prettier": "~3.1.4",
"eslint": "~7.15.0",
"eslint-config-prettier": "~7.0.0",
"eslint-plugin-prettier": "~3.2.0",
"jest": "~26.6.3",

@@ -57,4 +57,4 @@ "jest-junit": "~12.0.0",

"peerDependencies": {
"prettier": "^2.0.0"
"prettier": "^2.1.0"
}
}

@@ -130,14 +130,14 @@ <p align="center">

- [pugAttributeSeparator](#pugAttributeSeparator)
- [pugClosingBracketPosition](#pugClosingBracketPosition)
- [pugCommentPreserveSpaces](#pugCommentPreserveSpaces)
- [pugSortAttributesBeginning & pugSortAttributesEnd](#pugSortAttributesBeginning-&-pugSortAttributesEnd)
- [pugSortAttributes](#pugSortAttributes)
- [pugWrapAttributesThreshold](#pugWrapAttributesThreshold)
- [pugWrapAttributesPattern](#pugWrapAttributesPattern)
- [pugSingleFileComponentIndentation](#pugSingleFileComponentIndentation)
- [pugEmptyAttributes](#pugEmptyAttributes)
- [pugEmptyAttributesForceQuotes](#pugEmptyAttributesForceQuotes)
- [pugClassNotation](#pugClassNotation)
- [pugIdNotation](#pugIdNotation)
- [pugAttributeSeparator](#pugattributeseparator)
- [pugClosingBracketPosition](#pugclosingbracketposition)
- [pugCommentPreserveSpaces](#pugcommentpreservespaces)
- [pugSortAttributesBeginning & pugSortAttributesEnd](#pugsortattributesbeginning--pugsortattributesend)
- [pugSortAttributes](#pugsortattributes)
- [pugWrapAttributesThreshold](#pugwrapattributesthreshold)
- [pugWrapAttributesPattern](#pugwrapattributespattern)
- [pugSingleFileComponentIndentation](#pugsinglefilecomponentindentation)
- [pugEmptyAttributes](#pugemptyattributes)
- [pugEmptyAttributesForceQuotes](#pugemptyattributesforcequotes)
- [pugClassNotation](#pugclassnotation)
- [pugIdNotation](#pugidnotation)

@@ -144,0 +144,0 @@ #### `pugAttributeSeparator`

@@ -50,2 +50,3 @@ import { BuiltInParserName, format, RequiredOptions } from 'prettier';

} from 'pug-lexer';
import { types } from 'util';
import { DoctypeShortcut, DOCTYPE_SHORTCUT_REGISTRY } from './doctype-shortcut-registry';

@@ -1104,2 +1105,3 @@ import { createLogger, Logger, LogLevel } from './logger';

let rawText: string = '';
let usedInterpolatedCode: boolean = false;
while (tok && tok?.type !== 'end-pipeless-text') {

@@ -1113,4 +1115,13 @@ switch (tok.type) {

break;
case 'interpolated-code':
usedInterpolatedCode = true;
rawText += tok.mustEscape ? '#' : '!';
rawText += `{${tok.val}}`;
break;
default:
logger.warn('Unhandled token for pipeless script tag:', JSON.stringify(tok));
logger.warn(
'[PugPrinter:start-pipeless-text]:',
'Unhandled token for pipeless script tag:',
JSON.stringify(tok)
);
break;

@@ -1123,3 +1134,38 @@ }

result = format(rawText, { parser, ...this.codeInterpolationOptions });
try {
result = format(rawText, { parser, ...this.codeInterpolationOptions });
} catch (error: unknown) {
if (!usedInterpolatedCode) {
logger.error(error);
throw error;
}
// Continue without formatting the content
const warningContext: string[] = [
'[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.'
];
warningContext.push(`\ncode: \`${rawText.trim()}\``);
// TODO: If other token types occur use `if (usedInterpolatedCode)`
warningContext.push(
'\nYou used interpolated code in your pipeless script tag, so you may ignore this warning.'
);
if (types.isNativeError(error)) {
warningContext.push(`\nFound ${parser} ${error.name}: ${error.message}.`);
} else {
logger.debug('typeof error:', typeof error);
warningContext.push(`\nUnexpected error for parser ${parser}.`, error as string);
}
logger.warn(...warningContext);
result = rawText;
}
result = result.trimRight();

@@ -1126,0 +1172,0 @@ const indentString: string = this.indentString.repeat(this.indentLevel + 1);

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc