diff --git a/lib/.eslintrc b/lib/.eslintrc new file mode 100644 index 000000000000..7f629e4735d8 --- /dev/null +++ b/lib/.eslintrc @@ -0,0 +1,8 @@ +{ + "parserOptions": { + "sourceType": "script" + }, + "rules": { + "strict": ["error", "global"] + } +} diff --git a/lib/browser/api/auto-updater.js b/lib/browser/api/auto-updater.js index d15fa85a1a4d..db3e8da158c3 100644 --- a/lib/browser/api/auto-updater.js +++ b/lib/browser/api/auto-updater.js @@ -1,3 +1,5 @@ +'use strict' + if (process.platform === 'win32') { module.exports = require('@electron/internal/browser/api/auto-updater/auto-updater-win') } else { diff --git a/lib/browser/api/auto-updater/auto-updater-native.js b/lib/browser/api/auto-updater/auto-updater-native.js index c5ed2a94b914..d15a3c2e4a48 100644 --- a/lib/browser/api/auto-updater/auto-updater-native.js +++ b/lib/browser/api/auto-updater/auto-updater-native.js @@ -1,3 +1,5 @@ +'use strict' + const EventEmitter = require('events').EventEmitter const { autoUpdater, AutoUpdater } = process.atomBinding('auto_updater') diff --git a/lib/browser/api/auto-updater/squirrel-update-win.js b/lib/browser/api/auto-updater/squirrel-update-win.js index fecf7958cd0a..f1dc9387ca16 100644 --- a/lib/browser/api/auto-updater/squirrel-update-win.js +++ b/lib/browser/api/auto-updater/squirrel-update-win.js @@ -1,3 +1,5 @@ +'use strict' + const fs = require('fs') const path = require('path') const spawn = require('child_process').spawn diff --git a/lib/browser/api/content-tracing.js b/lib/browser/api/content-tracing.js index fbf676236b28..81bd70f1ebbf 100644 --- a/lib/browser/api/content-tracing.js +++ b/lib/browser/api/content-tracing.js @@ -1 +1,3 @@ +'use strict' + module.exports = process.atomBinding('content_tracing') diff --git a/lib/browser/api/exports/electron.js b/lib/browser/api/exports/electron.js index c2ba8725e494..0cf6c2673205 100644 --- a/lib/browser/api/exports/electron.js +++ b/lib/browser/api/exports/electron.js @@ -1,3 +1,5 @@ +'use strict' + const common = require('@electron/internal/common/api/exports/electron') // since browser module list is also used in renderer, keep it separate. const moduleList = require('@electron/internal/browser/api/module-list') diff --git a/lib/browser/api/global-shortcut.js b/lib/browser/api/global-shortcut.js index 9654e095fc06..ec9878ee43e2 100644 --- a/lib/browser/api/global-shortcut.js +++ b/lib/browser/api/global-shortcut.js @@ -1 +1,3 @@ +'use strict' + module.exports = process.atomBinding('global_shortcut').globalShortcut diff --git a/lib/browser/api/ipc-main.js b/lib/browser/api/ipc-main.js index 2c2978e97344..d610ac91f981 100644 --- a/lib/browser/api/ipc-main.js +++ b/lib/browser/api/ipc-main.js @@ -1,3 +1,5 @@ +'use strict' + const EventEmitter = require('events').EventEmitter const emitter = new EventEmitter() diff --git a/lib/browser/api/menu-item-roles.js b/lib/browser/api/menu-item-roles.js index 5cadcf92b2ed..4055d2fcbef3 100644 --- a/lib/browser/api/menu-item-roles.js +++ b/lib/browser/api/menu-item-roles.js @@ -1,3 +1,5 @@ +'use strict' + const { app } = require('electron') const roles = { diff --git a/lib/browser/api/menu-utils.js b/lib/browser/api/menu-utils.js index 0a60a88c9e9d..74682d748334 100644 --- a/lib/browser/api/menu-utils.js +++ b/lib/browser/api/menu-utils.js @@ -1,3 +1,5 @@ +'use strict' + function splitArray (arr, predicate) { const result = arr.reduce((multi, item) => { const current = multi[multi.length - 1] diff --git a/lib/browser/api/module-list.js b/lib/browser/api/module-list.js index 9f320c5298ed..02d73ec6d5ac 100644 --- a/lib/browser/api/module-list.js +++ b/lib/browser/api/module-list.js @@ -1,3 +1,5 @@ +'use strict' + const features = process.atomBinding('features') // Browser side modules, please sort alphabetically. diff --git a/lib/browser/api/notification.js b/lib/browser/api/notification.js index 19eca809f2d7..cc2374c11c77 100644 --- a/lib/browser/api/notification.js +++ b/lib/browser/api/notification.js @@ -1,3 +1,5 @@ +'use strict' + const { EventEmitter } = require('events') const { Notification, isSupported } = process.atomBinding('notification') diff --git a/lib/browser/api/power-monitor.js b/lib/browser/api/power-monitor.js index 8890b6eb591f..5e3371dcc592 100644 --- a/lib/browser/api/power-monitor.js +++ b/lib/browser/api/power-monitor.js @@ -1,3 +1,5 @@ +'use strict' + const { EventEmitter } = require('events') const { powerMonitor, PowerMonitor } = process.atomBinding('power_monitor') diff --git a/lib/browser/api/power-save-blocker.js b/lib/browser/api/power-save-blocker.js index 3e3c21fb62ec..964ead8a261d 100644 --- a/lib/browser/api/power-save-blocker.js +++ b/lib/browser/api/power-save-blocker.js @@ -1 +1,3 @@ +'use strict' + module.exports = process.atomBinding('power_save_blocker').powerSaveBlocker diff --git a/lib/browser/api/protocol.js b/lib/browser/api/protocol.js index cca01da05bc7..0f1b0e68d16f 100644 --- a/lib/browser/api/protocol.js +++ b/lib/browser/api/protocol.js @@ -1,3 +1,5 @@ +'use strict' + const { app, session } = require('electron') // Global protocol APIs. diff --git a/lib/browser/api/screen.js b/lib/browser/api/screen.js index 3a911504b6b7..a91df7dda273 100644 --- a/lib/browser/api/screen.js +++ b/lib/browser/api/screen.js @@ -1,3 +1,5 @@ +'use strict' + const { EventEmitter } = require('events') const { screen, Screen } = process.atomBinding('screen') diff --git a/lib/browser/api/session.js b/lib/browser/api/session.js index 60fed0ce6879..08c10eeff935 100644 --- a/lib/browser/api/session.js +++ b/lib/browser/api/session.js @@ -1,3 +1,5 @@ +'use strict' + const { EventEmitter } = require('events') const { app } = require('electron') const { fromPartition, Session, Cookies } = process.atomBinding('session') diff --git a/lib/browser/api/system-preferences.js b/lib/browser/api/system-preferences.js index 5d963baae84a..bb663e886fd3 100644 --- a/lib/browser/api/system-preferences.js +++ b/lib/browser/api/system-preferences.js @@ -1,3 +1,5 @@ +'use strict' + const { EventEmitter } = require('events') const { systemPreferences, SystemPreferences } = process.atomBinding('system_preferences') diff --git a/lib/browser/api/touch-bar.js b/lib/browser/api/touch-bar.js index bb65e20cadb6..ddacc733332e 100644 --- a/lib/browser/api/touch-bar.js +++ b/lib/browser/api/touch-bar.js @@ -1,3 +1,5 @@ +'use strict' + const { EventEmitter } = require('events') let nextItemID = 1 diff --git a/lib/browser/api/tray.js b/lib/browser/api/tray.js index 6f01540e39cd..1c6c108ec67b 100644 --- a/lib/browser/api/tray.js +++ b/lib/browser/api/tray.js @@ -1,3 +1,5 @@ +'use strict' + const { EventEmitter } = require('events') const { Tray } = process.atomBinding('tray') diff --git a/lib/browser/chrome-extension.js b/lib/browser/chrome-extension.js index 17d4b6dbe1bf..8f10658320ae 100644 --- a/lib/browser/chrome-extension.js +++ b/lib/browser/chrome-extension.js @@ -1,3 +1,5 @@ +'use strict' + const { app, ipcMain, webContents, BrowserWindow } = require('electron') const { getAllWebContents } = process.atomBinding('web_contents') const renderProcessPreferences = process.atomBinding('render_process_preferences').forAllWebContents() diff --git a/lib/common/api/clipboard.js b/lib/common/api/clipboard.js index b52524d75998..7e3ab510e08b 100644 --- a/lib/common/api/clipboard.js +++ b/lib/common/api/clipboard.js @@ -1,3 +1,5 @@ +'use strict' + if (process.platform === 'linux' && process.type === 'renderer') { // On Linux we could not access clipboard in renderer process. module.exports = require('electron').remote.clipboard diff --git a/lib/common/api/exports/electron.js b/lib/common/api/exports/electron.js index 1ec9f799874e..49c670201ee8 100644 --- a/lib/common/api/exports/electron.js +++ b/lib/common/api/exports/electron.js @@ -1,3 +1,5 @@ +'use strict' + const moduleList = require('@electron/internal/common/api/module-list') exports.memoizedGetter = (getter) => { diff --git a/lib/common/api/module-list.js b/lib/common/api/module-list.js index b1ae86993fc8..38f3832caf7c 100644 --- a/lib/common/api/module-list.js +++ b/lib/common/api/module-list.js @@ -1,3 +1,5 @@ +'use strict' + // Common modules, please sort alphabetically module.exports = [ { name: 'clipboard', file: 'clipboard' }, diff --git a/lib/common/api/native-image.js b/lib/common/api/native-image.js index 614298f51a0e..f703f9476c3e 100644 --- a/lib/common/api/native-image.js +++ b/lib/common/api/native-image.js @@ -1 +1,3 @@ +'use strict' + module.exports = process.atomBinding('native_image') diff --git a/lib/common/api/shell.js b/lib/common/api/shell.js index 78e2a0938ba0..6907d90119e3 100644 --- a/lib/common/api/shell.js +++ b/lib/common/api/shell.js @@ -1 +1,3 @@ +'use strict' + module.exports = process.atomBinding('shell') diff --git a/lib/common/asar.js b/lib/common/asar.js index b6d5f859343d..d170ce9f70d9 100644 --- a/lib/common/asar.js +++ b/lib/common/asar.js @@ -1,3 +1,5 @@ +'use strict'; + (function () { const asar = process.binding('atom_common_asar') const assert = require('assert') diff --git a/lib/common/asar_init.js b/lib/common/asar_init.js index aa3567e8a2dd..d35b976dd823 100644 --- a/lib/common/asar_init.js +++ b/lib/common/asar_init.js @@ -1,3 +1,5 @@ +'use strict' + ;(function () { // eslint-disable-line return function (process, require, asarSource) { const source = process.binding('natives') diff --git a/lib/common/atom-binding-setup.js b/lib/common/atom-binding-setup.js index 8292a23d698e..36954f56e0a2 100644 --- a/lib/common/atom-binding-setup.js +++ b/lib/common/atom-binding-setup.js @@ -1,3 +1,5 @@ +'use strict' + module.exports = function atomBindingSetup (binding, processType) { return function atomBinding (name) { try { diff --git a/lib/common/buffer-utils.js b/lib/common/buffer-utils.js index baa739986453..8bfdf66ee390 100644 --- a/lib/common/buffer-utils.js +++ b/lib/common/buffer-utils.js @@ -1,3 +1,5 @@ +'use strict' + // Note: Don't use destructuring assignment for `Buffer`, or we'll hit a // browserify bug that makes the statement invalid, throwing an error in // sandboxed renderer. diff --git a/lib/common/init.js b/lib/common/init.js index 6a6762376bab..96d43f11330e 100644 --- a/lib/common/init.js +++ b/lib/common/init.js @@ -1,3 +1,5 @@ +'use strict' + const timers = require('timers') const util = require('util') diff --git a/lib/common/parse-features-string.js b/lib/common/parse-features-string.js index d6682f639a10..955ab8f480f7 100644 --- a/lib/common/parse-features-string.js +++ b/lib/common/parse-features-string.js @@ -1,3 +1,5 @@ +'use strict' + // parses a feature string that has the format used in window.open() // - `features` input string // - `emit` function(key, value) - called for each parsed KV diff --git a/lib/common/reset-search-paths.js b/lib/common/reset-search-paths.js index 11e4e49a097b..5890592e338a 100644 --- a/lib/common/reset-search-paths.js +++ b/lib/common/reset-search-paths.js @@ -1,3 +1,5 @@ +'use strict' + const path = require('path') const Module = require('module') diff --git a/lib/isolated_renderer/init.js b/lib/isolated_renderer/init.js index 8a2aba5b7bb8..a13256527ffc 100644 --- a/lib/isolated_renderer/init.js +++ b/lib/isolated_renderer/init.js @@ -1,7 +1,7 @@ -/* global binding */ - 'use strict' +/* global binding */ + const { send, sendSync } = binding const ipcRenderer = { diff --git a/lib/renderer/api/desktop-capturer.js b/lib/renderer/api/desktop-capturer.js index 00c657b638ae..0d2e7883ae32 100644 --- a/lib/renderer/api/desktop-capturer.js +++ b/lib/renderer/api/desktop-capturer.js @@ -1,3 +1,5 @@ +'use strict' + const { ipcRenderer, nativeImage } = require('electron') const includes = [].includes diff --git a/lib/renderer/api/exports/electron.js b/lib/renderer/api/exports/electron.js index c3854259bfc8..63aa8d466202 100644 --- a/lib/renderer/api/exports/electron.js +++ b/lib/renderer/api/exports/electron.js @@ -1,3 +1,5 @@ +'use strict' + const common = require('@electron/internal/common/api/exports/electron') const moduleList = require('@electron/internal/renderer/api/module-list') diff --git a/lib/renderer/api/module-list.js b/lib/renderer/api/module-list.js index ed9732ee199c..cc9b12e2d2ad 100644 --- a/lib/renderer/api/module-list.js +++ b/lib/renderer/api/module-list.js @@ -1,3 +1,5 @@ +'use strict' + const features = process.atomBinding('features') // Renderer side modules, please sort alphabetically. diff --git a/lib/renderer/api/screen.js b/lib/renderer/api/screen.js index 9eecd49dc5bf..bc1c33e34b56 100644 --- a/lib/renderer/api/screen.js +++ b/lib/renderer/api/screen.js @@ -1 +1,3 @@ +'use strict' + module.exports = require('electron').remote.screen diff --git a/lib/renderer/chrome-api.js b/lib/renderer/chrome-api.js index 2d76c0c5ae05..629370b95968 100644 --- a/lib/renderer/chrome-api.js +++ b/lib/renderer/chrome-api.js @@ -1,3 +1,5 @@ +'use strict' + const { ipcRenderer } = require('electron') const Event = require('@electron/internal/renderer/extensions/event') const url = require('url') diff --git a/lib/renderer/content-scripts-injector.js b/lib/renderer/content-scripts-injector.js index 4ac75fd8cf4a..19727948401e 100644 --- a/lib/renderer/content-scripts-injector.js +++ b/lib/renderer/content-scripts-injector.js @@ -1,3 +1,5 @@ +'use strict' + const { ipcRenderer } = require('electron') const { runInThisContext } = require('vm') diff --git a/lib/renderer/extensions/event.js b/lib/renderer/extensions/event.js index 4a951407f594..93f5ad2f7e2f 100644 --- a/lib/renderer/extensions/event.js +++ b/lib/renderer/extensions/event.js @@ -1,3 +1,5 @@ +'use strict' + class Event { constructor () { this.listeners = [] diff --git a/lib/renderer/extensions/i18n.js b/lib/renderer/extensions/i18n.js index b28e61cb8617..027ec322b4aa 100644 --- a/lib/renderer/extensions/i18n.js +++ b/lib/renderer/extensions/i18n.js @@ -1,3 +1,5 @@ +'use strict' + // Implementation of chrome.i18n.getMessage // https://developer.chrome.com/extensions/i18n#method-getMessage // diff --git a/lib/renderer/extensions/storage.js b/lib/renderer/extensions/storage.js index f2a560f81c2c..40216c8cfbe5 100644 --- a/lib/renderer/extensions/storage.js +++ b/lib/renderer/extensions/storage.js @@ -1,3 +1,5 @@ +'use strict' + const fs = require('fs') const path = require('path') const { remote } = require('electron') diff --git a/lib/renderer/extensions/web-navigation.js b/lib/renderer/extensions/web-navigation.js index d907de1667c8..5ced9d5b79ed 100644 --- a/lib/renderer/extensions/web-navigation.js +++ b/lib/renderer/extensions/web-navigation.js @@ -1,3 +1,5 @@ +'use strict' + const Event = require('@electron/internal/renderer/extensions/event') const { ipcRenderer } = require('electron') diff --git a/lib/renderer/inspector.js b/lib/renderer/inspector.js index d6304f59d721..29c7cc12d358 100644 --- a/lib/renderer/inspector.js +++ b/lib/renderer/inspector.js @@ -1,3 +1,5 @@ +'use strict' + window.onload = function () { // Use menu API to show context menu. window.InspectorFrontendHost.showContextMenuAtPoint = createMenu diff --git a/lib/renderer/security-warnings.js b/lib/renderer/security-warnings.js index 600eba610179..0ed48a194919 100644 --- a/lib/renderer/security-warnings.js +++ b/lib/renderer/security-warnings.js @@ -1,3 +1,5 @@ +'use strict' + let shouldLog = null /** diff --git a/lib/renderer/web-frame-init.js b/lib/renderer/web-frame-init.js index 568f735d5cfc..bffd761612be 100644 --- a/lib/renderer/web-frame-init.js +++ b/lib/renderer/web-frame-init.js @@ -1,3 +1,5 @@ +'use strict' + const { ipcRenderer, webFrame } = require('electron') const errorUtils = require('@electron/internal/common/error-utils') diff --git a/lib/renderer/web-view/web-view-constants.js b/lib/renderer/web-view/web-view-constants.js index 327114be508d..86268f15780d 100644 --- a/lib/renderer/web-view/web-view-constants.js +++ b/lib/renderer/web-view/web-view-constants.js @@ -1,3 +1,5 @@ +'use strict' + module.exports = { // Attributes. ATTRIBUTE_NAME: 'name', diff --git a/lib/renderer/window-setup.js b/lib/renderer/window-setup.js index c72dfe4318bb..f4ab44adb5bc 100644 --- a/lib/renderer/window-setup.js +++ b/lib/renderer/window-setup.js @@ -1,3 +1,5 @@ +'use strict' + // This file should have no requires since it is used by the isolated context // preload bundle. Instead arguments should be passed in for everything it // needs. @@ -21,8 +23,6 @@ // - document.hidden // - document.visibilityState -'use strict' - const { defineProperty } = Object // Helper function to resolve relative url. diff --git a/lib/sandboxed_renderer/api/exports/child_process.js b/lib/sandboxed_renderer/api/exports/child_process.js index ff39e96a120e..d1abecfa25e1 100644 --- a/lib/sandboxed_renderer/api/exports/child_process.js +++ b/lib/sandboxed_renderer/api/exports/child_process.js @@ -1 +1,3 @@ +'use strict' + module.exports = require('electron').remote.require('child_process') diff --git a/lib/sandboxed_renderer/api/exports/electron.js b/lib/sandboxed_renderer/api/exports/electron.js index 2b69a1fa907b..2992797b7249 100644 --- a/lib/sandboxed_renderer/api/exports/electron.js +++ b/lib/sandboxed_renderer/api/exports/electron.js @@ -1,3 +1,5 @@ +'use strict' + const moduleList = require('@electron/internal/sandboxed_renderer/api/module-list') for (const { diff --git a/lib/sandboxed_renderer/api/exports/fs.js b/lib/sandboxed_renderer/api/exports/fs.js index 7342908e59a9..93c46e0293da 100644 --- a/lib/sandboxed_renderer/api/exports/fs.js +++ b/lib/sandboxed_renderer/api/exports/fs.js @@ -1 +1,3 @@ +'use strict' + module.exports = require('electron').remote.require('fs') diff --git a/lib/sandboxed_renderer/api/exports/os.js b/lib/sandboxed_renderer/api/exports/os.js index ecd0d38a63a6..bbbbe589235d 100644 --- a/lib/sandboxed_renderer/api/exports/os.js +++ b/lib/sandboxed_renderer/api/exports/os.js @@ -1 +1,3 @@ +'use strict' + module.exports = require('electron').remote.require('os') diff --git a/lib/sandboxed_renderer/api/exports/path.js b/lib/sandboxed_renderer/api/exports/path.js index f2b2f2a77fd4..fbc7b1808906 100644 --- a/lib/sandboxed_renderer/api/exports/path.js +++ b/lib/sandboxed_renderer/api/exports/path.js @@ -1 +1,3 @@ +'use strict' + module.exports = require('electron').remote.require('path') diff --git a/lib/sandboxed_renderer/api/ipc-renderer.js b/lib/sandboxed_renderer/api/ipc-renderer.js index 402fa6cbe80d..629818629234 100644 --- a/lib/sandboxed_renderer/api/ipc-renderer.js +++ b/lib/sandboxed_renderer/api/ipc-renderer.js @@ -1,3 +1,5 @@ +'use strict' + const ipcRenderer = require('@electron/internal/renderer/api/ipc-renderer') const v8Util = process.atomBinding('v8_util') diff --git a/lib/sandboxed_renderer/api/module-list.js b/lib/sandboxed_renderer/api/module-list.js index b1d032d40670..e510462a7381 100644 --- a/lib/sandboxed_renderer/api/module-list.js +++ b/lib/sandboxed_renderer/api/module-list.js @@ -1,3 +1,5 @@ +'use strict' + const features = process.atomBinding('features') module.exports = [ diff --git a/lib/sandboxed_renderer/init.js b/lib/sandboxed_renderer/init.js index d7535c4cf6ba..914562250ce4 100644 --- a/lib/sandboxed_renderer/init.js +++ b/lib/sandboxed_renderer/init.js @@ -1,3 +1,5 @@ +'use strict' + /* eslint no-eval: "off" */ /* global binding, Buffer */ const events = require('events')