mobxjs / mobx.dart

MobX for the Dart language. Hassle-free, reactive state-management for your Dart and Flutter apps.
https://mobx.netlify.app
MIT License
2.4k stars 310 forks source link

Each and every mobx store will warn: `Avoid using private types in public APIs.` with default linters in Flutter 3.0 #809

Open fzyzcjy opened 2 years ago

fzyzcjy commented 2 years ago

Documentation of that lint: https://dart-lang.github.io/linter/lints/library_private_types_in_public_api.html

What do you think? Shall we let users to manually suppress this lint for each and every store? That sounds very verbose.

jfahrenkrug commented 2 years ago

A workaround is to use class SomeStore extends _SomeStoreBase with _$SomeStore {} instead of class SomeStore = _SomeStoreBase with _$SomeStore;. However, the next linting error then occurs in the .g.dart file because a leading underscore is used for a local identifier (no_leading_underscores_for_local_identifiers). So it seems that some code changes to MobX might be needed to satisfy these new linter rules.

fzyzcjy commented 2 years ago

Good idea!

However, the next linting error then occurs in the .g.dart

No worries: We can configure build runner to add //ignore_for_file for .g.dart

muhammedaydogan commented 1 year ago

No worries: We can configure build runner to add //ignore_for_file for .g.dart

How do you do that? Did you read it from a document or sth?

hugobrancowb commented 1 year ago

you can put the following code in the build.yaml. I usually use it for ignoring code coverage from generated files

targets:
  $default:
    builders:
      source_gen|combining_builder:
        options:
          preamble: |
            // ignore_for_file: ...
ljoly83 commented 1 year ago

There is a better and simple solution. Either, for all the files in your projet: Modify in analysis_options.yaml at the root of your project rules:
library_private_types_in_public_api: false
Either, for a single file in your projet: add the comment // ignore: library_private_types_in_public_api above the line with problem (although they says it can be at the start of the file, it doesn't work for me. Hope this help.