Skip to content

Commit

Permalink
fix(format-files): ensure paths passed to prettier-eslint are absol…
Browse files Browse the repository at this point in the history
…ute paths (#259)

As of the 6.7.0 release of eslint, absolute paths are required when eslint is
searching for ignore patterns (eslint/eslint@ca3b2a6).
This causes prettier-eslint-cli to fail if called with a glob pattern using
relative paths. This commit passes the file path through the `path.resolve` method
to ensure they are always absolute paths.

Addresses issues #205 & #208
  • Loading branch information
dpwilhelmsen committed Mar 6, 2021
1 parent 29db6b5 commit dd70720
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 9 deletions.
13 changes: 12 additions & 1 deletion .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,18 @@
"contributions": [
"doc"
]
},
{
"login": "dpwilhelmsen",
"name": "Daniel Wilhelmsen",
"avatar_url": "https://avatars3.githubusercontent.com/u/1758049?v=4",
"profile": "http://danielwilhelmsen.com",
"contributions": [
"code",
"maintenance"
]
}
],
"repoType": "github"
"repoType": "github",
"commitConvention": "none"
}
43 changes: 38 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,44 @@ Any linter that support ESLint [CLIEngine](http://eslint.org/docs/developer-guid
Thanks goes to these people ([emoji key][emojis]):

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore -->
| [<img src="https://avatars.githubusercontent.com/u/1500684?v=3" width="100px;"/><br /><sub><b>Kent C. Dodds</b></sub>](https://kentcdodds.com)<br />[💻](https://github.com/prettier/prettier-eslint-cli/commits?author=kentcdodds "Code") [📖](https://github.com/prettier/prettier-eslint-cli/commits?author=kentcdodds "Documentation") [🚇](#infra-kentcdodds "Infrastructure (Hosting, Build-Tools, etc)") [⚠️](https://github.com/prettier/prettier-eslint-cli/commits?author=kentcdodds "Tests") | [<img src="https://avatars3.githubusercontent.com/u/3266363?v=3" width="100px;"/><br /><sub><b>Adam Harris</b></sub>](https://github.com/aharris88)<br />[💻](https://github.com/prettier/prettier-eslint-cli/commits?author=aharris88 "Code") [📖](https://github.com/prettier/prettier-eslint-cli/commits?author=aharris88 "Documentation") [👀](#review-aharris88 "Reviewed Pull Requests") | [<img src="https://avatars.githubusercontent.com/u/622118?v=3" width="100px;"/><br /><sub><b>Eric McCormick</b></sub>](https://ericmccormick.io)<br />[👀](#review-edm00se "Reviewed Pull Requests") | [<img src="https://avatars.githubusercontent.com/u/12389411?v=3" width="100px;"/><br /><sub><b>Joel Sequeira</b></sub>](https://github.com/joelseq)<br />[📖](https://github.com/prettier/prettier-eslint-cli/commits?author=joelseq "Documentation") | [<img src="https://avatars.githubusercontent.com/u/103008?v=3" width="100px;"/><br /><sub><b>Frank Taillandier</b></sub>](https://frank.taillandier.me)<br /> | [<img src="https://avatars3.githubusercontent.com/u/292365?v=3" width="100px;"/><br /><sub><b>Adam Stankiewicz</b></sub>](http://sheerun.net)<br />[💻](https://github.com/prettier/prettier-eslint-cli/commits?author=sheerun "Code") | [<img src="https://avatars3.githubusercontent.com/u/487068?v=3" width="100px;"/><br /><sub><b>Stephen John Sorensen</b></sub>](http://www.stephenjohnsorensen.com/)<br />[💻](https://github.com/prettier/prettier-eslint-cli/commits?author=spudly "Code") |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| [<img src="https://avatars0.githubusercontent.com/u/11560964?v=3" width="100px;"/><br /><sub><b>Gandem</b></sub>](https://github.com/Gandem)<br />[💻](https://github.com/prettier/prettier-eslint-cli/commits?author=Gandem "Code") [⚠️](https://github.com/prettier/prettier-eslint-cli/commits?author=Gandem "Tests") | [<img src="https://avatars0.githubusercontent.com/u/129991?v=3" width="100px;"/><br /><sub><b>Matteo Ronchi</b></sub>](https://github.com/cef62)<br />[🐛](https://github.com/prettier/prettier-eslint-cli/issues?q=author%3Acef62 "Bug reports") [💻](https://github.com/prettier/prettier-eslint-cli/commits?author=cef62 "Code") | [<img src="https://avatars2.githubusercontent.com/u/61787?v=3" width="100px;"/><br /><sub><b>Benoît Zugmeyer</b></sub>](https://github.com/BenoitZugmeyer)<br />[💻](https://github.com/prettier/prettier-eslint-cli/commits?author=BenoitZugmeyer "Code") [⚠️](https://github.com/prettier/prettier-eslint-cli/commits?author=BenoitZugmeyer "Tests") | [<img src="https://avatars0.githubusercontent.com/u/5038030?v=3" width="100px;"/><br /><sub><b>Charlike Mike Reagent</b></sub>](https://i.am.charlike.online)<br />[💻](https://github.com/prettier/prettier-eslint-cli/commits?author=tunnckoCore "Code") [⚠️](https://github.com/prettier/prettier-eslint-cli/commits?author=tunnckoCore "Tests") | [<img src="https://avatars0.githubusercontent.com/u/10954870?v=3" width="100px;"/><br /><sub><b>Dion Dirza</b></sub>](https://github.com/diondirza)<br />[🐛](https://github.com/prettier/prettier-eslint-cli/issues?q=author%3Adiondirza "Bug reports") | [<img src="https://avatars0.githubusercontent.com/u/3297808?v=3" width="100px;"/><br /><sub><b>mrm007</b></sub>](https://github.com/mrm007)<br />[🐛](https://github.com/prettier/prettier-eslint-cli/issues?q=author%3Amrm007 "Bug reports") [💻](https://github.com/prettier/prettier-eslint-cli/commits?author=mrm007 "Code") | [<img src="https://avatars0.githubusercontent.com/u/193238?v=3" width="100px;"/><br /><sub><b>Jack Franklin</b></sub>](http://www.jackfranklin.co.uk)<br />[💻](https://github.com/prettier/prettier-eslint-cli/commits?author=jackfranklin "Code") |
| [<img src="https://avatars0.githubusercontent.com/u/17342435?v=3" width="100px;"/><br /><sub><b>Ryan Zimmerman</b></sub>](http://www.ryanzim.com)<br />[📖](https://github.com/prettier/prettier-eslint-cli/commits?author=RyanZim "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/1186409?v=3" width="100px;"/><br /><sub><b>Paolo Moretti</b></sub>](http://stackoverflow.com/users/63011)<br />[🐛](https://github.com/prettier/prettier-eslint-cli/issues?q=author%3Amoretti "Bug reports") [💻](https://github.com/prettier/prettier-eslint-cli/commits?author=moretti "Code") [⚠️](https://github.com/prettier/prettier-eslint-cli/commits?author=moretti "Tests") | [<img src="https://avatars0.githubusercontent.com/u/6242574?v=3" width="100px;"/><br /><sub><b>bySabi Files</b></sub>](https://github.com/bySabi)<br />[📖](https://github.com/prettier/prettier-eslint-cli/commits?author=bySabi "Documentation") [🔧](#tool-bySabi "Tools") | [<img src="https://avatars1.githubusercontent.com/u/554231?v=4" width="100px;"/><br /><sub><b>Pavel Pertsev</b></sub>](http://morhetz.com)<br />[💻](https://github.com/prettier/prettier-eslint-cli/commits?author=morhetz "Code") [⚠️](https://github.com/prettier/prettier-eslint-cli/commits?author=morhetz "Tests") | [<img src="https://avatars3.githubusercontent.com/u/13577271?v=4" width="100px;"/><br /><sub><b>Josh English</b></sub>](http://www.joshenglish.com)<br />[⚠️](https://github.com/prettier/prettier-eslint-cli/commits?author=jmenglis "Tests") [🐛](https://github.com/prettier/prettier-eslint-cli/issues?q=author%3Ajmenglis "Bug reports") [💻](https://github.com/prettier/prettier-eslint-cli/commits?author=jmenglis "Code") [🔌](#plugin-jmenglis "Plugin/utility libraries") | [<img src="https://avatars2.githubusercontent.com/u/1706502?v=4" width="100px;"/><br /><sub><b>Spenser Isdahl</b></sub>](https://disquisition.net)<br />[💻](https://github.com/prettier/prettier-eslint-cli/commits?author=disquisition "Code") [📖](https://github.com/prettier/prettier-eslint-cli/commits?author=disquisition "Documentation") [⚠️](https://github.com/prettier/prettier-eslint-cli/commits?author=disquisition "Tests") | [<img src="https://avatars0.githubusercontent.com/u/10961167?v=4" width="100px;"/><br /><sub><b>Björn Dalfors</b></sub>](https://github.com/bj00rn)<br />[🚇](#infra-bj00rn "Infrastructure (Hosting, Build-Tools, etc)") |
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tr>
<td align="center"><a href="https://kentcdodds.com"><img src="https://avatars.githubusercontent.com/u/1500684?v=3" width="100px;" alt=""/><br /><sub><b>Kent C. Dodds</b></sub></a><br /><a href="https://github.com/prettier/prettier-eslint-cli/commits?author=kentcdodds" title="Code">💻</a> <a href="https://github.com/prettier/prettier-eslint-cli/commits?author=kentcdodds" title="Documentation">📖</a> <a href="#infra-kentcdodds" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="https://github.com/prettier/prettier-eslint-cli/commits?author=kentcdodds" title="Tests">⚠️</a></td>
<td align="center"><a href="https://github.com/aharris88"><img src="https://avatars3.githubusercontent.com/u/3266363?v=3" width="100px;" alt=""/><br /><sub><b>Adam Harris</b></sub></a><br /><a href="https://github.com/prettier/prettier-eslint-cli/commits?author=aharris88" title="Code">💻</a> <a href="https://github.com/prettier/prettier-eslint-cli/commits?author=aharris88" title="Documentation">📖</a> <a href="https://github.com/prettier/prettier-eslint-cli/pulls?q=is%3Apr+reviewed-by%3Aaharris88" title="Reviewed Pull Requests">👀</a></td>
<td align="center"><a href="https://ericmccormick.io"><img src="https://avatars.githubusercontent.com/u/622118?v=3" width="100px;" alt=""/><br /><sub><b>Eric McCormick</b></sub></a><br /><a href="https://github.com/prettier/prettier-eslint-cli/pulls?q=is%3Apr+reviewed-by%3Aedm00se" title="Reviewed Pull Requests">👀</a></td>
<td align="center"><a href="https://github.com/joelseq"><img src="https://avatars.githubusercontent.com/u/12389411?v=3" width="100px;" alt=""/><br /><sub><b>Joel Sequeira</b></sub></a><br /><a href="https://github.com/prettier/prettier-eslint-cli/commits?author=joelseq" title="Documentation">📖</a></td>
<td align="center"><a href="https://frank.taillandier.me"><img src="https://avatars.githubusercontent.com/u/103008?v=3" width="100px;" alt=""/><br /><sub><b>Frank Taillandier</b></sub></a><br /></td>
<td align="center"><a href="http://sheerun.net"><img src="https://avatars3.githubusercontent.com/u/292365?v=3" width="100px;" alt=""/><br /><sub><b>Adam Stankiewicz</b></sub></a><br /><a href="https://github.com/prettier/prettier-eslint-cli/commits?author=sheerun" title="Code">💻</a></td>
<td align="center"><a href="http://www.stephenjohnsorensen.com/"><img src="https://avatars3.githubusercontent.com/u/487068?v=3" width="100px;" alt=""/><br /><sub><b>Stephen John Sorensen</b></sub></a><br /><a href="https://github.com/prettier/prettier-eslint-cli/commits?author=spudly" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/Gandem"><img src="https://avatars0.githubusercontent.com/u/11560964?v=3" width="100px;" alt=""/><br /><sub><b>Gandem</b></sub></a><br /><a href="https://github.com/prettier/prettier-eslint-cli/commits?author=Gandem" title="Code">💻</a> <a href="https://github.com/prettier/prettier-eslint-cli/commits?author=Gandem" title="Tests">⚠️</a></td>
<td align="center"><a href="https://github.com/cef62"><img src="https://avatars0.githubusercontent.com/u/129991?v=3" width="100px;" alt=""/><br /><sub><b>Matteo Ronchi</b></sub></a><br /><a href="https://github.com/prettier/prettier-eslint-cli/issues?q=author%3Acef62" title="Bug reports">🐛</a> <a href="https://github.com/prettier/prettier-eslint-cli/commits?author=cef62" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/BenoitZugmeyer"><img src="https://avatars2.githubusercontent.com/u/61787?v=3" width="100px;" alt=""/><br /><sub><b>Benoît Zugmeyer</b></sub></a><br /><a href="https://github.com/prettier/prettier-eslint-cli/commits?author=BenoitZugmeyer" title="Code">💻</a> <a href="https://github.com/prettier/prettier-eslint-cli/commits?author=BenoitZugmeyer" title="Tests">⚠️</a></td>
<td align="center"><a href="https://i.am.charlike.online"><img src="https://avatars0.githubusercontent.com/u/5038030?v=3" width="100px;" alt=""/><br /><sub><b>Charlike Mike Reagent</b></sub></a><br /><a href="https://github.com/prettier/prettier-eslint-cli/commits?author=tunnckoCore" title="Code">💻</a> <a href="https://github.com/prettier/prettier-eslint-cli/commits?author=tunnckoCore" title="Tests">⚠️</a></td>
<td align="center"><a href="https://github.com/diondirza"><img src="https://avatars0.githubusercontent.com/u/10954870?v=3" width="100px;" alt=""/><br /><sub><b>Dion Dirza</b></sub></a><br /><a href="https://github.com/prettier/prettier-eslint-cli/issues?q=author%3Adiondirza" title="Bug reports">🐛</a></td>
<td align="center"><a href="https://github.com/mrm007"><img src="https://avatars0.githubusercontent.com/u/3297808?v=3" width="100px;" alt=""/><br /><sub><b>mrm007</b></sub></a><br /><a href="https://github.com/prettier/prettier-eslint-cli/issues?q=author%3Amrm007" title="Bug reports">🐛</a> <a href="https://github.com/prettier/prettier-eslint-cli/commits?author=mrm007" title="Code">💻</a></td>
<td align="center"><a href="http://www.jackfranklin.co.uk"><img src="https://avatars0.githubusercontent.com/u/193238?v=3" width="100px;" alt=""/><br /><sub><b>Jack Franklin</b></sub></a><br /><a href="https://github.com/prettier/prettier-eslint-cli/commits?author=jackfranklin" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="http://www.ryanzim.com"><img src="https://avatars0.githubusercontent.com/u/17342435?v=3" width="100px;" alt=""/><br /><sub><b>Ryan Zimmerman</b></sub></a><br /><a href="https://github.com/prettier/prettier-eslint-cli/commits?author=RyanZim" title="Documentation">📖</a></td>
<td align="center"><a href="http://stackoverflow.com/users/63011"><img src="https://avatars3.githubusercontent.com/u/1186409?v=3" width="100px;" alt=""/><br /><sub><b>Paolo Moretti</b></sub></a><br /><a href="https://github.com/prettier/prettier-eslint-cli/issues?q=author%3Amoretti" title="Bug reports">🐛</a> <a href="https://github.com/prettier/prettier-eslint-cli/commits?author=moretti" title="Code">💻</a> <a href="https://github.com/prettier/prettier-eslint-cli/commits?author=moretti" title="Tests">⚠️</a></td>
<td align="center"><a href="https://github.com/bySabi"><img src="https://avatars0.githubusercontent.com/u/6242574?v=3" width="100px;" alt=""/><br /><sub><b>bySabi Files</b></sub></a><br /><a href="https://github.com/prettier/prettier-eslint-cli/commits?author=bySabi" title="Documentation">📖</a> <a href="#tool-bySabi" title="Tools">🔧</a></td>
<td align="center"><a href="http://morhetz.com"><img src="https://avatars1.githubusercontent.com/u/554231?v=4" width="100px;" alt=""/><br /><sub><b>Pavel Pertsev</b></sub></a><br /><a href="https://github.com/prettier/prettier-eslint-cli/commits?author=morhetz" title="Code">💻</a> <a href="https://github.com/prettier/prettier-eslint-cli/commits?author=morhetz" title="Tests">⚠️</a></td>
<td align="center"><a href="http://www.joshenglish.com"><img src="https://avatars3.githubusercontent.com/u/13577271?v=4" width="100px;" alt=""/><br /><sub><b>Josh English</b></sub></a><br /><a href="https://github.com/prettier/prettier-eslint-cli/commits?author=jmenglis" title="Tests">⚠️</a> <a href="https://github.com/prettier/prettier-eslint-cli/issues?q=author%3Ajmenglis" title="Bug reports">🐛</a> <a href="https://github.com/prettier/prettier-eslint-cli/commits?author=jmenglis" title="Code">💻</a> <a href="#plugin-jmenglis" title="Plugin/utility libraries">🔌</a></td>
<td align="center"><a href="https://disquisition.net"><img src="https://avatars2.githubusercontent.com/u/1706502?v=4" width="100px;" alt=""/><br /><sub><b>Spenser Isdahl</b></sub></a><br /><a href="https://github.com/prettier/prettier-eslint-cli/commits?author=disquisition" title="Code">💻</a> <a href="https://github.com/prettier/prettier-eslint-cli/commits?author=disquisition" title="Documentation">📖</a> <a href="https://github.com/prettier/prettier-eslint-cli/commits?author=disquisition" title="Tests">⚠️</a></td>
<td align="center"><a href="https://github.com/bj00rn"><img src="https://avatars0.githubusercontent.com/u/10961167?v=4" width="100px;" alt=""/><br /><sub><b>Björn Dalfors</b></sub></a><br /><a href="#infra-bj00rn" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/sscaff1"><img src="https://avatars1.githubusercontent.com/u/1554424?v=4" width="100px;" alt=""/><br /><sub><b>Steven Scaffidi</b></sub></a><br /><a href="https://github.com/prettier/prettier-eslint-cli/commits?author=sscaff1" title="Documentation">📖</a></td>
<td align="center"><a href="http://danielwilhelmsen.com"><img src="https://avatars3.githubusercontent.com/u/1758049?v=4" width="100px;" alt=""/><br /><sub><b>Daniel Wilhelmsen</b></sub></a><br /><a href="https://github.com/prettier/prettier-eslint-cli/commits?author=dpwilhelmsen" title="Code">💻</a> <a href="#maintenance-dpwilhelmsen" title="Maintenance">🚧</a></td>
</tr>
</table>

<!-- markdownlint-enable -->
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->

Expand Down
2 changes: 1 addition & 1 deletion cli-test/tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ test('formats files and outputs to stdout', async () => {
expect(stdout).toContain(
stripIndent(
`
import baz, { stuff } from "fdjakfdlfw-baz";
import baz, { stuff } from 'fdjakfdlfw-baz';
export { bazzy };
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"ajv": "^6.10.0",
"all-contributors-cli": "^6.7.0",
"babel-jest": "^24.8.0",
"eslint-config-kentcdodds": "^14.3.3",
"eslint-config-kentcdodds": "14.3.3",
"husky": "^2.4.1",
"indent-string": "^4.0.0",
"jest": "^24.8.0",
Expand Down
3 changes: 2 additions & 1 deletion src/format-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ function formatFilesFromGlobs({
.subscribe(onNext, onError, onComplete);

function filePathToFormatted(filePath) {
return formatFile(filePath, prettierESLintOptions, cliOptions);
const absoluteFilePath = path.resolve(filePath);
return formatFile(absoluteFilePath, prettierESLintOptions, cliOptions);
}

function onNext(info) {
Expand Down

0 comments on commit dd70720

Please sign in to comment.