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

What is the difference between View & Pure Function Modifier in Solidity?

E2E Testing without the boring part — A tutorial with Cypress (part 1)

ES6, A [brief] History

How to create a Drawer Navigator in React Native using React Navigation 5

A common sense explanation of JavaScript array methods

Making the most out of up-skilling: An Elm Case Study — Part IV

Modules in JavaScript

Queued Async (pseudo-) modules with ES5

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

Most Efficient Ways Of Styling React Components: Dynamic Styles with CSS Modules

How to Set Up Multiple Environments with Webpack

Learn how to build resilient JavaScript code by using TypeScript Narrowing

My ELI5 For Basic React Concepts: Lifting State Up