Reputation: 2222
I am trying to exclude all generated files from a package using the following analysis_options.yaml
file.
include: package:pedantic/analysis_options.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
exclude:
- lib/**.g.dart
I still get errors for a file called lib/store/state/presentations_state.g.dart
breaking the rule implicit_dynamic_parameter
. If I exlcude **.g.dart
without the lib/
prefix, dartanalyzer
works properly, but the dart-code.dart-code
VS Code plugin reports Undefined alias. dart(parse_error)
somewhere in the first line of the YAML file, leaving the whole project marked as having an error.
I could reproduce this in both monorepos having multiple packages and single packages as well.
Upvotes: 19
Views: 5590
Reputation: 3550
I put the following to the analysis_options.yaml
which worked for me:
analyzer:
exclude:
- '**.freezed.dart'
- '**.g.dart'
- '**.gr.dart'
- '**/generated_plugin_registrant.dart'
All files matching the patterns are no longer analysed, independent of its location in the file path.
The quotation marks are necessary to prevent syntax errors in the yaml
Upvotes: 32
Reputation: 6161
Assuming the generator you use is based on package:source_gen
you can use this trick to create the right ignores in the generated file!
https://github.com/kevmoo/peanut.dart/commit/9877105daecf59b8f5eb25431ac691a38a3e636c https://github.com/kevmoo/stats/commit/bb2fefaa22fc11c10acfe2f6418b3abba1e51909 https://github.com/kevmoo/build_cli/commit/619495c91caab873c2f48ac36a941c893d9b86b7
Upvotes: 2