Skip to content

Commit

Permalink
Bail out early if no relevant files
Browse files Browse the repository at this point in the history
In a run where there are no relevant files, ESLint v6 was failing
because the list passed in was empty. It was rendering the help listing
instead of returning JSON that could be parsed.
  • Loading branch information
sheck committed Oct 8, 2024
1 parent 59a5f16 commit 70f8eaa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ async function run() {
`Changed files matching extensions: ${changedFilesMatchingExtensions}`,
)

// Bail out early if the file list is empty (older ESLint versions will
// complain if the list is empty)
if (changedFilesMatchingExtensions.length === 0) return

let { stdout: eslintOut, exitCode } = await getExecOutput(
"npx eslint --format=json",
changedFilesMatchingExtensions,
Expand Down

0 comments on commit 70f8eaa

Please sign in to comment.