dart-lang / dart_style

An opinionated formatter/linter for Dart code
https://pub.dev/packages/dart_style
BSD 3-Clause "New" or "Revised" License
645 stars 118 forks source link

Add a `--stdin-path` argument #1530

Closed natebosch closed 4 days ago

natebosch commented 1 month ago

The vim plugin formats using stdin so that we can format without writing the buffer. We added --stdin-name argument so that error messages can include the file name and makes it easier for us to associate the errors back to the buffer. Now that formatting depends on language version can we add a --stdin-path argument to ask the formatter to treat the content as if it had been written to that location, and find the language version accordingly.

https://github.com/dart-lang/dart_style/issues/1402#issuecomment-2292271853

munificent commented 6 days ago

I've been thinking about it more and maybe it makes more sense to just use the existing --stdin-name option as the path and search for a package config surrounding that. If you don't want it to search, you can always disable that by passing in an explicit language version or --language-version=latest. What do you think?

natebosch commented 5 days ago

That behavior SGTM. That should make the vim plugin just keep working without change.