V
V
Vadim Popov2019-05-28 13:22:22
git
Vadim Popov, 2019-05-28 13:22:22

Why doesn't pre-commit autoformater flutter work?

I use the flutter-format-pre-commit library to automatically format code before commit.
In the .pre-commit-config.yaml file, I specified the start file of the application for testing the functionality of the hook

- repo: https://github.com/Cretezy/flutter-format-pre-commit
  rev: "master"
  hooks:
    - id: flutter-format
      files: lib/src/app.dart # Only format source file

I deliberately indent the file and after that I make a commit, I get an error -
Commit failed with error
0 files committed, 1 file failed to commit: test hook

Format Flutter Code......................................................Failed

hookid: flutter-format          
Files were modified by this hook. Additional output:        
Formatted lib/src/app.dart
find: ‘>     bin [’: No such file or directory

How to decide?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Kravchenko, 2020-07-28
@vadimpopov94

put https://pre-commit.com/
run:
pre-commit install
git add .pre-commit-config.yaml
config file:

- repo: local
  hooks:
    - id: flutter-format-lib
      name: format-lib
      entry: dartfmt -l 150 -w lib
      language: system

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question