Skip to content

Fix multiline mixin call indentation - #655

Merged
Shinigami92 merged 3 commits into
prettier:mainfrom
LucasLeao18:fix/multiline-mixin-call-indentation
Sep 15, 2026
Merged

Shinigami92 merged 3 commits into
prettier:mainfrom
LucasLeao18:fix/multiline-mixin-call-indentation

Conversation

@LucasLeao18

Copy link
Copy Markdown
Contributor

Summary

  • format mixin-call arguments against the remaining Pug line width instead of the internal 9000-column interpolation width
  • re-indent multiline JavaScript output relative to the Pug call
  • cover long and nested mixin calls with regression fixtures

Fixes #620.

Verification

  • pnpm run format
  • pnpm run lint
  • pnpm run build
  • pnpm vitest run (142 files, 326 tests)
  • git diff --check

pnpm run ts-check was also run; it currently fails in unchanged eslint.config.ts and vitest.config.ts because the locked dependency graph contains incompatible @eslint/core type versions and a coverage-option type mismatch. The build, linter, and full test suite pass.

@LucasLeao18
LucasLeao18 marked this pull request as ready for review September 14, 2026 05:34
@Shinigami92 Shinigami92 added the type: bug Functionality that does not work as intended/expected label Sep 14, 2026
@github-actions

github-actions Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 93.69% (🎯 90%)
⬆️ +0.04%
1041 / 1111
🟢 Statements 93.58% (🎯 90%)
⬆️ +0.05%
1050 / 1122
🟢 Functions 97.94% (🎯 90%)
⬆️ +0.01%
143 / 146
🔴 Branches 88.15% (🎯 90%)
⬆️ +0.02%
685 / 777
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/printer.ts 94.02%
⬆️ +0.05%
89.15%
⬆️ +0.01%
100%
🟰 ±0%
94.23%
⬆️ +0.05%
337, 374, 524-526, 538-547, 552-563, 612-665, 704, 790-793, 1143, 1237, 1265, 1274, 1566, 1613, 1833, 1872, 2022-2027, 2067-2071
Unchanged Files
src/doctype-shortcut-registry.ts 100% 100% 100% 100%
src/index.ts 86.66% 100% 71.42% 86.66% 79-85
src/logger.ts 82.14% 42.85% 91.66% 82.14% 37-44, 93, 153-155
src/prettier.d.ts 100% 100% 100% 100%
src/options/common.ts 100% 100% 100% 100%
src/options/constants.ts 100% 100% 100% 100%
src/options/converge.ts 100% 82.6% 100% 100%
src/options/index.ts 100% 100% 100% 100%
src/options/pug-attribute-separator.ts 75% 100% 100% 75% 52-54
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 96% 91.66% 100% 95.83% 82, 94
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.7% 86.76% 100% 88.88% 19, 27, 56, 258, 262, 269-272, 331
src/utils/script-mime-types.ts 86.66% 75% 100% 86.66% 42, 49
src/utils/svelte.ts 100% 100% 100% 100%
src/utils/vue.ts 100% 100% 100% 100%
Generated in workflow #1590 for commit fba757b by the Vitest Coverage Report Action

@Shinigami92

Copy link
Copy Markdown
Member

CI is green 👍 Need to review it when I find time

Comment thread src/printer.ts Resolved
Comment thread src/printer.ts Resolved
Comment thread src/printer.ts Resolved
Comment thread src/printer.ts Resolved
Comment thread tests/mixins/multiline-calls.pug Resolved
Comment thread tests/mixins/mixins.test.ts Resolved
Comment thread src/printer.ts Resolved
Comment thread tests/mixins/mixins.test.ts Resolved
@LucasLeao18

Copy link
Copy Markdown
Contributor Author

Addressed the review in fba757b:

  • preserve the unbounded code-interpolation width and skip re-indentation for mixin calls inside #[...]
  • track only the final rendered line in currentLineLength
  • correct the one-column width budget and add 13/14/15-column boundary coverage
  • turn the multiline fixture into an actual unformatted-to-formatted case
  • add interpolation and trailing-attribute regression fixtures, including idempotency checks
  • document the conservative continuation-line width trade-off and the pugPrintWidth: 100 fixture choice

Verified locally: all 142 test files / 330 tests pass, and ESLint passes.

@Shinigami92
Shinigami92 self-requested a review September 15, 2026 06:05
@Shinigami92
Shinigami92 added this pull request to the merge queue Sep 15, 2026
Merged via the queue into prettier:main with commit 5ba953b Sep 15, 2026
13 checks passed
@Shinigami92

Copy link
Copy Markdown
Member

I need to setup potentially some more stuff before doing a new release, and I need to check if the infra rework had made effective changes to the dist. So you might need to wait until weekend before I do a release. I just want to do it safe and not rushed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug Functionality that does not work as intended/expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: mixin formating breaks

2 participants