[meta] Support globalThis, nullish coalesce operator and conditional chaining operator in ESLint
Categories
(Developer Infrastructure :: Lint and Formatting, task, P3)
Tracking
(Not tracked)
People
(Reporter: jdescottes, Unassigned)
References
(Blocks 1 open bug)
Details
(Keywords: meta)
Using globalThis
in xpc-shell tests raises an eslint warning. globalThis is supported since FF65, so I guess we could update the rules:
https://searchfox.org/mozilla-central/source/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/xpcshell-test.js
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis
Comment 1•4 years ago
|
||
I thought I'd already commented on this here, but maybe I was mistaken and it was somewhere else.
The main issue here is that ESLint doesn't know about globalThis
when it should do. This is due to a minor issue in the globals
module: https://github.com/sindresorhus/globals/issues/140
I've now just submitted https://github.com/sindresorhus/globals/pull/158 which would have helped, however I've just noticed that ESLint has changed their structure of how they do their globals.
I'll wait a couple of days and see what comes out of that pull request, but I might just propose that ESLint adds globalThis
directly as it is a stage 4 proposal - ESLint only implements these when they get to stage 4.
Comment 2•4 years ago
|
||
At the moment, it seems that globalThis
support in ESLint is probably going to be in ESLint 7, if they are able to get it done (unfortunately I don't have time to dig into all the changes they need) - there's more work than just adding the global as some of the rules need to support it.
I'm therefore going to propose we leave the status quo as-is until ESLint 7 is released, and then tidy up after that.
Reporter | ||
Comment 3•4 years ago
|
||
Sounds good, thanks for following up Mark!
Updated•4 years ago
|
Comment 4•4 years ago
|
||
I'm going to munge this into a meta to include the other fancy new javascript tools - the nullish coalesce operator and the conditional chaining operator.
There's some ideas and discussions going on in other bugs that we'll track here.
Comment 5•4 years ago
|
||
Note: Nullish coalesce operator and conditional chaining are now supported with thanks to @Mossop and @Mardak.
I think we'll have to wait for the next ESLint major version to get the globalThis support.
Comment 6•4 years ago
|
||
Bug 1620537 just landed ESLint 7.5.0 which adds full support for globalThis.
Updated•2 years ago
|
Description
•