diff --git a/lib/.eslintrc b/lib/.eslintrc new file mode 100644 index 00000000000..7f629e4735d --- /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 d15fa85a1a4..db3e8da158c 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 c5ed2a94b91..d15a3c2e4a4 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 fecf7958cd0..f1dc9387ca1 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 fbf676236b2..81bd70f1ebb 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 c2ba8725e49..0cf6c267320 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 9654e095fc0..ec9878ee43e 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 2c2978e9734..d610ac91f98 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 5cadcf92b2e..4055d2fcbef 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 0a60a88c9e9..74682d74833 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 9f320c5298e..02d73ec6d5a 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 19eca809f2d..cc2374c11c7 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 8890b6eb591..5e3371dcc59 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 3e3c21fb62e..964ead8a261 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 cca01da05bc..0f1b0e68d16 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 3a911504b6b..a91df7dda27 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 60fed0ce687..08c10eeff93 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 5d963baae84..bb663e886fd 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 bb65e20cadb..ddacc733332 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 6f01540e39c..1c6c108ec67 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 17d4b6dbe1b..8f10658320a 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 b52524d7599..7e3ab510e08 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 1ec9f799874..49c670201ee 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 b1ae86993fc..38f3832caf7 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 614298f51a0..f703f9476c3 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 78e2a0938ba..6907d90119e 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 b6d5f859343..d170ce9f70d 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 aa3567e8a2d..d35b976dd82 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 8292a23d698..36954f56e0a 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 baa73998645..8bfdf66ee39 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 6a6762376ba..96d43f11330 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 d6682f639a1..955ab8f480f 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 11e4e49a097..5890592e338 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 8a2aba5b7bb..a13256527ff 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 00c657b638a..0d2e7883ae3 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 c3854259bfc..63aa8d46620 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 ed9732ee199..cc9b12e2d2a 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 9eecd49dc5b..bc1c33e34b5 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 2d76c0c5ae0..629370b9596 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 4ac75fd8cf4..19727948401 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 4a951407f59..93f5ad2f7e2 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 b28e61cb861..027ec322b4a 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 f2a560f81c2..40216c8cfbe 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 d907de1667c..5ced9d5b79e 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 d6304f59d72..29c7cc12d35 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 600eba61017..0ed48a19491 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 568f735d5cf..bffd761612b 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 327114be508..86268f15780 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 c72dfe4318b..f4ab44adb5b 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 ff39e96a120..d1abecfa25e 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 2b69a1fa907..2992797b724 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 7342908e59a..93c46e0293d 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 ecd0d38a63a..bbbbe589235 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 f2b2f2a77fd..fbc7b180890 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 402fa6cbe80..62981862923 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 b1d032d4067..e510462a738 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 d7535c4cf6b..914562250ce 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')