Skip to content

Commit

Permalink
Make App.js ES5-compatible again, update ESLint rules around ES versions
Browse files Browse the repository at this point in the history
  • Loading branch information
ericyhwang committed Jun 17, 2023
1 parent fe7ac40 commit 29aa680
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
12 changes: 10 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"node": true
},
"parserOptions": {
"ecmaVersion": 8
"ecmaVersion": 5
},
"globals": {
"window": false,
Expand Down Expand Up @@ -37,7 +37,15 @@
},
"overrides": [
{
"files": ["test/**/*.mocha.js", "test/browser/*.js"],
// Files that are only run in Node can use more modern ES syntax.
"files": ["**/*ForServer.js", "test/**/*.mocha.js"],
"parserOptions": {
// Node 16 LTS supports up through ES2021.
"ecmaVersion": 2021
}
},
{
"files": ["test/**/*.js"],
"env": {"mocha": true, "node": true}
}
]
Expand Down
11 changes: 6 additions & 5 deletions lib/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ var PageBase = require('./Page');

module.exports = App;

globalThis.APPS = globalThis.APPS || new Map();
// TODO: Change to Map once we officially drop support for ES5.
global.APPS = global.APPS || {};

function App(derby, name, filename, options) {
EventEmitter.call(this);
Expand Down Expand Up @@ -71,14 +72,14 @@ App.prototype._finishInit = function() {

var previousAppInfo;
if (!util.isProduction) {
previousAppInfo = globalThis.APPS.get(this.name);
previousAppInfo = global.APPS[this.name];
if (previousAppInfo) {
previousAppInfo.app._destroyCurrentPage();
}
globalThis.APPS.set(this.name, {
global.APPS[this.name] = {
app: this,
initialState: data,
});
};
}

this.model.createConnection(data);
Expand Down Expand Up @@ -120,7 +121,7 @@ App.prototype._getAppData = function () {
if (script) {
return App._parseInitialData(script.textContent);
} else {
return globalThis.APPS.get(this.name).initialState;
return global.APPS[this.name].initialState;
}
}

Expand Down

0 comments on commit 29aa680

Please sign in to comment.