Skip to content

Conversation

dkrutskikh
Copy link
Contributor

Requirements

  • Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion.
  • All new code requires tests to ensure against regressions

Description of the Change

Effective Dart require sort imports in alphabetically order

Alternate Designs

Why Should This Be In Core?

Benefits

Possible Drawbacks

Verification Process

Applicable Issues

@BirjuVachhani
Copy link
Owner

@dkrutskikh Thank you for opening this PR. Can you take a look at the failing tests please?

@BirjuVachhani BirjuVachhani requested a review from Copilot May 26, 2025 04:18
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors test file generation to sort import statements alphabetically and consolidates import templates.

  • Introduces separate templates for test and project imports
  • Sorts package import lines before insertion into the test template
  • Adds a new placeholder ([TEST_IMPORTS]) and supporting constant

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
lib/src/generation_utils.dart Builds and sorts import list, replaces single placeholder
lib/src/data/test_template.dart Replaces hard-coded imports with [TEST_IMPORTS] and adds import templates
lib/src/cli/utils/constants.dart Adds TEST_IMPORTS placeholder constant
Comments suppressed due to low confidence (3)

lib/src/generation_utils.dart:143

  • [nitpick] Consider renaming importsContent to a more descriptive name like sortedImportLines or sortedImports to clarify its purpose.
var importsContent = [

lib/src/generation_utils.dart:149

  • Add a unit test that verifies the import lines are correctly sorted alphabetically, guarding against regressions in this new sorting behavior.
]..sort();

lib/src/data/test_template.dart:13

  • Remove the leading space before [TEST_IMPORTS] so that generated import statements start at the leftmost column, preventing syntax errors.
 [TEST_IMPORTS]

@BirjuVachhani BirjuVachhani merged commit 573c14a into BirjuVachhani:main May 26, 2025
3 checks passed
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.

2 participants