Conversation
There was a problem hiding this comment.
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
classnamesPrintWidthoption in the plugin’s option schema, types, and README docs. - Update the core formatter to prefer
classnamesPrintWidth(when provided) overprintWidthfor 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
printWidthvalue is used as default.