Skip to content

Commit

Permalink
chore: enable husky pre-commit tasks (#1984)
Browse files Browse the repository at this point in the history
* chore: add husky pre-commit tasks

Signed-off-by: Maryam Tahhan <[email protected]>
  • Loading branch information
maryamtahhan authored Oct 25, 2024
1 parent 5ff2948 commit 7db2361
Show file tree
Hide file tree
Showing 5 changed files with 825 additions and 11 deletions.
36 changes: 36 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/sh
#
# Copyright (C) 2024 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
set -u
# avoid [[ which is not POSIX sh.
if test "$#" != 1; then
echo "$0 requires an argument."
exit 1
fi
if test ! -f "$1"; then
echo "file does not exist: $1"
exit 1
fi
pnpm commitlint --edit "$1"
SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
grep -qs "^$SOB" "$1" || echo "$SOB" >>"$1"
# Catches duplicate Signed-off-by lines.
test "" = "$(grep '^Signed-off-by: ' "$1" |
sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
echo >&2 Duplicate Signed-off-by lines.
exit 1
}
17 changes: 17 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# Copyright (C) 2024 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
pnpm lint-staged
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { extends: ['@commitlint/config-conventional'] };
15 changes: 14 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,30 @@
"typecheck:shared": "tsc --noEmit --project packages/shared",
"typecheck:frontend": "tsc --noEmit --project packages/frontend",
"typecheck:backend": "cd packages/backend && npm run typecheck",
"typecheck": "npm run typecheck:shared && npm run typecheck:frontend && npm run typecheck:backend"
"typecheck": "npm run typecheck:shared && npm run typecheck:frontend && npm run typecheck:backend",
"prepare": "husky"
},
"resolutions": {
"string-width": "^4.2.0",
"wrap-ansi": "^7.0.0",
"postman-code-generators": "1.10.1"
},
"lint-staged": {
"*.{js,ts,tsx,svelte}": [
"eslint --cache --fix",
"prettier --cache --write"
],
"*.{md,css,json}": "prettier --write"
},
"devDependencies": {
"@commitlint/cli": "^19.5.0",
"@commitlint/config-conventional": "^19.5.0",
"@eslint/compat": "^1.2.1",
"@typescript-eslint/eslint-plugin": "^8.11.0",
"@typescript-eslint/parser": "^8.11.0",
"@vitest/coverage-v8": "^2.0.5",
"autoprefixer": "^10.4.20",
"commitlint": "^19.5.0",
"concurrently": "^9.0.1",
"eslint": "^9.13.0",
"eslint-import-resolver-custom-alias": "^1.3.2",
Expand All @@ -53,6 +64,8 @@
"eslint-plugin-svelte": "^2.46.0",
"eslint-plugin-unicorn": "^56.0.0",
"globals": "^15.11.0",
"husky": "^9.1.6",
"lint-staged": "^15.2.10",
"prettier": "^3.3.3",
"prettier-plugin-svelte": "^3.2.7",
"svelte-check": "^4.0.5",
Expand Down
Loading

0 comments on commit 7db2361

Please sign in to comment.