Skip to content

Commit

Permalink
speed-up commit hook
Browse files Browse the repository at this point in the history
- remove type checking and linting from commit hook. Only format and stylelint --fix (which actually modify files).
- check for file changes after build, e.g. `lib/papi.d.ts`
  • Loading branch information
irahopkinson committed Nov 15, 2024
1 parent 778d291 commit 5d3355b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ jobs:
- name: Build
run: npm run build

- name: Verify files changed after build
id: verify-changed-files
uses: tj-actions/verify-changed-files@v20

- name: Report file changes
if: steps.verify-changed-files.outputs.files_changed == 'true'
env:
CHANGED_FILES: ${{ steps.verify-changed-files.outputs.changed_files }}
run: |
echo "Error - changed files after build: $CHANGED_FILES"
exit 1
- name: dotnet unit tests
run: dotnet test c-sharp-tests/c-sharp-tests.csproj

Expand Down
9 changes: 2 additions & 7 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

echo "Lint checking..."
# generate papi.d.ts as part of lint:staged
echo "Format and stylelint fixes..."
npm run lint:staged
echo "Lint check finished"

echo "Type checking..."
npm run typecheck
echo "Type check finished"
echo "Format and stylelint fixes finished"

echo "If the following fails run npm run editor:unlink"
npx yalc check
2 changes: 1 addition & 1 deletion extensions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"update-from-templates": "tsx ./lib/update-from-templates.ts"
},
"lint-staged": {
"*.{cjs,js,jsx,ts,tsx}": ["prettier --write", "cross-env NODE_ENV=development eslint --cache"],
"*.{cjs,js,jsx,ts,tsx}": ["prettier --write"],
"*.json": ["prettier --parser json --write"],
"*.{css,scss}": ["stylelint --fix"],
"*.{html,md,yml}": ["prettier --single-quote --write"]
Expand Down
2 changes: 1 addition & 1 deletion lib/papi-dts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"typecheck": "tsc -p ./tsconfig.lint.json"
},
"lint-staged": {
"*.{cjs,js,jsx,ts,tsx}": ["prettier --write", "cross-env NODE_ENV=development eslint --cache"],
"*.{cjs,js,jsx,ts,tsx}": ["prettier --write"],
"*.json": ["prettier --parser json --write"],
"*.{html,md,yml}": ["prettier --single-quote --write"]
},
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"lint": "cross-env NODE_OPTIONS=\"--max-old-space-size=4096\" npm run build:types && npm run lint:scripts && npm run lint:styles && cd lib/papi-dts && npm run lint && cd ../../extensions && npm run lint",
"lint:config": "cross-env NODE_ENV=development eslint --print-config .eslintrc.js > .eslintConfig.json",
"lint:scripts": "cross-env NODE_ENV=development eslint --ext .cjs,.js,.jsx,.ts,.tsx --cache .",
"lint:staged": "npm run build:types && lint-staged -q && cd lib/papi-dts && npm run lint:staged && cd ../../extensions && npm run lint:staged",
"lint:staged": "lint-staged -q && npm run lint:staged --workspaces --if-present",
"lint:styles": "stylelint **/*.{css,scss}",
"lint-fix": "npm run build:types && npm run lint-fix:scripts && npm run lint-fix:styles && cd lib/papi-dts && npm run lint-fix && cd ../../extensions && npm run lint-fix",
"lint-fix:scripts": "prettier --write \"**/*.{ts,tsx,js,jsx,cjs}\" && npm run lint:scripts",
Expand Down Expand Up @@ -96,7 +96,7 @@
"typecheck:platform-bible-utils": "cd lib/platform-bible-utils && npm run typecheck"
},
"lint-staged": {
"*.{cjs,js,jsx,ts,tsx}": ["prettier --write", "cross-env NODE_ENV=development eslint --cache"],
"*.{cjs,js,jsx,ts,tsx}": ["prettier --write"],
"*.json": ["prettier --parser json --write"],
"*.{css,scss}": ["stylelint --fix --allow-empty-input"],
"*.{html,md,yml}": ["prettier --single-quote --write"]
Expand Down

0 comments on commit 5d3355b

Please sign in to comment.