invertase / dart_custom_lint

💡 Easily write powerful Dart & Flutter lint rules for your projects or for users of your packages.
https://pub.dev/packages/custom_lint
Apache License 2.0
288 stars 65 forks source link

`LintCode` class conflicts with `LintCode` from `analyzer` #261

Closed Rexios80 closed 3 months ago

Rexios80 commented 3 months ago

Describe the bug

The name 'LintCode' is defined in the libraries 'package:analyzer/src/dart/error/lint_codes.dart (via package:analyzer/error/error.dart)' and 'package:custom_lint_core/src/lint_codes.dart'.
Try using 'as prefix' for one of the import directives, or hiding the name from all but one of the imports.dart[ambiguous_import](https://dart.dev/diagnostics/ambiguous_import)

It looks like LintCode got exported in analyzer: 6.8.0. Should we switch to using it instead of the object owned by custom_lint?

To Reproduce

  1. Be on Flutter master or any other version of Dart/Flutter that supports analyzer: 6.8.0
  2. Attempt to use a custom_lint

Expected behavior No conflicts

Rexios80 commented 3 months ago

This might not be the only issue with using custom_lint with Flutter channel master

rrousselGit commented 3 months ago

There are lots of issues with the master channel unfortunately. I'm working on all of those already

Rexios80 commented 3 months ago

Welp this started causing analysis issues on pub.dev: https://pub.dev/packages/firebase_rules_linter

Is there anything I can do to help here?

rrousselGit commented 3 months ago

For plugins, you can use import ... as prefix or import ... hide LintCode, ..., and publish a new version with those.

As for how broken custom_lint currently is, unfortunately you can only wait until I fix it. It's effectively a rewrite, so it's taking time.

provokateurin commented 3 months ago

Downgrading to Dart 3.4 works for now. Alternatively one could force downgrade the analyzer version using overrides, but that could potentially lead to other problems.

rrousselGit commented 3 months ago

Overriding analyzer to >=6.0.0<6.6.0 should be relatively fine for now. I'm working on a fix, but it's challenging

brilliapps commented 3 months ago

Sorry, i am not sure if i understand (still not experienced). Could possibly custom_lint work out of the box with dart 3.5 (it doesn't) if i changed the analyzer version? I have 3.4.4 and actually need also the 3.5 version of macros (need both), but custom_lint is NOW more important and the macros can wait a little longer.

rrousselGit commented 3 months ago

Well I'm working on it.

brilliapps commented 3 months ago

Yeah, i already knew this and asked recently in a separate issue and got answered. I didn't mean my request here to be rude because it looks like i am impatient. The question was if having dart 3.5 and the newest custom_lint from pub.dev (0.6.4) downgrading analyser only to some older version would cause custom_lint start to work, although maybe even not fully well (3.5 has improved macros to the 3.4 dart version). So please, this post here is more to explain myself not to bother you and get answer :)

rrousselGit commented 3 months ago

Fixed in 0.6.5

provokateurin commented 3 months ago

Awesome!! Will try it out right away

provokateurin commented 3 months ago

Works as expected, thank you so much :)

Rexios80 commented 3 months ago

Works great! Thanks @rrousselGit!