Skip to content

Latest commit

 

History

History
57 lines (42 loc) · 867 Bytes

no-window.md

File metadata and controls

57 lines (42 loc) · 867 Bytes

Prohibits the usage of window global

Addng variables to the global scope can cause unintended consequences.

Rule Details

The following pattern is considered a warning:

function setDetail(detail) {
	window.detail = detail;
}

function getDetail() {
	return window.detail;
}

The following pattern is not considered a warning:

let __detail;

function setDetail(detail) {
	__detail = detail;
}

function getDetail() {
	return __detail;
}

Rule Options

This rule can take one argument to exclude some properties calls.

...
"more/no-window": [<enabled>, { exclude: <exclude> }]
...
  • enabled: for enabling the rule. 0=off, 1=warn, 2=error.
  • exclude: optional array of methods.

The default configuration is:

{
  exclude: [
    'postMessage',
    'open',
    'addEventListener',
    'removeEventListener'
  ]
}