@prettier/plugin-pug
Advanced tools
Comparing version 1.1.1 to 1.1.2
# Next | ||
[diff](https://github.com/prettier/plugin-pug/compare/1.1.1...master) | ||
[diff](https://github.com/prettier/plugin-pug/compare/1.1.2...master) | ||
# 1.1.2 | ||
[diff](https://github.com/prettier/plugin-pug/compare/1.1.1...1.1.2) | ||
- Transform only valid `id` attributes ([#51]) | ||
- Indent interpolated-code after outdent ([#52]) | ||
- Suggest workarounds in README.md ([8d69f1e], [58157f6]) | ||
[#51]: https://github.com/prettier/plugin-pug/issues/51 | ||
[#52]: https://github.com/prettier/plugin-pug/issues/52 | ||
[8d69f1e]: https://github.com/prettier/plugin-pug/commit/8d69f1ec795d918d69a1e65b8e70d060ab1c6eb5 | ||
[58157f6]: https://github.com/prettier/plugin-pug/commit/58157f6363fc354b97fd048e616735433c9e124a | ||
# 1.1.1 | ||
@@ -6,0 +19,0 @@ |
{ | ||
"name": "@prettier/plugin-pug", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Prettier Pug Plugin", | ||
@@ -34,9 +34,9 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"@types/jest": "~24.0.23", | ||
"@types/node": "~12.12.17", | ||
"@types/jest": "~24.0.25", | ||
"@types/node": "~13.1.4", | ||
"@types/prettier": "~1.19.0", | ||
"@typescript-eslint/eslint-plugin": "~2.11.0", | ||
"@typescript-eslint/parser": "~2.11.0", | ||
"eslint": "~6.7.2", | ||
"eslint-config-prettier": "~6.7.0", | ||
"@typescript-eslint/eslint-plugin": "~2.14.0", | ||
"@typescript-eslint/parser": "~2.14.0", | ||
"eslint": "~6.8.0", | ||
"eslint-config-prettier": "~6.9.0", | ||
"eslint-plugin-prettier": "~3.1.2", | ||
@@ -47,3 +47,3 @@ "jest": "~24.9.0", | ||
"ts-jest": "~24.2.0", | ||
"typescript": "~3.7.3" | ||
"typescript": "~3.7.4" | ||
}, | ||
@@ -50,0 +50,0 @@ "peerDependencies": { |
@@ -151,2 +151,35 @@ <p align="center"> | ||
## Some workarounds | ||
There are some code examples that are not formatted well with this plugin and can damage your code. | ||
But there are workarounds for it. These generate even better pug code! | ||
### Examples | ||
[Issue 53](https://github.com/prettier/plugin-pug/issues/53) | ||
```pug | ||
input(onClick="methodname(\"" + variable + "\", this)") | ||
// transforms to | ||
input(onClick="methodname(\"\" + variable + \"\", this)") | ||
// In most cases ES6 template strings are a good solution | ||
input(onClick=`methodname("${variable}", this)`) | ||
``` | ||
[Issue 54](https://github.com/prettier/plugin-pug/issues/54) | ||
```pug | ||
- const id = 42 | ||
- const collapsed = true | ||
div(id=id, class='collapse' + (collapsed ? '' : ' show') + ' cardcontent') | ||
// transforms to | ||
.cardcontent(id=id, class="collapse' + (collapsed ? '' : ' show') + '") | ||
// better write | ||
.cardcontent.collapse(id=id, class=collapsed ? '' : 'show') | ||
// Now your js logic is extracted from the plain logic | ||
``` | ||
## Integration with editors | ||
@@ -153,0 +186,0 @@ |
@@ -238,2 +238,8 @@ import { Doc, FastPath, format, Options, Parser, ParserOptions, Plugin, util } from 'prettier'; | ||
val = val.trim(); | ||
const validIdNameRegex: RegExp = /^-?[_a-zA-Z]+[_a-zA-Z0-9-]*$/; | ||
if (!validIdNameRegex.test(val)) { | ||
val = makeString(val, singleQuote ? "'" : '"', false); | ||
result += `id=${val}`; | ||
break; | ||
} | ||
// Write css-id in front of css-classes | ||
@@ -506,2 +512,3 @@ const position: number = startTagPosition; | ||
case 'newline': | ||
case 'outdent': | ||
result = printIndent(previousToken, result, indent, indentLevel); | ||
@@ -508,0 +515,0 @@ result += '| '; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
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
134806
2064
222