alveifbklsiu259 opened a new pull request, #32333:
URL: https://github.com/apache/superset/pull/32333
fix(eslint-hook): ensure eslint hook receives arguments
### SUMMARY
**Issue**
For some reason, the `$@` variable is not correctly received by the eslint
hook in `pre-commit-config.yaml`.
**Solution**
Moving the code to a separate file solves this issue.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
<!--- Skip this if not applicable -->
### TESTING INSTRUCTIONS
`pre-commit-config.yaml`
```yaml
- repo: local
hooks:
- id: eslint
name: eslint
entry: bash -c 'echo "$@"; exit 1'
language: system
pass_filenames: true
files: \.(js|jsx|ts|tsx)$
```
`superset-frontend/src/components/Alert/index.tsx` is modified, but the hook
receives nothing.

This causes the eslint hook to always pass because no files are being passed
to it.
Now, set `entry` back to `bash -c 'cd superset-frontend && npm run eslint --
$(echo "$@" | sed "s|superset-frontend/||g")'`, and add this to the index:

Running eslint correctly catches the error.

But running eslint hook does not.

Moving the code to a separate file does solve the issue, it correctly
receives the variable `$@`.
`scripts/eslint.sh`
```bash
echo "$@"
exit 1
```
`pre-commit-config.yaml`
```yaml
- repo: local
hooks:
- id: eslint
name: eslint
entry: ./scripts/eslint.sh
language: script
pass_filenames: true
files: \.(js|jsx|ts|tsx)$
```

### ADDITIONAL INFORMATION
<!--- Check any relevant boxes with "x" -->
<!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in
[SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]