Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] not working with eslint 6 #870

Open
jimblue opened this issue Jul 9, 2019 · 30 comments

Comments

@jimblue
Copy link

commented Jul 9, 2019

Hi,

When using the option eslint-integration, Prettier is not working and output the following error:

ENOENT/home/dev/frontend/webpacker/app/index.js:: no such file or directory, open '/home/dev/projects/frontend/node_modules/eslint/lib/linter.js'

I've check in my node_modules and effectively, linter.js doesn't exist.

It was previously working with eslint version 5 because linter.js did exist at this path here.

But in eslint version 6, linter.js has been moved in a subfolder here.

That's why it's actually broken.
So basically all you have to do is to modify the require:

from:

require /node_modules/eslint/lib/linter.js

to:

require /node_modules/eslint/lib/linter/index.js

Cheers

@jakeleventhal

This comment has been minimized.

Copy link

commented Jul 11, 2019

Need this ASAP!

@chengjia080787

This comment has been minimized.

Copy link

commented Jul 22, 2019

any luck on this? it's a critical issue to be honest

@mbalaam

This comment has been minimized.

Copy link

commented Jul 22, 2019

I’ve ended up removing the extension and I am using https://github.com/prettier/eslint-plugin-prettier instead.

@Thomazella

This comment has been minimized.

Copy link

commented Jul 30, 2019

running "prettier.eslintIntegration": false as a work around

@asbjornh

This comment has been minimized.

Copy link

commented Aug 7, 2019

to:

require /node_modules/eslint/lib/linter/index.js

Maybe change to require('node_modules/eslint/lib/linter') instead? Node's module resolution would then check both linter.js and linter/index.js. If the import looked like that in the first place we wouldn't have an issue now 😃

@asbjornh

This comment has been minimized.

Copy link

commented Aug 8, 2019

@jimblue Where is that require call coming from? I can't see that this package imports eslint anywhere in the source and eslint isn't listed in package.json either. I tried grep'ing the plugin folder and nothing really looks suspicious.

In ~/.vscode/extensions/esbenp.prettier-vscode-1.9.0:

$ grep -r "/linter" .
./node_modules/tslint/lib/test.js:var linter_1 = require("./linter");
./node_modules/tslint/lib/runner.js:var linter_1 = require("./linter");
./node_modules/tslint/lib/index.js:tslib_1.__exportStar(require("./linter"), exports);
./node_modules/tslint/lib/index.d.ts:export * from "./linter";
./node_modules/tslint/lib/tslintCli.js:var linter_1 = require("./linter");
./node_modules/prettier-tslint/dist/format.js:  // Adapted from: https://github.com/palantir/tslint/blob/5.12.0/src/linter.ts
./node_modules/eslint/lib/config/autoconfig.js:    Linter = require("../linter"),
./node_modules/eslint/lib/testers/rule-tester.js:    Linter = require("../linter"),
./node_modules/eslint/lib/api.js:const Linter = require("./linter");
./node_modules/eslint/lib/cli-engine.js:    Linter = require("./linter"),
@asbjornh

This comment has been minimized.

Copy link

commented Aug 9, 2019

I tried creating a fresh project to reproduce, and I'm now getting a different error message:

Failed to load plugin 'prettier' declared in 'CLIOptions'<project-path>/index.js:: Cannot find module 'eslint-plugin-prettier'
Require stack:
- /__placeholder__.js

eslint-plugin-prettier is most definitely installed. For anyone interested in debugging this, here is a setup for reproducing this:

  "dependencies": {
    "eslint": "^6.1.0",
    "eslint-config-prettier": "^6.0.0",
    "eslint-plugin-prettier": "^3.1.0",
    "prettier": "^1.18.2"
  }

eslintrc:

{
  "plugins": ["prettier"],
  "extends": ["prettier"],
  "rules": {
    "prettier/prettier": ["warn"]
  }
}

Running with prettier.eslintIntegration: true and selecting Format Document With from the command palette in an empty js file should result in the above error message.

@ntotten ntotten added the bug label Aug 9, 2019

@ntotten ntotten modified the milestones: 1.9.0, 1.10.0 Aug 9, 2019

@asbjornh

This comment has been minimized.

Copy link

commented Aug 11, 2019

Oh, this seems to be caused by a known issue with prettier-eslint (prettier/prettier-eslint#222). I guess we'll have to wait for them to fix that first :)

@ntotten

This comment has been minimized.

Copy link
Contributor

commented Aug 12, 2019

As mentioned above, there is an upstream dependancy on the prettier eslint module. It is not yet compatible with eslint 6. see: prettier/prettier-eslint#222

This was referenced Aug 24, 2019

@ntotten ntotten removed this from the 2.0.0 milestone Aug 24, 2019

@ntotten

This comment has been minimized.

Copy link
Contributor

commented Aug 25, 2019

Here is a good article explaining the type of setup that is recommended going forward: https://dorshinar.me/linting-your-react+typescript-project-with-eslint-and-prettier

@ntotten

This comment has been minimized.

Copy link
Contributor

commented Aug 25, 2019

More discussion also in #922

@YuriScarbaci

This comment has been minimized.

Copy link

commented Aug 26, 2019

Until this is fixed in the extension if anyone is relying on the eslint-vscode extension and wishes to setup a keybinding to "format" (well, fixing with eslint, but in most cases it's formatting anyway) you could set a keybindg in your vscode with "shift+alt+f" (or whatever you wish) listening to eslint.executeAutofix

for more info about this refeer to https://github.com/Microsoft/vscode-eslint/issues/70

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.