-
Notifications
You must be signed in to change notification settings - Fork 221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to process files with a $
in their path
#303
Comments
$
in their path$
in their path
Hey @hollandThomas ! Thank you for the feedback! Could you provide your lefthook.yml file? I have tested a few cases, and I see the following: Using {staged_files}pre-commit:
commands:
echo:
run: echo {staged_files} $ lefthook run pre-commit
Lefthook v1.0.5
RUNNING HOOK: pre-commit
EXECUTE > echo
lefthook.yml some.$file.tsx
SUMMARY: (done in 0.01 seconds)
✔️ echo Using '{staged_files}'pre-commit:
commands:
echo:
run: echo '{staged_files}' $ lefthook run pre-commit
Lefthook v1.0.5
RUNNING HOOK: pre-commit
EXECUTE > echo
lefthook.yml some..tsx
SUMMARY: (done in 0.01 seconds)
✔️ echo This can be an issue. But I need to know the content of your config file to make sure I am not missing anything. |
Hi @mrexox This is my config: pre-commit:
commands:
echo:
run: echo {staged_files}
echoQuotes:
run: echo '{staged_files}'
eslint:
glob: '*.{js,ts,jsx,tsx}'
run: npx eslint {staged_files} It produces this output (paths abbreviated)
|
Thank you. Seems like there is a problem with escaping. I'll try to figure it out. |
Hey, thanks! The issue still persists unfortunately pre-commit:
parallel: true
commands:
eslint:
glob: '*.{js,ts,jsx,tsx}'
run: npx eslint '{staged_files}' yarn run v1.22.17
$ /…/node_modules/.bin/lefthook run pre-commit
Lefthook v1.1.0
RUNNING HOOK: pre-commit
EXECUTE > eslint
Oops! Something went wrong! :(
ESLint: 8.22.0
No files matching the pattern "…/service..tsx" were found.
Please check for typing mistakes in the pattern.
SUMMARY: (done in 1.28 seconds)
🥊 eslint
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. |
@hollandThomas , could you share a minimal example? I need the following files to reproduce the issue:
Why the file is |
It's a Remix app. Remix has a concept called "file-based routing" where certain filename-patterns have to be followed. E.g.
To reproduce
package.json {
"private": true,
"sideEffects": false,
"scripts": {
"prepare": "lefthook install",
"build": "remix build",
"dev": "remix dev",
"start": "remix-serve build"
},
"dependencies": {
"@remix-run/node": "^1.6.8",
"@remix-run/react": "^1.6.8",
"@remix-run/serve": "^1.6.8",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@evilmartians/lefthook-installer": "^1.1.0",
"@remix-run/dev": "^1.6.8",
"@remix-run/eslint-config": "^1.6.8",
"@types/react": "^18.0.15",
"@types/react-dom": "^18.0.6",
"eslint": "^8.22.0",
"typescript": "^4.7.4"
},
"engines": {
"node": ">=14"
}
} lefthook.yml pre-commit:
commands:
eslint:
glob: '*.{js,ts,jsx,tsx}'
run: npx eslint {staged_files} There is no yarn run v1.22.17
$ /Users/tho/Projects/lefthook-reproduction/node_modules/.bin/lefthook run pre-commit
Lefthook v1.1.0
RUNNING HOOK: pre-commit
EXECUTE > eslint
Oops! Something went wrong! :(
ESLint: 8.22.0
No files matching the pattern "app/routes/service..tsx" were found.
Please check for typing mistakes in the pattern. |
Thank you for such a detailed repro steps! 🙏 Just noticed that I can't lint with this command from CLI: $ npx eslint app/routes/service.\$serviceId.tsx # the same for 'app/routes/service.$serviceId.tsx'
Oops! Something went wrong! :(
ESLint: 8.22.0
No files matching the pattern "app/routes/service..tsx" were found.
Please check for typing mistakes in the pattern. By the way, I found an issue in remix repo: remix-run/remix#3339. What I noticed is that when I execute eslint binary without $ node_modules/.bin/eslint 'app/routes/service.$serviceId.tsx'
$ echo $?
0 So, my advise would be to use the following setting: pre-commit:
commands:
eslint:
glob: '*.{js,ts,jsx,tsx}'
run: node_modules/.bin/eslint {staged_files} This is not "cool" but this is working. I guess there is an arguments preprocessing by npm. Anyway, I can't find a way lefthook can change this 😕 |
Oh wow, it didn't occur to me to try and use the eslint binary directly. That does work, thank you! |
Description
When there are files with a
$
in their path, the dollar sign and anything that follows is interpreted as a variable, replaced with an empty string (given that the variable does not exist) and thus stripped from the path.Steps to reproduce
Have some file with $ in its name and run
lefthook
on it.some/path/to.$file.tsx
becomessome/path/to..tsx
Tools like ESLint then of course error with a message like
lint-staged
has got the same buglint-staged/lint-staged#962
Environment
The text was updated successfully, but these errors were encountered: