microsoft / vscode-eslint

VSCode extension to integrate eslint into VSCode
MIT License
1.73k stars 333 forks source link

Validate coffee script by default #1176

Open edemaine opened 3 years ago

edemaine commented 3 years ago

I'm having trouble getting this extension to run at all, within a Meteor project on a Windows 10 machine. I can run eslint . and eslint <filename> fine from the terminal. But in the ESLint output I get:

Uncaught exception received.
Error: ENOENT: no such file or directory, realpath 'C:\Users\edemaine\Projects\cocreate\.meteor\local\build\programs\.build768781.web.browser\dynamic\package.json'
    at Function.realpathSync.native (fs.js:1588:3)
    at Function.native (electron/js2c/asar.js:302:42)
    at c:\Users\edemaine\.vscode\extensions\dbaeumer.vscode-eslint-2.1.14\server\out\eslintServer.js:1:14128
    at I (c:\Users\edemaine\.vscode\extensions\dbaeumer.vscode-eslint-2.1.14\server\out\eslintServer.js:1:14188)
    at c:\Users\edemaine\.vscode\extensions\dbaeumer.vscode-eslint-2.1.14\server\out\eslintServer.js:1:28946
    at Array.forEach (<anonymous>)
    at Object.handler (c:\Users\edemaine\.vscode\extensions\dbaeumer.vscode-eslint-2.1.14\server\out\eslintServer.js:1:28925)
    at Object.processQueue (c:\Users\edemaine\.vscode\extensions\dbaeumer.vscode-eslint-2.1.14\server\out\eslintServer.js:1:22071)
    at Immediate.<anonymous> (c:\Users\edemaine\.vscode\extensions\dbaeumer.vscode-eslint-2.1.14\server\out\eslintServer.js:1:21212)
    at processImmediate (internal/timers.js:439:21)

I believe the relevant context is that Meteor creates builds in .meteor/local which includes package.json files that (on Windows) are weird Windows symlinks.

What I don't understand is why this extension is looking at these files at all. I have a package.json at the root, and an .eslintrc.yml. I tried adding ignorePatterns: [.meteor], and I tried creating an .eslintignore with contents .meteor, but the extension still seems to be looking through all directories and calling realpath...

dbaeumer commented 3 years ago

@edemaine I am pretty sure that this fails because the ESLint server by default tries to run with the node version that ships with VS Code and therefore tries to do some asar resolving.

Can you try to use the eslint.runtime setting and point to to you local node install. If it is on the path you can simple set it to node.

edemaine commented 3 years ago

Thanks for the quick response! I tried setting eslint.runtime to "node", and ESLint server now says "running in node v15.5.1" which is the version I have installed. Unfortunately, I'm still getting the same error.

dbaeumer commented 3 years ago

@edemaine can you please provide me with a GitHub repository I can clone that demos what you are experiencing.

edemaine commented 3 years ago

Sure! Here are reproduction instructions:

dbaeumer commented 3 years ago

@edemaine can you use ESLint correctly when running in a terminal and using ESLint from the node_modules folder using something like node node_modules\eslint\bin\eslint.js file to validate

Usually we expect a smaller reproducible case and installing something like Meteor is not what I want to do.

edemaine commented 3 years ago

I tried to make a smaller reproduction, but it's tricky because the error seems to be transient, from during a build; probably the file gets created and removed before the ESLint server can access.

Fortunately, on further investigation, it seems that the error message doesn't actually cause the ESLint server to crash; it keeps going despite the transient errors.

My actual problem seems to be that I can't get ESLint to recognize *.coffee files. I'm using the script eslint --ext .coffee . to check all files. I added coffeescript to eslint.probe and "eslint.lintTask.options": "--ext .coffee" and "eslint.options": {"extensions": [".js", ".coffee"]}, but nothing seems to run when editing a .coffee file. I only just realized that other files (e.g. Markdown files) do correctly trigger eslint.

dbaeumer commented 3 years ago

@edemaine just to double check. Validating coffeescript using ESLint in the terminal works (e.g. eslint --ext .coffee .)?

edemaine commented 3 years ago

Yes, correct.

dbaeumer commented 3 years ago

I assume the probing for coffee script fails. You can always force validation using the deprecated validate setting. I will look into making coffee script probing work.