numen31337/copy_with_extension

generated code should follow the sort_constructors_first lint rule

LostInDarkMath opened this issue · 4 comments

Describe the issue

In the generated _$FooCWProxyIml class the constructor comes after the field final Foo _value;. But most linters like to follow the sort_constructor_first lint rule.

Environment details

Paste the flutter environment detail.

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.3.5, on Microsoft Windows [Version 6.1.7601], locale de-DE)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc2)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Build Tools 2019 16.10.3)
[√] Android Studio (version 2021.3)
[√] VS Code (version 1.70.1)
[√] Connected device (2 available)
[√] HTTP Host Availability

• No issues found!

package version:

dependencies:
  copy_with_extension: 4.0.4
dev_dependencies:
  copy_with_extension_gen: 4.0.4

Expected behaviour

Constructor should be above the field in the generated code file.

Code organization is opinionated. Lints should be used for hand written code, not generated code. I would suggest for you to ignore all generated files from your linter. You can do this by excludeing them within your analysis_options.yaml file.

analyzer:
  exclude:
   - '**/*.g.dart'
   - '**/*.freezed.dart'

Okay, good point. Maybe you include this hint in the documentation as well :)

@numen31337 (or @LostInDarkMath) this issue can be closed

I'll have a look when I have nothing else to do :)
Changing the order won't hurt, but might make some people happy who want to lint their generated code.
Of course, I agree that this is a purely stylistic decision.