fluttercommunity / import_sorter

🎯 Automatically organize your dart imports. Maintainer: @gleich
https://pub.dev/packages/import_sorter
MIT License
170 stars 41 forks source link

Fix generated_plugin_registrant.dart not being ignored #52

Closed bartekpacia closed 3 years ago

bartekpacia commented 3 years ago

Wow, finally! I've lost a few hours in the last few days tracking a very strange error with this package, which led to my GitHub Action (which was using import_sorter to check if imports are sorted) failing for seemingly no reason.

What was wrong

generated_plugin_registrant.dart file was not being ignored by import_sorter - the logic was flawed. We want to check if dependencies in pubspec.yaml contain flutter, not flutter/!

Also, if import_sorter failed, it now prints which file caused that.

Now it's fixed and works just fine. Please release v4.5.2 ASAP, I want to be able to use it finally in my GH Actions :D

Trivia

Why were my GitHub Actions failing? Because I've set up import_sorter to run automatically on save on my computers. It formatted all files, including generated_plugin_registrant.dart. But on GitHub Actions, after generated_plugin_registrant.dart was generated, nothing was sorting its imports, so this tool was failing.

I hope I described it clearly and that nobody before had lost theirs time because of this bug:)

bartekpacia commented 3 years ago

Another nice solution would be removing all logic related to removing generated_plugin_registrant.dart and just advising users to add it to ignored_files in pubspec.yaml.

gleich commented 3 years ago

Hey @bartekpacia! Thank you so much for the PR! Sorry to hear that you were having an issue. Looks like you've added some pretty cool things here. I'll take a look after I finish school today :)

gleich commented 3 years ago

This is now out in import_sorter v4.6.0. Thanks for the PR!