Resolving Prettier + React: context.getPhysicalFilename is not a function

If you’ve recently upgraded to eslint-plugin-prettier@^4 on an existing React project, you may have encountered the cryptic error:

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/$repository/$repository/src/index.tsx

Error: Process completed with exit code 1.

--

--

--

Staff front end engineer | Tech lead | Architect | charlesstover.com

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Stop freaking memory! Release the JavaScript Streams API — Part I

Set Up Background Removal Using Chroma Keying

How to add React Native Web to an existing React Native project

19 ways to become a better Node.JS developer in 2019

READ/DOWNLOAD@$ CFIN (with MindTap Finance, 1 term

解構賦值 const {X,X,X}

TypeScript strictly typed: strict mode is not enough

test in getcampo

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Charles Stover

Charles Stover

Staff front end engineer | Tech lead | Architect | charlesstover.com

More from Medium

All About Rendering: Client and Server

Hide and replace sticky element on scrolling in a React way

My ELI5 For Basic React Concepts: Lifting State Up

Using React State with Functional Components