Skip to content

Latest commit

 

History

History
22 lines (13 loc) · 705 Bytes

no-restricted-globals.md

File metadata and controls

22 lines (13 loc) · 705 Bytes

Pattern: Use of restricted global

Issue: -

Description

Disallow specific global variables.

Rationale:

function broken(evt: Event) {
    // Meant to do something with `evt` but typed it incorrectly.
    Event.target;  // compiler error
    event.target;  // should be a lint failure
}

Early Internet Explorer versions exposed the current DOM event as a global variable event, but using this variable has been considered a bad practice for a long time. Restricting this will make sure this variable isn’t used in browser code.

Further Reading