Skip to content

Commit

Permalink
Add ktlint to pre-commit and move folder to root
Browse files Browse the repository at this point in the history
  • Loading branch information
simejo committed Aug 22, 2022
1 parent fe52995 commit 437ef62
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 5 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ ij_kotlin_while_on_new_line = false
ij_kotlin_wrap_elvis_expressions = 1
ij_kotlin_wrap_expression_body_functions = 1
ij_kotlin_wrap_first_method_in_call_chain = false
ktlint_disabled_rules=filename

[{*.graphqlconfig,*.har,*.json}]
indent_size = 2
Expand Down
23 changes: 23 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

cd ./apps/etterlatte-saksbehandling-ui && yarn lint-staged

echo "Running ktlint..."

#store the result of the commit in a variable and split into array items with newline
cd ../../
committedFiles=$(git diff --name-only --cached)
files=$(echo $committedFiles | tr ";" "\\n")

ktlint -F '**/*.kt' '!/**/build/*'

#replay items in the commits array and add only those files
for file in $files
do
git add $file
done

exit 0

echo "Running ktlint check..."
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# pensjon-etterlatte-saksbehandling

Monorepoet bruker `husky` for pre-commit-hooks. Denne kjører `Prettier` for frontend og `ktlint` for backend.
Før man starter å kode er det derfor viktig å kjøre `bash get-started.sh` fra Root. Da vil alle de tre overnevnte bli
installert.

Monorepo for ny saksbehandlingsløsning for ytelser til etterlatte

## Apper
Expand Down
4 changes: 0 additions & 4 deletions apps/etterlatte-saksbehandling-ui/.husky/pre-commit

This file was deleted.

2 changes: 1 addition & 1 deletion apps/etterlatte-saksbehandling-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
},
"scripts": {
"postinstall": "yarn --cwd server install && yarn --cwd client install",
"prepare": "cd ../../ && husky install apps/etterlatte-saksbehandling-ui/.husky"
"prepare": "cd ../../ && husky install .husky"
},
"devDependencies": {
"eslint": "^8.22.0",
Expand Down
3 changes: 3 additions & 0 deletions get-started.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env sh
cd apps/etterlatte-saksbehandling-ui && yarn
brew install ktlint

0 comments on commit 437ef62

Please sign in to comment.