feat(oxfmt): add arrayWrap option for array literal wrapping control#20114
Open
jgeurts wants to merge 6 commits intooxc-project:mainfrom
Open
feat(oxfmt): add arrayWrap option for array literal wrapping control#20114jgeurts wants to merge 6 commits intooxc-project:mainfrom
arrayWrap option for array literal wrapping control#20114jgeurts wants to merge 6 commits intooxc-project:mainfrom
Conversation
Add `arrayWrap` configuration option to oxfmt with three modes:
- `"preserve"` (default): use Prettier's auto-expand heuristic
- `"collapse"`: collapse arrays to single line when they fit within printWidth
- `{ "minElementsToWrap": N }`: force one-element-per-line when count >= threshold
Applies to array expressions, array destructuring patterns, and array
assignment targets.
819b7c0 to
3450a6d
Compare
|
Tangentially realated: I've been dreaming of a "matrix wrap", if key count exceeds a threshold it would wrap them more efficiently. Is this something oxfmt could have or are we on plugin territory? export const timezones = {
// oxfmt-ignore
Africa: [
'Abidjan', 'Accra', 'Addis_Ababa', 'Algiers', 'Asmara', 'Bamako',
'Bangui', 'Banjul', 'Bissau', 'Blantyre', 'Brazzaville', 'Bujumbura',
'Cairo', 'Casablanca', 'Ceuta', 'Conakry', 'Dakar', 'Djibouti', 'Douala',
'El_Aaiun', 'Freetown', 'Gaborone', 'Harare', 'Johannesburg', 'Juba',
'Kampala', 'Khartoum', 'Kigali', 'Kinshasa', 'Lagos', 'Libreville',
'Lome', 'Luanda', 'Lubumbashi', 'Lusaka', 'Malabo', 'Maputo',
'Maseru', 'Mbabane', 'Mogadishu', 'Monrovia', 'Nairobi', 'Ndjamena',
'Niamey', 'Nouakchott', 'Ouagadougou', 'Sao_Tome', 'Tripoli', 'Tunis',
'Windhoek',
],
// ...
} |
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.
Fix #20007
Add
arrayWrapconfiguration option to oxfmt with three modes:"preserve"(default): use Prettier's auto-expand heuristic"collapse": collapse arrays to single line when they fit within printWidth{ "minElementsToWrap": N }: force one-element-per-line when count >= thresholdApplies to array expressions, array destructuring patterns, and array assignment targets.
NOTE: I used Claude to help create these changes. Rust is not my first language, so please let me know if there are any improvements or changes that I can make!