Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion .github/workflows/lint_audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,46 @@ on:
branches: [main, master, develop]
pull_request:
branches: [main, master, develop]
paths:
- '**/*.js'
- '**/*.ts'
- '**/*.tsx'
- '**/*.jsx'
- 'package.json'
- 'package-lock.json'

jobs:
lint-and-audit:
uses: PSMRI/.github/.github/workflows/lint_audit.yml@main
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '16.x'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v35
with:
files: |
**/*.js
**/*.ts
**/*.tsx
**/*.jsx

Comment on lines +33 to +42
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ› οΈ Refactor suggestion

⚠️ Potential issue

Include dependency files in changed-files patterns
Right now the changed-files action only watches JS/TS source, so changes to package.json or package-lock.json won’t be reported. This breaks your npm audit condition.
Apply this diff to capture dependency file changes:

 with:
   files: |
     **/*.js
     **/*.ts
     **/*.tsx
     **/*.jsx
+    package.json
+    package-lock.json
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v35
with:
files: |
**/*.js
**/*.ts
**/*.tsx
**/*.jsx
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v35
with:
files: |
**/*.js
**/*.ts
**/*.tsx
**/*.jsx
package.json
package-lock.json

- name: Run ESLint on changed files
if: steps.changed-files.outputs.any_changed == 'true'
run: |
npx eslint ${{ steps.changed-files.outputs.all_changed_files }}

- name: Run npm audit
if: ${{ contains(steps.changed-files.outputs.all_changed_files, 'package.json') || contains(steps.changed-files.outputs.all_changed_files, 'package-lock.json') }}
run: npm audit