Skip to content

Commit

Permalink
fix(ts): does not add ts hooks by default (#152)
Browse files Browse the repository at this point in the history
feat(code-style): adds staged make code style targets

Co-authored-by: Artur Troian <troian.ap@gmail.com>
  • Loading branch information
ygrishajev and troian authored Apr 20, 2024
1 parent 23f791b commit 5ecc2bc
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 27 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ include $(AKASH_ROOT)/make/test.mk
include $(AKASH_ROOT)/make/codegen.mk
include $(AKASH_ROOT)/make/lint.mk
include $(AKASH_ROOT)/make/release-ts.mk
include $(AKASH_ROOT)/make/code-style.mk

.PHONY: clean
clean:
Expand Down
13 changes: 13 additions & 0 deletions make/code-style.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
MODULES ?= go \
ts

.PHONY: code-style-staged
code-style-staged: $(patsubst %, code-style-staged-%,$(MODULES))

.PHONY: code-style-staged-ts
code-style-staged-ts: $(AKASH_TS_NODE_MODULES)
ts/node_modules/.bin/lint-staged --cwd ts

.PHONY: code-style-staged-go
code-style-staged-go:
script/gofmt-staged.sh
8 changes: 8 additions & 0 deletions script/gofmt-staged.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

for file in $(git diff --cached --name-only --diff-filter=ACMRTUXB | grep "\.go$")
do
echo "(gofmt) $file"
gofmt -w "$file"
git add "$file"
done
1 change: 0 additions & 1 deletion ts/.husky/pre-commit

This file was deleted.

16 changes: 0 additions & 16 deletions ts/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 3 additions & 10 deletions ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"conventional-changelog-conventionalcommits": "^7.0.2",
"eslint": "^8.57.0",
"eslint-plugin-simple-import-sort": "^12.0.0",
"husky": "^9.0.11",
"jest": "^29.7.0",
"lint-staged": "^15.2.2",
"prettier": "^3.2.5",
Expand All @@ -28,19 +27,14 @@
"license": "Apache-2.0",
"lint-staged": {
"*.{js,jsx,ts,tsx}": [
"npm run test",
"npm run lint:fix",
"npm run format"
],
"package.json": [
"script/remove-exports.js",
"sort-json package.json"
"script/remove-exports.js"
],
"tsconfig.build.json": [
"sort-json tsconfig.build.json"
],
"tsconfig.json": [
"sort-json tsconfig.json"
"*.json": [
"sort-json"
]
},
"main": "dist/index.js",
Expand All @@ -56,7 +50,6 @@
"lint": "eslint src",
"lint:fix": "npm run lint -- --fix",
"postbuild": "script/generate-exports.js",
"prepare": "cd .. && husky ts/.husky",
"test": "jest --selectProjects unit functional",
"test:cov": "jest --selectProjects unit functional --coverage",
"test:functional": "jest --selectProjects functional",
Expand Down

0 comments on commit 5ecc2bc

Please sign in to comment.