-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow configuring project-wide page width using a surrounding analysis_options.yaml file #1571
Merged
Conversation
This file contains 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
This can find, read, and merge them. It handles `include` inside the file. It works using an abstraction over the file system so that (in theory at least), this code could be harvested and made reusable by other tools that need to work with analysis_options.yaml files but don't want to work directly with files on disk. It also includes an implementation of that abstraction using dart:io. Right now, this is all just private inside dart_style, but is organized so that it would be easy to pull out into a separate package later if we want.
It was getting pretty huge. I didn't want to stuff more tests in there for CLI integration of analysis_options, so splitting it up into smaller files first. There are no meaningful changes here, just moving code around.
When formatting from the CLI using files or stdin with a --stdin-name option, looks in the surrounding directories for an analysis_options.yaml file. If found and the file specifies a formatter page width, uses that. Handles includes and merging as well. Doesn't handle "package:" includes yet.
lrhn
reviewed
Oct 4, 2024
lrhn
reviewed
Oct 4, 2024
lrhn
reviewed
Oct 4, 2024
natebosch
approved these changes
Oct 4, 2024
# Conflicts: # lib/src/language_version_cache.dart
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.
When using the
dart format
CLI (and not the library API), if the user doesn't specify a page width using--line-length
, then the formatter will walk the directories surrounding each formatted file looking for ananalysis_options.yaml
file. If one is found, then it looks for a configured page width like:If found, then the file is formatted at that page width. If any sort of failure occurs, the default page width is used instead.
This is hidden behind the "tall-style" experiment flag and the intent is to ship this when the rest of the new tall style ships.
This is a fairly large change. To try to make it easier to review, I broke it into a series of hopefully more digestible commits. You might want to review those separately.
Fix #833.
cc @mit-mit