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 ignores // ignore: implementation_imports above imports when sorting #38

Open
SchnMar opened this issue Dec 6, 2020 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@SchnMar
Copy link

SchnMar commented Dec 6, 2020

Describe the bug
I use // ignore: implementation_imports in my project above some imports because I use some packages and their implementation.

To Reproduce
What command or actions did you take to produce this error?
I added these comments and ran flutter pub run import_sorter:main. Now these comments are listed below all the imports and not above the imports, which actually import implementation from packages.

Expected behavior
I expected that the comments are sorted with the imports.

Please let me know, if you need additional information. Thank you for your help.

@SchnMar SchnMar added the bug Something isn't working label Dec 6, 2020
@github-actions
Copy link

github-actions bot commented Dec 6, 2020

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

@gleich gleich self-assigned this Dec 6, 2020
@gleich
Copy link
Member

gleich commented Dec 6, 2020

Hello @SchnMar! Mind sending an example file so it easier for me to debug? Thanks!

@SchnMar
Copy link
Author

SchnMar commented Dec 9, 2020

Hallo @Matt-Gleich,

thank you for your help and sorry for the late reply.

I have the following imports prior to sorting:

// Flutter imports:
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

// Package imports:
// ignore: implementation_imports
import 'package:chewie/src/chewie_player.dart';
// ignore: implementation_imports
import 'package:chewie/src/chewie_progress_colors.dart';
// ignore: implementation_imports
import 'package:chewie/src/cupertino_progress_bar.dart';
// ignore: implementation_imports
import 'package:chewie/src/utils.dart';
import 'package:open_iconic_flutter/open_iconic_flutter.dart';
import 'package:video_player/video_player.dart';

After sorting, the imports appear like this:

// Flutter imports:
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

// Package imports:
import 'package:chewie/src/chewie_player.dart';
import 'package:chewie/src/chewie_progress_colors.dart';
import 'package:chewie/src/cupertino_progress_bar.dart';
import 'package:chewie/src/utils.dart';
import 'package:open_iconic_flutter/open_iconic_flutter.dart';
import 'package:video_player/video_player.dart';

// Package imports:
// ignore: implementation_imports
// ignore: implementation_imports
// ignore: implementation_imports
// ignore: implementation_imports

This leads to me annotating with ```//ignore: implementation_imports after every sort.

What do you think? I'm aware that I shouldn't be doing this, but in this case I think it's reasonable to do so.

@bartekpacia
Copy link
Contributor

bartekpacia commented Aug 25, 2021

I also encounter this issue.

My Dart file:

import 'package:flutter/widgets.dart';

import 'package:easy_localization/easy_localization.dart';
// ignore: implementation_imports
import 'package:easy_localization/src/localization.dart';
import 'package:logging/logging.dart';

import 'l10n.dart';

import_sorter ignores the //ignore.. statement and messed this up to the following state:

import 'package:flutter/widgets.dart';

import 'package:easy_localization/easy_localization.dart';
import 'package:easy_localization/src/localization.dart';
import 'package:logging/logging.dart';

import 'l10n.dart';

// ignore: implementation_imports

A workaround I found is to put // ignore_for_file: implementation_imports in the file's first line. Then import_sorter works fine, but it's just a workaround.

@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

3 participants