Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude all generated code from dartanalyzer

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.

like image 862
wigy Avatar asked Dec 03 '25 16:12

wigy


1 Answers

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

like image 52
tmaihoff Avatar answered Dec 05 '25 08:12

tmaihoff



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!