Skip to content
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

FormatCommand.formatGenerated allows ignoring generated files (.g.dart) #223

Merged
merged 3 commits into from Feb 6, 2023

Conversation

passsy
Copy link
Contributor

@passsy passsy commented Feb 6, 2023

// ignores *.g.dart and *.freezed.dart files
runner.addCommand(FormatCommand(formatGenerated: false));

@passsy passsy requested a review from Giuspepe February 6, 2023 11:46
@@ -96,17 +103,18 @@ class FormatCommand extends Command {

final allFiles =
SidekickContext.projectRoot.findFilesToFormat(globExcludes).toList();
final withoutGenerated = filterGeneratedFiles(allFiles).toList();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this filename still correct?
If formatGenerated is true, this includes all files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any better idea than maybeWithithOrWithoutGeneratedFiles?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filteredFiles?

Copy link
Contributor

@Giuspepe Giuspepe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but I think we can do this with much less code

  final bool formatGenerated;

  FormatCommand({
    List<String> excludeGlob = const [],
    this.defaultLineLength = 80,
    this.formatGenerated = true,
  }) : this.excludeGlob = [
          ...excludeGlob,
          if (!formatGenerated) ...['**.freezed.dart', '**.g.dart'],
        ] {
    ...
  }

@passsy passsy requested a review from Giuspepe February 6, 2023 13:26
@Giuspepe Giuspepe merged commit 46b4a64 into main Feb 6, 2023
@Giuspepe Giuspepe deleted the allow-exclusion-of-generated-files branch February 6, 2023 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants