question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

incompatibility with Next eslint config

See original GitHub issue
  • prettier-eslint-cli version: 6.0.1
  • prettier version: 2.7.1
  • eslint version: 8.18.0

Relevant code/config.

\\ .eslintrc.js
module.exports = {
  extends: ['next', 'prettier'],
};

What you did: I installed the latest version of prettier-eslint-cli (@6.0.1) I launched it on a project using the above .eslintrc.js with the command npx prettier-eslint "src/**/*.js"

What happened:

prettier-eslint [ERROR]: eslint fix failed due to an eslint error
prettier-eslint-cli [ERROR]: There was an error formatting "/home/linuxpoutous/Ekwateur/edito-front/src/prismic-template/content/InteractiveBills/EnergyButton/EnergyButton.js": 
    TypeError [ERR_INVALID_ARG_VALUE]: Failed to load plugin 'react-hooks' declared in 'CLIOptions': The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received ''
        at new NodeError (node:internal/errors:371:5)
        at createRequire (node:internal/modules/cjs/loader:1218:13)
        at Object.resolve (/home/linuxpoutous/Ekwateur/edito-front/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2325:16)
        at Object.ModuleResolver.resolve (/home/linuxpoutous/Ekwateur/edito-front/node_modules/@rushstack/eslint-patch/lib/modern-module-resolution.js:201:44)
        at ConfigArrayFactory._loadPlugin (/home/linuxpoutous/Ekwateur/edito-front/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3376:33)
        at ConfigArrayFactory._loadPlugin (/home/linuxpoutous/Ekwateur/edito-front/node_modules/@rushstack/eslint-patch/lib/modern-module-resolution.js:203:43)
        at /home/linuxpoutous/Ekwateur/edito-front/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3267:33
        at Array.reduce (<anonymous>)
        at ConfigArrayFactory._loadPlugins (/home/linuxpoutous/Ekwateur/edito-front/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3263:22)
        at ConfigArrayFactory._normalizeObjectConfigDataBody (/home/linuxpoutous/Ekwateur/edito-front/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3063:44)
prettier-eslint [ERROR]: eslint fix failed due to an eslint error
prettier-eslint-cli [ERROR]: There was an error formatting "/home/linuxpoutous/Ekwateur/edito-front/src/prismic-template/content/InteractiveBills/EnergyButton/EnergyButton.styles.js": 
    TypeError [ERR_INVALID_ARG_VALUE]: Failed to load plugin 'react-hooks' declared in 'CLIOptions': The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received ''

Problem description:

My guess is that it is because the next eslint config is using @rushstack/eslint-patch which changes the way plugins are loaded. I found out about this issue when using vs-code-prettier-eslint, and raised an issue for this there (https://github.com/idahogurl/vs-code-prettier-eslint/issues/42), but since the problem lies with prettier-eslint, here is the relevant issue !

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
JounQincommented, Jul 31, 2022

@mattbrannon Sorry I was a bit busy these days, hope I can find some free time to invest today.

2reactions
mattbrannoncommented, Jul 28, 2022

@JounQin Sure thing. In the example, the file at pages/index.js has this code with a long string of text:

export default function Home() {
  return (
    <p>
      Lorem, ipsum dolor sit amet consectetur adipisicing elit. Veniam illum placeat ratione consequuntur dolor ea? Quas explicabo minus voluptate, laudantium aliquam accusamus aperiam aliquid nisi, iste adipisci placeat, repudiandae cumque.
    </p>
  )
}

Problem: Running prettier-eslint on this file throws an error:

TypeError [ERR_INVALID_ARG_VALUE]: Failed to load plugin 'react-hooks' declared in 'CLIOptions': The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received ''

Expected: prettier-eslint should format the file without throwing an error.

Steps to reproduce:

  • Clone the repo and install dependencies.
  • From the root directory, run yarn format or yarn prettier-eslint pages/.*js

The eslint config is the default provided by Next.js. If the config is removed, prettier-eslint formats the code as expected.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[eslint-config-next] Incompatible with eslint@8.0.0 #29829
I'm managing my own eslintrc.js and I have all dependencies versions strict (without ^). I've created this issue, cos I've tested updating ...
Read more >
Unable to run eslint in Next.js - Stack Overflow
I tried running yarn add --dev eslint , but I still receive the same error after running the lint command. Edit: This is...
Read more >
Basic Features: ESLint - Next.js
Next.js provides an integrated ESLint experience by default. These conformance rules help you use Next.js in the optimal way.
Read more >
Lift-Off I Setup Client Error - eslint version incompatibility?
Hey there, I'm having an issue with eslint and running npm start in the client directory. While in /client directory in terminal, after...
Read more >
eslint-config-standard-next - npm
Shareable configs are designed to work with the extends feature of .eslintrc files. You can learn more about Shareable Configs on the official ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found