Skip to content

Add new option classnamesPrintWidth#138

Merged
ony3000 merged 6 commits intomasterfrom
output-option
Mar 22, 2026
Merged

Add new option classnamesPrintWidth#138
ony3000 merged 6 commits intomasterfrom
output-option

Conversation

@ony3000
Copy link
Copy Markdown
Owner

@ony3000 ony3000 commented Mar 22, 2026

This PR closes #96.

What option is this?

This option specifies the print width of the class name. It can be used to branch the print width of class names and the print width of other code.

What options are available?

You can specify an integer value. If no value is provided, the printWidth value is used as default.

@ony3000 ony3000 self-assigned this Mar 22, 2026
@ony3000 ony3000 added the enhancement New feature or request label Mar 22, 2026
@ony3000 ony3000 requested a review from Copilot March 22, 2026 04:24
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new Prettier-plugin option (classnamesPrintWidth) to control wrapping width for class name formatting independently of Prettier’s global printWidth, addressing #96.

Changes:

  • Introduce the classnamesPrintWidth option in the plugin’s option schema, types, and README docs.
  • Update the core formatter to prefer classnamesPrintWidth (when provided) over printWidth for class name wrapping calculations.
  • Add snapshot test coverage across supported parsers (absolute/relative ending position modes) to validate the new behavior.

Reviewed changes

Copilot reviewed 68 out of 69 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
src/options.ts Declares the new classnamesPrintWidth plugin option.
src/core-parts/processor.ts Uses classnamesPrintWidth ?? printWidth when wrapping class name tokens.
global.d.ts Extends ThisPluginOptions with classnamesPrintWidth?: number.
README.md Documents the new option and its CLI/API overrides.
tests/vue/classnames-print-width/relative.test.ts Adds Vue snapshot test runner (relative).
tests/vue/classnames-print-width/absolute.test.ts Adds Vue snapshot test runner (absolute).
tests/vue/classnames-print-width/fixtures.ts Vue fixtures covering default/shorter/longer classnames print width cases.
tests/vue/classnames-print-width/snapshots/relative.test.ts.snap Vue expected output snapshots (relative).
tests/vue/classnames-print-width/snapshots/absolute.test.ts.snap Vue expected output snapshots (absolute).
tests/typescript/classnames-print-width/relative.test.ts Adds TS snapshot test runner (relative).
tests/typescript/classnames-print-width/absolute.test.ts Adds TS snapshot test runner (absolute).
tests/typescript/classnames-print-width/fixtures.ts TS fixtures for classnamesPrintWidth.
tests/typescript/classnames-print-width/snapshots/relative.test.ts.snap TS expected output snapshots (relative).
tests/typescript/classnames-print-width/snapshots/absolute.test.ts.snap TS expected output snapshots (absolute).
tests/svelte/classnames-print-width/relative.test.ts Adds Svelte snapshot test runner (relative).
tests/svelte/classnames-print-width/absolute.test.ts Adds Svelte snapshot test runner (absolute).
tests/svelte/classnames-print-width/fixtures.ts Svelte fixtures for classnamesPrintWidth.
tests/svelte/classnames-print-width/snapshots/relative.test.ts.snap Svelte expected output snapshots (relative).
tests/svelte/classnames-print-width/snapshots/absolute.test.ts.snap Svelte expected output snapshots (absolute).
tests/scss/classnames-print-width/relative.test.ts Adds SCSS snapshot test runner (relative).
tests/scss/classnames-print-width/absolute.test.ts Adds SCSS snapshot test runner (absolute).
tests/scss/classnames-print-width/fixtures.ts SCSS fixtures for classnamesPrintWidth.
tests/scss/classnames-print-width/snapshots/relative.test.ts.snap SCSS expected output snapshots (relative).
tests/scss/classnames-print-width/snapshots/absolute.test.ts.snap SCSS expected output snapshots (absolute).
tests/oxc/classnames-print-width/relative.test.ts Adds OXC snapshot test runner (relative).
tests/oxc/classnames-print-width/absolute.test.ts Adds OXC snapshot test runner (absolute).
tests/oxc/classnames-print-width/fixtures.ts OXC fixtures for classnamesPrintWidth.
tests/oxc/classnames-print-width/snapshots/relative.test.ts.snap OXC expected output snapshots (relative).
tests/oxc/classnames-print-width/snapshots/absolute.test.ts.snap OXC expected output snapshots (absolute).
tests/oxc-ts/classnames-print-width/relative.test.ts Adds OXC-TS snapshot test runner (relative).
tests/oxc-ts/classnames-print-width/absolute.test.ts Adds OXC-TS snapshot test runner (absolute).
tests/oxc-ts/classnames-print-width/fixtures.ts OXC-TS fixtures for classnamesPrintWidth.
tests/oxc-ts/classnames-print-width/snapshots/relative.test.ts.snap OXC-TS expected output snapshots (relative).
tests/oxc-ts/classnames-print-width/snapshots/absolute.test.ts.snap OXC-TS expected output snapshots (absolute).
tests/less/classnames-print-width/relative.test.ts Adds Less snapshot test runner (relative).
tests/less/classnames-print-width/absolute.test.ts Adds Less snapshot test runner (absolute).
tests/less/classnames-print-width/fixtures.ts Less fixtures for classnamesPrintWidth.
tests/less/classnames-print-width/snapshots/relative.test.ts.snap Less expected output snapshots (relative).
tests/less/classnames-print-width/snapshots/absolute.test.ts.snap Less expected output snapshots (absolute).
tests/html/classnames-print-width/relative.test.ts Adds HTML snapshot test runner (relative).
tests/html/classnames-print-width/absolute.test.ts Adds HTML snapshot test runner (absolute).
tests/html/classnames-print-width/fixtures.ts HTML fixtures for classnamesPrintWidth.
tests/html/classnames-print-width/snapshots/relative.test.ts.snap HTML expected output snapshots (relative).
tests/html/classnames-print-width/snapshots/absolute.test.ts.snap HTML expected output snapshots (absolute).
tests/css/classnames-print-width/relative.test.ts Adds CSS snapshot test runner (relative).
tests/css/classnames-print-width/absolute.test.ts Adds CSS snapshot test runner (absolute).
tests/css/classnames-print-width/fixtures.ts CSS fixtures for classnamesPrintWidth.
tests/css/classnames-print-width/snapshots/relative.test.ts.snap CSS expected output snapshots (relative).
tests/css/classnames-print-width/snapshots/absolute.test.ts.snap CSS expected output snapshots (absolute).
tests/babel/classnames-print-width/relative.test.ts Adds Babel snapshot test runner (relative).
tests/babel/classnames-print-width/absolute.test.ts Adds Babel snapshot test runner (absolute).
tests/babel/classnames-print-width/fixtures.ts Babel fixtures for classnamesPrintWidth.
tests/babel/classnames-print-width/snapshots/relative.test.ts.snap Babel expected output snapshots (relative).
tests/babel/classnames-print-width/snapshots/absolute.test.ts.snap Babel expected output snapshots (absolute).
tests/babel-ts/classnames-print-width/relative.test.ts Adds Babel-TS snapshot test runner (relative).
tests/babel-ts/classnames-print-width/absolute.test.ts Adds Babel-TS snapshot test runner (absolute).
tests/babel-ts/classnames-print-width/fixtures.ts Babel-TS fixtures for classnamesPrintWidth.
tests/babel-ts/classnames-print-width/snapshots/relative.test.ts.snap Babel-TS expected output snapshots (relative).
tests/babel-ts/classnames-print-width/snapshots/absolute.test.ts.snap Babel-TS expected output snapshots (absolute).
tests/astro/classnames-print-width/relative.test.ts Adds Astro snapshot test runner (relative).
tests/astro/classnames-print-width/absolute.test.ts Adds Astro snapshot test runner (absolute).
tests/astro/classnames-print-width/fixtures.ts Astro fixtures for classnamesPrintWidth.
tests/astro/classnames-print-width/snapshots/relative.test.ts.snap Astro expected output snapshots (relative).
tests/astro/classnames-print-width/snapshots/absolute.test.ts.snap Astro expected output snapshots (absolute).
tests/angular/classnames-print-width/relative.test.ts Adds Angular snapshot test runner (relative).
tests/angular/classnames-print-width/absolute.test.ts Adds Angular snapshot test runner (absolute).
tests/angular/classnames-print-width/fixtures.ts Angular fixtures for classnamesPrintWidth.
tests/angular/classnames-print-width/snapshots/relative.test.ts.snap Angular expected output snapshots (relative).
tests/angular/classnames-print-width/snapshots/absolute.test.ts.snap Angular expected output snapshots (absolute).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/typescript/classnames-print-width/fixtures.ts
Comment thread tests/vue/classnames-print-width/fixtures.ts
Comment thread tests/html/classnames-print-width/fixtures.ts
Comment thread tests/css/classnames-print-width/fixtures.ts
Comment thread tests/less/classnames-print-width/fixtures.ts
Comment thread tests/svelte/classnames-print-width/fixtures.ts
Comment thread tests/scss/classnames-print-width/fixtures.ts
Comment thread tests/oxc/classnames-print-width/fixtures.ts
Comment thread tests/oxc-ts/classnames-print-width/fixtures.ts
Comment thread tests/astro/classnames-print-width/fixtures.ts
@ony3000 ony3000 merged commit 9b35578 into master Mar 22, 2026
10 checks passed
@ony3000 ony3000 deleted the output-option branch March 22, 2026 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

all classNames should wrap at 50, but code should allow 160

2 participants