leancodepl / flutter_corelibrary

Our core packages used for building the best Flutter apps.
https://pub.dev/publishers/leancode.co
57 stars 7 forks source link

[leancode_lint] custom_lint not detecting issues #285

Closed SAGARSURI closed 6 months ago

SAGARSURI commented 6 months ago

Hey team,

Thank you for this great package. I really like your custom_lint rules. But I am not able to make it run in my multi-package flutter project setup. I have the following structure of my project:

my_movies/
 - app/
    - movie_app/
 - utilities/
    - movie_lint/

movie_app: my flutter app movie_lint: my custom lint which internally use leancode_lint package

In my movie_lint package. I have analysis_options.yaml inside the lib/ folder which have the following code:

include: package:leancode_lint/analysis_options.yaml

custom_lint:
  rules:
#    TODO: Add lint for design system [make task also]
    - use_design_system_item:
      AppText:
        - instead_of: Text
          from_package: flutter

analyzer:
  plugins:
    # Required for our custom lints support
    - custom_lint
  exclude:
    - '**/*.g.dart'

In my movie_app the analysis_options.yaml looks like this:

include: package:movie_lint/analysis_options.yaml

Now when I use this package inside my movie_app flutter app. The dart analyze . is working fine but dart run custom_lint is not detecting the issues in my codebase.

shilangyu commented 6 months ago

Does your movie_app have custom_lint as a dependency?

SAGARSURI commented 6 months ago

Nope! It's defined inside the movie_lint package. Idea is not to add it to all the packages that I will have in the future.

shilangyu commented 6 months ago

Unfortunately, thats a limitation of analyzer plugins, as far as I know you cannot do that. You have to mention custom_lint in every package (both in pubspec and analysis options, I think, you have to check). What is worse, I don't think its possible to have just movie_lint mention leancode_lint, but all of them have to do that. The only thing that I think will work indeed is using include: in analysis_options to bring in configuration of lints.

SAGARSURI commented 6 months ago

So I do have analysis_options.yaml in every package but it include movie_lint's analysis_options.yaml which internally uses leancode_lint. It works for me. The advantage I get is, I now have a central place to enable/disable rules.

shilangyu commented 6 months ago

So is this issue resolved then? Or can I help with something else?

SAGARSURI commented 6 months ago

Yeah let's close this out as it's the analyze plugin limitation. Thank you for the support