|
1 |
| -# This workflow uses actions that are not certified by GitHub. |
2 |
| -# They are provided by a third-party and are governed by |
3 |
| -# separate terms of service, privacy policy, and support |
4 |
| -# documentation. |
5 |
| -# ESLint is a tool for identifying and reporting on patterns |
6 |
| -# found in ECMAScript/JavaScript code. |
7 |
| -# More details at https://github.com/eslint/eslint |
8 |
| -# and https://eslint.org |
9 |
| - |
10 | 1 | name: ESLint
|
11 | 2 |
|
12 | 3 | on:
|
13 | 4 | push:
|
14 | 5 | branches: ["main"]
|
15 | 6 | pull_request:
|
16 |
| - # The branches below must be a subset of the branches above |
17 | 7 | branches: ["main"]
|
18 | 8 | schedule:
|
19 | 9 | - cron: "25 21 * * 4"
|
20 | 10 |
|
21 | 11 | jobs:
|
22 | 12 | eslint:
|
23 |
| - name: Run eslint scanning |
| 13 | + name: Run ESLint Scanning |
24 | 14 | runs-on: ubuntu-latest
|
25 | 15 | permissions:
|
26 | 16 | contents: read
|
27 | 17 | security-events: write
|
28 |
| - actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status |
| 18 | + actions: read |
29 | 19 | steps:
|
30 | 20 | - name: Checkout code
|
31 | 21 | uses: actions/checkout@v3
|
32 | 22 |
|
33 |
| - - name: Install ESLint |
| 23 | + - name: Detect package manager |
| 24 | + id: detect-package-manager |
| 25 | + run: | |
| 26 | + if [ -f "${{ github.workspace }}/yarn.lock" ]; then |
| 27 | + echo "manager=yarn" >> $GITHUB_OUTPUT |
| 28 | + echo "install-command=install" >> $GITHUB_OUTPUT |
| 29 | + echo "runner=yarn" >> $GITHUB_OUTPUT |
| 30 | + exit 0 |
| 31 | + elif [ -f "${{ github.workspace }}/package-lock.json" ]; then |
| 32 | + echo "manager=npm" >> $GITHUB_OUTPUT |
| 33 | + echo "install-command=ci" >> $GITHUB_OUTPUT |
| 34 | + echo "runner=npx" >> $GITHUB_OUTPUT |
| 35 | + exit 0 |
| 36 | + else |
| 37 | + echo "Unable to determine package manager" |
| 38 | + exit 1 |
| 39 | + fi |
| 40 | +
|
| 41 | + - name: Setup Node.js |
| 42 | + uses: actions/setup-node@v4 |
| 43 | + with: |
| 44 | + node-version: "20" |
| 45 | + cache: ${{ steps.detect-package-manager.outputs.manager }} |
| 46 | + |
| 47 | + - name: Install dependencies |
| 48 | + run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.install-command }} |
| 49 | + |
| 50 | + - name: Install ESLint dependencies |
34 | 51 | run: |
|
35 |
| - |
36 |
| - npm install @microsoft/[email protected] |
| 52 | + ${{ steps.detect-package-manager.outputs.manager }} add [email protected] |
| 53 | + ${{ steps.detect-package-manager.outputs.manager }} add @microsoft/[email protected] |
37 | 54 |
|
38 | 55 | - name: Run ESLint
|
39 |
| - run: npx eslint . |
40 |
| - --config .eslintrc.cjs |
41 |
| - --ext .js,.jsx,.ts,.tsx |
42 |
| - # --format @microsoft/eslint-formatter-sarif |
43 |
| - # --output-file eslint-results.sarif |
44 |
| - # continue-on-error: false |
| 56 | + run: | |
| 57 | + ${{ steps.detect-package-manager.outputs.runner }} eslint . \ |
| 58 | + --config .eslintrc.cjs \ |
| 59 | + --ext .js,.jsx,.ts,.tsx |
| 60 | + # --format @microsoft/eslint-formatter-sarif |
| 61 | + # --output-file eslint-results.sarif |
45 | 62 |
|
| 63 | + # Uncomment the following step to upload SARIF results |
46 | 64 | # - name: Upload analysis results to GitHub
|
47 | 65 | # uses: github/codeql-action/upload-sarif@v2
|
48 | 66 | # with:
|
|
0 commit comments