slang
slang copied to clipboard
Use source_gen
In the Dart package ecosystem, most of the packages are using source_gen which formats the output code. This process has 2 main benefits:
- The generator can just produce valid code and not care about indentation, carriage returns, etc. since the output is formatted at the end anyway
- The developer can run
dart format .
and there is no change in the generated code since it has already been formatted that way.
I have started using slang and everytime I run dart run slang
, I have to run dart format .
and commit the changes otherwise my CI build is broken.
There is no way to exclude file in Dart formatter (yet) https://github.com/dart-lang/dart_style/issues/864 so having generated code properly formatted like code gen packages do would be great.
To repro:
- Clone the slang repo
- Run
cd slang/example
- Run
flutter pub get
- Run
dart format .
- Run
git diff
👉 There are some changes that shouldn't be here.
A temporary workaround is to remove the generated file inside the CI before running dart format .
. This essentially ignores the file as it doesn't exist anymore.
Integrating source_gen requires a lot of effort so it is unlikely in the near future.
Having the same problem. Would wish this feature to be implemented.