eslint-plugin-prettier: context.getPhysicalFilename is not a function
eslint-plugin-prettier@4.0.0
is not compatible with eslint@7.11.0
and requires an upgrade to eslint@7.32.0
. This is particularly relevant as react-scripts
relies on eslint@7.11.0
.
What version of eslint
are you using? 7.11.0, 7.32.0
What version of prettier
are you using? 2.3.2
What version of eslint-plugin-prettier
are you using? 4.0.0
Please paste any applicable config files that you’re using (e.g. .prettierrc
or .eslintrc
files)
- https://github.com/CharlesStover/charlesstover.com/blob/1fef52f3616173c81d8b6e95f55cb817bd055ca1/.eslintrc.json
- https://github.com/CharlesStover/charlesstover.com/blob/1fef52f3616173c81d8b6e95f55cb817bd055ca1/.prettierrc.json
What source code are you linting?
https://github.com/CharlesStover/charlesstover.com/
What did you expect to happen?
Success.
What actually happened?
https://github.com/CharlesStover/charlesstover.com/runs/3511215999?check_suite_focus=true
Run yarn build
Creating an optimized production build...
Failed to compile.
Error while loading rule 'prettier/prettier': context.getPhysicalFilename is not a function
Occurred while linting /home/runner/work/charlesstover.com/charlesstover.com/src/index.tsx
Error: Process completed with exit code 1.
However, you can see from the eslint step that running eslint
succeeds. The only two differences between these two steps is the version of ESLint being run.
By upgrading react-scripts
’s eslint
version with yarn up -R eslint
, this error is resolved.
I’m opening this issue for two reasons:
- Anyone also encountering this error has an easily-googleable solution that does not otherwise exist at time of posting. To re-iterate, that solution is
yarn up -R eslint
. - The documentation should probably mention this, just based on the popularity of
react-scripts
. 🙂
I noticed this package lists the correct semvar in peer dependencies, but there are no warning or errors about versioning in the logs (see: GitHub workflow links above).
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 13
- Comments: 16 (1 by maintainers)
Commits related to this issue
- `yarn upgrade -R eslint` to fix eslint-plugin-prettier issue https://github.com/prettier/eslint-plugin-prettier/issues/434 — committed to helpmap/helpmap.io by gianpaj 3 years ago
- Revert eslint-prettier to 3.4.1 Context: https://github.com/prettier/eslint-plugin-prettier/issues/434 — committed to lblod/ember-rdfa-editor by abeforgit 3 years ago
- Revert eslint-prettier to 3.4.1 Context: https://github.com/prettier/eslint-plugin-prettier/issues/434 — committed to lblod/ember-rdfa-editor by abeforgit 3 years ago
- Revert eslint-prettier to 3.4.1 Context: https://github.com/prettier/eslint-plugin-prettier/issues/434 — committed to lblod/ember-rdfa-editor by abeforgit 3 years ago
- Fix issue with eslint run `yarn upgrade -R eslint` https://github.com/prettier/eslint-plugin-prettier/issues/434 — committed to mrloop/ember-sortable by mrloop 2 years ago
- Fix issue with eslint run `yarn upgrade -R eslint` https://github.com/prettier/eslint-plugin-prettier/issues/434 — committed to mrloop/ember-sortable by mrloop 2 years ago
- Fix issue with eslint run `yarn upgrade -R eslint` https://github.com/prettier/eslint-plugin-prettier/issues/434 — committed to mrloop/ember-sortable by mrloop 2 years ago
- fix(pencil): replaced failing tsdx lint command Replaced buggy tsdx lint https://github.com/jaredpalmer/tsdx/issues/1056 Package.json eslint non standard prop fails with tsdx due to old eslint https:/... — committed to TakitoTech/schemez by TriStarGod 2 years ago
Also “solved” by reverting to
3.3.1
I guess? This has been working for me:Users who have ESLint >=7.28 installed can still encounter this error when using other dependencies that depend on ESLint. My suggestion was for the documentation to address how to resolve this error, which the CHANGELOG neither does nor is it easily accessible, versus the README or an FAQ.
There in fact is not a warning, because I have both versions of ESLint installed. That is the point of this issue. It is quite possible for users to have both installed and get no warnings. They only get cryptic errors which do not tell how to resolve the issue.
Correct.
I feel like unblocking users who encounter common errors is within scope. “I installed
react-scripts
before late 2021” probably represents >90% of React users. I’m not saying it’s this project’s responsibility to fix the error. I’m saying it’s this project’s responsibility to help users onboard. The root cause and solution were outlined in the OP. It’s minimal effort to point to it as a debug step.Nonetheless, my intention was for it to become Google-able, as there were zero results for this error previously. Hopefully that goal is still met, even if the project doesn’t formally support the unblocking process. 👍
Hmm, anyone know what is the equal command of
yarn up -R eslint
for npm? Thanks!Same problem here. Solved by
yarn upgrade -R eslint
as you mentioned. Thank you!For what it’s worth, googling this error brought me straight here, and the advice to upgrade to
7.32.0
worked for me. So I guess just filing this issue is a good start to help new people.I’m having this issue with
eslint@8.41.0
andeslint-plugin-prettier@4.2.1
and I only have one version of eslint installed.I had something else triggering this where just doing a recursive update wasn’t persistent for me - deleting yarn.lock and reinstalling, or doing recursive upgrade didn’t work, I didn’t inspect too much because it also works if you just put a resolutions block in your package.json:
Another addition:
Unfortunately this seems not to be correct. Creating a new react app using cra installs current react-scripts
4.0.3
but eslint in version7.20.0
🙁Small addition: if you’re using yarn v2+ the command has been renamed to the following
yarn up -R eslint
.As first line of the CHANGELOG entry for v4.0.0 states:
Because the peer-dependency is also set as to v7.28.0 you probably got n warning when you ran your yarn / npm install that stated that the eslint version you have installed does not match what was required by peer dependencies.
react-scripts relies on
eslint@^7.11.0
according to your own yarn.lock. That means any fresh installs of react-scripts will pick up newer versions of eslint, so this isn’t an issue for new users. It only affects people that have an existing install of an older eslint version, and telling people how to their dependency manager isn’t the scope of this project.super helpful!