-
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"dart.lineLength": 80 | ||
} | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,11 +67,17 @@ void main(List<String> args) { | |
|
||
// Getting all the dart files for the project | ||
final dartFiles = files.dartFiles(currentPath, args); | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. This PR could basically be just changing |
||
final containsRegistrant = dartFiles | ||
.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 commentThe 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. |
||
|
||
if (containsFlutter && containsRegistrant) { | ||
dartFiles.remove('${currentPath}/lib/generated_plugin_registrant.dart'); | ||
} | ||
|
||
for (final pattern in ignored_files) { | ||
dartFiles.removeWhere((key, _) => | ||
RegExp(pattern).hasMatch(key.replaceFirst(currentPath, ''))); | ||
|
@@ -90,7 +96,13 @@ void main(List<String> args) { | |
} | ||
|
||
final sortedFile = sort.sortImports( | ||
file.readAsLinesSync(), packageName, emojis, exitOnChange, noComments); | ||
file.readAsLinesSync(), | ||
packageName, | ||
emojis, | ||
exitOnChange, | ||
noComments, | ||
filePath: filePath, | ||
); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. I'll remove the whole There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would be great, thank you! |
||
filesFormatted++; | ||
|
||
dartFiles[filePath]?.writeAsStringSync(sortedFile.sortedFile); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
// 🎯 Dart imports: | ||
import 'dart:io'; | ||
|
||
// 📦 Package imports: | ||
import 'package:tint/tint.dart'; | ||
|
||
/// Sort the imports | ||
/// Returns the sorted file as a string at | ||
/// index 0 and the number of sorted imports | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Optional named argument so tests don't require refactors. |
||
String? filePath, | ||
}) { | ||
String dartImportComment(bool emojis) => | ||
'//${emojis ? ' 🎯 ' : ' '}Dart imports:'; | ||
String flutterImportComment(bool emojis) => | ||
|
@@ -156,8 +154,10 @@ ImportSortData sortImports( | |
final sortedFile = sortedLines.join('\n'); | ||
final original = lines.join('\n') + '\n'; | ||
if (exitIfChanged && original != sortedFile) { | ||
stdout.write('\n┗━━🚨 '); | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. I've removed Also, printing the file name on which the tool failed is very useful. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Ok, we can cut it then |
||
} | ||
exit(1); | ||
} | ||
if (original == sortedFile) { | ||
|
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