@prettier/plugin-pug
Advanced tools
Comparing version 1.1.4 to 1.1.5
# Next | ||
[diff](https://github.com/prettier/plugin-pug/compare/1.1.4...master) | ||
[diff](https://github.com/prettier/plugin-pug/compare/1.1.5...master) | ||
# 1.1.5 | ||
[diff](https://github.com/prettier/plugin-pug/compare/1.1.4...1.1.5) | ||
- Improve handling of `id` and `class` attributes ([#63]) | ||
- Some minor internal changes like | ||
- Optimize indent handling ([b734666], [15bec8e]) | ||
- Target ES2018 with module CommonJS ([054b56f]) | ||
- Move options to subdirectory ([f8ead13]) | ||
[#63]: https://github.com/prettier/plugin-pug/issues/63 | ||
[b734666]: https://github.com/prettier/plugin-pug/commit/b7346666f38f8323d72fdee84cd8aa6cd07760b4 | ||
[15bec8e]: https://github.com/prettier/plugin-pug/commit/15bec8e204482b08bcefc5c6620f783e00a43b58 | ||
[054b56f]: https://github.com/prettier/plugin-pug/commit/054b56fe33fa113c178b9a9f655e6ab35cf98c86 | ||
[f8ead13]: https://github.com/prettier/plugin-pug/commit/f8ead13d65c7f236091e8497ace25fcc71cd5bef | ||
# 1.1.4 | ||
@@ -6,0 +23,0 @@ |
"use strict"; | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DOCTYPE_SHORTCUT_REGISTRY = { | ||
@@ -4,0 +4,0 @@ '<!doctype html>': 'doctype html', |
"use strict"; | ||
var __spreadArrays = (this && this.__spreadArrays) || function () { | ||
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; | ||
for (var r = Array(s), k = 0, i = 0; i < il; i++) | ||
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) | ||
r[k] = a[j]; | ||
return r; | ||
}; | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var LogLevel; | ||
@@ -19,72 +12,43 @@ (function (LogLevel) { | ||
})(LogLevel = exports.LogLevel || (exports.LogLevel = {})); | ||
var Logger = (function () { | ||
function Logger(logger, level) { | ||
if (logger === void 0) { logger = console; } | ||
if (level === void 0) { level = LogLevel.INFO; } | ||
class Logger { | ||
constructor(logger = console, level = LogLevel.INFO) { | ||
this.logger = logger; | ||
this.level = level; | ||
} | ||
Logger.prototype.setLogLevel = function (level) { | ||
setLogLevel(level) { | ||
this.level = level; | ||
}; | ||
Logger.prototype.debug = function (message) { | ||
var optionalParams = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
optionalParams[_i - 1] = arguments[_i]; | ||
} | ||
this.message.apply(this, __spreadArrays([LogLevel.DEBUG, message], optionalParams)); | ||
}; | ||
Logger.prototype.log = function (message) { | ||
var optionalParams = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
optionalParams[_i - 1] = arguments[_i]; | ||
} | ||
this.message.apply(this, __spreadArrays([LogLevel.LOG, message], optionalParams)); | ||
}; | ||
Logger.prototype.info = function (message) { | ||
var optionalParams = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
optionalParams[_i - 1] = arguments[_i]; | ||
} | ||
this.message.apply(this, __spreadArrays([LogLevel.INFO, message], optionalParams)); | ||
}; | ||
Logger.prototype.warn = function (message) { | ||
var optionalParams = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
optionalParams[_i - 1] = arguments[_i]; | ||
} | ||
this.message.apply(this, __spreadArrays([LogLevel.WARN, message], optionalParams)); | ||
}; | ||
Logger.prototype.error = function (message) { | ||
var optionalParams = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
optionalParams[_i - 1] = arguments[_i]; | ||
} | ||
this.message.apply(this, __spreadArrays([LogLevel.ERROR, message], optionalParams)); | ||
}; | ||
Logger.prototype.message = function (level, message) { | ||
var _a; | ||
var optionalParams = []; | ||
for (var _i = 2; _i < arguments.length; _i++) { | ||
optionalParams[_i - 2] = arguments[_i]; | ||
} | ||
} | ||
debug(message, ...optionalParams) { | ||
this.message(LogLevel.DEBUG, message, ...optionalParams); | ||
} | ||
log(message, ...optionalParams) { | ||
this.message(LogLevel.LOG, message, ...optionalParams); | ||
} | ||
info(message, ...optionalParams) { | ||
this.message(LogLevel.INFO, message, ...optionalParams); | ||
} | ||
warn(message, ...optionalParams) { | ||
this.message(LogLevel.WARN, message, ...optionalParams); | ||
} | ||
error(message, ...optionalParams) { | ||
this.message(LogLevel.ERROR, message, ...optionalParams); | ||
} | ||
message(level, message, ...optionalParams) { | ||
if (this.level !== LogLevel.OFF && this.level <= level) { | ||
(_a = this.logger)[Logger.LOG_LEVELS[level]].apply(_a, __spreadArrays([message], optionalParams)); | ||
this.logger[Logger.LOG_LEVELS[level]](message, ...optionalParams); | ||
} | ||
}; | ||
Logger.LOG_LEVELS = [ | ||
'debug', | ||
'log', | ||
'info', | ||
'warn', | ||
'error' | ||
]; | ||
return Logger; | ||
}()); | ||
} | ||
} | ||
exports.Logger = Logger; | ||
function createLogger(logger) { | ||
if (logger === void 0) { logger = console; } | ||
Logger.LOG_LEVELS = [ | ||
'debug', | ||
'log', | ||
'info', | ||
'warn', | ||
'error' | ||
]; | ||
function createLogger(logger = console) { | ||
return new Logger(logger); | ||
} | ||
exports.createLogger = createLogger; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9nZ2VyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2xvZ2dlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7QUFBQSxJQUFZLFFBT1g7QUFQRCxXQUFZLFFBQVE7SUFDbkIseUNBQUssQ0FBQTtJQUNMLHFDQUFHLENBQUE7SUFDSCx1Q0FBSSxDQUFBO0lBQ0osdUNBQUksQ0FBQTtJQUNKLHlDQUFLLENBQUE7SUFDTCxxQ0FBRyxDQUFBO0FBQ0osQ0FBQyxFQVBXLFFBQVEsR0FBUixnQkFBUSxLQUFSLGdCQUFRLFFBT25CO0FBVUQ7SUFTQyxnQkFBb0MsTUFBeUIsRUFBVSxLQUErQjtRQUFs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QUMsQ0FBQztBQUMzQixDQUFDO0FBRkQsb0NBRUMifQ== |
{ | ||
"name": "@prettier/plugin-pug", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"description": "Prettier Pug Plugin", | ||
@@ -35,6 +35,7 @@ "main": "dist/index.js", | ||
"@types/jest": "~24.9.0", | ||
"@types/node": "~13.1.7", | ||
"@types/node": "~13.1.8", | ||
"@types/prettier": "~1.19.0", | ||
"@typescript-eslint/eslint-plugin": "~2.16.0", | ||
"@typescript-eslint/parser": "~2.16.0", | ||
"@typescript-eslint/eslint-plugin": "~2.17.0", | ||
"@typescript-eslint/parser": "~2.17.0", | ||
"benchmark": "~2.1.4", | ||
"eslint": "~6.8.0", | ||
@@ -47,3 +48,3 @@ "eslint-config-prettier": "~6.9.0", | ||
"ts-jest": "~24.3.0", | ||
"typescript": "~3.7.4" | ||
"typescript": "~3.7.5" | ||
}, | ||
@@ -50,0 +51,0 @@ "peerDependencies": { |
137
src/index.ts
@@ -35,13 +35,11 @@ import { Doc, FastPath, format, Options, Parser, ParserOptions, Plugin, util } from 'prettier'; | ||
function printIndent(previousToken: Token, result: string, indent: string, indentLevel: number): string { | ||
function printIndent(previousToken: Token, indent: string, indentLevel: number): string { | ||
switch (previousToken?.type) { | ||
case 'newline': | ||
case 'outdent': | ||
result += indent.repeat(indentLevel); | ||
break; | ||
return indent.repeat(indentLevel); | ||
case 'indent': | ||
result += indent; | ||
break; | ||
return indent; | ||
} | ||
return result; | ||
return ''; | ||
} | ||
@@ -149,6 +147,3 @@ | ||
let indentLevel: number = 0; | ||
let indent: string = ' '.repeat(tabWidth); | ||
if (useTabs) { | ||
indent = '\t'; | ||
} | ||
const indent: string = useTabs ? '\t' : ' '.repeat(tabWidth); | ||
let pipelessText: boolean = false; | ||
@@ -159,4 +154,4 @@ let pipelessComment: boolean = false; | ||
let startTagPosition: number = 0; | ||
let startAttributePosition: number = 0; | ||
let possibleIdPosition: number = 0; | ||
let possibleClassPosition: number = 0; | ||
let previousAttributeRemapped: boolean = false; | ||
@@ -182,7 +177,8 @@ let wrapAttributes: boolean = false; | ||
case 'tag': | ||
result = printIndent(previousToken, result, indent, indentLevel); | ||
result += printIndent(previousToken, indent, indentLevel); | ||
if (!(token.val === 'div' && (nextToken.type === 'class' || nextToken.type === 'id'))) { | ||
result += token.val; | ||
} | ||
startTagPosition = result.length; | ||
possibleIdPosition = result.length; | ||
possibleClassPosition = result.length; | ||
break; | ||
@@ -192,3 +188,3 @@ case 'start-attributes': | ||
previousAttributeRemapped = false; | ||
startAttributePosition = result.length; | ||
possibleClassPosition = result.length; | ||
result += '('; | ||
@@ -231,3 +227,3 @@ const start: number = result.lastIndexOf('\n') + 1; | ||
// Write css-class in front of attributes | ||
const position: number = startAttributePosition; | ||
const position: number = possibleClassPosition; | ||
result = [ | ||
@@ -238,3 +234,3 @@ result.slice(0, position), | ||
].join(''); | ||
startAttributePosition += 1 + className.length; | ||
possibleClassPosition += 1 + className.length; | ||
result = result.replace(/div\./, '.'); | ||
@@ -265,7 +261,7 @@ } | ||
// Write css-id in front of css-classes | ||
const position: number = startTagPosition; | ||
const position: number = possibleIdPosition; | ||
result = [result.slice(0, position), `#${val}`, result.slice(position)].join( | ||
'' | ||
); | ||
startAttributePosition += 1 + val.length; | ||
possibleClassPosition += 1 + val.length; | ||
result = result.replace(/div#/, '#'); | ||
@@ -408,4 +404,21 @@ if (previousToken.type === 'attribute' && previousToken.name !== 'class') { | ||
case 'class': | ||
result = printIndent(previousToken, result, indent, indentLevel); | ||
result += `.${token.val}`; | ||
switch (previousToken?.type) { | ||
case 'newline': | ||
case 'outdent': | ||
case 'indent': { | ||
const prefix = result.slice(0, result.length); | ||
const _indent = printIndent(previousToken, indent, indentLevel); | ||
const val = `.${token.val}`; | ||
result = [prefix, _indent, val, result.slice(result.length)].join(''); | ||
possibleClassPosition = prefix.length + _indent.length + val.length; | ||
break; | ||
} | ||
default: { | ||
const prefix = result.slice(0, possibleClassPosition); | ||
const val = `.${token.val}`; | ||
result = [prefix, val, result.slice(possibleClassPosition)].join(''); | ||
possibleClassPosition = prefix.length + val.length; | ||
break; | ||
} | ||
} | ||
if (nextToken?.type === 'text') { | ||
@@ -424,3 +437,3 @@ result += ' '; | ||
case 'comment': { | ||
result = printIndent(previousToken, result, indent, indentLevel); | ||
result += printIndent(previousToken, indent, indentLevel); | ||
if (previousToken && !['newline', 'indent', 'outdent'].includes(previousToken.type)) { | ||
@@ -453,4 +466,3 @@ result += ' '; | ||
case 'newline': | ||
result += indent.repeat(indentLevel); | ||
result += indent; | ||
result += indent.repeat(indentLevel + 1); | ||
break; | ||
@@ -538,3 +550,3 @@ case 'start-pipeless-text': | ||
case 'outdent': | ||
result = printIndent(previousToken, result, indent, indentLevel); | ||
result += printIndent(previousToken, indent, indentLevel); | ||
result += '| '; | ||
@@ -547,3 +559,3 @@ break; | ||
case 'code': { | ||
result = printIndent(previousToken, result, indent, indentLevel); | ||
result += printIndent(previousToken, indent, indentLevel); | ||
if (!token.mustEscape && token.buffer) { | ||
@@ -577,26 +589,21 @@ result += '!'; | ||
case 'id': { | ||
// Handle id attribute | ||
// Write css-id in front of css-classes | ||
let lastPositionOfNewline = result.lastIndexOf('\n'); | ||
if (lastPositionOfNewline === -1) { | ||
// If no newline was found, set position to zero | ||
lastPositionOfNewline = 0; | ||
} | ||
let position: number = result.indexOf('.', lastPositionOfNewline); | ||
if (position === -1) { | ||
position = result.length; | ||
} | ||
let _indent = ''; | ||
switch (previousToken?.type) { | ||
case 'newline': | ||
case 'outdent': | ||
_indent = indent.repeat(indentLevel); | ||
case 'indent': { | ||
const prefix = result.slice(0, result.length); | ||
const _indent = printIndent(previousToken, indent, indentLevel); | ||
const val = `#${token.val}`; | ||
result = [prefix, _indent, val, result.slice(result.length)].join(''); | ||
possibleClassPosition = prefix.length + _indent.length + val.length; | ||
break; | ||
case 'indent': | ||
_indent = indent; | ||
} | ||
default: { | ||
const prefix = result.slice(0, possibleIdPosition); | ||
const val = `#${token.val}`; | ||
result = [prefix, val, result.slice(possibleIdPosition)].join(''); | ||
possibleClassPosition = prefix.length + val.length; | ||
break; | ||
} | ||
} | ||
result = [result.slice(0, position), _indent, `#${token.val}`, result.slice(position)].join( | ||
'' | ||
); | ||
break; | ||
@@ -623,3 +630,3 @@ } | ||
case 'block': | ||
result = printIndent(previousToken, result, indent, indentLevel); | ||
result += printIndent(previousToken, indent, indentLevel); | ||
result += 'block '; | ||
@@ -648,15 +655,17 @@ if (token.mode !== 'replace') { | ||
case 'interpolation': | ||
result = printIndent(previousToken, result, indent, indentLevel); | ||
result += printIndent(previousToken, indent, indentLevel); | ||
result += `#{${token.val}}`; | ||
possibleIdPosition = result.length; | ||
possibleClassPosition = result.length; | ||
break; | ||
case 'include': | ||
result = printIndent(previousToken, result, indent, indentLevel); | ||
result += printIndent(previousToken, indent, indentLevel); | ||
result += 'include'; | ||
break; | ||
case 'filter': | ||
result = printIndent(previousToken, result, indent, indentLevel); | ||
result += printIndent(previousToken, indent, indentLevel); | ||
result += `:${token.val}`; | ||
break; | ||
case 'call': { | ||
result = printIndent(previousToken, result, indent, indentLevel); | ||
result += printIndent(previousToken, indent, indentLevel); | ||
result += `+${token.val}`; | ||
@@ -669,6 +678,8 @@ let args: string | null = token.args; | ||
} | ||
possibleIdPosition = result.length; | ||
possibleClassPosition = result.length; | ||
break; | ||
} | ||
case 'mixin': { | ||
result = printIndent(previousToken, result, indent, indentLevel); | ||
result += printIndent(previousToken, indent, indentLevel); | ||
result += `mixin ${token.val}`; | ||
@@ -684,3 +695,3 @@ let args: string | null = token.args; | ||
case 'if': { | ||
result = printIndent(previousToken, result, indent, indentLevel); | ||
result += printIndent(previousToken, indent, indentLevel); | ||
const match = /^!\((.*)\)$/.exec(token.val); | ||
@@ -692,7 +703,7 @@ logger.debug(match); | ||
case 'mixin-block': | ||
result = printIndent(previousToken, result, indent, indentLevel); | ||
result += printIndent(previousToken, indent, indentLevel); | ||
result += 'block'; | ||
break; | ||
case 'else': | ||
result = printIndent(previousToken, result, indent, indentLevel); | ||
result += printIndent(previousToken, indent, indentLevel); | ||
result += 'else'; | ||
@@ -704,3 +715,3 @@ break; | ||
case 'text-html': { | ||
result = printIndent(previousToken, result, indent, indentLevel); | ||
result += printIndent(previousToken, indent, indentLevel); | ||
const match: RegExpExecArray | null = /^<(.*?)>(.*)<\/(.*?)>$/.exec(token.val); | ||
@@ -723,3 +734,3 @@ logger.debug(match); | ||
case 'each': | ||
result = printIndent(previousToken, result, indent, indentLevel); | ||
result += printIndent(previousToken, indent, indentLevel); | ||
result += `each ${token.val}`; | ||
@@ -732,11 +743,11 @@ if (token.key !== null) { | ||
case 'while': | ||
result = printIndent(previousToken, result, indent, indentLevel); | ||
result += printIndent(previousToken, indent, indentLevel); | ||
result += `while ${token.val}`; | ||
break; | ||
case 'case': | ||
result = printIndent(previousToken, result, indent, indentLevel); | ||
result += printIndent(previousToken, indent, indentLevel); | ||
result += `case ${token.val}`; | ||
break; | ||
case 'when': | ||
result = printIndent(previousToken, result, indent, indentLevel); | ||
result += printIndent(previousToken, indent, indentLevel); | ||
result += `when ${token.val}`; | ||
@@ -746,17 +757,19 @@ break; | ||
result += ': '; | ||
possibleIdPosition = result.length; | ||
possibleClassPosition = result.length; | ||
break; | ||
case 'default': | ||
result = printIndent(previousToken, result, indent, indentLevel); | ||
result += printIndent(previousToken, indent, indentLevel); | ||
result += 'default'; | ||
break; | ||
case 'else-if': | ||
result = printIndent(previousToken, result, indent, indentLevel); | ||
result += printIndent(previousToken, indent, indentLevel); | ||
result += `else if ${token.val}`; | ||
break; | ||
case 'blockcode': | ||
result = printIndent(previousToken, result, indent, indentLevel); | ||
result += printIndent(previousToken, indent, indentLevel); | ||
result += '-'; | ||
break; | ||
case 'yield': | ||
result = printIndent(previousToken, result, indent, indentLevel); | ||
result += printIndent(previousToken, indent, indentLevel); | ||
result += 'yield'; | ||
@@ -763,0 +776,0 @@ break; |
{ | ||
"compilerOptions": { | ||
"target": "ES2018", | ||
"module": "CommonJS", | ||
"inlineSourceMap": true, | ||
"lib": ["es2016", "dom"], | ||
"lib": ["ES2018", "DOM"], | ||
"outDir": "dist", | ||
@@ -6,0 +8,0 @@ "moduleResolution": "node", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
138160
14
2083