Closed Bug 1595810 Opened 5 years ago Closed 4 years ago

[meta] Support globalThis, nullish coalesce operator and conditional chaining operator in ESLint

Categories

(Developer Infrastructure :: Lint and Formatting, task, P3)

Tracking

(Not tracked)

RESOLVED FIXED

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

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.

Assignee: nobody → standard8
Status: NEW → ASSIGNED

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.

Assignee: standard8 → nobody
Status: ASSIGNED → NEW

Sounds good, thanks for following up Mark!

Summary: globalThis is not listed in the xpcshell globals → Support globalThis in ESLint

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.

Depends on: 1617959
Summary: Support globalThis in ESLint → [meta] Support globalThis, nullish coalesce operator and conditional chaining operator in ESLint
Blocks: 1607095
Depends on: 1620556
Depends on: 1622717

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.

Depends on: 1620537

Bug 1620537 just landed ESLint 7.5.0 which adds full support for globalThis.

Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Product: Firefox Build System → Developer Infrastructure
You need to log in before you can comment on or make changes to this bug.