Does not work for absolute path
Hi @jurosh 👋
I tried using eolConverter in lint-staged, but it did not work for me. Here's what my config looked like in package.json:
"lint-staged": {
"{**/*.md,{*,src/**/*}.{json,js,jsx,ts,tsx,css}}": [
"prettier --write",
"eolConverter",
"git add"
]
Context: https://github.com/prettier/prettier/issues/5320
The above config resulted the following commands to run before committing:
prettier --write /path/to/repo/path/to/file1.js
prettier --write /path/to/repo/path/to/file2.js
eolConverter /path/to/repo/path/to/file1.js
eolConverter /path/to/repo/path/to/file2.js
eolConverter was treating /path/to/repo/path/to/file1.js as glob and converted it to /path/to/repo/path/to/repo/path/to/file1.js, which resulted into Error: ENOENT: no such file or directory.
It'd be great if your tool could deal with absolute paths too!
Nice catch, what might solve it is adding more params - eg. eolConverter --absolutePath=true PATH which will deal with absolute path..
Hmm... or just check if first character is / and based on that make implicit use of absolute paths instead of glob...
Thanks! BTW it feels like I managed to solve the problem by just adding * text=auto eol=lf to .gitattributes + configuring endOfLine: lf in Prettier