-
-
Notifications
You must be signed in to change notification settings - Fork 561
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
💅 FileReaderSync Variable is undeclared #2121
Comments
@Conaclos I'm not sure this should be a bug. The API is not always available unless the JS file js executed in a worker context. How can Biome help here, considering the current infrastructure? I think it makes more sense to use overrides, and declare a global for that single file |
@ematipico If it doesn't make sense then I will do what you say, just to extend a bit the issue, the function |
Yes. However, we could also claim that browser globals are not always available (for example in the backend) and Node globals are not always available (for example in a browser or in Deno). We should certainly look for a way of declaring/detecting environments. |
Important In both cases it stops being flagged as an issue if you prepend |
Thank you for your answer. My comment was a way to start a conversation and understand what's the best way to fix it. Probably it came off wrong. Sorry about that. My suggestion is a workaround, so you don't need to wait for a fix for that. @Conaclos you made a good point. It's possible that our globals are outdated |
@ematipico Oh I didn't mean anything with what I said! I actually meant that if you said that it didn't make any sense then I would do what you said (you're a maintainer after all, you know how this works far better than me), which, by the way I already did! I apologize if it came off wrong too, I am not a native English speaker so it was probably not formulated very well. What I meant with "in case you decide to fix it" it's because from your initial comment I understood that the issue could have been expected behaviour, and I wasn't sure if you were going to fix it or not. |
For anyone that wants to fix the issue, we should port this: In here: https://github.com/biomejs/biome/blob/main/crates/biome_js_analyze/src/globals/mod.rs Just create a new Then add a new check in here: biome/crates/biome_js_analyze/src/semantic_analyzers/correctness/no_undeclared_variables.rs Line 94 in 7a4f9e2
|
I think we already have worker globals defined in
|
Look at that :D It seems we aren't using it, so that will be even simpler! |
I'd like to work on this. I plan to update the globals and also fix the rule. |
Environment information
Rule name
lint/correctness/noUndeclaredVariables
Playground link
https://biomejs.dev/playground/?lintRules=all&code=YwBvAG4AcwB0ACAAbgBvAHIAbQBhAGwAUgBlAGEAZABlAHIAIAA9ACAAbgBlAHcAIABGAGkAbABlAFIAZQBhAGQAZQByACgAKQA7ACAALwAvACAAVwBvAHIAawBzAAoAYwBvAG4AcwB0ACAAcwB5AG4AYwBSAGUAYQBkAGUAcgAgAD0AIABuAGUAdwAgAEYAaQBsAGUAUgBlAGEAZABlAHIAUwB5AG4AYwAoACkAOwAgAC8ALwAgAEYAbABhAGcAcwAgAGEAbgAgAGUAcgByAG8AcgAKAAoA
Expected result
It should not flag an error, the
FileReaderSync
API is only available on Web Workers but it still exists after all.Code of Conduct
The text was updated successfully, but these errors were encountered: