Skip to content

Commit

Permalink
Fix compatibility with eslint v9
Browse files Browse the repository at this point in the history
  • Loading branch information
rkuykendall committed Jun 17, 2024
1 parent 2436be9 commit e1ffb4a
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 19 deletions.
1 change: 0 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ inputs:
eslint_extensions:
description: Extensions of files to check with ESLint
required: false
default: "js"
eslint_command_prefix:
description: Shell command to prepend to the linter command. Will default to `npx --no-install` for NPM and `yarn run --silent` for Yarn.
required: false
Expand Down
30 changes: 21 additions & 9 deletions dist/index.js

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

30 changes: 21 additions & 9 deletions src/linters/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,29 @@ class ESLint {
* @param {string} prefix - Prefix to the lint command
* @returns {{status: number, stdout: string, stderr: string}} - Output of the lint command
*/
static lint(dir, extensions, args = "", fix = false, prefix = "") {
const extensionsArg = extensions.map((ext) => `.${ext}`).join(",");
static lint(dir, extensions = [], args = "", fix = false, prefix = "") {
const extensionsArg =
extensions.length > 0 ? `--ext ${extensions.map((ext) => `.${ext}`).join(",")}` : "";
const fixArg = fix ? "--fix" : "";
const commandPrefix = prefix || getNpmBinCommand(dir);
return run(
`${commandPrefix} eslint --ext ${extensionsArg} ${fixArg} --no-color --format json ${args} "."`,
{
dir,
ignoreErrors: true,
},
);

const command = [
commandPrefix,
"eslint",
extensionsArg,
fixArg,
"--no-color",
"--format json",
args,
'"."',
]
.filter((s) => s.length > 0)
.join(" ");

return run(command, {
dir,
ignoreErrors: true,
});
}

/**
Expand Down

0 comments on commit e1ffb4a

Please sign in to comment.