Skip to content
This repository was archived by the owner on Mar 25, 2026. It is now read-only.

Specify dart format width in generated files#827

Closed
turtledev1 wants to merge 1 commit intodart-archive:masterfrom
turtledev1:fix-formatter
Closed

Specify dart format width in generated files#827
turtledev1 wants to merge 1 commit intodart-archive:masterfrom
turtledev1:fix-formatter

Conversation

@turtledev1
Copy link
Copy Markdown

@turtledev1 turtledev1 commented Aug 19, 2025

Fixes dart-lang/build#4597

By specifying the width of the generated files, the dart formatter will use that instead of the configured width, therefore not returning an error in pipelines when the config differs.


  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.
Contribution guidelines:

Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.

@google-cla
Copy link
Copy Markdown

google-cla Bot commented Aug 19, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@srawlins
Copy link
Copy Markdown
Collaborator

I would rather go the other way and use the configured width for an analysis options file. But it looks like dart_style does not do that automatically with the DartFormatter API, and we'd have to read analysis options ourselves.

This would be something like grabbing the entryLib's path with entryLib.firstFragment.source.fullName and then getting the File for that path with entryLib.session.resourceProvider.getFile and then getting the analysis options for that file with entryLib.session.analysisContext.getAnalysisOptionsForFile and then read the formatterOptions and the pageWidth.

@davidmorgan
Copy link
Copy Markdown
Contributor

Closing as the dart-lang/mockito repository is merged into the dart-lang/build monorepo. Please re-open this PR there if you'd like to continue to propose it for merging.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Generated mocks do not use our formatter options

3 participants