Skip to content

Commit

Permalink
JavaScript (v3): Add Husky for githook management.
Browse files Browse the repository at this point in the history
  • Loading branch information
cpyle0819 committed Oct 15, 2024
1 parent 3432730 commit e118bcb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
5 changes: 2 additions & 3 deletions javascriptv3/hook_scripts/pre-commit.sh → javascriptv3/.husky/pre-commit
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#!/bin/bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0

set -e

# Lint
npm run lint
npm run --prefix ./javascriptv3 lint

# Test
npm test
npm test --prefix ./javascriptv3
14 changes: 1 addition & 13 deletions javascriptv3/github_scripts/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,4 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0

# Filter out JSON files
filtered_files=()
for file in "$@"; do
if [[ "$file" != *"javascriptv3/"*.json ]]; then
filtered_files+=("$file")
fi
done

# Run linting only on filtered files
npm run --prefix javascriptv3 ci-lint -- "${filtered_files[@]//javascriptv3\/}"

# Run format check
npm run --prefix javascriptv3 ci-format-check -- "${@//javascriptv3\/}"
npm run --prefix javascriptv3 ci-lint
4 changes: 3 additions & 1 deletion javascriptv3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"merge-test-results": "jrm test-results.xml \"**/test_results/**/*.junit.xml\"",
"log-tests": "cat test-results.xml",
"lint": "lint-staged",
"ci-lint": "biome check"
"ci-lint": "biome check",
"prepare": "cd .. && husky javascriptv3/.husky"
},
"lint-staged": {
"*.{js,ts,jsx,tsx}": ["biome format --write", "biome lint"],
Expand Down Expand Up @@ -68,6 +69,7 @@
],
"devDependencies": {
"@biomejs/biome": "1.9.3",
"husky": "^9.1.6",
"junit-report-merger": "^7.0.0",
"lint-staged": "^14.0.1",
"typescript": "^5.2.2",
Expand Down

0 comments on commit e118bcb

Please sign in to comment.