.prettierignore entries containing path separators are ignored
See original GitHub issueWhat version of eslint
are you using?
5.9.0
What version of prettier
are you using?
1.15.2
What version of eslint-plugin-prettier
are you using?
3.0.0
Please paste any applicable config files that you’re using (e.g. .prettierrc
or .eslintrc
files)
https://github.com/edmorley/testcase-eslint-plugin-prettier-ignore/blob/master/.eslintrc.js
https://github.com/edmorley/testcase-eslint-plugin-prettier-ignore/blob/master/.prettierignore
What source code are you linting? https://github.com/edmorley/testcase-eslint-plugin-prettier-ignore/blob/master/src/not_pretty.js
Steps to reproduce
- Git clone https://github.com/edmorley/testcase-eslint-plugin-prettier-ignore
yarn install
yarn prettier:check
# runs prettieryarn eslint:check
# runs eslint and soeslint-plugin-prettier
What did you expect to happen?
- No errors reported by either
yarn prettier:check
oryarn eslint:check
, since the file with bad formatting is listed in.prettierignore
.
What actually happened?
- No errors reported by
yarn prettier:check
(as expected) - Formatting errors reported by
yarn eslint:check
:
$ yarn eslint:check
yarn run v1.12.3
$ eslint src
C:\Users\Ed\src\testcase-eslint-plugin-prettier-ignore\src\not_pretty.js
1:12 error Replace `⏎··'a'` with `"a"` prettier/prettier
✖ 1 problem (1 error, 0 warnings)
1 error and 0 warnings potentially fixable with the `--fix` option.
Additional Notes
- The error goes away if I edit the
.prettierignore
entry to not contain a path component (eg changing it tonot_pretty.js
) - The variations
/src/not_pretty.js
and./src/not_pretty.js
didn’t help. - This reproduced on both Windows and Ubuntu.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Ignoring Code - Prettier
Use .prettierignore to ignore (i.e. not reformat) certain files and folders completely. Use “prettier-ignore” comments to ignore parts of files.
Read more >Documentation: MultiQC
If the --ignore-symlinks flag is set, MultiQC will ignore symlinked ... Note that pattern delimiters are not needed (use pattern , not /pattern/...
Read more >How to ignore node_modules from prettier - Stack Overflow
According the npm package description, prettier ignores the files you wrote a path in .prettierrc , .prettierignore , and .editorconfig .
Read more >prettier ignore all files | The AI Search Engine You Control
Runtime: Node.js v8.11.4; Operating System: macOS. Steps to reproduce: Create a index.d.ts file with the following content:.
Read more >Relay
RelayThe GraphQL client that scales with you. · Built for scale · Keeps iteration quick · Automatic optimizations · Data consistency · Fetching...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yo @edmorley, it looks like prettier 1.15.3 got released with a fix for this. It seems to work for me in your test repo. Can you give it a go and close this issue if it works for you.
Thanks for the report and the minimal reproduction repo (my favourite kind!)
It seems like Prettier’s
getFileInfo()
only works out nested ignore paths correctly if you specify a relative filepath.Replacing https://github.com/prettier/eslint-plugin-prettier/blob/master/eslint-plugin-prettier.js#L166-L168 with
Seems to fix things, but I think this should be addressed upstream -
getFileInfo()
andgetFileInfo.sync()
should be able to work out ignores if you give it relative or absolute paths.Minimal test to prove this: Save the following file as
check-getinfo.js
then run it withnode check-getinfo.js
and note that the values differ. I would expect them both to be true.