Skip to content

Commit aa06492

Browse files
sidoshiromaindso
authored andcommitted
Forbid using window properties as global variables (facebook#1840)
* Forbid using window properties as global variables * Change globals list to match Standard. * Fix globals
1 parent 9c7e34f commit aa06492

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

packages/eslint-config-react-app/index.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,19 @@ module.exports = {
2626
plugins: ['import', 'flowtype', 'jsx-a11y', 'react'],
2727

2828
env: {
29-
browser: true,
3029
commonjs: true,
3130
es6: true,
3231
jest: true,
3332
node: true,
3433
},
3534

35+
globals: {
36+
document: true,
37+
window: true,
38+
console: true,
39+
navigator: true
40+
},
41+
3642
parserOptions: {
3743
ecmaVersion: 6,
3844
sourceType: 'module',

packages/react-scripts/fixtures/kitchensink/src/App.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class BuiltEmitter extends Component {
2626
}
2727

2828
handleReady() {
29-
document.dispatchEvent(new Event('ReactFeatureDidMount'));
29+
document.dispatchEvent(new window.Event('ReactFeatureDidMount'));
3030
}
3131

3232
render() {
@@ -54,7 +54,7 @@ class App extends Component {
5454
}
5555

5656
componentDidMount() {
57-
const feature = location.hash.slice(1);
57+
const feature = window.location.hash.slice(1);
5858
switch (feature) {
5959
case 'array-destructuring':
6060
import(

packages/react-scripts/fixtures/kitchensink/src/features/webpack/NoExtInclusion.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import React from 'react';
1111
import aFileWithoutExt from './assets/aFileWithoutExt';
1212

1313
const text = aFileWithoutExt.includes('base64')
14-
? atob(aFileWithoutExt.split('base64,')[1]).trim()
14+
? window.atob(aFileWithoutExt.split('base64,')[1]).trim()
1515
: aFileWithoutExt;
1616

1717
export default () => (

packages/react-scripts/fixtures/kitchensink/src/features/webpack/UnknownExtInclusion.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import React from 'react';
1111
import aFileWithExtUnknown from './assets/aFileWithExt.unknown';
1212

1313
const text = aFileWithExtUnknown.includes('base64')
14-
? atob(aFileWithExtUnknown.split('base64,')[1]).trim()
14+
? window.atob(aFileWithExtUnknown.split('base64,')[1]).trim()
1515
: aFileWithExtUnknown;
1616

1717
export default () => (

0 commit comments

Comments
 (0)