xsahil03x / super_enum

Create super-powered dart enums similar to sealed classes in Kotlin
https://pub.dev/packages/super_enum
MIT License
116 stars 13 forks source link

Linter Error with super_enum_generator 0.4.2 #48

Closed cfregin closed 4 years ago

cfregin commented 4 years ago

I do get a linter error 'return_of_invalid_type' in the generated R when<R>, R whenOrElse<R> etc. methods. you are returning a FutureOr and not R. (Flutter (Channel beta, v1.14.6, on Mac OS X 10.15.3 19D76, locale de-DE))

xsahil03x commented 4 years ago

@cfregin can you please mention the super_enum_generator version you are using? Try upgrading to the latest v0.5.0.

cfregin commented 4 years ago

I am using super_enum_generator: ^0.5.0

dev_dependencies:
  lint: ^1.1.1

analysis_options.yaml include: package:lint/analysis_options.yaml

xsahil03x commented 4 years ago

This shouldn't be a problem as we are following effective dart guidelines. https://dart.dev/guides/language/effective-dart/design#avoid-using-futureort-as-a-return-type

cfregin commented 4 years ago

Ok, but the linter errors still exists. I could use super_enum now only by moving all enums to an extra folder where I can override the linter rules. In this Github Repository I added linter tests for lint, package lint, effective dart and pedantic. All of them are failing. It would be nice, if you could add an // ignore_for_file: return_of_invalid_type,constant_identifier_names, prefer_const_constructors_in_immutables, unnecessary_this, sort_unnamed_constructors_first, join_return_with_assignment or fix the warnings.

klisiewicz commented 4 years ago

I'm facing the same issue. The lintner shows a bunch of errors in generated files.

xsahil03x commented 4 years ago

Okay, I'll soon look into this and fix this in the next release.

xsahil03x commented 4 years ago

@cfregin, @klisiewicz I need to change the whole part builder in order to add ignore rules in file headers, If this is urgent, you can create a build.yaml file in your local project and add these lines for autogenerating it.

For example https://github.com/dart-lang/source_gen/blob/master/example_usage/build.yaml

targets:
  $default:
    builders:
      source_gen|combining_builder:
        options:
          ignore_for_file:
            - return_of_invalid_type
            - constant_identifier_names
            - prefer_const_constructors_in_immutables
            - unnecessary_this
            - sort_unnamed_constructors_first
            - join_return_with_assignment
xsahil03x commented 4 years ago

Fixed in #59