microsoft/vscode-eslint

Shows variables not defined when they are defined (no-undef rule)

DANser-freelancer opened this issue · 3 comments

I have eslint extension v3.0.10
I am on an electron-vite setup with the usual main.js, preload.js, and renderer.js.
Running isolated context I need to expose parts of main process to the renderer process. So I have contextBridge.exposeInMainWorld('fileSystem', function in preload.js that effectively calls a function in main.js, and in renderer.js I have const dirList = await fileSystem.openFile('select-directory', operation); function that is supposed to open a folder picking dialog.

The issue

My electron functions work completely fine as expected, but eslint highlights the fileSystem part as undefined. Kind of annoying.

@DANser-freelancer does the validation happen correctly when you use eslint in the terminal. If this is the case can you please provide me with a GitHub repository I can clone that demos what you are experiencing.

I ran npx eslint myfile.js if that's what you're asking and it said the same thing "api is not defined" even though api.fileSystem.selectDir(operation); works as expected. I can't really make a repo because I have this whole electron-vite setup going on and it's a bunch of files and I don't know just how much code I need to make it work. I may have changed the functionality a bit since I opened the issue, I now expose an "api" object in preload.js but it's the same thing and it has the same problem with eslint.

I ran npx eslint myfile.js if that's what you're asking and it said the same thing "api is not defined" even though api.fileSystem.selectDir(operation);

@DANser-freelancer then this is a configuration problem of ESLint itself and is not related to the extension. The extension tries to report exactly the same problems as reported by ESLint in the terminal.

I will close the issue since there is nothing the extension can do about this. You might want to ask for help in one of the ESLint communities.