Skip to content

Conversation

@DavidSemke
Copy link
Contributor

This PR solves issue #531. Previously, using the Vue v-bind directive on an attribute whose value involved a string could result in the string's delimiting quotes being incorrectly escaped. Now escaping behaves as expected, so this:

div(:value=attributes['data-value'])
div(:value=attributes['"data-value"'])
div(:value=attributes['"\'data-value\'"'])
div(:value='"\'data-value\'"')

Becomes this when formatted:

div(:value=attributes["data-value"])
div(:value=attributes['"data-value"'])
div(:value=attributes["\"'data-value'\""])
div(:value="\"\'data-value\'\"")

Some quotes are transformed because of option singleQuote or pugSingleQuote being set to false.

@DavidSemke DavidSemke marked this pull request as ready for review April 19, 2025 05:45
@DavidSemke DavidSemke requested a review from Shinigami92 as a code owner April 19, 2025 05:45
@github-actions
Copy link
Contributor

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 94.59% (🎯 90%)
⬆️ +0.01%
2641 / 2792
🟢 Statements 94.59% (🎯 90%)
⬆️ +0.01%
2641 / 2792
🟢 Functions 96.29% (🎯 90%)
🟰 ±0%
104 / 108
🟢 Branches 92.97% (🎯 90%)
⬇️ -0.01%
635 / 683
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/printer.ts 94.07%
⬆️ +0.01%
94.17%
⬇️ -0.02%
100%
🟰 ±0%
94.07%
⬆️ +0.01%
334-335, 371-372, 521-523, 535-544, 549-562, 610-646, 662-663, 701-702, 769-773, 1122-1123, 1216-1217, 1244, 1256-1257, 1557-1558, 1604-1605, 1930-1936, 1974-1979
Unchanged Files
src/doctype-shortcut-registry.ts 100% 100% 100% 100%
src/index.ts 93.18% 100% 71.42% 93.18% 79-81, 84-86
src/logger.ts 77.46% 90.9% 81.81% 77.46% 37-46, 93-94, 153-157
src/options/common.ts 100% 100% 100% 100%
src/options/constants.ts 100% 100% 100% 100%
src/options/converge.ts 100% 60% 100% 100%
src/options/index.ts 100% 100% 100% 100%
src/options/pug-attribute-separator.ts 89.74% 75% 100% 89.74% 52-55
src/options/pug-class-location.ts 100% 100% 100% 100%
src/options/pug-class-notation.ts 100% 100% 100% 100%
src/options/pug-closing-bracket-indent-depth.ts 100% 100% 100% 100%
src/options/pug-comment-preserve-spaces.ts 100% 100% 100% 100%
src/options/pug-explicit-div.ts 100% 100% 100% 100%
src/options/pug-framework.ts 100% 100% 100% 100%
src/options/pug-id-notation.ts 100% 100% 100% 100%
src/options/pug-preserve-attribute-brackets.ts 100% 100% 100% 100%
src/options/pug-preserve-whitespace.ts 100% 100% 100% 100%
src/options/pug-single-file-component-indentation.ts 100% 100% 100% 100%
src/options/pug-wrap-attributes.ts 100% 100% 100% 100%
src/options/types.ts 100% 100% 100% 100%
src/options/attribute-sorting/index.ts 100% 100% 100% 100%
src/options/attribute-sorting/utils.ts 95.69% 94.44% 100% 95.69% 82-83, 94-95
src/options/empty-attributes/index.ts 100% 100% 100% 100%
src/options/empty-attributes/types.ts 100% 100% 100% 100%
src/options/empty-attributes/utils.ts 100% 100% 100% 100%
src/utils/angular.ts 100% 100% 100% 100%
src/utils/common.ts 89.67% 86.11% 100% 89.67% 19-20, 27-28, 56-57, 258-259, 262-263, 269-272, 331-332
src/utils/script-mime-types.ts 87.5% 83.33% 100% 87.5% 42-43, 49-50
src/utils/svelte.ts 100% 100% 100% 100%
src/utils/vue.ts 100% 100% 100% 100%
Generated in workflow #550 for commit eff552a by the Vitest Coverage Report Action

@Shinigami92 Shinigami92 added type: enhancement Functionality that enhances existing features framework: Vue Related to the framework Vue labels Apr 28, 2025
@Shinigami92 Shinigami92 linked an issue Apr 28, 2025 that may be closed by this pull request
@Shinigami92 Shinigami92 merged commit b09e029 into prettier:main Apr 28, 2025
10 checks passed
@DavidSemke DavidSemke deleted the fix/vue-v-bind branch May 4, 2025 03:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

framework: Vue Related to the framework Vue type: enhancement Functionality that enhances existing features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: unnecessary slashes

2 participants