Skip to content

Commit

Permalink
cmd/shfmt: test that -i=0 does not skip ignore=true from EditorConfig
Browse files Browse the repository at this point in the history
The man page says:

    If any parser or printer flags are given to the tool, no
    EditorConfig formatting options will be used. A default like -i=0
    can be used for this purpose.

Since ignore=true is not a formatting option, and it's still useful
when formatting options are given as flags, it should still work then.
The docs said so, but we had no specific test for it.

For #1095.
  • Loading branch information
mvdan committed Sep 29, 2024
1 parent 8a6585b commit f14e0d2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/shfmt/testdata/script/editorconfig.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ stdout 'regular\.sh'
! stdout 'ignored\.sh'
! stderr .

# EditorConfig ignore=true properties are obeyed even when any formatting flags
# are used, which cause formatting options from EditorConfig files to be skipped.
exec shfmt -i=0 -l ignored
stdout 'regular\.sh'
! stdout 'ignored\.sh'
! stderr .

# Formatting files directly does not obey ignore=true properties by default.
# Test the various modes in which shfmt can run.
! exec shfmt -l input.sh ignored/1_lone_ignored.sh ignored/third_party/bad_syntax_ignored.sh
Expand Down

0 comments on commit f14e0d2

Please sign in to comment.