-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix generated_plugin_registrant.dart not being ignored #52
Fix generated_plugin_registrant.dart not being ignored #52
Conversation
`generated_plugin_registrant.dart` file was not being ignored by import_sorter. The logic was flawed - the slash was redundant. * set VSCode line length for dartfmt to 80
if (dependencies.contains('flutter/') && | ||
dartFiles | ||
.containsKey('${currentPath}/lib/generated_plugin_registrant.dart')) { | ||
final containsFlutter = dependencies.contains('flutter'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR could basically be just changing flutter/
to flutter
, but I decided to improve some other parts a bit as well.
.containsKey('${currentPath}/lib/generated_plugin_registrant.dart'); | ||
|
||
stdout.writeln('contains flutter: ${containsFlutter}'); | ||
stdout.writeln('contains registrant: ${containsRegistrant}'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to remove this after merge, I added this so it's more clear.
@@ -13,8 +10,9 @@ ImportSortData sortImports( | |||
String package_name, | |||
bool emojis, | |||
bool exitIfChanged, | |||
bool noComments, | |||
) { | |||
bool noComments, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional named argument so tests don't require refactors.
stdout.write('Please run import sorter!'.bold().red()); | ||
if (filePath != null) { | ||
stdout.writeln( | ||
'\n┗━━🚨 File ${filePath} does not have its imports sorted.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed .bold().red()
- believe me or not, but it doesn't show up on Ubuntu 20.04 LTS machines.
Also, printing the file name on which the tool failed is very useful.
Another nice solution would be removing all logic related to removing |
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 :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @bartekpacia! Thanks for the work on this. Just a few little changes and then we should be good to merge.
.vscode/settings.json
Outdated
{ | ||
"dart.lineLength": 80 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually see a comment I made later please
bin/main.dart
Outdated
file.readAsLinesSync(), | ||
packageName, | ||
emojis, | ||
exitOnChange, | ||
noComments, | ||
filePath: filePath, | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this from that vscode settings file? If so feel free to keep the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's me – I almost always (when it makes sense) add the trailing comma because it makes the code prettier :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll remove the whole .vscode
directory and add it to .gitignore
, but then it'd be nice to include some info in README.md
or CONTRIBUTING.md
that this project uses lineLength = 80
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be great, thank you!
stdout.write('Please run import sorter!'.bold().red()); | ||
if (filePath != null) { | ||
stdout.writeln( | ||
'\n┗━━🚨 File ${filePath} does not have its imports sorted.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please bring back the red and bold display. It's most likely a problem with your terminal's display colors/system if the color isn't being displayed correctly. It works fine for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't customize anything - just a default Ubuntu terminal (test it out for yourself – it's available on GitHub Actions). I think that many people are using Ubuntu and may encounter this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, we can cut it then
Signed-off-by: Matthew Gleich <git@mattglei.ch>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Thanks for this!
This is now out in import_sorter v4.6.0. Thanks for the PR! |
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 ifdependencies
inpubspec.yaml
containflutter
, notflutter/
!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 :DTrivia
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, includinggenerated_plugin_registrant.dart
. But on GitHub Actions, aftergenerated_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:)