Description
Generated code (through build_runner or whatever) often have analysis issues.
Usually, on our own code, we regulate those issues through analysis_options.yaml
.
Since the generated code is uneditable and we cannot control how it is generated, we often need to ignore some rules just on generated code, which is impossible.
If we use the exclude
key to exclude **.g.dart
, then errors do not appear anymore (example: some class that is referenced in generated files and are not imported through import 'class.dart';
just doesn't appear on VSCode problems window (you will only know about them when you try to build).
So:
-
Stop ignoring "ERRORS" just because the file is in the
exclude
section ofanalysis_options.yaml
. It doesn't make sense whatsoever to ignore COMPILE errors! -
Allow us to use a different list of rules for some path, in
analysis_options.yaml
, so I can ignoreunused_element
(or whatever) for**.g.dart
, but not for my files. -
Since
part
andpart of
infers that we're using multiple files as one, make// ignore_for_file: unused_element
work on the root file (i.e.: the file that imports the .g.dart file throughpart 'some.g.dart';
)