chore: configure pre-commit stages and add build hook #83

Closed
Philipp wants to merge 6 commits from feature/pre-commit-build into main
Showing only changes of commit 3abc837f78 - Show all commits
+12 -1
View File
@@ -1,3 +1,4 @@
default_stages: [pre-commit, pre-push, manual]
exclude: ^(dist|node_modules)/
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
@@ -39,8 +40,18 @@ repos:
rev: v6.0.0
hooks:
- id: end-of-file-fixer
exclude: (.txt$|.ipynb$|README.md$|readme.mde$)
exclude: (.txt$|.ipynb$|README.md$)
- id: trailing-whitespace
exclude: (.txt$|README.md$)
- id: mixed-line-ending
args: [--fix=lf]
- repo: local
hooks:
- id: build
name: rebuild-distribution
Review

monitor.js is still included in the regex but does not exist in the repository. As noted in previous reviews, if there are no immediate plans for this file, it's cleaner to remove it.

`monitor.js` is still included in the regex but does not exist in the repository. As noted in previous reviews, if there are no immediate plans for this file, it's cleaner to remove it.
entry: npm run build
language: system
Review

You've added monitor.js to the list of files that trigger a rebuild. However, looking at package.json, the build script only targets index.js. If monitor.js is not imported by index.js, changes to it won't be reflected in the dist/ folder via the current build command.

You've added `monitor.js` to the list of files that trigger a rebuild. However, looking at `package.json`, the build script only targets `index.js`. If `monitor.js` is not imported by `index.js`, changes to it won't be reflected in the `dist/` folder via the current build command.
files: ^(index\.js|monitor\.js|package\.json|package-lock\.json)$
Review

Since npm run build updates the dist/ directory, these changes won't be included in the current commit unless they are staged.
You might want to change the entry to:
entry: /bin/bash -c "npm run build && git add dist/"
Or ensure that developers are aware they need to stage dist/ if the hook fails (though usually, pre-commit hooks should ideally handle the staging if they modify files).

Since `npm run build` updates the `dist/` directory, these changes won't be included in the current commit unless they are staged. You might want to change the entry to: `entry: /bin/bash -c "npm run build && git add dist/"` Or ensure that developers are aware they need to stage `dist/` if the hook fails (though usually, pre-commit hooks should ideally handle the staging if they modify files).
pass_filenames: false
stages: [pre-commit]
Review

The file monitor.js is not present in the repository root. If this is a future file, keep it; otherwise, this entry will never trigger the hook for that specific file. Additionally, the build script in package.json only compiles index.js.

The file `monitor.js` is not present in the repository root. If this is a future file, keep it; otherwise, this entry will never trigger the hook for that specific file. Additionally, the `build` script in `package.json` only compiles `index.js`.
Review

monitor.js is included in the file filter but does not exist in the repository. If there are no plans to add this file, it should be removed from the regex.

`monitor.js` is included in the file filter but does not exist in the repository. If there are no plans to add this file, it should be removed from the regex.
1