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.8.0 to 1.8.1

12

CHANGELOG.md
# Next
[diff](https://github.com/prettier/plugin-pug/compare/1.8.0...master)
[diff](https://github.com/prettier/plugin-pug/compare/1.8.1...master)
# 1.8.1
[diff](https://github.com/prettier/plugin-pug/compare/1.8.0...1.8.1)
- Improve conversion of tags to literals ([#133])
- Handle plain-text tokens after outdent ([#135])
[#133]: https://github.com/prettier/plugin-pug/issues/133
[#135]: https://github.com/prettier/plugin-pug/issues/135
# 1.8.0

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

6

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

@@ -48,4 +48,4 @@ "main": "dist/index.js",

"eslint-plugin-prettier": "~3.1.4",
"jest": "~26.4.2",
"jest-junit": "~11.1.0",
"jest": "~26.5.0",
"jest-junit": "~12.0.0",
"prettier": "2.1.2",

@@ -52,0 +52,0 @@ "ts-jest": "~26.4.1",

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

private currentTagPosition: number = 0;
private possibleIdPosition: number = 0;

@@ -268,2 +269,17 @@ private possibleClassPosition: number = 0;

private replaceTagWithLiteralIfPossible(search: RegExp, replace: string): void {
const currentTagEnd: number = Math.max(this.possibleIdPosition, this.possibleClassPosition);
const tag: string = this.result.slice(this.currentTagPosition, currentTagEnd);
const replaced: string = tag.replace(search, replace);
if (replaced !== tag) {
const prefix: string = this.result.slice(0, this.currentTagPosition);
const suffix: string = this.result.slice(currentTagEnd);
this.result = `${prefix}${replaced}${suffix}`;
// tag was replaced, so adjust possible positions as well
const diff: number = tag.length - replaced.length;
this.possibleIdPosition -= diff;
this.possibleClassPosition -= diff;
}
}
private formatDelegatePrettier(

@@ -437,2 +453,3 @@ val: string,

logger.debug('tag', { result, val: token.val, length: token.val.length }, this.currentLineLength);
this.currentTagPosition = this.result.length + this.computedIndent.length;
this.possibleIdPosition = this.result.length + result.length;

@@ -553,7 +570,4 @@ this.possibleClassPosition = this.result.length + result.length;

// Handle class attribute
let val: string = token.val;
val = val.slice(1, -1);
val = val.trim();
val = val.replace(/\s\s+/g, ' ');
const classes: string[] = val.split(' ');
const val: string = token.val.slice(1, -1).trim();
const classes: string[] = val.split(/\s+/);
const specialClasses: string[] = [];

@@ -579,10 +593,3 @@ const normalClasses: string[] = [];

this.possibleClassPosition += 1 + normalClasses.join('.').length;
// See if `div` can be removed from the literal
const replaced: string = this.result.replace(/div\./, '.');
if (replaced !== this.result) {
this.result = replaced;
// `div` was removed, so reduce possible positions as well
this.possibleIdPosition -= 3;
this.possibleClassPosition -= 3;
}
this.replaceTagWithLiteralIfPossible(/div\./, '.');
}

@@ -616,10 +623,3 @@ if (specialClasses.length > 0) {

this.possibleClassPosition += literal.length;
// See if `div` can be removed from the literal
const replaced: string = this.result.replace(/div#/, '#');
if (replaced !== this.result) {
this.result = replaced;
// `div` was removed, so reduce possible positions as well
this.possibleIdPosition -= 3;
this.possibleClassPosition -= 3;
}
this.replaceTagWithLiteralIfPossible(/div#/, '#');
this.previousAttributeRemapped = true;

@@ -733,5 +733,5 @@ return;

const result: string = `\n${this.indentString.repeat(this.indentLevel)}`;
this.indentLevel++;
this.currentLineLength = result.length - 1 + 1 + this.indentString.length; // -1 for \n, +1 for non zero based
logger.debug('indent', { result, indentLevel: this.indentLevel }, this.currentLineLength);
this.indentLevel++;
return result;

@@ -905,2 +905,3 @@ }

case 'indent':
case 'outdent':
result += this.indentString;

@@ -907,0 +908,0 @@ if (/^ .+$/.test(val)) {

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