solid-software / solid_lints

🟧 Lints for Dart and Flutter based on software industry standards and best practices.
Other
36 stars 17 forks source link

Avoid Using API Lint Rule #81

Closed getBoolean closed 5 months ago

getBoolean commented 7 months ago

I've been working on a custom lint rule for banning external code by the identifier. Is this something you would want PR'd to this project?

I started working on it before custom_lint exposed the lint options, so I have some refactoring to do. I would rather add contribute it here since it is already setup for it.

illia-romanenko commented 7 months ago

Sure, we can take a look. Do you have any example or code available? Curious to know your real-world use case as well.

getBoolean commented 7 months ago

I've currently got it implemented in boolean_lints. I had to custom roll the configuration options when I started on it, which I plan to refactor.

For example, you can "deprecate" external code when you have a better option available:

    banned_code:
      # Default severity
      severity: info
      entries:
        - class_name: Future
          id: wait
          source: dart:async
          reason: "Future.wait should be avoided because it loses type safety for the results. Use a Record's `wait` method instead."
          # Override severity for this entry
          severity: warning

Result:

void main() async {
  await Future.wait([...]); // LINT
  await (...,).wait; // OK
}
illia-romanenko commented 7 months ago

Wow - looks really nice! If you are up for a contribution - I think we would definitely be happy having it!

getBoolean commented 7 months ago

Awesome, I'll start working on it and open a pull request when its ready

getBoolean commented 7 months ago

After much hard work and some additional improvements to the lint, I have created PR #89