Skip to content

Commit 01cbfb6

Browse files
committed
ci: Add custom eslint command
1 parent f559a01 commit 01cbfb6

File tree

3 files changed

+32
-21
lines changed

3 files changed

+32
-21
lines changed

README.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,20 @@ export default {
8888

8989
## Inputs
9090

91-
| Name | Description | Required | Default |
92-
| ------------------- | ------------------------------------------------------------------- | -------- | --------------------------- |
93-
| token | Token used for pushing fixes and commenting on PRs. | true | |
94-
| working-directory | Working directory to run the action in | false | "." |
95-
| web-components-src | The path to the directory containing the web components source code | false | "src/\*_/_.{ts,tsx}" |
96-
| test-src | The path to the directory containing the test source code | false | "src/test/\*_/_.test.ts" |
97-
| test-results-path | The path to the test results file | false | "./test-results.xml" |
98-
| coverage-path | The path to the coverage file | false | "coverage/lcov.info" |
99-
| run-static-analysis | Whether to run static analysis | false | true |
100-
| run-code-formatting | Whether to run code formatting | false | true |
101-
| run-tests | Whether tests should be run. | false | true |
102-
| run-coverage | Whether to run coverage | false | true |
103-
| create-comment | Whether to create a comment on the PR | false | true |
104-
| coverage-pass-score | The minimum coverage score required to pass | false | "80" |
105-
| eslint-config-path | The path to the ESLint configuration file | false | "eslint.config.\*" |
106-
| test-config-path | The path to the test configuration file | false | "web-test-runner.config.\*" |
91+
| Name | Description | Required | Default |
92+
| ------------------- | ------------------------------------------------------------------- | -------- | --------------------------------------------------------------------- |
93+
| token | Token used for pushing fixes and commenting on PRs. | true | |
94+
| working-directory | Working directory to run the action in | false | "." |
95+
| web-components-src | The path to the directory containing the web components source code | false | "src/\*_/_.{ts,tsx}" |
96+
| test-src | The path to the directory containing the test source code | false | "src/test/\*_/_.test.ts" |
97+
| test-results-path | The path to the test results file | false | "./test-results.xml" |
98+
| coverage-path | The path to the coverage file | false | "coverage/lcov.info" |
99+
| run-static-analysis | Whether to run static analysis | false | true |
100+
| run-code-formatting | Whether to run code formatting | false | true |
101+
| run-tests | Whether tests should be run. | false | true |
102+
| run-coverage | Whether to run coverage | false | true |
103+
| create-comment | Whether to create a comment on the PR | false | true |
104+
| coverage-pass-score | The minimum coverage score required to pass | false | "80" |
105+
| eslint-config-path | The path to the ESLint configuration file | false | "eslint.config.\*" |
106+
| test-config-path | The path to the test configuration file | false | "web-test-runner.config.\*" |
107+
| eslint-cmd | The command used for eslint | false | "npx eslint -f unix $web-components-src --config $eslint-config-path" |

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ inputs:
8080
required: false
8181
default: "web-test-runner.config.*"
8282

83+
eslint-cmd:
84+
description: "The command to run ESLint"
85+
required: false
86+
default: ""
8387
runs:
8488
using: node20
8589
main: dist/index.js

src/main.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ const getInputs = (
204204
boolean,
205205
string,
206206
string,
207+
string,
207208
] => {
208209
// get the token and octokit
209210
let token = "";
@@ -263,6 +264,8 @@ const getInputs = (
263264
? "web-test-runner.config.*"
264265
: getInput("test-config-path");
265266

267+
const esLintCmd: string = isLocal ? "" : getInput("eslint-cmd");
268+
266269
return [
267270
token,
268271
workingDirectory,
@@ -278,6 +281,7 @@ const getInputs = (
278281
createComment,
279282
eslintConfigPath,
280283
testConfigPath,
284+
esLintCmd,
281285
];
282286
};
283287

@@ -322,6 +326,7 @@ export async function run(): Promise<void> {
322326
createComment,
323327
eslintConfigPath,
324328
testConfigPath,
329+
esLintCmd,
325330
] = getInputs(isLocal);
326331

327332
// Check if the working directory is different from the current directory
@@ -339,11 +344,12 @@ export async function run(): Promise<void> {
339344
const eslintStr: StepResponse | undefined = doStaticAnalysis
340345
? await eslint({
341346
label: "ESLint",
342-
command:
343-
"npx eslint -f unix " +
344-
wcSrcDirectory +
345-
" --config " +
346-
eslintConfigPath,
347+
command: esLintCmd.isEmpty()
348+
? "npx eslint -f unix " +
349+
wcSrcDirectory +
350+
" --config " +
351+
eslintConfigPath
352+
: esLintCmd,
347353
})
348354
: undefined;
349355

0 commit comments

Comments
 (0)