-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
getFileInfo does not resolve ignores correctly when filePath is absolute #5513
Copy link
Copy link
Closed
Labels
area:apiIssues with Prettier's Application Programming InterfaceIssues with Prettier's Application Programming Interfacelocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.status:has prIssues with an accompanying pull request. These issues will probably be fixed soon!Issues with an accompanying pull request. These issues will probably be fixed soon!
Milestone
Metadata
Metadata
Assignees
Labels
area:apiIssues with Prettier's Application Programming InterfaceIssues with Prettier's Application Programming Interfacelocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.status:has prIssues with an accompanying pull request. These issues will probably be fixed soon!Issues with an accompanying pull request. These issues will probably be fixed soon!
I received the following issue on eslint-plugin-prettier: prettier/eslint-plugin-prettier#126
When passing an absolute path into
getFileInfo()(or in my casegetFileInfo.sync()) the linesrc/not_pretty.jswithin a.prettierignoreis not honored. This results in a file being parsed by prettier when it should be ignored.This seems to occur for any ignore line that contains a path instead of a single segment.
Environments:
Steps to reproduce:
git clone https://github.com/edmorley/testcase-eslint-plugin-prettier-ignoreand cd into the folderAdd the following file to the repository as
check-getfileinfo.jsand run it usingnode check-getfileinfo.js:Expected behavior:
All console logs should return true
Actual behavior:
truefalsefalseThis behaviour does not occur when using the prettier CLI as all paths get resolved to be relative due to #2969. I think the solution is ensure the paths are relative when using getFileInfo() too.