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

Sorter violates directives_ordering lint rule when file has named imports #28

Open
andrewrowe-wk opened this issue Aug 4, 2020 · 15 comments
Labels
bug Something isn't working

Comments

@andrewrowe-wk
Copy link

andrewrowe-wk commented Aug 4, 2020

Describe the bug

In a file that contains relative import paths, and an absolute path to a named import, then the Dart linting rule directives_ordering fails.

To Reproduce

  1. In your analysis_options.yaml file, enable the directives_ordering option (more info here: http://dart-lang.github.io/linter/lints/directives_ordering.html)
  2. Create a file that contains the following:
    1. An absolute path to a project import
    2. An absolute path to a named project import
    3. A relative path to a project import
  3. Run the sorter
  4. You should see a linting error (I'm using VSCode)

Expected behavior

The import sorter should respect conventional dart styling guidelines.

Screenshots
If applicable, add screenshots to help explain your problem.

Meta Information:

  • Dart Version: SDK version >=2.7.1 <3.0.0
  • import_sorter Version: 4.2.1
  • Is it a Flutter project? No
  • What version of Flutter are you using (if flutter project): N/a

Additional context
Add any other context about the problem here.

@andrewrowe-wk andrewrowe-wk added the bug Something isn't working label Aug 4, 2020
@github-actions
Copy link

github-actions bot commented Aug 4, 2020

👋 Hello! Thanks for submitting a issue 😄! @Matt-Gleich Will try to respond as soon as possible.

@gleich
Copy link
Member

gleich commented Aug 4, 2020

Hello! What version of import_sorter are you using? Please fill out the template

@andrewrowe-wk
Copy link
Author

Sorry, I hit submit by accidentally ctrl+entering!

@gleich
Copy link
Member

gleich commented Aug 4, 2020

No worries!

@andrewrowe-wk
Copy link
Author

Screen Shot 2020-08-04 at 3 07 18 PM

Here is a screenshot of the problem. Sorry for the obfuscation, but it's required :)

@gleich
Copy link
Member

gleich commented Aug 4, 2020

Awesome, thank you! I will debug it when I get out of work in an hour or so.

@andrewrowe-wk
Copy link
Author

Hi Matt!

I think I've almost finished an implementation for this if you're up for the PR! The parsing for imports is actually pretty complicated, because, for my usecase, I leverage a lot of the import related Dart features. That being said, I've got a WIP version that conforms to 90% of the Dart language specification. Would be happy to answer any questions that you would have about it!

@andrewrowe-wk
Copy link
Author

It will be 100% tested, and I will ensure that previous tests still pass.

@gleich
Copy link
Member

gleich commented Aug 10, 2020

Hey! Yeah, that would super great! Sorry about the lack of work on this, I am super busy with my internship recently.

@andrewrowe-wk
Copy link
Author

No worries!

@andrewrowe-wk
Copy link
Author

As an FYI, the issue was around lack of support for "multiline", as opposed to the as keyword. All details will be in PR.

@gleich
Copy link
Member

gleich commented Aug 30, 2020

@andrewrowe-wk any update on this? If need be I can start work on it

@andrewrowe-wk
Copy link
Author

@Matt-Gleich Hi Matt! Yes, I've been working on it, and have a big PR I'm getting together, but I can only work on it on Fridays now, because I have other work that has come up. The change is pretty substantial, and the problem of sorting import statements is not very straightforward due to Dart the dart language specification. I ended up having to import a parser combinator library, to fully parse the import statements. The link to my branch is here if you want to take a look: https://github.com/andrewrowe-wk/import_sorter/tree/issue_28_fix_for_directive_ordering_lint_rule

@gleich
Copy link
Member

gleich commented Sep 2, 2020

Awesome! Looks pretty great so far. No rush on the timing btw, keep it up tho!

@gleich
Copy link
Member

gleich commented Dec 7, 2021

See #63

@gleich gleich closed this as completed Dec 7, 2021
@gleich gleich reopened this Dec 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants