bluefireteam / vscode-dart-import

A simple plugin for VSCode to change all Dart/Flutter imports to relative format.
64 stars 14 forks source link

Not working with import sorter package #30

Open ianjaspersantos opened 3 years ago

ianjaspersantos commented 3 years ago

The extension do not work when working with flutter package "import sorter". The problem is occuring when the dart import extension trying to sort lines with comments in between the imported files..

luanpotter commented 3 years ago

If you have comments within your imports it gets really hard for this to automatically sort everything right? Dare I say impossible as there can multiple desired outcomes.

Let's say you have:

// group 1
import 'local/file.dart';
import 'package:foo/bar.dart';

// group 2
import 'package:my_package/local/file2.dart';
import 'dart:foo';

The expected result (removing the comments would be):

import 'dart:foo';

import 'package:foo/bar.dart';

import 'local/file.dart';
import 'local/file2.dart';

Where should each comment be put on the new structure? Since every import can change place, I don't see how we can correctly place comments back. If you are using this plugin you are relying on automatically defining the ordering of imports; in that case I think it doesn't make sense to have any comments in your import section. Comments are for humans. This plugin treats your import section as a "generated" part of your code.