Skip to content

Commit 59f676e

Browse files
committed
Ignore unrecognized file extensions for shell formatting
1 parent 133e98e commit 59f676e

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

entry.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,13 +349,14 @@ const HOOKS: Record<HookName, LockableHook> = {
349349
}),
350350
[HookName.Shfmt]: createLockableHook({
351351
action: async sources => {
352-
// Find source files that are Shell files
352+
// Find source files that are Shell files. shfmt has a `-f` flag that
353+
// does this, but it sometimes returns false positives
353354
const shellSources = (
354355
await Promise.all(
355356
sources.map(async source => {
356357
// Check file extension
357-
if (/\.(bash|sh|zsh)$/.test(source)) {
358-
return source;
358+
if (source.split("/").slice(-1)[0].includes(".")) {
359+
return /\.(bash|sh|zsh)$/.test(source) ? source : undefined;
359360
}
360361

361362
// Check shebang

0 commit comments

Comments
 (0)