-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Runs the eslint defined in the given package.json, configured by the associated eslint.config.mjs file.
- Loading branch information
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: reusable eslint | ||
on: | ||
workflow_call: | ||
inputs: | ||
paths: | ||
required: true | ||
type: string | ||
description: | | ||
A list of root directory/s to where a package.json and eslint | ||
configuration file (eslint.config.mjs) exist. | ||
e.g.: my/root/one my/cool/root/two | ||
jobs: | ||
eslint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- if: ${{ startsWith(github.repository, 'GeoNet/') == false }} | ||
name: require GeoNet org | ||
run: | | ||
exit 1 | ||
- name: Parse paths | ||
id: parse-paths | ||
run: | | ||
if [ -n "${{ inputs.paths }}" ]; then | ||
echo "paths=$(echo '${{ inputs.paths }}' | tr '\n' ' ')" >> $GITHUB_OUTPUT | ||
else | ||
exit 1 | ||
fi | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 | ||
with: | ||
node-version: '20.x' | ||
- name: Install Node modules | ||
id: install-node-modules | ||
env: | ||
PATHS: ${{ steps.parse-paths.outputs.paths }} | ||
run: | | ||
echo "$PATHS" | tr ' ' '\n' | xargs -i -n 1 npm install --prefix '{}' | ||
- name: Run ESLint | ||
id: eslint | ||
env: | ||
PATHS: ${{ steps.parse-paths.outputs.paths }} | ||
run: | | ||
echo "$PATHS" | tr ' ' '\n' | xargs -I '{}' -n 1 sh -c 'ESLINT_USE_FLAT_CONFIG=true $1/node_modules/.bin/eslint -c $1/eslint.config.mjs "$1"' _ '{}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters