From 9103253f62208f52d556a4738ec9d9c47a1830e6 Mon Sep 17 00:00:00 2001 From: Jessica Lord Date: Thu, 14 Jan 2016 13:16:42 -0800 Subject: [PATCH 1/8] Use `const` --- atom/browser/api/lib/app.js | 24 +++++++++------ atom/browser/api/lib/auto-updater.js | 7 ++--- .../lib/auto-updater/auto-updater-native.js | 7 ++--- .../api/lib/auto-updater/auto-updater-win.js | 18 +++++------- .../lib/auto-updater/squirrel-update-win.js | 18 +++++------- atom/browser/api/lib/browser-window.js | 11 +++---- atom/browser/api/lib/dialog.js | 29 +++++++++---------- atom/browser/api/lib/exports/electron.js | 4 +-- atom/browser/api/lib/ipc-main.js | 4 +-- atom/browser/api/lib/ipc.js | 5 ++-- 10 files changed, 55 insertions(+), 72 deletions(-) diff --git a/atom/browser/api/lib/app.js b/atom/browser/api/lib/app.js index 560fcb8630ee..bd820127cd9a 100644 --- a/atom/browser/api/lib/app.js +++ b/atom/browser/api/lib/app.js @@ -1,15 +1,21 @@ -var EventEmitter, Menu, app, appPath, bindings, deprecate, downloadItemBindings, fn, i, len, name, ref, ref1, session, wrapDownloadItem, - slice = [].slice; +const deprecate = require('electron').deprecate; +const session = require('electron').session; +const Menu = require('electron').Menu; +const EventEmitter = require('events').EventEmitter; -ref = require('electron'), deprecate = ref.deprecate, session = ref.session, Menu = ref.Menu; +const bindings = process.atomBinding('app'); +const downloadItemBindings = process.atomBinding('download_item'); +const app = bindings.app; -EventEmitter = require('events').EventEmitter; +var slice = [].slice; -bindings = process.atomBinding('app'); - -downloadItemBindings = process.atomBinding('download_item'); - -app = bindings.app; +var appPath; +var fn; +var i; +var len; +var name; +var ref1; +var wrapDownloadItem; app.__proto__ = EventEmitter.prototype; diff --git a/atom/browser/api/lib/auto-updater.js b/atom/browser/api/lib/auto-updater.js index a3ffc12e9f2d..9cc1fada0675 100644 --- a/atom/browser/api/lib/auto-updater.js +++ b/atom/browser/api/lib/auto-updater.js @@ -1,8 +1,5 @@ -var autoUpdater, deprecate; - -deprecate = require('electron').deprecate; - -autoUpdater = process.platform === 'win32' ? require('./auto-updater/auto-updater-win') : require('./auto-updater/auto-updater-native'); +const deprecate = require('electron').deprecate; +const autoUpdater = process.platform === 'win32' ? require('./auto-updater/auto-updater-win') : require('./auto-updater/auto-updater-native'); // Deprecated. deprecate.rename(autoUpdater, 'setFeedUrl', 'setFeedURL'); diff --git a/atom/browser/api/lib/auto-updater/auto-updater-native.js b/atom/browser/api/lib/auto-updater/auto-updater-native.js index 9f22b33feb1d..20c69cdb5a2b 100644 --- a/atom/browser/api/lib/auto-updater/auto-updater-native.js +++ b/atom/browser/api/lib/auto-updater/auto-updater-native.js @@ -1,8 +1,5 @@ -var EventEmitter, autoUpdater; - -EventEmitter = require('events').EventEmitter; - -autoUpdater = process.atomBinding('auto_updater').autoUpdater; +const EventEmitter = require('events').EventEmitter; +const autoUpdater = process.atomBinding('auto_updater').autoUpdater; autoUpdater.__proto__ = EventEmitter.prototype; diff --git a/atom/browser/api/lib/auto-updater/auto-updater-win.js b/atom/browser/api/lib/auto-updater/auto-updater-win.js index 61b1911e232e..bbe02555a0b8 100644 --- a/atom/browser/api/lib/auto-updater/auto-updater-win.js +++ b/atom/browser/api/lib/auto-updater/auto-updater-win.js @@ -1,16 +1,12 @@ -var AutoUpdater, EventEmitter, app, squirrelUpdate, url, - extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - hasProp = {}.hasOwnProperty; +const app = require('electron').app; +const EventEmitter = require('events').EventEmitter; +const url = require('url'); +const squirrelUpdate = require('./squirrel-update-win'); -app = require('electron').app; +var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, +hasProp = {}.hasOwnProperty; -EventEmitter = require('events').EventEmitter; - -url = require('url'); - -squirrelUpdate = require('./squirrel-update-win'); - -AutoUpdater = (function(superClass) { +var AutoUpdater = (function(superClass) { extend(AutoUpdater, superClass); function AutoUpdater() { diff --git a/atom/browser/api/lib/auto-updater/squirrel-update-win.js b/atom/browser/api/lib/auto-updater/squirrel-update-win.js index 49d525f4a684..8fe8a3786db9 100644 --- a/atom/browser/api/lib/auto-updater/squirrel-update-win.js +++ b/atom/browser/api/lib/auto-updater/squirrel-update-win.js @@ -1,22 +1,18 @@ -var appFolder, exeName, fs, path, spawn, spawnUpdate, updateExe; - -fs = require('fs'); - -path = require('path'); - -spawn = require('child_process').spawn; +const fs = require('fs'); +const path = require('path'); +const spawn = require('child_process').spawn; // i.e. my-app/app-0.1.13/ -appFolder = path.dirname(process.execPath); +const appFolder = path.dirname(process.execPath); // i.e. my-app/Update.exe -updateExe = path.resolve(appFolder, '..', 'Update.exe'); +const updateExe = path.resolve(appFolder, '..', 'Update.exe'); -exeName = path.basename(process.execPath); +const exeName = path.basename(process.execPath); // Spawn a command and invoke the callback when it completes with an error // and the output from standard out. -spawnUpdate = function(args, detached, callback) { +var spawnUpdate = function(args, detached, callback) { var error, error1, errorEmitted, spawnedProcess, stderr, stdout; try { spawnedProcess = spawn(updateExe, args, { diff --git a/atom/browser/api/lib/browser-window.js b/atom/browser/api/lib/browser-window.js index df9ae1647383..1268b0f80127 100644 --- a/atom/browser/api/lib/browser-window.js +++ b/atom/browser/api/lib/browser-window.js @@ -1,10 +1,7 @@ -var BrowserWindow, EventEmitter, deprecate, ipcMain, ref; - -ref = require('electron'), ipcMain = ref.ipcMain, deprecate = ref.deprecate; - -EventEmitter = require('events').EventEmitter; - -BrowserWindow = process.atomBinding('window').BrowserWindow; +const ipcMain = require('electron').ipcMain; +const deprecate = require('electron').deprecate; +const EventEmitter = require('events').EventEmitter; +const BrowserWindow = process.atomBinding('window').BrowserWindow; BrowserWindow.prototype.__proto__ = EventEmitter.prototype; diff --git a/atom/browser/api/lib/dialog.js b/atom/browser/api/lib/dialog.js index 9ed49738a55b..302fa7bf07fe 100644 --- a/atom/browser/api/lib/dialog.js +++ b/atom/browser/api/lib/dialog.js @@ -1,27 +1,25 @@ -var BrowserWindow, api, app, binding, checkAppInitialized, fileDialogProperties, j, len, messageBoxOptions, messageBoxTypes, parseArgs, ref, ref1, v8Util, - slice = [].slice, - indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; +const app = require('electron').app; +const BrowserWindow = require('electron').BrowserWindow; +const binding = process.atomBinding('dialog'); +const v8Util = process.atomBinding('v8_util'); -ref = require('electron'), app = ref.app, BrowserWindow = ref.BrowserWindow; +var slice = [].slice; +var indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; -binding = process.atomBinding('dialog'); - -v8Util = process.atomBinding('v8_util'); - -fileDialogProperties = { +var fileDialogProperties = { openFile: 1 << 0, openDirectory: 1 << 1, multiSelections: 1 << 2, createDirectory: 1 << 3 }; -messageBoxTypes = ['none', 'info', 'warning', 'error', 'question']; +var messageBoxTypes = ['none', 'info', 'warning', 'error', 'question']; -messageBoxOptions = { +var messageBoxOptions = { noLink: 1 << 0 }; -parseArgs = function(window, options, callback) { +var parseArgs = function(window, options, callback) { if (!(window === null || (window != null ? window.constructor : void 0) === BrowserWindow)) { // Shift. callback = options; @@ -36,7 +34,7 @@ parseArgs = function(window, options, callback) { return [window, options, callback]; }; -checkAppInitialized = function() { +var checkAppInitialized = function() { if (!app.isReady()) { throw new Error('dialog module can only be used after app is ready'); } @@ -164,8 +162,9 @@ module.exports = { }; // Mark standard asynchronous functions. -ref1 = ['showMessageBox', 'showOpenDialog', 'showSaveDialog']; +var ref1 = ['showMessageBox', 'showOpenDialog', 'showSaveDialog']; +var j, len for (j = 0, len = ref1.length; j < len; j++) { - api = ref1[j]; + var api = ref1[j]; v8Util.setHiddenValue(module.exports[api], 'asynchronous', true); } diff --git a/atom/browser/api/lib/exports/electron.js b/atom/browser/api/lib/exports/electron.js index 74ae751e0834..7f97fcdbc4cf 100644 --- a/atom/browser/api/lib/exports/electron.js +++ b/atom/browser/api/lib/exports/electron.js @@ -1,6 +1,4 @@ -var common; - -common = require('../../../../common/api/lib/exports/electron'); +const common = require('../../../../common/api/lib/exports/electron'); // Import common modules. diff --git a/atom/browser/api/lib/ipc-main.js b/atom/browser/api/lib/ipc-main.js index bd4300d2c244..e253e03eaabe 100644 --- a/atom/browser/api/lib/ipc-main.js +++ b/atom/browser/api/lib/ipc-main.js @@ -1,5 +1,3 @@ -var EventEmitter; - -EventEmitter = require('events').EventEmitter; +const EventEmitter = require('events').EventEmitter; module.exports = new EventEmitter; diff --git a/atom/browser/api/lib/ipc.js b/atom/browser/api/lib/ipc.js index ed20e976173f..6e9715154234 100644 --- a/atom/browser/api/lib/ipc.js +++ b/atom/browser/api/lib/ipc.js @@ -1,6 +1,5 @@ -var deprecate, ipcMain, ref; - -ref = require('electron'), deprecate = ref.deprecate, ipcMain = ref.ipcMain; +const deprecate = require('electron').deprecate; +const ipcMain = require('electron').ipcMain; // This module is deprecated, we mirror everything from ipcMain. deprecate.warn('ipc module', 'require("electron").ipcMain'); From 3a0fb42737080bfe411d2dcd3adff41cdef7ca60 Mon Sep 17 00:00:00 2001 From: Jessica Lord Date: Thu, 14 Jan 2016 13:18:52 -0800 Subject: [PATCH 2/8] Use `const` --- atom/browser/api/lib/menu-item.js | 4 +-- atom/browser/api/lib/menu.js | 26 ++++++-------- atom/browser/api/lib/navigation-controller.js | 7 ++-- atom/browser/api/lib/power-monitor.js | 7 ++-- atom/browser/api/lib/protocol.js | 8 ++--- atom/browser/api/lib/screen.js | 7 ++-- atom/browser/api/lib/session.js | 12 +++---- atom/browser/api/lib/tray.js | 10 ++---- atom/browser/api/lib/web-contents.js | 23 +++++++------ atom/browser/lib/chrome-extension.js | 34 +++++++------------ 10 files changed, 55 insertions(+), 83 deletions(-) diff --git a/atom/browser/api/lib/menu-item.js b/atom/browser/api/lib/menu-item.js index b8357dd34918..80fdd46fd89b 100644 --- a/atom/browser/api/lib/menu-item.js +++ b/atom/browser/api/lib/menu-item.js @@ -26,8 +26,8 @@ MenuItem = (function() { MenuItem.types = ['normal', 'separator', 'submenu', 'checkbox', 'radio']; function MenuItem(options) { - var Menu, click, ref; - Menu = require('electron').Menu; + var click, ref; + const Menu = require('electron').Menu; click = options.click, this.selector = options.selector, this.type = options.type, this.role = options.role, this.label = options.label, this.sublabel = options.sublabel, this.accelerator = options.accelerator, this.icon = options.icon, this.enabled = options.enabled, this.visible = options.visible, this.checked = options.checked, this.submenu = options.submenu; if ((this.submenu != null) && this.submenu.constructor !== Menu) { this.submenu = Menu.buildFromTemplate(this.submenu); diff --git a/atom/browser/api/lib/menu.js b/atom/browser/api/lib/menu.js index 5af39e18af32..69ad4fec051d 100644 --- a/atom/browser/api/lib/menu.js +++ b/atom/browser/api/lib/menu.js @@ -1,19 +1,15 @@ -var BrowserWindow, EventEmitter, Menu, MenuItem, applicationMenu, bindings, generateGroupId, indexOfItemById, indexToInsertByPosition, nextGroupId, ref, v8Util; - -ref = require('electron'), BrowserWindow = ref.BrowserWindow, MenuItem = ref.MenuItem; - -EventEmitter = require('events').EventEmitter; - -v8Util = process.atomBinding('v8_util'); - -bindings = process.atomBinding('menu'); +const BrowserWindow = require('electron').BrowserWindow; +const MenuItem = require('electron').MenuItem; +const EventEmitter = require('events').EventEmitter; +const v8Util = process.atomBinding('v8_util'); +const bindings = process.atomBinding('menu'); // Automatically generated radio menu item's group id. -nextGroupId = 0; +var nextGroupId = 0; // Search between seperators to find a radio menu item and return its group id, // otherwise generate a group id. -generateGroupId = function(items, pos) { +var generateGroupId = function(items, pos) { var i, item, j, k, ref1, ref2, ref3; if (pos > 0) { for (i = j = ref1 = pos - 1; ref1 <= 0 ? j <= 0 : j >= 0; i = ref1 <= 0 ? ++j : --j) { @@ -40,7 +36,7 @@ generateGroupId = function(items, pos) { }; // Returns the index of item according to |id|. -indexOfItemById = function(items, id) { +var indexOfItemById = function(items, id) { var i, item, j, len; for (i = j = 0, len = items.length; j < len; i = ++j) { item = items[i]; @@ -52,7 +48,7 @@ indexOfItemById = function(items, id) { }; // Returns the index of where to insert the item according to |position|. -indexToInsertByPosition = function(items, position) { +var indexToInsertByPosition = function(items, position) { var id, insertIndex, query, ref1; if (!position) { return items.length; @@ -87,7 +83,7 @@ indexToInsertByPosition = function(items, position) { return insertIndex; }; -Menu = bindings.Menu; +const Menu = bindings.Menu; Menu.prototype.__proto__ = EventEmitter.prototype; @@ -265,7 +261,7 @@ Menu.prototype._callMenuWillShow = function() { return results; }; -applicationMenu = null; +var applicationMenu = null; Menu.setApplicationMenu = function(menu) { var j, len, results, w, windows; diff --git a/atom/browser/api/lib/navigation-controller.js b/atom/browser/api/lib/navigation-controller.js index 5478b6dd3264..80756eb13e49 100644 --- a/atom/browser/api/lib/navigation-controller.js +++ b/atom/browser/api/lib/navigation-controller.js @@ -1,7 +1,6 @@ -var NavigationController, ipcMain, - slice = [].slice; +const ipcMain = require('electron').ipcMain; -ipcMain = require('electron').ipcMain; +var slice = [].slice; // The history operation in renderer is redirected to browser. ipcMain.on('ATOM_SHELL_NAVIGATION_CONTROLLER', function() { @@ -21,7 +20,7 @@ ipcMain.on('ATOM_SHELL_SYNC_NAVIGATION_CONTROLLER', function() { // control on user land, and only rely on WebContents.loadURL for navigation. // This helps us avoid Chromium's various optimizations so we can ensure renderer // process is restarted everytime. -NavigationController = (function() { +var NavigationController = (function() { function NavigationController(webContents) { this.webContents = webContents; this.clearHistory(); diff --git a/atom/browser/api/lib/power-monitor.js b/atom/browser/api/lib/power-monitor.js index df4b28c6eb66..239eb3b4d47a 100644 --- a/atom/browser/api/lib/power-monitor.js +++ b/atom/browser/api/lib/power-monitor.js @@ -1,8 +1,5 @@ -var EventEmitter, powerMonitor; - -EventEmitter = require('events').EventEmitter; - -powerMonitor = process.atomBinding('power_monitor').powerMonitor; +const EventEmitter = require('events').EventEmitter; +const powerMonitor = process.atomBinding('power_monitor').powerMonitor; powerMonitor.__proto__ = EventEmitter.prototype; diff --git a/atom/browser/api/lib/protocol.js b/atom/browser/api/lib/protocol.js index f04eab121f15..41cb48db09b9 100644 --- a/atom/browser/api/lib/protocol.js +++ b/atom/browser/api/lib/protocol.js @@ -1,15 +1,13 @@ -var app, logAndThrow, protocol; - -app = require('electron').app; +const app = require('electron').app; if (!app.isReady()) { throw new Error('Can not initialize protocol module before app is ready'); } -protocol = process.atomBinding('protocol').protocol; +const protocol = process.atomBinding('protocol').protocol; // Warn about removed APIs. -logAndThrow = function(callback, message) { +var logAndThrow = function(callback, message) { console.error(message); if (callback) { return callback(new Error(message)); diff --git a/atom/browser/api/lib/screen.js b/atom/browser/api/lib/screen.js index 3dca49e99d90..04965278a3c8 100644 --- a/atom/browser/api/lib/screen.js +++ b/atom/browser/api/lib/screen.js @@ -1,8 +1,5 @@ -var EventEmitter, screen; - -EventEmitter = require('events').EventEmitter; - -screen = process.atomBinding('screen').screen; +const EventEmitter = require('events').EventEmitter; +const screen = process.atomBinding('screen').screen; screen.__proto__ = EventEmitter.prototype; diff --git a/atom/browser/api/lib/session.js b/atom/browser/api/lib/session.js index 8ba9e61be45a..dc65264349fa 100644 --- a/atom/browser/api/lib/session.js +++ b/atom/browser/api/lib/session.js @@ -1,10 +1,6 @@ -var EventEmitter, PERSIST_PERFIX, bindings, wrapSession; - -EventEmitter = require('events').EventEmitter; - -bindings = process.atomBinding('session'); - -PERSIST_PERFIX = 'persist:'; +const EventEmitter = require('events').EventEmitter; +const bindings = process.atomBinding('session'); +const PERSIST_PERFIX = 'persist:'; // Returns the Session from |partition| string. exports.fromPartition = function(partition) { @@ -29,7 +25,7 @@ Object.defineProperty(exports, 'defaultSession', { } }); -wrapSession = function(session) { +var wrapSession = function(session) { // session is an EventEmitter. return session.__proto__ = EventEmitter.prototype; }; diff --git a/atom/browser/api/lib/tray.js b/atom/browser/api/lib/tray.js index a2b732964ea4..342683552f62 100644 --- a/atom/browser/api/lib/tray.js +++ b/atom/browser/api/lib/tray.js @@ -1,10 +1,6 @@ -var EventEmitter, Tray, deprecate; - -deprecate = require('electron').deprecate; - -EventEmitter = require('events').EventEmitter; - -Tray = process.atomBinding('tray').Tray; +const deprecate = require('electron').deprecate; +const EventEmitter = require('events').EventEmitter; +const Tray = process.atomBinding('tray').Tray; Tray.prototype.__proto__ = EventEmitter.prototype; diff --git a/atom/browser/api/lib/web-contents.js b/atom/browser/api/lib/web-contents.js index c507daab077e..47f5eb4639b9 100644 --- a/atom/browser/api/lib/web-contents.js +++ b/atom/browser/api/lib/web-contents.js @@ -1,21 +1,22 @@ 'use strict'; -var EventEmitter, Menu, NavigationController, PDFPageSize, binding, deprecate, getNextId, ipcMain, nextId, ref, session, wrapWebContents, - slice = [].slice; +const EventEmitter = require('events').EventEmitter; +const deprecate = require('electron').deprecate; +const ipcMain = require('electron').ipcMain; +const session = require('electron').session; +const NavigationController = require('electron').NavigationController; +const Menu = require('electron').Menu; -EventEmitter = require('events').EventEmitter; +const binding = process.atomBinding('web_contents'); -ref = require('electron'), deprecate = ref.deprecate, ipcMain = ref.ipcMain, session = ref.session, NavigationController = ref.NavigationController, Menu = ref.Menu; +let slice = [].slice; +let nextId = 0; -binding = process.atomBinding('web_contents'); - -nextId = 0; - -getNextId = function() { +let getNextId = function() { return ++nextId; }; -PDFPageSize = { +let PDFPageSize = { A5: { custom_display_name: "A5", height_microns: 210000, @@ -64,7 +65,7 @@ const webFrameMethods = [ 'setZoomLevelLimits', ]; -wrapWebContents = function(webContents) { +let wrapWebContents = function(webContents) { // webContents is an EventEmitter. var controller, method, name, ref1; webContents.__proto__ = EventEmitter.prototype; diff --git a/atom/browser/lib/chrome-extension.js b/atom/browser/lib/chrome-extension.js index 44e7f947e391..32459c3a20e2 100644 --- a/atom/browser/lib/chrome-extension.js +++ b/atom/browser/lib/chrome-extension.js @@ -1,33 +1,28 @@ -var app, electron, extensionInfoMap, fs, getExtensionInfoFromPath, getHostForPath, getPathForHost, hostPathMap, hostPathMapNextKey, loadedExtensions, loadedExtensionsPath, path, url; - -electron = require('electron'); - -fs = require('fs'); - -path = require('path'); - -url = require('url'); +const electron = require('electron'); +const app = electron.app; +const fs = require('fs'); +const path = require('path'); +const url = require('url'); // Mapping between hostname and file path. -hostPathMap = {}; +var hostPathMap = {}; +var hostPathMapNextKey = 0; -hostPathMapNextKey = 0; - -getHostForPath = function(path) { +var getHostForPath = function(path) { var key; key = "extension-" + (++hostPathMapNextKey); hostPathMap[key] = path; return key; }; -getPathForHost = function(host) { +var getPathForHost = function(host) { return hostPathMap[host]; }; // Cache extensionInfo. -extensionInfoMap = {}; +var extensionInfoMap = {}; -getExtensionInfoFromPath = function(srcDirectory) { +var getExtensionInfoFromPath = function(srcDirectory) { var manifest, page; manifest = JSON.parse(fs.readFileSync(path.join(srcDirectory, 'manifest.json'))); if (extensionInfoMap[manifest.name] == null) { @@ -51,11 +46,8 @@ getExtensionInfoFromPath = function(srcDirectory) { }; // The loaded extensions cache and its persistent path. -loadedExtensions = null; -loadedExtensionsPath = null; - -// Persistent loaded extensions. -app = electron.app; +var loadedExtensions = null; +var loadedExtensionsPath = null; app.on('will-quit', function() { var e, error1, error2; From 177970144522f2be863c3839627beafe5ec28090 Mon Sep 17 00:00:00 2001 From: Jessica Lord Date: Thu, 14 Jan 2016 13:21:11 -0800 Subject: [PATCH 3/8] Use `const` --- atom/browser/lib/desktop-capturer.js | 11 +++--- atom/browser/lib/guest-view-manager.js | 31 ++++++++--------- atom/browser/lib/guest-window-manager.js | 19 +++++------ atom/browser/lib/init.js | 41 ++++++++++------------ atom/browser/lib/objects-registry.js | 12 +++---- atom/browser/lib/rpc-server.js | 30 +++++++---------- atom/common/api/lib/crash-reporter.js | 25 +++++--------- atom/common/api/lib/exports/electron.js | 3 +- atom/common/api/lib/native-image.js | 7 ++-- atom/common/lib/asar.js | 43 +++++++++++------------- 10 files changed, 92 insertions(+), 130 deletions(-) diff --git a/atom/browser/lib/desktop-capturer.js b/atom/browser/lib/desktop-capturer.js index 638d87c3af32..da649df1ce0c 100644 --- a/atom/browser/lib/desktop-capturer.js +++ b/atom/browser/lib/desktop-capturer.js @@ -1,15 +1,12 @@ -var deepEqual, desktopCapturer, ipcMain, requestsQueue; +const ipcMain = require('electron').ipcMain; +const desktopCapturer = process.atomBinding('desktop_capturer').desktopCapturer; -ipcMain = require('electron').ipcMain; - -desktopCapturer = process.atomBinding('desktop_capturer').desktopCapturer; - -deepEqual = function(opt1, opt2) { +var deepEqual = function(opt1, opt2) { return JSON.stringify(opt1) === JSON.stringify(opt2); }; // A queue for holding all requests from renderer process. -requestsQueue = []; +var requestsQueue = []; ipcMain.on('ATOM_BROWSER_DESKTOP_CAPTURER_GET_SOURCES', function(event, captureWindow, captureScreen, thumbnailSize, id) { var request; diff --git a/atom/browser/lib/guest-view-manager.js b/atom/browser/lib/guest-view-manager.js index a07803069966..bf92cf80706c 100644 --- a/atom/browser/lib/guest-view-manager.js +++ b/atom/browser/lib/guest-view-manager.js @@ -1,33 +1,30 @@ -var attachGuest, createGuest, destroyGuest, embedderElementsMap, getNextInstanceId, guestInstances, ipcMain, moveLastToFirst, nextInstanceId, ref, reverseEmbedderElementsMap, supportedWebViewEvents, webContents, webViewManager, - slice = [].slice; +const ipcMain = require('electron').ipcMain; +const webContents = require('electron').webContents; -ref = require('electron'), ipcMain = ref.ipcMain, webContents = ref.webContents; +var slice = [].slice; // Doesn't exist in early initialization. -webViewManager = null; +var webViewManager = null; -supportedWebViewEvents = ['load-commit', 'did-finish-load', 'did-fail-load', 'did-frame-finish-load', 'did-start-loading', 'did-stop-loading', 'did-get-response-details', 'did-get-redirect-request', 'dom-ready', 'console-message', 'devtools-opened', 'devtools-closed', 'devtools-focused', 'new-window', 'will-navigate', 'did-navigate', 'did-navigate-in-page', 'close', 'crashed', 'gpu-crashed', 'plugin-crashed', 'destroyed', 'page-title-updated', 'page-favicon-updated', 'enter-html-full-screen', 'leave-html-full-screen', 'media-started-playing', 'media-paused', 'found-in-page', 'did-change-theme-color']; +var supportedWebViewEvents = ['load-commit', 'did-finish-load', 'did-fail-load', 'did-frame-finish-load', 'did-start-loading', 'did-stop-loading', 'did-get-response-details', 'did-get-redirect-request', 'dom-ready', 'console-message', 'devtools-opened', 'devtools-closed', 'devtools-focused', 'new-window', 'will-navigate', 'did-navigate', 'did-navigate-in-page', 'close', 'crashed', 'gpu-crashed', 'plugin-crashed', 'destroyed', 'page-title-updated', 'page-favicon-updated', 'enter-html-full-screen', 'leave-html-full-screen', 'media-started-playing', 'media-paused', 'found-in-page', 'did-change-theme-color']; -nextInstanceId = 0; - -guestInstances = {}; - -embedderElementsMap = {}; - -reverseEmbedderElementsMap = {}; +var nextInstanceId = 0; +var guestInstances = {}; +var embedderElementsMap = {}; +var reverseEmbedderElementsMap = {}; // Moves the last element of array to the first one. -moveLastToFirst = function(list) { +var moveLastToFirst = function(list) { return list.unshift(list.pop()); }; // Generate guestInstanceId. -getNextInstanceId = function(webContents) { +var getNextInstanceId = function(webContents) { return ++nextInstanceId; }; // Create a new guest instance. -createGuest = function(embedder, params) { +var createGuest = function(embedder, params) { var destroy, destroyEvents, event, fn, guest, i, id, j, len, len1, listeners; if (webViewManager == null) { webViewManager = process.atomBinding('web_view_manager'); @@ -139,7 +136,7 @@ createGuest = function(embedder, params) { }; // Attach the guest to an element of embedder. -attachGuest = function(embedder, elementInstanceId, guestInstanceId, params) { +var attachGuest = function(embedder, elementInstanceId, guestInstanceId, params) { var guest, key, oldGuestInstanceId, ref1, webPreferences; guest = guestInstances[guestInstanceId].guest; @@ -173,7 +170,7 @@ attachGuest = function(embedder, elementInstanceId, guestInstanceId, params) { }; // Destroy an existing guest instance. -destroyGuest = function(embedder, id) { +var destroyGuest = function(embedder, id) { var key; webViewManager.removeGuest(embedder, id); guestInstances[id].guest.destroy(); diff --git a/atom/browser/lib/guest-window-manager.js b/atom/browser/lib/guest-window-manager.js index f57b8eb1327e..152167cccc0c 100644 --- a/atom/browser/lib/guest-window-manager.js +++ b/atom/browser/lib/guest-window-manager.js @@ -1,15 +1,14 @@ -var BrowserWindow, createGuest, frameToGuest, ipcMain, mergeBrowserWindowOptions, mergeOptions, ref, v8Util, - hasProp = {}.hasOwnProperty, - slice = [].slice; +const ipcMain = require('electron').ipcMain; +const BrowserWindow = require('electron').BrowserWindow; -ref = require('electron'), ipcMain = ref.ipcMain, BrowserWindow = ref.BrowserWindow; +const v8Util = process.atomBinding('v8_util'); -v8Util = process.atomBinding('v8_util'); - -frameToGuest = {}; +var hasProp = {}.hasOwnProperty; +var slice = [].slice; +var frameToGuest = {}; // Copy attribute of |parent| to |child| if it is not defined in |child|. -mergeOptions = function(child, parent) { +var mergeOptions = function(child, parent) { var key, value; for (key in parent) { if (!hasProp.call(parent, key)) continue; @@ -26,7 +25,7 @@ mergeOptions = function(child, parent) { }; // Merge |options| with the |embedder|'s window's options. -mergeBrowserWindowOptions = function(embedder, options) { +var mergeBrowserWindowOptions = function(embedder, options) { if (embedder.browserWindowOptions != null) { // Inherit the original options if it is a BrowserWindow. @@ -43,7 +42,7 @@ mergeBrowserWindowOptions = function(embedder, options) { }; // Create a new guest created by |embedder| with |options|. -createGuest = function(embedder, url, frameName, options) { +var createGuest = function(embedder, url, frameName, options) { var closedByEmbedder, closedByUser, guest, guestId, ref1; guest = frameToGuest[frameName]; if (frameName && (guest != null)) { diff --git a/atom/browser/lib/init.js b/atom/browser/lib/init.js index 03e4c9c18718..a38cd6f9e41f 100644 --- a/atom/browser/lib/init.js +++ b/atom/browser/lib/init.js @@ -1,13 +1,9 @@ -var Module, Readable, app, consoleLog, e, error1, fs, globalPaths, i, len, mainStartupScript, packageJson, packagePath, path, searchPaths, stdin, streamWrite, util, - slice = [].slice; +const fs = require('fs'); +const path = require('path'); +const util = require('util'); +const Module = require('module'); -fs = require('fs'); - -path = require('path'); - -util = require('util'); - -Module = require('module'); +var slice = [].slice; // We modified the original process.argv to let node.js load the atom.js, // we need to restore it here. @@ -19,7 +15,7 @@ require(path.resolve(__dirname, '..', '..', 'common', 'lib', 'reset-search-paths // Import common settings. require(path.resolve(__dirname, '..', '..', 'common', 'lib', 'init')); -globalPaths = Module.globalPaths; +var globalPaths = Module.globalPaths; if (!process.env.ELECTRON_HIDE_INTERNAL_MODULES) { globalPaths.push(path.resolve(__dirname, '..', 'api', 'lib')); @@ -31,12 +27,12 @@ globalPaths.push(path.resolve(__dirname, '..', 'api', 'lib', 'exports')); if (process.platform === 'win32') { // Redirect node's console to use our own implementations, since node can not // handle console output when running as GUI program. - consoleLog = function() { + var consoleLog = function() { var args; args = 1 <= arguments.length ? slice.call(arguments, 0) : []; return process.log(util.format.apply(util, args) + "\n"); }; - streamWrite = function(chunk, encoding, callback) { + var streamWrite = function(chunk, encoding, callback) { if (Buffer.isBuffer(chunk)) { chunk = chunk.toString(encoding); } @@ -50,8 +46,8 @@ if (process.platform === 'win32') { process.stdout.write = process.stderr.write = streamWrite; // Always returns EOF for stdin stream. - Readable = require('stream').Readable; - stdin = new Readable; + var Readable = require('stream').Readable; + var stdin = new Readable; stdin.push(null); process.__defineGetter__('stdin', function() { return stdin; @@ -75,7 +71,7 @@ process.on('uncaughtException', function(error) { }); // Emit 'exit' event on quit. -app = require('electron').app; +var app = require('electron').app; app.on('quit', function(event, exitCode) { return process.emit('exit', exitCode); @@ -92,20 +88,17 @@ require('./guest-view-manager'); require('./guest-window-manager'); - // Now we try to load app's package.json. -packageJson = null; - -searchPaths = ['app', 'app.asar', 'default_app']; - +var packageJson = null; +var searchPaths = ['app', 'app.asar', 'default_app']; +var i, len; for (i = 0, len = searchPaths.length; i < len; i++) { - packagePath = searchPaths[i]; + var packagePath = searchPaths[i]; try { packagePath = path.join(process.resourcesPath, packagePath); packageJson = JSON.parse(fs.readFileSync(path.join(packagePath, 'package.json'))); break; - } catch (error1) { - e = error1; + } catch (error) { continue; } } @@ -153,7 +146,7 @@ require('./chrome-extension'); require('./desktop-capturer'); // Set main startup script of the app. -mainStartupScript = packageJson.main || 'index.js'; +var mainStartupScript = packageJson.main || 'index.js'; // Finally load app's main.js and transfer control to C++. Module._load(path.join(packagePath, mainStartupScript), Module, true); diff --git a/atom/browser/lib/objects-registry.js b/atom/browser/lib/objects-registry.js index a468c89219cc..953b2f47c9fd 100644 --- a/atom/browser/lib/objects-registry.js +++ b/atom/browser/lib/objects-registry.js @@ -1,12 +1,10 @@ -var EventEmitter, ObjectsRegistry, v8Util, - extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - hasProp = {}.hasOwnProperty; +const EventEmitter = require('events').EventEmitter; +const v8Util = process.atomBinding('v8_util'); -EventEmitter = require('events').EventEmitter; +var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; +var hasProp = {}.hasOwnProperty; -v8Util = process.atomBinding('v8_util'); - -ObjectsRegistry = (function(superClass) { +var ObjectsRegistry = (function(superClass) { extend(ObjectsRegistry, superClass); function ObjectsRegistry() { diff --git a/atom/browser/lib/rpc-server.js b/atom/browser/lib/rpc-server.js index a8add74e0321..346db74f6ecd 100644 --- a/atom/browser/lib/rpc-server.js +++ b/atom/browser/lib/rpc-server.js @@ -1,20 +1,14 @@ -var IDWeakMap, callFunction, electron, exceptionToMeta, ipcMain, objectsRegistry, path, plainObjectToMeta, unwrapArgs, v8Util, valueToMeta, - slice = [].slice; +const path = require('path'); +const electron = require('electron'); +const ipcMain = electron.ipcMain; +const objectsRegistry = require('./objects-registry'); +const v8Util = process.atomBinding('v8_util'); +const IDWeakMap = process.atomBinding('id_weak_map').IDWeakMap; -path = require('path'); - -electron = require('electron'); - -ipcMain = electron.ipcMain; - -objectsRegistry = require('./objects-registry'); - -v8Util = process.atomBinding('v8_util'); - -IDWeakMap = process.atomBinding('id_weak_map').IDWeakMap; +var slice = [].slice; // Convert a real value into meta data. -valueToMeta = function(sender, value, optimizeSimpleObject) { +var valueToMeta = function(sender, value, optimizeSimpleObject) { var el, field, i, len, meta, name; if (optimizeSimpleObject == null) { optimizeSimpleObject = false; @@ -97,7 +91,7 @@ valueToMeta = function(sender, value, optimizeSimpleObject) { }; // Convert object to meta by value. -plainObjectToMeta = function(obj) { +var plainObjectToMeta = function(obj) { return Object.getOwnPropertyNames(obj).map(function(name) { return { name: name, @@ -107,7 +101,7 @@ plainObjectToMeta = function(obj) { }; // Convert Error into meta data. -exceptionToMeta = function(error) { +var exceptionToMeta = function(error) { return { type: 'exception', message: error.message, @@ -116,7 +110,7 @@ exceptionToMeta = function(error) { }; // Convert array of meta data from renderer into array of real values. -unwrapArgs = function(sender, args) { +var unwrapArgs = function(sender, args) { var metaToValue; metaToValue = function(meta) { var i, len, member, ref, rendererReleased, ret, returnValue; @@ -187,7 +181,7 @@ unwrapArgs = function(sender, args) { // Call a function and send reply asynchronously if it's a an asynchronous // style function and the caller didn't pass a callback. -callFunction = function(event, func, caller, args) { +var callFunction = function(event, func, caller, args) { var e, error1, funcMarkedAsync, funcName, funcPassedCallback, ref, ret; funcMarkedAsync = v8Util.getHiddenValue(func, 'asynchronous'); funcPassedCallback = typeof args[args.length - 1] === 'function'; diff --git a/atom/common/api/lib/crash-reporter.js b/atom/common/api/lib/crash-reporter.js index 57cde40f8507..8a3de9eaa14d 100644 --- a/atom/common/api/lib/crash-reporter.js +++ b/atom/common/api/lib/crash-reporter.js @@ -1,18 +1,11 @@ -var CrashReporter, binding, crashRepoter, electron, fs, os, path, spawn; +const fs = require('fs'); +const os = require('os'); +const path = require('path'); +const spawn = require('child_process').spawn; +const electron = require('electron'); +const binding = process.atomBinding('crash_reporter'); -fs = require('fs'); - -os = require('os'); - -path = require('path'); - -spawn = require('child_process').spawn; - -electron = require('electron'); - -binding = process.atomBinding('crash_reporter'); - -CrashReporter = (function() { +var CrashReporter = (function() { function CrashReporter() {} CrashReporter.prototype.start = function(options) { @@ -99,6 +92,4 @@ CrashReporter = (function() { })(); -crashRepoter = new CrashReporter; - -module.exports = crashRepoter; +module.exports = new CrashReporter; diff --git a/atom/common/api/lib/exports/electron.js b/atom/common/api/lib/exports/electron.js index 178b2d1046bc..5b93d286da61 100644 --- a/atom/common/api/lib/exports/electron.js +++ b/atom/common/api/lib/exports/electron.js @@ -1,7 +1,6 @@ // Do not expose the internal modules to `require`. exports.hideInternalModules = function() { - var globalPaths; - globalPaths = require('module').globalPaths; + var globalPaths = require('module').globalPaths; if (globalPaths.length === 3) { // Remove the "common/api/lib" and "browser-or-renderer/api/lib". diff --git a/atom/common/api/lib/native-image.js b/atom/common/api/lib/native-image.js index 1546cfaa7e6d..6f9a9bd7d542 100644 --- a/atom/common/api/lib/native-image.js +++ b/atom/common/api/lib/native-image.js @@ -1,8 +1,5 @@ -var deprecate, nativeImage; - -deprecate = require('electron').deprecate; - -nativeImage = process.atomBinding('native_image'); +const deprecate = require('electron').deprecate; +const nativeImage = process.atomBinding('native_image'); // Deprecated. deprecate.rename(nativeImage, 'createFromDataUrl', 'createFromDataURL'); diff --git a/atom/common/lib/asar.js b/atom/common/lib/asar.js index 82a5139ee67e..6c8aa64e024a 100644 --- a/atom/common/lib/asar.js +++ b/atom/common/lib/asar.js @@ -1,19 +1,15 @@ (function () { -var asar, asarStatsToFsStats, cachedArchives, child_process, fakeTime, getOrCreateArchive, gid, invalidArchiveError, nextInode, notDirError, notFoundError, overrideAPI, overrideAPISync, path, splitPath, uid, util, - hasProp = {}.hasOwnProperty; +const asar = process.binding('atom_common_asar'); +const child_process = require('child_process'); +const path = require('path'); +const util = require('util'); -asar = process.binding('atom_common_asar'); - -child_process = require('child_process'); - -path = require('path'); - -util = require('util'); +var hasProp = {}.hasOwnProperty; // Cache asar archive objects. -cachedArchives = {}; +var cachedArchives = {}; -getOrCreateArchive = function(p) { +var getOrCreateArchive = function(p) { var archive; archive = cachedArchives[p]; if (archive != null) { @@ -39,13 +35,14 @@ process.on('exit', function() { }); // Separate asar package's path from full path. -splitPath = function(p) { +var splitPath = function(p) { + var index; // shortcut to disable asar. - var index; if (process.noAsar) { return [false]; } + if (typeof p !== 'string') { return [false]; } @@ -61,15 +58,15 @@ splitPath = function(p) { }; // Convert asar archive's Stats object to fs's Stats object. -nextInode = 0; +var nextInode = 0; -uid = process.getuid != null ? process.getuid() : 0; +var uid = process.getuid != null ? process.getuid() : 0; -gid = process.getgid != null ? process.getgid() : 0; +var gid = process.getgid != null ? process.getgid() : 0; -fakeTime = new Date(); +var fakeTime = new Date(); -asarStatsToFsStats = function(stats) { +var asarStatsToFsStats = function(stats) { return { dev: 1, ino: ++nextInode, @@ -108,7 +105,7 @@ asarStatsToFsStats = function(stats) { }; // Create a ENOENT error. -notFoundError = function(asarPath, filePath, callback) { +var notFoundError = function(asarPath, filePath, callback) { var error; error = new Error("ENOENT, " + filePath + " not found in " + asarPath); error.code = "ENOENT"; @@ -122,7 +119,7 @@ notFoundError = function(asarPath, filePath, callback) { }; // Create a ENOTDIR error. -notDirError = function(callback) { +var notDirError = function(callback) { var error; error = new Error('ENOTDIR, not a directory'); error.code = 'ENOTDIR'; @@ -136,7 +133,7 @@ notDirError = function(callback) { }; // Create invalid archive error. -invalidArchiveError = function(asarPath, callback) { +var invalidArchiveError = function(asarPath, callback) { var error; error = new Error("Invalid package " + asarPath); if (typeof callback !== 'function') { @@ -148,7 +145,7 @@ invalidArchiveError = function(asarPath, callback) { }; // Override APIs that rely on passing file path instead of content to C++. -overrideAPISync = function(module, name, arg) { +var overrideAPISync = function(module, name, arg) { var old; if (arg == null) { arg = 0; @@ -174,7 +171,7 @@ overrideAPISync = function(module, name, arg) { }; }; -overrideAPI = function(module, name, arg) { +var overrideAPI = function(module, name, arg) { var old; if (arg == null) { arg = 0; From ab8908a4afb0655913a244b915f7316852d16fdc Mon Sep 17 00:00:00 2001 From: Jessica Lord Date: Thu, 14 Jan 2016 14:11:50 -0800 Subject: [PATCH 4/8] Use `const` --- atom/common/lib/init.js | 15 +++++---------- atom/common/lib/reset-search-paths.js | 7 ++----- atom/renderer/api/lib/desktop-capturer.js | 13 ++++++------- atom/renderer/api/lib/exports/electron.js | 4 +--- atom/renderer/api/lib/ipc-renderer.js | 13 +++++-------- atom/renderer/lib/chrome-api.js | 7 ++----- atom/renderer/lib/inspector.js | 19 ++++++++----------- 7 files changed, 29 insertions(+), 49 deletions(-) diff --git a/atom/common/lib/init.js b/atom/common/lib/init.js index 2165603e87e6..76fe1b45820a 100644 --- a/atom/common/lib/init.js +++ b/atom/common/lib/init.js @@ -1,12 +1,7 @@ -var Module, fs, path, timers, wrapWithActivateUvLoop; - -fs = require('fs'); - -path = require('path'); - -timers = require('timers'); - -Module = require('module'); +const fs = require('fs'); +const path = require('path'); +const timers = require('timers'); +const Module = require('module'); process.atomBinding = function(name) { var e, error; @@ -32,7 +27,7 @@ if (!process.env.ELECTRON_HIDE_INTERNAL_MODULES) { // which would delay the callbacks for arbitrary long time. So we should // initiatively activate the uv loop once setImmediate and process.nextTick is // called. -wrapWithActivateUvLoop = function(func) { +var wrapWithActivateUvLoop = function(func) { return function() { process.activateUvLoop(); return func.apply(this, arguments); diff --git a/atom/common/lib/reset-search-paths.js b/atom/common/lib/reset-search-paths.js index a996cd4ceca8..abf671196735 100644 --- a/atom/common/lib/reset-search-paths.js +++ b/atom/common/lib/reset-search-paths.js @@ -1,8 +1,5 @@ -var Module, path; - -path = require('path'); - -Module = require('module'); +const path = require('path'); +const Module = require('module'); // Clear Node's global search paths. Module.globalPaths.length = 0; diff --git a/atom/renderer/api/lib/desktop-capturer.js b/atom/renderer/api/lib/desktop-capturer.js index 5b44bdf5f23e..f9b7ca393d86 100644 --- a/atom/renderer/api/lib/desktop-capturer.js +++ b/atom/renderer/api/lib/desktop-capturer.js @@ -1,16 +1,15 @@ -var getNextId, ipcRenderer, isValid, nativeImage, nextId, ref, - indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; +const ipcRenderer = require('electron').ipcRenderer; +const nativeImage = require('electron').ref.nativeImage; -ref = require('electron'), ipcRenderer = ref.ipcRenderer, nativeImage = ref.nativeImage; +var nextId = 0; +var indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; -nextId = 0; - -getNextId = function() { +var getNextId = function() { return ++nextId; }; // |options.type| can not be empty and has to include 'window' or 'screen'. -isValid = function(options) { +var isValid = function(options) { return ((options != null ? options.types : void 0) != null) && Array.isArray(options.types); }; diff --git a/atom/renderer/api/lib/exports/electron.js b/atom/renderer/api/lib/exports/electron.js index e3fe7b335317..3f0d3254cb8b 100644 --- a/atom/renderer/api/lib/exports/electron.js +++ b/atom/renderer/api/lib/exports/electron.js @@ -1,6 +1,4 @@ -var common; - -common = require('../../../../common/api/lib/exports/electron'); +const common = require('../../../../common/api/lib/exports/electron'); // Import common modules. common.defineProperties(exports); diff --git a/atom/renderer/api/lib/ipc-renderer.js b/atom/renderer/api/lib/ipc-renderer.js index cd6b37c3db45..5b3c0a4eb788 100644 --- a/atom/renderer/api/lib/ipc-renderer.js +++ b/atom/renderer/api/lib/ipc-renderer.js @@ -1,14 +1,11 @@ -var EventEmitter, binding, ipcRenderer, v8Util, - slice = [].slice; +const EventEmitter = require('events').EventEmitter; +const binding = process.atomBinding('ipc'); +const v8Util = process.atomBinding('v8_util'); -EventEmitter = require('events').EventEmitter; - -binding = process.atomBinding('ipc'); - -v8Util = process.atomBinding('v8_util'); +var slice = [].slice; // Created by init.coffee. -ipcRenderer = v8Util.getHiddenValue(global, 'ipc'); +const ipcRenderer = v8Util.getHiddenValue(global, 'ipc'); ipcRenderer.send = function() { var args; diff --git a/atom/renderer/lib/chrome-api.js b/atom/renderer/lib/chrome-api.js index 535f7f2103b5..7ff7d2e87b99 100644 --- a/atom/renderer/lib/chrome-api.js +++ b/atom/renderer/lib/chrome-api.js @@ -1,8 +1,5 @@ -var chrome, url; - -url = require('url'); - -chrome = window.chrome = window.chrome || {}; +const url = require('url'); +const chrome = window.chrome = window.chrome || {}; chrome.extension = { getURL: function(path) { diff --git a/atom/renderer/lib/inspector.js b/atom/renderer/lib/inspector.js index b37e1d3de905..9ef6440720ff 100644 --- a/atom/renderer/lib/inspector.js +++ b/atom/renderer/lib/inspector.js @@ -1,5 +1,3 @@ -var convertToMenuTemplate, createFileSelectorElement, createMenu, pathToHtml5FileObject, showFileChooserDialog; - window.onload = function() { // Use menu API to show context menu. InspectorFrontendHost.showContextMenuAtPoint = createMenu; @@ -8,7 +6,7 @@ window.onload = function() { return WebInspector.createFileSelectorElement = createFileSelectorElement; }; -convertToMenuTemplate = function(items) { +var convertToMenuTemplate = function(items) { var fn, i, item, len, template; template = []; fn = function(item) { @@ -45,11 +43,10 @@ convertToMenuTemplate = function(items) { return template; }; -createMenu = function(x, y, items, document) { - var Menu, menu, remote; - remote = require('electron').remote; - Menu = remote.Menu; - menu = Menu.buildFromTemplate(convertToMenuTemplate(items)); +var createMenu = function(x, y, items, document) { + const remote = require('electron').remote; + const Menu = remote.Menu; + const menu = Menu.buildFromTemplate(convertToMenuTemplate(items)); // The menu is expected to show asynchronously. return setTimeout(function() { @@ -57,7 +54,7 @@ createMenu = function(x, y, items, document) { }); }; -showFileChooserDialog = function(callback) { +var showFileChooserDialog = function(callback) { var dialog, files, remote; remote = require('electron').remote; dialog = remote.dialog; @@ -67,7 +64,7 @@ showFileChooserDialog = function(callback) { } }; -pathToHtml5FileObject = function(path) { +var pathToHtml5FileObject = function(path) { var blob, fs; fs = require('fs'); blob = new Blob([fs.readFileSync(path)]); @@ -75,7 +72,7 @@ pathToHtml5FileObject = function(path) { return blob; }; -createFileSelectorElement = function(callback) { +var createFileSelectorElement = function(callback) { var fileSelectorElement; fileSelectorElement = document.createElement('span'); fileSelectorElement.style.display = 'none'; From 5412ecdcc18d2f42bf55465fde7fcea01ab32671 Mon Sep 17 00:00:00 2001 From: Jessica Lord Date: Thu, 14 Jan 2016 14:20:06 -0800 Subject: [PATCH 5/8] Use `const` --- atom/renderer/api/lib/ipc.js | 13 +++--- atom/renderer/api/lib/remote.js | 42 +++++++++---------- atom/renderer/lib/init.js | 30 ++++++------- atom/renderer/lib/override.js | 16 +++---- .../lib/web-view/guest-view-internal.js | 15 ++++--- .../lib/web-view/web-view-attributes.js | 39 ++++++++--------- atom/renderer/lib/web-view/web-view.js | 32 +++++++------- 7 files changed, 87 insertions(+), 100 deletions(-) diff --git a/atom/renderer/api/lib/ipc.js b/atom/renderer/api/lib/ipc.js index 1e0e703e6a84..e58cd0273c2b 100644 --- a/atom/renderer/api/lib/ipc.js +++ b/atom/renderer/api/lib/ipc.js @@ -1,15 +1,14 @@ -var EventEmitter, deprecate, ipc, ipcRenderer, method, ref, - slice = [].slice; +const ipcRenderer = require('electron').ipcRenderer; +const deprecate = require('electron').deprecate; +const EventEmitter = require('events').EventEmitter; -ref = require('electron'), ipcRenderer = ref.ipcRenderer, deprecate = ref.deprecate; - -EventEmitter = require('events').EventEmitter; +var slice = [].slice; // This module is deprecated, we mirror everything from ipcRenderer. deprecate.warn('ipc module', 'require("electron").ipcRenderer'); // Routes events of ipcRenderer. -ipc = new EventEmitter; +var ipc = new EventEmitter; ipcRenderer.emit = function() { var args, channel, event; @@ -19,7 +18,7 @@ ipcRenderer.emit = function() { }; // Deprecated. -for (method in ipcRenderer) { +for (var method in ipcRenderer) { if (method.startsWith('send')) { ipc[method] = ipcRenderer[method]; } diff --git a/atom/renderer/api/lib/remote.js b/atom/renderer/api/lib/remote.js index f50fca7a2d4a..c9b823b3b397 100644 --- a/atom/renderer/api/lib/remote.js +++ b/atom/renderer/api/lib/remote.js @@ -1,14 +1,13 @@ -var CallbacksRegistry, browserModules, builtinCache, callbacksRegistry, createRemoteMemberFunction, createRemoteMemberProperty, fn, ipcRenderer, isCircular, metaToPlainObject, metaToValue, moduleCache, name, processCache, ref, v8Util, webContentsCache, windowCache, wrapArgs, - indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; +const ipcRenderer = require('electron').ipcRenderer; +const CallbacksRegistry = require('electron').CallbacksRegistry; +const v8Util = process.atomBinding('v8_util'); -ref = require('electron'), ipcRenderer = ref.ipcRenderer, CallbacksRegistry = ref.CallbacksRegistry; +const callbacksRegistry = new CallbacksRegistry; -v8Util = process.atomBinding('v8_util'); - -callbacksRegistry = new CallbacksRegistry; +var indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; // Check for circular reference. -isCircular = function(field, visited) { +var isCircular = function(field, visited) { if (typeof field === 'object') { if (indexOf.call(visited, field) >= 0) { return true; @@ -19,7 +18,7 @@ isCircular = function(field, visited) { }; // Convert the arguments object into an array of meta data. -wrapArgs = function(args, visited) { +var wrapArgs = function(args, visited) { var valueToMeta; if (visited == null) { visited = []; @@ -87,7 +86,7 @@ wrapArgs = function(args, visited) { }; // Convert meta data from browser into real value. -metaToValue = function(meta) { +var metaToValue = function(meta) { var RemoteFunction, el, i, j, len, len1, member, ref1, ref2, results, ret; switch (meta.type) { case 'value': @@ -169,7 +168,7 @@ metaToValue = function(meta) { }; // Construct a plain object from the meta. -metaToPlainObject = function(meta) { +var metaToPlainObject = function(meta) { var i, len, name, obj, ref1, ref2, value; obj = (function() { switch (meta.type) { @@ -190,7 +189,7 @@ metaToPlainObject = function(meta) { // Create a RemoteMemberFunction instance. // This function's content should not be inlined into metaToValue, otherwise V8 // may consider it circular reference. -createRemoteMemberFunction = function(metaId, name) { +var createRemoteMemberFunction = function(metaId, name) { var RemoteMemberFunction; return RemoteMemberFunction = (function() { function RemoteMemberFunction() { @@ -216,7 +215,7 @@ createRemoteMemberFunction = function(metaId, name) { // Create configuration for defineProperty. // This function's content should not be inlined into metaToValue, otherwise V8 // may consider it circular reference. -createRemoteMemberProperty = function(metaId, name) { +var createRemoteMemberProperty = function(metaId, name) { return { enumerable: true, configurable: false, @@ -245,25 +244,24 @@ ipcRenderer.on('ATOM_RENDERER_RELEASE_CALLBACK', function(event, id) { }); // List all built-in modules in browser process. -browserModules = require('../../../browser/api/lib/exports/electron'); +const browserModules = require('../../../browser/api/lib/exports/electron'); // And add a helper receiver for each one. -fn = function(name) { +var fn = function(name) { return Object.defineProperty(exports, name, { get: function() { return exports.getBuiltin(name); } }); }; -for (name in browserModules) { +for (var name in browserModules) { fn(name); } - // Get remote module. // (Just like node's require, the modules are cached permanently, note that this // is safe leak since the object is not expected to get freed in browser) -moduleCache = {}; +var moduleCache = {}; exports.require = function(module) { var meta; @@ -274,13 +272,11 @@ exports.require = function(module) { return moduleCache[module] = metaToValue(meta); }; - // Optimize require('electron'). moduleCache.electron = exports; - // Alias to remote.require('electron').xxx. -builtinCache = {}; +var builtinCache = {}; exports.getBuiltin = function(module) { var meta; @@ -292,7 +288,7 @@ exports.getBuiltin = function(module) { }; // Get current BrowserWindow object. -windowCache = null; +var windowCache = null; exports.getCurrentWindow = function() { var meta; @@ -304,7 +300,7 @@ exports.getCurrentWindow = function() { }; // Get current WebContents object. -webContentsCache = null; +var webContentsCache = null; exports.getCurrentWebContents = function() { var meta; @@ -323,7 +319,7 @@ exports.getGlobal = function(name) { }; // Get the process object in browser. -processCache = null; +var processCache = null; exports.__defineGetter__('process', function() { if (processCache == null) { diff --git a/atom/renderer/lib/init.js b/atom/renderer/lib/init.js index 8fd0d2e25e71..297ee61fcff2 100644 --- a/atom/renderer/lib/init.js +++ b/atom/renderer/lib/init.js @@ -1,14 +1,9 @@ 'user strict'; -var Module, arg, error, error1, events, globalPaths, i, len, nodeIntegration, path, pathname, preloadScript, ref, url, v8Util; - -events = require('events'); - -path = require('path'); - -url = require('url'); - -Module = require('module'); +const events = require('events'); +const path = require('path'); +const url = require('url'); +const Module = require('module'); // We modified the original process.argv to let node.js load the @@ -23,7 +18,7 @@ require(path.resolve(__dirname, '..', '..', 'common', 'lib', 'reset-search-paths // Import common settings. require(path.resolve(__dirname, '..', '..', 'common', 'lib', 'init')); -globalPaths = Module.globalPaths; +var globalPaths = Module.globalPaths; if (!process.env.ELECTRON_HIDE_INTERNAL_MODULES) { globalPaths.push(path.resolve(__dirname, '..', 'api', 'lib')); @@ -33,7 +28,7 @@ if (!process.env.ELECTRON_HIDE_INTERNAL_MODULES) { globalPaths.push(path.resolve(__dirname, '..', 'api', 'lib', 'exports')); // The global variable will be used by ipc for event dispatching -v8Util = process.atomBinding('v8_util'); +var v8Util = process.atomBinding('v8_util'); v8Util.setHiddenValue(global, 'ipc', new events.EventEmitter); @@ -46,11 +41,13 @@ electron.ipcRenderer.on('ELECTRON_INTERNAL_RENDERER_WEB_FRAME_METHOD', (event, m }); // Process command line arguments. -nodeIntegration = 'false'; +var nodeIntegration = 'false'; +var preloadScript = null; -ref = process.argv; +var ref = process.argv; +var i, len; for (i = 0, len = ref.length; i < len; i++) { - arg = ref[i]; + var arg = ref[i]; if (arg.indexOf('--guest-instance-id=') === 0) { // This is a guest web view. process.guestInstanceId = parseInt(arg.substr(arg.indexOf('=') + 1)); @@ -90,7 +87,7 @@ if (nodeIntegration === 'true' || nodeIntegration === 'all' || nodeIntegration = // Set the __filename to the path of html file if it is file: protocol. if (window.location.protocol === 'file:') { - pathname = process.platform === 'win32' && window.location.pathname[0] === '/' ? window.location.pathname.substr(1) : window.location.pathname; + var pathname = process.platform === 'win32' && window.location.pathname[0] === '/' ? window.location.pathname.substr(1) : window.location.pathname; global.__filename = path.normalize(decodeURIComponent(pathname)); global.__dirname = path.dirname(global.__filename); @@ -132,8 +129,7 @@ if (nodeIntegration === 'true' || nodeIntegration === 'all' || nodeIntegration = if (preloadScript) { try { require(preloadScript); - } catch (error1) { - error = error1; + } catch (error) { if (error.code === 'MODULE_NOT_FOUND') { console.error("Unable to load preload script " + preloadScript); } else { diff --git a/atom/renderer/lib/override.js b/atom/renderer/lib/override.js index c240281363b9..6ff1e80785d8 100644 --- a/atom/renderer/lib/override.js +++ b/atom/renderer/lib/override.js @@ -1,18 +1,18 @@ -var BrowserWindowProxy, a, getHistoryOperation, ipcRenderer, ref, remote, resolveURL, sendHistoryOperation, - slice = [].slice; +const ipcRenderer = require('electron').ipcRenderer; +const remote = require('electron').remote; -ref = require('electron'), ipcRenderer = ref.ipcRenderer, remote = ref.remote; +var slice = [].slice; // Helper function to resolve relative url. -a = window.top.document.createElement('a'); +var a = window.top.document.createElement('a'); -resolveURL = function(url) { +var resolveURL = function(url) { a.href = url; return a.href; }; // Window object returned by "window.open". -BrowserWindowProxy = (function() { +var BrowserWindowProxy = (function() { BrowserWindowProxy.proxies = {}; BrowserWindowProxy.getOrCreate = function(guestId) { @@ -180,13 +180,13 @@ ipcRenderer.on('ATOM_SHELL_GUEST_WINDOW_POSTMESSAGE', function(event, sourceId, }); // Forward history operations to browser. -sendHistoryOperation = function() { +var sendHistoryOperation = function() { var args; args = 1 <= arguments.length ? slice.call(arguments, 0) : []; return ipcRenderer.send.apply(ipcRenderer, ['ATOM_SHELL_NAVIGATION_CONTROLLER'].concat(slice.call(args))); }; -getHistoryOperation = function() { +var getHistoryOperation = function() { var args; args = 1 <= arguments.length ? slice.call(arguments, 0) : []; return ipcRenderer.sendSync.apply(ipcRenderer, ['ATOM_SHELL_SYNC_NAVIGATION_CONTROLLER'].concat(slice.call(args))); diff --git a/atom/renderer/lib/web-view/guest-view-internal.js b/atom/renderer/lib/web-view/guest-view-internal.js index 5dd86aff6613..046c9643eadd 100644 --- a/atom/renderer/lib/web-view/guest-view-internal.js +++ b/atom/renderer/lib/web-view/guest-view-internal.js @@ -1,11 +1,10 @@ -var DEPRECATED_EVENTS, WEB_VIEW_EVENTS, dispatchEvent, ipcRenderer, ref, requestId, webFrame, - slice = [].slice; +const ipcRenderer = require('electron').ipcRenderer; +const webFrame = require('electron').webFrame; -ref = require('electron'), ipcRenderer = ref.ipcRenderer, webFrame = ref.webFrame; +var slice = [].slice; +var requestId = 0; -requestId = 0; - -WEB_VIEW_EVENTS = { +var WEB_VIEW_EVENTS = { 'load-commit': ['url', 'isMainFrame'], 'did-finish-load': [], 'did-fail-load': ['errorCode', 'errorDescription', 'validatedURL'], @@ -38,11 +37,11 @@ WEB_VIEW_EVENTS = { 'found-in-page': ['result'] }; -DEPRECATED_EVENTS = { +var DEPRECATED_EVENTS = { 'page-title-updated': 'page-title-set' }; -dispatchEvent = function() { +var dispatchEvent = function() { var args, domEvent, eventKey, eventName, f, i, j, len, ref1, webView; webView = arguments[0], eventName = arguments[1], eventKey = arguments[2], args = 4 <= arguments.length ? slice.call(arguments, 3) : []; if (DEPRECATED_EVENTS[eventName] != null) { diff --git a/atom/renderer/lib/web-view/web-view-attributes.js b/atom/renderer/lib/web-view/web-view-attributes.js index 0352dc5e821d..90ce9f1290fc 100644 --- a/atom/renderer/lib/web-view/web-view-attributes.js +++ b/atom/renderer/lib/web-view/web-view-attributes.js @@ -1,26 +1,23 @@ -var AllowTransparencyAttribute, AutosizeAttribute, AutosizeDimensionAttribute, BooleanAttribute, HttpReferrerAttribute, PartitionAttribute, PreloadAttribute, SrcAttribute, UserAgentAttribute, WebViewAttribute, WebViewImpl, a, guestViewInternal, remote, resolveURL, webViewConstants, - extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - hasProp = {}.hasOwnProperty; +const WebViewImpl = require('./web-view'); +const guestViewInternal = require('./guest-view-internal'); +const webViewConstants = require('./web-view-constants'); +const remote = require('electron').remote; -WebViewImpl = require('./web-view'); +var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; -guestViewInternal = require('./guest-view-internal'); - -webViewConstants = require('./web-view-constants'); - -remote = require('electron').remote; +var hasProp = {}.hasOwnProperty; // Helper function to resolve url set in attribute. -a = document.createElement('a'); +var a = document.createElement('a'); -resolveURL = function(url) { +var resolveURL = function(url) { a.href = url; return a.href; }; // Attribute objects. // Default implementation of a WebView attribute. -WebViewAttribute = (function() { +var WebViewAttribute = (function() { function WebViewAttribute(name, webViewImpl) { this.name = name; this.value = webViewImpl.webviewNode[name] || ''; @@ -71,7 +68,7 @@ WebViewAttribute = (function() { })(); // An attribute that is treated as a Boolean. -BooleanAttribute = (function(superClass) { +var BooleanAttribute = (function(superClass) { extend(BooleanAttribute, superClass); function BooleanAttribute(name, webViewImpl) { @@ -95,7 +92,7 @@ BooleanAttribute = (function(superClass) { })(WebViewAttribute); // Attribute that specifies whether transparency is allowed in the webview. -AllowTransparencyAttribute = (function(superClass) { +var AllowTransparencyAttribute = (function(superClass) { extend(AllowTransparencyAttribute, superClass); function AllowTransparencyAttribute(webViewImpl) { @@ -114,7 +111,7 @@ AllowTransparencyAttribute = (function(superClass) { })(BooleanAttribute); // Attribute used to define the demension limits of autosizing. -AutosizeDimensionAttribute = (function(superClass) { +var AutosizeDimensionAttribute = (function(superClass) { extend(AutosizeDimensionAttribute, superClass); function AutosizeDimensionAttribute(name, webViewImpl) { @@ -147,7 +144,7 @@ AutosizeDimensionAttribute = (function(superClass) { })(WebViewAttribute); // Attribute that specifies whether the webview should be autosized. -AutosizeAttribute = (function(superClass) { +var AutosizeAttribute = (function(superClass) { extend(AutosizeAttribute, superClass); function AutosizeAttribute(webViewImpl) { @@ -161,7 +158,7 @@ AutosizeAttribute = (function(superClass) { })(BooleanAttribute); // Attribute representing the state of the storage partition. -PartitionAttribute = (function(superClass) { +var PartitionAttribute = (function(superClass) { extend(PartitionAttribute, superClass); function PartitionAttribute(webViewImpl) { @@ -189,7 +186,7 @@ PartitionAttribute = (function(superClass) { })(WebViewAttribute); // Attribute that handles the location and navigation of the webview. -SrcAttribute = (function(superClass) { +var SrcAttribute = (function(superClass) { extend(SrcAttribute, superClass); function SrcAttribute(webViewImpl) { @@ -292,7 +289,7 @@ SrcAttribute = (function(superClass) { })(WebViewAttribute); // Attribute specifies HTTP referrer. -HttpReferrerAttribute = (function(superClass) { +var HttpReferrerAttribute = (function(superClass) { extend(HttpReferrerAttribute, superClass); function HttpReferrerAttribute(webViewImpl) { @@ -304,7 +301,7 @@ HttpReferrerAttribute = (function(superClass) { })(WebViewAttribute); // Attribute specifies user agent -UserAgentAttribute = (function(superClass) { +var UserAgentAttribute = (function(superClass) { extend(UserAgentAttribute, superClass); function UserAgentAttribute(webViewImpl) { @@ -316,7 +313,7 @@ UserAgentAttribute = (function(superClass) { })(WebViewAttribute); // Attribute that set preload script. -PreloadAttribute = (function(superClass) { +var PreloadAttribute = (function(superClass) { extend(PreloadAttribute, superClass); function PreloadAttribute(webViewImpl) { diff --git a/atom/renderer/lib/web-view/web-view.js b/atom/renderer/lib/web-view/web-view.js index 07624b79b67a..1daf66e55aa3 100644 --- a/atom/renderer/lib/web-view/web-view.js +++ b/atom/renderer/lib/web-view/web-view.js @@ -1,26 +1,26 @@ 'user strict'; -var WebViewImpl, deprecate, getNextId, guestViewInternal, ipcRenderer, listener, nextId, ref, registerBrowserPluginElement, registerWebViewElement, remote, useCapture, v8Util, webFrame, webViewConstants, - hasProp = {}.hasOwnProperty, - slice = [].slice; +const deprecate = require('electron').deprecate; +const webFrame = require('electron').webFrame; +const remote = require('electron').remote; +const ipcRenderer = require('electron').ipcRenderer; -ref = require('electron'), deprecate = ref.deprecate, webFrame = ref.webFrame, remote = ref.remote, ipcRenderer = ref.ipcRenderer; +const v8Util = process.atomBinding('v8_util'); +const guestViewInternal = require('./guest-view-internal'); +const webViewConstants = require('./web-view-constants'); -v8Util = process.atomBinding('v8_util'); - -guestViewInternal = require('./guest-view-internal'); - -webViewConstants = require('./web-view-constants'); +var hasProp = {}.hasOwnProperty; +var slice = [].slice; // ID generator. -nextId = 0; +var nextId = 0; -getNextId = function() { +var getNextId = function() { return ++nextId; }; // Represents the internal state of the WebView node. -WebViewImpl = (function() { +var WebViewImpl = (function() { function WebViewImpl(webviewNode) { var shadowRoot; this.webviewNode = webviewNode; @@ -274,7 +274,7 @@ WebViewImpl = (function() { })(); // Registers browser plugin custom element. -registerBrowserPluginElement = function() { +var registerBrowserPluginElement = function() { var proto; proto = Object.create(HTMLObjectElement.prototype); proto.createdCallback = function() { @@ -310,7 +310,7 @@ registerBrowserPluginElement = function() { }; // Registers custom element. -registerWebViewElement = function() { +var registerWebViewElement = function() { var createBlockHandler, createNonBlockHandler, i, j, len, len1, m, methods, nonblockMethods, proto; proto = Object.create(HTMLObjectElement.prototype); proto.createdCallback = function() { @@ -444,9 +444,9 @@ registerWebViewElement = function() { return delete proto.attributeChangedCallback; }; -useCapture = true; +var useCapture = true; -listener = function(event) { +var listener = function(event) { if (document.readyState === 'loading') { return; } From ae2893ceaaac64b720bea0dd799524452b918ac8 Mon Sep 17 00:00:00 2001 From: Jessica Lord Date: Thu, 14 Jan 2016 15:44:33 -0800 Subject: [PATCH 6/8] Inline `var` --- atom/browser/api/lib/app.js | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/atom/browser/api/lib/app.js b/atom/browser/api/lib/app.js index bd820127cd9a..bb194be62a01 100644 --- a/atom/browser/api/lib/app.js +++ b/atom/browser/api/lib/app.js @@ -9,14 +9,6 @@ const app = bindings.app; var slice = [].slice; -var appPath; -var fn; -var i; -var len; -var name; -var ref1; -var wrapDownloadItem; - app.__proto__ = EventEmitter.prototype; app.setApplicationMenu = function(menu) { @@ -49,7 +41,7 @@ if (process.platform === 'darwin') { }; } -appPath = null; +var appPath = null; app.setAppPath = function(path) { return appPath = path; @@ -60,16 +52,17 @@ app.getAppPath = function() { }; // Routes the events to webContents. -ref1 = ['login', 'certificate-error', 'select-client-certificate']; -fn = function(name) { +var ref1 = ['login', 'certificate-error', 'select-client-certificate']; +var fn = function(name) { return app.on(name, function() { var args, event, webContents; event = arguments[0], webContents = arguments[1], args = 3 <= arguments.length ? slice.call(arguments, 2) : []; return webContents.emit.apply(webContents, [name, event].concat(slice.call(args))); }); }; +var i, len; for (i = 0, len = ref1.length; i < len; i++) { - name = ref1[i]; + var name = ref1[i]; fn(name); } @@ -112,7 +105,7 @@ deprecate.event(app, 'activate-with-no-open-windows', 'activate', function(event deprecate.event(app, 'select-certificate', 'select-client-certificate'); // Wrappers for native classes. -wrapDownloadItem = function(downloadItem) { +var wrapDownloadItem = function(downloadItem) { // downloadItem is an EventEmitter. downloadItem.__proto__ = EventEmitter.prototype; From 5a4a8e1fa75c23246bd91e36bab0f5e378bfaeb6 Mon Sep 17 00:00:00 2001 From: Jessica Lord Date: Thu, 14 Jan 2016 17:03:55 -0800 Subject: [PATCH 7/8] :fire: stray `ref` --- atom/renderer/api/lib/desktop-capturer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atom/renderer/api/lib/desktop-capturer.js b/atom/renderer/api/lib/desktop-capturer.js index f9b7ca393d86..c445bfecbe1b 100644 --- a/atom/renderer/api/lib/desktop-capturer.js +++ b/atom/renderer/api/lib/desktop-capturer.js @@ -1,5 +1,5 @@ const ipcRenderer = require('electron').ipcRenderer; -const nativeImage = require('electron').ref.nativeImage; +const nativeImage = require('electron').nativeImage; var nextId = 0; var indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; From 003de0debe1046caf1d4ec41464ec25b53be1dbe Mon Sep 17 00:00:00 2001 From: Jessica Lord Date: Thu, 14 Jan 2016 18:07:29 -0800 Subject: [PATCH 8/8] Clean up variable declarations --- atom/browser/api/lib/app.js | 6 +++--- atom/browser/api/lib/dialog.js | 4 ++-- atom/browser/lib/init.js | 4 ++-- atom/renderer/lib/init.js | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/atom/browser/api/lib/app.js b/atom/browser/api/lib/app.js index bb194be62a01..c4cdb5124651 100644 --- a/atom/browser/api/lib/app.js +++ b/atom/browser/api/lib/app.js @@ -60,10 +60,10 @@ var fn = function(name) { return webContents.emit.apply(webContents, [name, event].concat(slice.call(args))); }); }; -var i, len; +var i, len, name; for (i = 0, len = ref1.length; i < len; i++) { - var name = ref1[i]; - fn(name); + name = ref1[i]; + fn(ref1[i]); } // Deprecated. diff --git a/atom/browser/api/lib/dialog.js b/atom/browser/api/lib/dialog.js index 302fa7bf07fe..b77773be2096 100644 --- a/atom/browser/api/lib/dialog.js +++ b/atom/browser/api/lib/dialog.js @@ -163,8 +163,8 @@ module.exports = { // Mark standard asynchronous functions. var ref1 = ['showMessageBox', 'showOpenDialog', 'showSaveDialog']; -var j, len +var j, len, api; for (j = 0, len = ref1.length; j < len; j++) { - var api = ref1[j]; + api = ref1[j]; v8Util.setHiddenValue(module.exports[api], 'asynchronous', true); } diff --git a/atom/browser/lib/init.js b/atom/browser/lib/init.js index a38cd6f9e41f..272cebbf875b 100644 --- a/atom/browser/lib/init.js +++ b/atom/browser/lib/init.js @@ -91,9 +91,9 @@ require('./guest-window-manager'); // Now we try to load app's package.json. var packageJson = null; var searchPaths = ['app', 'app.asar', 'default_app']; -var i, len; +var i, len, packagePath; for (i = 0, len = searchPaths.length; i < len; i++) { - var packagePath = searchPaths[i]; + packagePath = searchPaths[i]; try { packagePath = path.join(process.resourcesPath, packagePath); packageJson = JSON.parse(fs.readFileSync(path.join(packagePath, 'package.json'))); diff --git a/atom/renderer/lib/init.js b/atom/renderer/lib/init.js index 297ee61fcff2..556e9d617bdb 100644 --- a/atom/renderer/lib/init.js +++ b/atom/renderer/lib/init.js @@ -45,9 +45,9 @@ var nodeIntegration = 'false'; var preloadScript = null; var ref = process.argv; -var i, len; +var i, len, arg; for (i = 0, len = ref.length; i < len; i++) { - var arg = ref[i]; + arg = ref[i]; if (arg.indexOf('--guest-instance-id=') === 0) { // This is a guest web view. process.guestInstanceId = parseInt(arg.substr(arg.indexOf('=') + 1));