From 5787bb022680f966d80fe4a28bbba584f854d3c5 Mon Sep 17 00:00:00 2001 From: Plusb Preco Date: Tue, 10 May 2016 18:42:11 +0900 Subject: [PATCH] :memo: Fix code style issue * Match equality operators for consistent that `==`, `!=` by `===`, `!==`. * Match string expression notation `"` by `'`. [ci skip] --- docs/api/app.md | 2 +- docs/api/desktop-capturer.md | 2 +- docs/api/download-item.md | 6 ++--- docs/api/menu.md | 2 +- docs/api/remote.md | 2 +- docs/api/screen.md | 2 +- docs/api/session.md | 10 ++++---- docs/api/web-contents.md | 24 +++++++++---------- docs/api/web-frame.md | 2 +- docs/api/web-view-tag.md | 6 ++--- .../desktop-environment-integration.md | 8 +++---- 11 files changed, 33 insertions(+), 33 deletions(-) diff --git a/docs/api/app.md b/docs/api/app.md index cb19b49b7c18..00580c0ac84b 100644 --- a/docs/api/app.md +++ b/docs/api/app.md @@ -176,7 +176,7 @@ certificate you should prevent the default behavior with ```javascript app.on('certificate-error', function(event, webContents, url, error, certificate, callback) { - if (url == "https://github.com") { + if (url === 'https://github.com') { // Verification logic. event.preventDefault(); callback(true); diff --git a/docs/api/desktop-capturer.md b/docs/api/desktop-capturer.md index 9c6d220112b5..dd37d3b60aaa 100644 --- a/docs/api/desktop-capturer.md +++ b/docs/api/desktop-capturer.md @@ -10,7 +10,7 @@ var { desktopCapturer } = require('electron'); desktopCapturer.getSources({types: ['window', 'screen']}, (error, sources) => { if (error) throw error; for (var i = 0; i < sources.length; ++i) { - if (sources[i].name == "Electron") { + if (sources[i].name === 'Electron') { navigator.webkitGetUserMedia({ audio: false, video: { diff --git a/docs/api/download-item.md b/docs/api/download-item.md index 6d15176aa09c..14d1931e4468 100644 --- a/docs/api/download-item.md +++ b/docs/api/download-item.md @@ -18,10 +18,10 @@ win.webContents.session.on('will-download', (event, item, webContents) => { console.log('Received bytes: ' + item.getReceivedBytes()); }); item.on('done', (e, state) => { - if (state === "completed") { - console.log("Download successfully"); + if (state === 'completed') { + console.log('Download successfully'); } else { - console.log("Download is cancelled or interrupted that can't be resumed"); + console.log('Download is cancelled or interrupted that can\'t be resumed'); } }); }); diff --git a/docs/api/menu.md b/docs/api/menu.md index 944a4f810933..53ba9430a4b6 100644 --- a/docs/api/menu.md +++ b/docs/api/menu.md @@ -98,7 +98,7 @@ const template = [ { label: 'Toggle Developer Tools', accelerator: (() => { - if (process.platform == 'darwin') + if (process.platform === 'darwin') return 'Alt+Command+I'; else return 'Ctrl+Shift+I'; diff --git a/docs/api/remote.md b/docs/api/remote.md index 51dc20bdb2cc..a0c120c1a4d2 100644 --- a/docs/api/remote.md +++ b/docs/api/remote.md @@ -79,7 +79,7 @@ exports.withLocalCallback = () => { ```javascript // renderer process -const mapNumbers = require("remote").require("./mapNumbers"); +const mapNumbers = require('remote').require('./mapNumbers'); const withRendererCb = mapNumbers.withRendererCallback(x => x + 1); diff --git a/docs/api/screen.md b/docs/api/screen.md index 1e04bdc73888..fbe104b89fda 100644 --- a/docs/api/screen.md +++ b/docs/api/screen.md @@ -37,7 +37,7 @@ app.on('ready', () => { var displays = electronScreen.getAllDisplays(); var externalDisplay = null; for (let i in displays) { - if (displays[i].bounds.x != 0 || displays[i].bounds.y != 0) { + if (displays[i].bounds.x !== 0 || displays[i].bounds.y !== 0) { externalDisplay = displays[i]; break; } diff --git a/docs/api/session.md b/docs/api/session.md index 651264b635ee..38103f5820ac 100644 --- a/docs/api/session.md +++ b/docs/api/session.md @@ -12,7 +12,7 @@ property of [`webContents`](web-contents.md) which is a property of const { BrowserWindow } = require('electron'); let win = new BrowserWindow({ width: 800, height: 600 }); -win.loadURL("http://github.com"); +win.loadURL('http://github.com'); const ses = win.webContents.session; ``` @@ -89,13 +89,13 @@ session.defaultSession.cookies.get({}, (error, cookies) => { }); // Query all cookies associated with a specific url. -session.defaultSession.cookies.get({ url : "http://www.github.com" }, (error, cookies) => { +session.defaultSession.cookies.get({ url : 'http://www.github.com' }, (error, cookies) => { console.log(cookies); }); // Set a cookie with the given cookie data; // may overwrite equivalent cookies if they exist. -const cookie = { url : "http://www.github.com", name : "dummy_name", value : "dummy" }; +const cookie = { url : 'http://www.github.com', name : 'dummy_name', value : 'dummy' }; session.defaultSession.cookies.set(cookie, (error) => { if (error) console.error(error); @@ -307,7 +307,7 @@ Calling `callback(true)` will allow the permission and `callback(false)` will re ```javascript session.fromPartition(partition).setPermissionRequestHandler((webContents, permission, callback) => { if (webContents.getURL() === host) { - if (permission === "notifications") { + if (permission === 'notifications') { callback(false); // denied. return; } @@ -343,7 +343,7 @@ called with an `response` object when `listener` has done its work. ```javascript // Modify the user agent for all requests to the following urls. const filter = { - urls: ["https://*.github.com/*", "*://electron.github.io"] + urls: ['https://*.github.com/*', '*://electron.github.io'] }; session.defaultSession.webRequest.onBeforeSendHeaders(filter, (details, callback) => { diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index 3800388b56e3..cd4b9f231789 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -12,7 +12,7 @@ the [`BrowserWindow`](browser-window.md) object. An example of accessing the const { BrowserWindow } = require('electron'); let win = new BrowserWindow({width: 800, height: 1500}); -win.loadURL("http://github.com"); +win.loadURL('http://github.com'); let webContents = win.webContents; ``` @@ -384,7 +384,7 @@ e.g. the `http://` or `file://`. If the load should bypass http cache then use the `pragma` header to achieve it. ```javascript -const options = {"extraHeaders" : "pragma: no-cache\n"} +const options = {extraHeaders: 'pragma: no-cache\n'}; webContents.loadURL(url, options) ``` @@ -401,7 +401,7 @@ Returns URL of the current web page. ```javascript let win = new BrowserWindow({width: 800, height: 600}); -win.loadURL("http://github.com"); +win.loadURL('http://github.com'); let currentURL = win.webContents.getURL(); ``` @@ -605,10 +605,10 @@ Stops any `findInPage` request for the `webContents` with the provided `action`. ```javascript webContents.on('found-in-page', function(event, result) { if (result.finalUpdate) - webContents.stopFindInPage("clearSelection"); + webContents.stopFindInPage('clearSelection'); }); -const requestId = webContents.findInPage("api"); +const requestId = webContents.findInPage('api'); ``` ### `webContents.hasServiceWorker(callback)` @@ -898,7 +898,7 @@ win.loadURL('https://github.com'); win.webContents.on('did-finish-load', () => { win.webContents.savePage('/tmp/test.html', 'HTMLComplete', (error) => { if (!error) - console.log("Save page successfully"); + console.log('Save page successfully'); }); }); ``` @@ -928,23 +928,23 @@ Debugger API serves as an alternate transport for [remote debugging protocol][rd ```javascript try { - win.webContents.debugger.attach("1.1"); + win.webContents.debugger.attach('1.1'); } catch(err) { - console.log("Debugger attach failed : ", err); + console.log('Debugger attach failed : ', err); }; win.webContents.debugger.on('detach', (event, reason) => { - console.log("Debugger detached due to : ", reason); + console.log('Debugger detached due to : ', reason); }); win.webContents.debugger.on('message', (event, method, params) => { - if (method === "Network.requestWillBeSent") { - if (params.request.url === "https://www.github.com") + if (method === 'Network.requestWillBeSent') { + if (params.request.url === 'https://www.github.com') win.webContents.debugger.detach(); } }) -win.webContents.debugger.sendCommand("Network.enable"); +win.webContents.debugger.sendCommand('Network.enable'); ``` #### `webContents.debugger.attach([protocolVersion])` diff --git a/docs/api/web-frame.md b/docs/api/web-frame.md index dcd595d3d973..e7ed05567f2a 100644 --- a/docs/api/web-frame.md +++ b/docs/api/web-frame.md @@ -58,7 +58,7 @@ whether the word passed is correctly spelled. An example of using [node-spellchecker][spellchecker] as provider: ```javascript -webFrame.setSpellCheckProvider("en-US", true, { +webFrame.setSpellCheckProvider('en-US', true, { spellCheck: function(text) { return !(require('spellchecker').isMisspelled(text)); } diff --git a/docs/api/web-view-tag.md b/docs/api/web-view-tag.md index a7410e146ae7..da23658c9571 100644 --- a/docs/api/web-view-tag.md +++ b/docs/api/web-view-tag.md @@ -213,7 +213,7 @@ The `webview` tag has the following methods: **Example** ```javascript -webview.addEventListener("dom-ready", () => { +webview.addEventListener('dom-ready', () => { webview.openDevTools(); }); ``` @@ -622,10 +622,10 @@ Fired when a result is available for ```javascript webview.addEventListener('found-in-page', function(e) { if (e.result.finalUpdate) - webview.stopFindInPage("keepSelection"); + webview.stopFindInPage('keepSelection'); }); -const rquestId = webview.findInPage("test"); +const rquestId = webview.findInPage('test'); ``` ### Event: 'new-window' diff --git a/docs/tutorial/desktop-environment-integration.md b/docs/tutorial/desktop-environment-integration.md index 470e7799656b..939da469b220 100644 --- a/docs/tutorial/desktop-environment-integration.md +++ b/docs/tutorial/desktop-environment-integration.md @@ -219,15 +219,15 @@ let win = new BrowserWindow({ win.setThumbarButtons([ { - tooltip: "button1", + tooltip: 'button1', icon: path.join(__dirname, 'button1.png'), - click: () => { console.log("button2 clicked"); } + click: () => { console.log('button2 clicked'); } }, { - tooltip: "button2", + tooltip: 'button2', icon: path.join(__dirname, 'button2.png'), flags:['enabled', 'dismissonclick'], - click: () => { console.log("button2 clicked."); } + click: () => { console.log('button2 clicked.'); } } ]); ```