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

[feature] need a process undefined linting rule #70

Open
wraithgar opened this issue May 15, 2023 · 5 comments
Open

[feature] need a process undefined linting rule #70

wraithgar opened this issue May 15, 2023 · 5 comments

Comments

@wraithgar
Copy link
Member

Code that checks for the presence of process should test its type against undefined. Trying to access it AT ALL in a browser environment will throw an exception.

I don't know if a linting rule exists or if one needs to be written. But it should prevent things like:

if (process) {

or

if (process?.foo) {
@nlf
Copy link
Contributor

nlf commented May 15, 2023

i did a bit of searching and the best i came up with is disabling process as a global and leaning on the no-undef rule. the gotcha here is that actually using process in the places you need to means either disabling the no-undef rule for each line or referencing it as const process = require('process') which entirely possibly has its own browser related issues that it brings up

@wraithgar
Copy link
Member Author

require('process') would make more issues in places where we currently work correctly I think, since bundlers would start needing to either shim or throw.

@nlf
Copy link
Contributor

nlf commented May 15, 2023

yeah, that's the issue with that approach for sure. adding a comment to disable the no-undef rule on the lines that you actually use process would work and avoids that problem, but is also kind of wonky feeling

@wraithgar
Copy link
Member Author

Yeah it still wouldn't prevent process?.x which is the real thing we need to prevent. If it doesn't prevent that it's all just pretend anyways.

@voxpelli
Copy link

Using a types in js would catch this and feel more tuned into the job than eslint. Have you considered that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants