Skip to content

Commit

Permalink
feat: add pre-commit hook for linter and prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
oyo authored Jun 4, 2024
2 parents 5aa112d + 0abf5bb commit ab0312b
Show file tree
Hide file tree
Showing 14 changed files with 289 additions and 46 deletions.
29 changes: 14 additions & 15 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,32 @@
version: 2
updates:
# NPM
-
package-ecosystem: "npm"
- package-ecosystem: 'npm'
directory: /
labels:
- "dependabot"
- "dependencies"
- 'dependabot'
- 'dependencies'
schedule:
interval: "weekly"
interval: 'weekly'
# restrict to patch updates (due to the big amount of dependencies)
ignore:
- dependency-name: "*"
update-types: ["version-update:semver-major", "version-update:semver-minor"]
- dependency-name: '*'
update-types:
['version-update:semver-major', 'version-update:semver-minor']
groups:
production-dependencies:
dependency-type: "production"
dependency-type: 'production'
development-dependencies:
dependency-type: "development"
dependency-type: 'development'

# Github Actions
-
package-ecosystem: "github-actions"
- package-ecosystem: 'github-actions'
directory: /
labels:
- "dependabot"
- "github-actions"
- 'dependabot'
- 'github-actions'
schedule:
interval: "weekly"
interval: 'weekly'
groups:
dependencies:
dependency-type: "production"
dependency-type: 'production'
9 changes: 6 additions & 3 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

name: pr checks

on:
on:
pull_request:
paths:
- src/**
Expand All @@ -41,9 +41,9 @@ jobs:
id: git-tag-latest
uses: actions-ecosystem/action-get-latest-tag@v1

Check warning on line 42 in .github/workflows/checks.yml

View workflow job for this annotation

GitHub Actions / Analyze

[LOW] Unpinned Actions Full Length Commit SHA

Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps mitigate the risk of a bad actor adding a backdoor to the action's repository, as they would need to generate a SHA-1 collision for a valid Git object payload. When selecting a SHA, you should verify it is from the action's repository and not a repository fork.

Check warning on line 42 in .github/workflows/checks.yml

View workflow job for this annotation

GitHub Actions / Analyze

[LOW] Unpinned Actions Full Length Commit SHA

Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps mitigate the risk of a bad actor adding a backdoor to the action's repository, as they would need to generate a SHA-1 collision for a valid Git object payload. When selecting a SHA, you should verify it is from the action's repository and not a repository fork.

Check warning on line 42 in .github/workflows/checks.yml

View workflow job for this annotation

GitHub Actions / Analyze

[LOW] Unpinned Actions Full Length Commit SHA

Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps mitigate the risk of a bad actor adding a backdoor to the action's repository, as they would need to generate a SHA-1 collision for a valid Git object payload. When selecting a SHA, you should verify it is from the action's repository and not a repository fork.

- name: Remove tag 'v' prefix
- name: Remove tag 'v' prefix
run: echo "GIT_VERSION=$(echo ${{ steps.git-tag-latest.outputs.tag }} | cut -c2-)" >> $GITHUB_ENV

- name: Get npm version
id: npm-version
uses: martinbeentjes/npm-get-version-action@3cf273023a0dda27efcd3164bdfb51908dd46a5b # v1.3.1
Expand All @@ -65,6 +65,9 @@ jobs:
- name: Install Dependencies
run: yarn

- name: Prettier Checks
run: yarn pretty:check

- name: Linter Checks
run: yarn lint

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# supported CodeQL languages.
#

name: "CodeQL"
name: 'CodeQL'

on:
push:
Expand All @@ -44,7 +44,7 @@ on:
- '.storybook/**'
- '.cx-packer/**'
schedule:
- cron: "0 0 * * *"
- cron: '0 0 * * *'
workflow_dispatch:

jobs:
Expand All @@ -65,7 +65,7 @@ jobs:
strategy:
fail-fast: false
matrix:
language: ["javascript"]
language: ['javascript']
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ]
# Use only 'java' to analyze code written in Java, Kotlin or both
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
Expand Down Expand Up @@ -106,4 +106,4 @@ jobs:
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@9fdb3e49720b44c48891d036bb502feb25684276 # v2.227
with:
category: "/language:${{matrix.language}}"
category: '/language:${{matrix.language}}'
4 changes: 1 addition & 3 deletions .github/workflows/dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,16 @@ name: Check Dependencies

on:
push:
branches: [ main ]
branches: [main]
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:

jobs:
check-dependencies:

runs-on: ubuntu-latest

steps:

- name: Set up JDK 17
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/kics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ on:
push:
branches: [main]
schedule:
- cron: "0 0 * * *"
- cron: '0 0 * * *'
workflow_dispatch:

jobs:
Expand All @@ -44,7 +44,7 @@ jobs:
uses: checkmarx/kics-github-action@d1b692d84c536f4e8696954ce7aab6818f95f5bc # v2.0.0
with:
# Scanning directory .
path: "."
path: '.'
# Fail on HIGH severity results
fail_on: high
# when provided with a directory on output_path
Expand All @@ -53,7 +53,7 @@ jobs:
# - results-dir/results.json
# - results-dir/results.sarif
output_path: kicsResults/
output_formats: "json,sarif"
output_formats: 'json,sarif'
# If you want KICS to ignore the results and return exit status code 0 unless a KICS engine error happens
# ignore_on_exit: results
# GITHUB_TOKEN enables this github action to access github API and post comments in a pull request
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pullRequest-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# SPDX-License-Identifier: Apache-2.0
# #############################################################################

name: "Lint PullRequest"
name: 'Lint PullRequest'

on:
pull_request_target:
Expand All @@ -44,11 +44,11 @@ jobs:
header: pr-title-lint-error
message: |
Hey there and thank you for opening this pull request! 👋🏼
We require pull request titles to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) and it looks like your proposed title needs to be adjusted.
Details:
```
${{ steps.lint_pr_title.outputs.error_message }}
```
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,3 @@ jobs:
uses: rickstaa/action-create-tag@a1c7777fcb2fee4f19b0f283ba888afa11678b72 # v1.7.2
with:
tag: v${{ steps.npm-tag.outputs.current-version }}

14 changes: 7 additions & 7 deletions .github/workflows/trivy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ name: trivy

on:
push:
branches: [ main ]
branches: [main]
schedule:
- cron: "0 0 * * *"
- cron: '0 0 * * *'
workflow_dispatch:

jobs:
Expand All @@ -43,14 +43,14 @@ jobs:
- name: Run Trivy vulnerability scanner in repo mode
uses: aquasecurity/trivy-action@fd25fed6972e341ff0007ddb61f77e88103953c2 # v0.21.0
with:
scan-type: "config"
scan-type: 'config'
hide-progress: false
format: "sarif"
output: "trivy-results1.sarif"
vuln-type: "os,library"
format: 'sarif'
output: 'trivy-results1.sarif'
vuln-type: 'os,library'

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@9fdb3e49720b44c48891d036bb502feb25684276 # v3.25.6
if: always()
with:
sarif_file: "trivy-results1.sarif"
sarif_file: 'trivy-results1.sarif'
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yarn lint:staged
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 3.0.19

- Add pre-commit hook with lint-staged and prettier

## 3.0.18

- Add new Scroll to top button component
Expand Down
Loading

0 comments on commit ab0312b

Please sign in to comment.