Skip to content

Commit 75bb119

Browse files
committed
Add Notes on Usage with end-of-file-fixer
1 parent 97b3de0 commit 75bb119

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Diff for: README.md

+16
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,19 @@ in your `$PATH`.
5454
- `swag-fmt` - Runs `swag fmt` on all files in the project.
5555
- `swag-init` - Runs `swag init` on the project. Please
5656
reference [available CLI flags in the documentation](https://github.com/swaggo/swag#swag-cli).
57+
58+
## Additional Notes
59+
60+
### Usage with `end-of-file-fixer`
61+
62+
- When using the `swag-fmt` hook together with `end-of-file-fixer`
63+
from [pre-commit-hooks](https://github.com/pre-commit/pre-commit-hooks), consider:
64+
- Defining the `end-of-file-fixer` _after_ the `swag-fmt` hook.
65+
- Excluding the `swagger.json` file from pre-commit actions by adding this to the top-level exclude
66+
pattern, otherwise you end up in an infinite loop where `swag-fmt` generates JSON without a new line at the end,
67+
and `end-of-file-fixer` keeps adding it:
68+
69+
```yaml
70+
exclude: '^.*swagger\.json$'
71+
```
72+

0 commit comments

Comments
 (0)