Skip to content

Commit

Permalink
chore: have 'use strict' consistently across our lib files (#14721)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarshallOfSound committed Sep 22, 2018
1 parent 0a621bf commit 176a762
Show file tree
Hide file tree
Showing 57 changed files with 120 additions and 4 deletions.
8 changes: 8 additions & 0 deletions lib/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"parserOptions": {
"sourceType": "script"
},
"rules": {
"strict": ["error", "global"]
}
}
2 changes: 2 additions & 0 deletions lib/browser/api/auto-updater.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

if (process.platform === 'win32') {
module.exports = require('@electron/internal/browser/api/auto-updater/auto-updater-win')
} else {
Expand Down
2 changes: 2 additions & 0 deletions lib/browser/api/auto-updater/auto-updater-native.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

const EventEmitter = require('events').EventEmitter
const { autoUpdater, AutoUpdater } = process.atomBinding('auto_updater')

Expand Down
2 changes: 2 additions & 0 deletions lib/browser/api/auto-updater/squirrel-update-win.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

const fs = require('fs')
const path = require('path')
const spawn = require('child_process').spawn
Expand Down
2 changes: 2 additions & 0 deletions lib/browser/api/content-tracing.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
'use strict'

module.exports = process.atomBinding('content_tracing')
2 changes: 2 additions & 0 deletions lib/browser/api/exports/electron.js
Original file line number Diff line number Diff line change
@@ -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')
Expand Down
2 changes: 2 additions & 0 deletions lib/browser/api/global-shortcut.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
'use strict'

module.exports = process.atomBinding('global_shortcut').globalShortcut
2 changes: 2 additions & 0 deletions lib/browser/api/ipc-main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

const EventEmitter = require('events').EventEmitter

const emitter = new EventEmitter()
Expand Down
2 changes: 2 additions & 0 deletions lib/browser/api/menu-item-roles.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

const { app } = require('electron')

const roles = {
Expand Down
2 changes: 2 additions & 0 deletions lib/browser/api/menu-utils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

function splitArray (arr, predicate) {
const result = arr.reduce((multi, item) => {
const current = multi[multi.length - 1]
Expand Down
2 changes: 2 additions & 0 deletions lib/browser/api/module-list.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

const features = process.atomBinding('features')

// Browser side modules, please sort alphabetically.
Expand Down
2 changes: 2 additions & 0 deletions lib/browser/api/notification.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

const { EventEmitter } = require('events')
const { Notification, isSupported } = process.atomBinding('notification')

Expand Down
2 changes: 2 additions & 0 deletions lib/browser/api/power-monitor.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

const { EventEmitter } = require('events')
const { powerMonitor, PowerMonitor } = process.atomBinding('power_monitor')

Expand Down
2 changes: 2 additions & 0 deletions lib/browser/api/power-save-blocker.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
'use strict'

module.exports = process.atomBinding('power_save_blocker').powerSaveBlocker
2 changes: 2 additions & 0 deletions lib/browser/api/protocol.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

const { app, session } = require('electron')

// Global protocol APIs.
Expand Down
2 changes: 2 additions & 0 deletions lib/browser/api/screen.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

const { EventEmitter } = require('events')
const { screen, Screen } = process.atomBinding('screen')

Expand Down
2 changes: 2 additions & 0 deletions lib/browser/api/session.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

const { EventEmitter } = require('events')
const { app } = require('electron')
const { fromPartition, Session, Cookies } = process.atomBinding('session')
Expand Down
2 changes: 2 additions & 0 deletions lib/browser/api/system-preferences.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

const { EventEmitter } = require('events')
const { systemPreferences, SystemPreferences } = process.atomBinding('system_preferences')

Expand Down
2 changes: 2 additions & 0 deletions lib/browser/api/touch-bar.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

const { EventEmitter } = require('events')

let nextItemID = 1
Expand Down
2 changes: 2 additions & 0 deletions lib/browser/api/tray.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

const { EventEmitter } = require('events')
const { Tray } = process.atomBinding('tray')

Expand Down
2 changes: 2 additions & 0 deletions lib/browser/chrome-extension.js
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
2 changes: 2 additions & 0 deletions lib/common/api/clipboard.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions lib/common/api/exports/electron.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

const moduleList = require('@electron/internal/common/api/module-list')

exports.memoizedGetter = (getter) => {
Expand Down
2 changes: 2 additions & 0 deletions lib/common/api/module-list.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

// Common modules, please sort alphabetically
module.exports = [
{ name: 'clipboard', file: 'clipboard' },
Expand Down
2 changes: 2 additions & 0 deletions lib/common/api/native-image.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
'use strict'

module.exports = process.atomBinding('native_image')
2 changes: 2 additions & 0 deletions lib/common/api/shell.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
'use strict'

module.exports = process.atomBinding('shell')
2 changes: 2 additions & 0 deletions lib/common/asar.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

(function () {
const asar = process.binding('atom_common_asar')
const assert = require('assert')
Expand Down
2 changes: 2 additions & 0 deletions lib/common/asar_init.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

;(function () { // eslint-disable-line
return function (process, require, asarSource) {
const source = process.binding('natives')
Expand Down
2 changes: 2 additions & 0 deletions lib/common/atom-binding-setup.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

module.exports = function atomBindingSetup (binding, processType) {
return function atomBinding (name) {
try {
Expand Down
2 changes: 2 additions & 0 deletions lib/common/buffer-utils.js
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 2 additions & 0 deletions lib/common/init.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

const timers = require('timers')
const util = require('util')

Expand Down
2 changes: 2 additions & 0 deletions lib/common/parse-features-string.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions lib/common/reset-search-paths.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

const path = require('path')
const Module = require('module')

Expand Down
4 changes: 2 additions & 2 deletions lib/isolated_renderer/init.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* global binding */

'use strict'

/* global binding */

const { send, sendSync } = binding

const ipcRenderer = {
Expand Down
2 changes: 2 additions & 0 deletions lib/renderer/api/desktop-capturer.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

const { ipcRenderer, nativeImage } = require('electron')

const includes = [].includes
Expand Down
2 changes: 2 additions & 0 deletions lib/renderer/api/exports/electron.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

const common = require('@electron/internal/common/api/exports/electron')
const moduleList = require('@electron/internal/renderer/api/module-list')

Expand Down
2 changes: 2 additions & 0 deletions lib/renderer/api/module-list.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

const features = process.atomBinding('features')

// Renderer side modules, please sort alphabetically.
Expand Down
2 changes: 2 additions & 0 deletions lib/renderer/api/screen.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
'use strict'

module.exports = require('electron').remote.screen
2 changes: 2 additions & 0 deletions lib/renderer/chrome-api.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

const { ipcRenderer } = require('electron')
const Event = require('@electron/internal/renderer/extensions/event')
const url = require('url')
Expand Down
2 changes: 2 additions & 0 deletions lib/renderer/content-scripts-injector.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

const { ipcRenderer } = require('electron')
const { runInThisContext } = require('vm')

Expand Down
2 changes: 2 additions & 0 deletions lib/renderer/extensions/event.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

class Event {
constructor () {
this.listeners = []
Expand Down
2 changes: 2 additions & 0 deletions lib/renderer/extensions/i18n.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

// Implementation of chrome.i18n.getMessage
// https://developer.chrome.com/extensions/i18n#method-getMessage
//
Expand Down
2 changes: 2 additions & 0 deletions lib/renderer/extensions/storage.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

const fs = require('fs')
const path = require('path')
const { remote } = require('electron')
Expand Down
2 changes: 2 additions & 0 deletions lib/renderer/extensions/web-navigation.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

const Event = require('@electron/internal/renderer/extensions/event')
const { ipcRenderer } = require('electron')

Expand Down
2 changes: 2 additions & 0 deletions lib/renderer/inspector.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

window.onload = function () {
// Use menu API to show context menu.
window.InspectorFrontendHost.showContextMenuAtPoint = createMenu
Expand Down
2 changes: 2 additions & 0 deletions lib/renderer/security-warnings.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

let shouldLog = null

/**
Expand Down
2 changes: 2 additions & 0 deletions lib/renderer/web-frame-init.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

const { ipcRenderer, webFrame } = require('electron')
const errorUtils = require('@electron/internal/common/error-utils')

Expand Down
2 changes: 2 additions & 0 deletions lib/renderer/web-view/web-view-constants.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

module.exports = {
// Attributes.
ATTRIBUTE_NAME: 'name',
Expand Down
4 changes: 2 additions & 2 deletions lib/renderer/window-setup.js
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -21,8 +23,6 @@
// - document.hidden
// - document.visibilityState

'use strict'

const { defineProperty } = Object

// Helper function to resolve relative url.
Expand Down
2 changes: 2 additions & 0 deletions lib/sandboxed_renderer/api/exports/child_process.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
'use strict'

module.exports = require('electron').remote.require('child_process')
2 changes: 2 additions & 0 deletions lib/sandboxed_renderer/api/exports/electron.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

const moduleList = require('@electron/internal/sandboxed_renderer/api/module-list')

for (const {
Expand Down
2 changes: 2 additions & 0 deletions lib/sandboxed_renderer/api/exports/fs.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
'use strict'

module.exports = require('electron').remote.require('fs')
2 changes: 2 additions & 0 deletions lib/sandboxed_renderer/api/exports/os.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
'use strict'

module.exports = require('electron').remote.require('os')
2 changes: 2 additions & 0 deletions lib/sandboxed_renderer/api/exports/path.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
'use strict'

module.exports = require('electron').remote.require('path')
2 changes: 2 additions & 0 deletions lib/sandboxed_renderer/api/ipc-renderer.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

const ipcRenderer = require('@electron/internal/renderer/api/ipc-renderer')

const v8Util = process.atomBinding('v8_util')
Expand Down
2 changes: 2 additions & 0 deletions lib/sandboxed_renderer/api/module-list.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

const features = process.atomBinding('features')

module.exports = [
Expand Down
2 changes: 2 additions & 0 deletions lib/sandboxed_renderer/init.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

/* eslint no-eval: "off" */
/* global binding, Buffer */
const events = require('events')
Expand Down

0 comments on commit 176a762

Please sign in to comment.