-
Notifications
You must be signed in to change notification settings - Fork 4
"add workflow-templates EsLint and audit" #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+102
−0
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,13 @@ | ||
| { | ||
| "name": "ESLint Check", | ||
| "description": "This template runs ESLint to check for linting errors in the project.", | ||
| "iconName": "octicon-lint", | ||
| "categories": [ | ||
| "JavaScript", | ||
| "TypeScript" | ||
| ], | ||
| "filePatterns": [ | ||
| "src/**/*.js", | ||
| "src/**/*.ts" | ||
| ] | ||
| } |
This file contains hidden or 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,46 @@ | ||
| name: Linting # This can include other types of linting later on | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| - master | ||
| - develop | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| - master | ||
| - develop | ||
|
|
||
| jobs: | ||
| lint: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - name: Set up Node.js | ||
| uses: actions/setup-node@v2 | ||
| with: | ||
| node-version: '16' | ||
| - name: Install dependencies | ||
| run: npm install | ||
|
|
||
| # Get the list of changed files in the PR | ||
| - name: Get list of changed files | ||
| id: changed-files | ||
| run: | | ||
| git fetch origin ${{ github.base_ref }} | ||
| git diff --name-only origin/${{ github.base_ref }}...${{ github.sha }} > changed_files.txt | ||
| cat changed_files.txt | ||
|
|
||
|
|
||
| # Run linter only on changed JavaScript/TypeScript files | ||
| - name: Run linter on changed JavaScript/TypeScript files | ||
| run: | | ||
| CHANGED_FILES=$(cat changed_files.txt | grep '\.js\|\.jsx\|\.ts\|\.tsx' || true) | ||
| if [ -n "$CHANGED_FILES" ]; then | ||
| echo "Linting the following files:" | ||
| echo "$CHANGED_FILES" | ||
| npx eslint $CHANGED_FILES | ||
| else | ||
| echo "No JavaScript/TypeScript files to lint." | ||
| fi | ||
This file contains hidden or 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,13 @@ | ||
| { | ||
| "name": "NPM Audit", | ||
| "description": "This template runs npm audit to check for vulnerabilities in dependencies.", | ||
| "iconName": "octicon-security", | ||
| "categories": [ | ||
| "Security", | ||
| "JavaScript" | ||
| ], | ||
| "filePatterns": [ | ||
| "package.json$", | ||
| "package-lock.json$" | ||
| ] | ||
| } |
This file contains hidden or 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,30 @@ | ||
| name: npm Audit | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - 'package.json' | ||
| - 'package-lock.json' | ||
|
|
||
| jobs: | ||
| audit: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - name: Install dependencies | ||
| run: npm install | ||
|
|
||
| - name: Run npm audit (Allow skipping unfixed vulnerabilities) | ||
| run: npm audit | ||
| continue-on-error: true # Allow PR to pass even if vulnerabilities are found | ||
|
|
||
| - name: Check for fixable vulnerabilities | ||
| run: | | ||
| npm audit --json > audit-report.json | ||
| FIXABLE=$(grep -c '"fixAvailable": true' audit-report.json) | ||
| if [ "$FIXABLE" -gt 0 ]; then | ||
| echo "$FIXABLE fixable vulnerabilities found." | ||
| exit 1 # Block PR if there are fixable vulnerabilities | ||
| else | ||
| echo "No fixable vulnerabilities found." | ||
| fi |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add main, master and develop branches
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay i will add