Currently it's impossible to use vscode-eslint with any plugin that needs NODE_ENV because there's no way to define it.
The ideal solution would be to expose a eslint.nodeEnv setting, or a more generalized eslint.processEnv setting, so that users can define whatever environment variables are needed by their eslint plugins.
Example:
[eslint-import-resolver-babel-module] Error: Using
babel-preset-razzlerequires that you specifyNODE_ENVorBABEL_ENVenvironment variables. Valid values are "development", "test", and "production". Instead, received: undefined.
This is essentially the same issue as #741, but for some reason, that issue was closed when a platform-dependent workaround was found (which didn't address the underlying root cause). Clearly, defining NODE_ENV for the entire VS Code process is overkill and not really a viable solution, as doing so is likely to cause other problems.
Anyone interested working on a PR for this?
I'm willing to take a stab at it, although I haven't worked with code in a VSCode extension before, or written much TypeScript either (just FYI).
Is this the right place to add environment variables? https://github.com/microsoft/vscode-eslint/blob/master/client/src/extension.ts#L886
Would these be the right places to add a new configuration setting?
PR is submitted, and changes seem to work correctly while running the debugging task! :)
Still waiting on a final PR review + merge. Some attention on this issue would be really appreciated! 馃檹馃槄馃檹
Sorry. Slipped through the cracks. Will have a look.
I merged the PR. Will look into a new version when we ship a new version of VS Code beginning of August.
Thanks a lot @mattlubner, I'm using eslint-import-resolver-babel-module also with a custom babel config that requires a custom NODE_ENV, so this feature will greatly improve my workflow :smile:.
@dbaeumer, do you have an ETA for a new version of the extension containing this feature ?
Thanks again for all your work !
Actually this got delayed due to the security work. I will look into it in September.
Most helpful comment
Thanks a lot @mattlubner, I'm using
eslint-import-resolver-babel-modulealso with a custombabelconfig that requires a customNODE_ENV, so this feature will greatly improve my workflow :smile:.@dbaeumer, do you have an ETA for a new version of the extension containing this feature ?
Thanks again for all your work !