Closed martinloretzzz closed 3 years ago
👋 Hello! Thanks for submitting a issue! @Matt-Gleich will try to respond as soon as possible.
@lig worked on this. Any idea on why this isn't working?
@lig worked on this. Any idea on why this isn't working?
I have some suspicions. I'll look into this.
files: \.dart$
It seems like it worked for me.
@0b01001101 just to clarify: what pre-commit version do you use? Does replacing flutter-import-sorter
with dart-import-sorter
change anything?
pre-commit 2.9.3
If i use dart-import-sorter i get this:
Dart Import Sorter.......................................................Failed
- hook id: dart-import-sorter
- exit code: 1
The Flutter SDK is not available.
If I remove the files
completely, everything works fine(In my first example the ^lib/
regex has a pattern error, so I got the same effect).
I use Windows 10
@0b01001101 could you please run pre-commit autoupdate
and try again with flutter-import-sorter
? @Matt-Gleich has just merged a fix.
Still doesn't work for me
It may have something to do with windows: https://stackoverflow.com/a/23384429
I will investigate the problem further tomorrow
Still doesn't work for me
Could you please provide the full output?
Please run it like this: pre-commit run --verbose --all-files flutter-import-sorter
- hook id: flutter-import-sorter
- duration: 1.76s
┏━━🗂 Sorting 0 dart files
┃ ┃┃
┗━━🙌 Sorted 0 imports in 0.113 seconds
@0b01001101 have you run git add
for any dart source files already? Files not known to git won't be checked by git hooks.
Also, consider removing any files
patterns you still might have defined.
This might be windows related indeed. However, pre-commit
should be able to handle that.
It is strange: if I use types: [file]
instead of types: [dart]
, then everything works like expected. It just doesn't like sorting only dart files.
For me the hotfix with sorting all files works more than good enough, I would say if nobody else has the same problem we close this issue for now. It may be a complex interaction between the flutter installation on a custom location, something related to windows or some other factors I can't even think of.
I am also having issues on Windows. This is my output of pre-commit run --verbose --all-files flutter-import-sorter
:
Flutter Import Sorter....................................................Passed
- hook id: flutter-import-sorter
- duration: 4.79s
contains flutter: true
contains registrant: false
┏━━ Sorting 0 dart files
┗━━ Sorted 0 files in 0.266 seconds
contains flutter: true
contains registrant: false
┏━━ Sorting 0 dart files
┗━━ Sorted 0 files in 0.117 seconds
This is what I have in .pre-commit-config.yaml
:
exclude: "build|debug-info|.git"
default_stages: [commit]
fail_fast: true
repos:
- repo: "https://github.com/pre-commit/pre-commit-hooks"
rev: v4.0.1
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/fluttercommunity/import_sorter
rev: "aeb26a791ea546506cc8cd2207b320b64a7ed6b5"
hooks:
- id: flutter-import-sorter
Describe the bug Precommit hook doesn't sort imports
To Reproduce What command or actions did you take to produce this error? Followed the steps at https://pub.dev/packages/import_sorter When I run 'pre-commit run --all-files' nothing happens
.pre-commit-config.yaml:
I got it working with this hotfix as .pre-commit-config.yaml:
It may have something to do with the 'files: .dart$'
Meta Information:
import_sorter
Version: ^4.4.1