fluttercommunity / import_sorter

🎯 Automatically organize your dart imports. Maintainer: @gleich
https://pub.dev/packages/import_sorter
MIT License
174 stars 40 forks source link

Ignore files not working #77

Closed Jannik-dev closed 9 months ago

Jannik-dev commented 9 months ago

Describe the bug I am not able to ignore generated files by localization and freezed. I apologize if I am using the parameter wrong, but I am expecting to use the same syntax as in a .gitignore file. Regardless of the outcome of this issue: It would be great if the documentation covers all 3 cases described below and maybe provides an example.

To Reproduce Create a file (for example t.dart under lib) Use the following configuraion in pubspec.yaml

import_sorter:
  ignored_files:
    - lib/t.dart

File: lib/t.dart nothing happens Extension: lib/\*\*.freezed.dart FormatException: Nothing to repeat lib/**.freezed.dart Folder: lib/generated nothing happens

Expected behavior File: lib/t.dart ignore the file Extension: lib/**.freezed.dart ignore all files generated by freezed in folder lib Folder: lib/generated ignore all files with lib/generated as a parent

Meta Information:

Additional Information Weird is that when using the sorter the file is mentioned as a child of itself: generated\intl\messages_all.dart/messages_all.dart

Jannik-dev commented 9 months ago

Managed to get it to work using regex. This should be noted in the documentation and some more complex examples would be helpful

import_sorter:
  ignored_files:
    - (\\|\/)?lib(\\|\/)features(\\|\/)localization(\\|\/)generated((\\|\/)\w+)*.dart
    - (\\|\/)?(\w+(\\|\/))*\w+.freezed.dart