determined
determined copied to clipboard
chore: lint-staged for web
Description
Test Plan
- Check if only staged files are checked by ci when git commit
Commentary (optional)
I wrote bash script to run commands for staged files. I thought about using lint-staged but I think the bash code can be reusable for Go and Python code
However, the bash script looks ugly, idk which approach is the best way
Also, pre-commit
doesnt support to pass relative file paths.
Checklist
- [ ] Changes have been manually QA'd
- [ ] User-facing API changes need the "User-facing API Change" label.
- [ ] Release notes should be added as a separate file under
docs/release-notes/
. See Release Note for details. - [ ] Licenses should be included for new code which was copied and/or modified from any external code.
- [ ] If modifying
/webui/react/src/shared/
verifymake -C webui/react test-shared
passes.
Deploy Preview for storybook-det canceled.
Name | Link |
---|---|
Latest commit | 0caad630f7c43dcc0f3bb207602c369bd9676826 |
Latest deploy log | https://app.netlify.com/sites/storybook-det/deploys/633b11a35ab52600081549e4 |
Deploy Preview for determined-ui canceled.
Name | Link |
---|---|
Latest commit | 0caad630f7c43dcc0f3bb207602c369bd9676826 |
Latest deploy log | https://app.netlify.com/sites/determined-ui/deploys/633b11a3e503260009404d03 |
If you're going to go the route of writing a whole bash script then the simpler solution to this is to just manually strip the prefixes. Something like
entry: bash -c 'strip-prefix.sh -p "webui/react" $@ | make -j$(nproc) -C webui/react check-eslint check-prettier-js'
where strip-prefix.sh takes any number of args, removes the specified prefix, then re-emits the args.
Since we already have to reference the directory when telling pre-commit what command to use this doesn't reduce any portability.
If you're going to go the route of writing a whole bash script then the simpler solution to this is to just manually strip the prefixes. Something like
Yes, I thought about it. I had some issues with that. Probably my settings on pre-commit would be wrong. let me check it out
- id: web-js-lint-check
name: Web JS Lint Check
entry: >
bash -c
'
echo $@
'
language: system
verbose: true
files: '^webui/react/'
types_or: [javascript, jsx, ts, tsx]
and I changed webui/react/src/pages/ProjectDetails.settings.ts
and webui/react/src/pages/ProjectDetails.tsx
Pre-commit only detect ProjectDetails.tsx, but /ProjectDetails.settings.ts.
If I disable types_or
, pre-commit detect both.
$@ doesn't take $0 in bash v3, that was the issue
@dannysauer Thank you for reviewing. I learned a lot about shell :)