Docs: (languageOptions.globals) How to specify more than one globals.(env) #18803
Labels
accepted
There is consensus among the team that this change meets the criteria for inclusion
documentation
Relates to ESLint's documentation
Docs page(s)
https://eslint.org/docs/latest/use/configure/migration-guide#configuring-language-options
and
https://eslint.org/docs/latest/use/configure/language-options
What documentation issue do you want to solve?
Currently the docs specify how to use a single globals.brower or globals.jest or globals.(env), but not more than one at a time. The docs suggest that using the spread operator should work, so maybe something like this:
But that does not work, and neither does
and neither does
or
I have tests that are using BOTH jest globals, and window (browser) globals, I need BOTH! How can I configure this?
What do you think is the correct solution?
I'd like the ESLint docs to specify how to do this. Even better, I'd like the error messages to give me more of a hint than
Unexpected token: .
because that isn't very helpful, there's plenty of.
in my config file, can you give some context, a line number, SOMETHING, and tell me how to fix it? IfUnexpected token: ...
in languageOptions.globals, maybe I'm trying to do this specific thing (that the docs tell me should work) and you could link me to some information?It seems like the underlying structure here is objects, so it seems like one of these should work, either with spread syntax:
which would be fine but kind of unintuitive for a new user, or without spread syntax:
which was the first thing I tried because it makes sense.
Participation
Additional comments
In general, I am in favor of MORE specificity and examples in documentation, even at the cost of brevity. Or a happy middle ground: I don't think anyone has ever complained about a documentation that said "find more examples here" and linked to a page full of examples showing how to make each piece of the system singular or plural or what all the options are and what they do, etc. I know that takes time but further examples help a TON when the concept is unclear/not intuitive.
The text was updated successfully, but these errors were encountered: