question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rule proposal: `prefer-global-this`

See original GitHub issue

globalThis is the unified way to access the “global” object.

This has the benefit of making code more cross-platform and more consistent.

globalThis requires Node.js 12, so we cannot add it to the recommended preset until April 2021 (date of Node.js 10 obsoletion).

Fail

window.foo; // Browser

self.foo; // Web Worker

global.foo; // Node.js

Pass

globalThis.foo;

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:6
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
fregantecommented, Jun 4, 2021

Changed my mind. globalThis is more clear 👍

0reactions
sindresorhuscommented, Jul 19, 2022

@fregante The REPL doesn’t represent a proper Node.js environment. Try running the same in a file instead.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Proposed rule: Order Competition Rule - SEC.gov
proposed rule would prohibit a restricted competition trading center from internally executing certain orders of individual investors at a ...
Read more >
The Most Curious Rule Proposal in Securities and Exchange ...
The Proposed Rules are of three categories: Disclosure Rules, Audit Rules, and Prohibited Activity Rules. These comments relate solely to the ...
Read more >
Wikipedia:SOPA initiative
For more information on the proposed law itself, see SOPA ... Voice your support or opposition to the proposals by voting. You may...
Read more >
eslint-plugin-unicorn - Bountysource
I wanted to propose a new rule to address a pattern that I have seen from a lot of our students at @upleveled...
Read more >
sindresorhus/eslint-plugin-unicorn (Raised $2856.00)
Rule proposal : Prefer explicit array check over `Array#flat()`. Unfunded#1719created byfisker. $0.00.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found