chore: cleanup eslint suppressions (#38417)

* chore: cleanup eslint suppressions

* address feedback

* revert script/lib/azput.js

* revert spec/fixtures/apps/remote-control/main.js

* address feedback

* revert typings/internal-ambient.d.ts
This commit is contained in:
Milan Burda 2023-05-25 03:09:17 +02:00 committed by GitHub
parent 1c075e5ea0
commit 82af000a37
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 76 additions and 115 deletions

View file

@ -574,7 +574,6 @@ export const wrapFsWithAsar = (fs: Record<string, any>) => {
};
const { readFile: readFilePromise } = fs.promises;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
fs.promises.readFile = function (pathArgument: string, options: any) {
const pathInfo = splitPath(pathArgument);
if (!pathInfo.isAsar) {

View file

@ -24,8 +24,6 @@ const spawnUpdate = function (args: string[], detached: boolean, callback: Funct
// Process spawned, different args: Return with error
// No process spawned: Spawn new process
if (spawnedProcess && !isSameArgs(args)) {
// Disabled for backwards compatibility:
// eslint-disable-next-line standard/no-callback-literal
return callback(`AutoUpdater process with arguments ${args} is already running`);
} else if (!spawnedProcess) {
spawnedProcess = spawn(updateExe, args, {
@ -66,8 +64,6 @@ const spawnUpdate = function (args: string[], detached: boolean, callback: Funct
// Process terminated with error.
if (code !== 0) {
// Disabled for backwards compatibility:
// eslint-disable-next-line standard/no-callback-literal
return callback(`Command failed: ${signal ?? code}\n${stderr}`);
}
@ -93,8 +89,6 @@ export function checkForUpdate (updateURL: string, callback: (error: Error | nul
const json = stdout.trim().split('\n').pop();
update = (ref = JSON.parse(json!)) != null ? (ref1 = ref.releasesToApply) != null ? typeof ref1.pop === 'function' ? ref1.pop() : undefined : undefined : undefined;
} catch {
// Disabled for backwards compatibility:
// eslint-disable-next-line standard/no-callback-literal
return callback(new Error(`Invalid result:\n${stdout}`));
}
return callback(null, update);

View file

@ -237,8 +237,6 @@ const messageBox = (sync: boolean, window: BrowserWindow | null, options?: Messa
}
};
// eat dirt, eslint
/* eslint-disable import/export */
export function showOpenDialog(window: BrowserWindow, options: OpenDialogOptions): OpenDialogReturnValue;
export function showOpenDialog(options: OpenDialogOptions): OpenDialogReturnValue;
export function showOpenDialog (windowOrOptions: BrowserWindow | OpenDialogOptions, maybeOptions?: OpenDialogOptions): OpenDialogReturnValue {

View file

@ -14,8 +14,8 @@ import * as deprecate from '@electron/internal/common/deprecate';
// session is not used here, the purpose is to make sure session is initialized
// before the webContents module.
// eslint-disable-next-line
session
// eslint-disable-next-line no-unused-expressions
session;
const webFrameMainBinding = process._linkedBinding('electron_browser_web_frame_main');

View file

@ -96,7 +96,6 @@ const createGuest = function (embedder: Electron.WebContents, embedderFrameId: n
return -1;
}
// eslint-disable-next-line no-undef
const guest = (webContents as typeof ElectronInternal.WebContents).create({
...webPreferences,
type: 'webview',

View file

@ -81,7 +81,8 @@ export function event (emitter: NodeJS.EventEmitter, oldName: string, newName: s
// remove a property with no replacement
export function removeProperty<T, K extends (keyof T & string)>(object: T, removedName: K, onlyForValues?: any[]): T {
// if the property's already been removed, warn about it
const info = Object.getOwnPropertyDescriptor((object as any).__proto__, removedName) // eslint-disable-line
// eslint-disable-next-line no-proto
const info = Object.getOwnPropertyDescriptor((object as any).__proto__, removedName);
if (!info) {
log(`Unable to remove property '${removedName}' from an object that lacks it.`);
return object;

View file

@ -57,7 +57,7 @@ require('@electron/internal/renderer/common-init');
if (nodeIntegration) {
// Export node bindings to global.
const { makeRequireFunction } = __non_webpack_require__('internal/modules/cjs/helpers') // eslint-disable-line
const { makeRequireFunction } = __non_webpack_require__('internal/modules/cjs/helpers');
global.module = new Module('electron/js2c/renderer_init');
global.require = makeRequireFunction(global.module);

View file

@ -86,9 +86,7 @@ const defineWebViewElement = (hooks: WebViewImplHooks) => {
// Register <webview> custom element.
const registerWebViewElement = (hooks: WebViewImplHooks) => {
// I wish eslint wasn't so stupid, but it is
// eslint-disable-next-line
const WebViewElement = defineWebViewElement(hooks) as unknown as typeof ElectronInternal.WebViewElement
const WebViewElement = defineWebViewElement(hooks) as unknown as typeof ElectronInternal.WebViewElement;
setupMethods(WebViewElement, hooks);

View file

@ -197,8 +197,6 @@ export class WebViewImpl {
}
}
// I wish eslint wasn't so stupid, but it is
// eslint-disable-next-line
export const setupMethods = (WebViewElement: typeof ElectronInternal.WebViewElement, hooks: WebViewImplHooks) => {
// Focusing the webview should move page focus to the underlying iframe.
WebViewElement.prototype.focus = function () {

View file

@ -16,7 +16,7 @@ require('@electron/internal/common/init');
const { hasSwitch, getSwitchValue } = process._linkedBinding('electron_common_command_line');
// Export node bindings to global.
const { makeRequireFunction } = __non_webpack_require__('internal/modules/cjs/helpers') // eslint-disable-line
const { makeRequireFunction } = __non_webpack_require__('internal/modules/cjs/helpers');
global.module = new Module('electron/js2c/worker_init');
global.require = makeRequireFunction(global.module);

View file

@ -321,7 +321,8 @@ describe('BrowserView module', () => {
const rc = await startRemoteControlApp();
await rc.remotely(() => {
const { BrowserView, app } = require('electron');
new BrowserView({}) // eslint-disable-line
// eslint-disable-next-line no-new
new BrowserView({});
setTimeout(() => {
app.quit();
});

View file

@ -84,7 +84,6 @@ describe('BrowserWindow module', () => {
it('window does not get garbage collected when opened', async () => {
const w = new BrowserWindow({ show: false });
// Keep a weak reference to the window.
// eslint-disable-next-line no-undef
const wr = new WeakRef(w);
await setTimeout();
// Do garbage collection, since |w| is not referenced in this closure
@ -3158,15 +3157,15 @@ describe('BrowserWindow module', () => {
afterEach(closeAllWindows);
it('can be set on a window', () => {
expect(() => {
/* eslint-disable no-new */
/* eslint-disable-next-line no-new */
new BrowserWindow({
tabbingIdentifier: 'group1'
});
/* eslint-disable-next-line no-new */
new BrowserWindow({
tabbingIdentifier: 'group2',
frame: false
});
/* eslint-enable no-new */
}).not.to.throw();
});
});

View file

@ -113,8 +113,7 @@ describe('ipc module', () => {
});
it('throws an error in the renderer if the reply callback is dropped', async () => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
ipcMain.handleOnce('test', () => new Promise(resolve => {
ipcMain.handleOnce('test', () => new Promise(() => {
setTimeout(() => v8Util.requestGarbageCollectionForTesting());
/* never resolve */
}));

View file

@ -859,7 +859,6 @@ describe('Menu module', function () {
menu.popup({ window: w });
// Keep a weak reference to the menu.
// eslint-disable-next-line no-undef
const wr = new WeakRef(menu);
await setTimeout();

View file

@ -1336,8 +1336,6 @@ describe('net module', () => {
(details, callback) => {
if (details.url === `${serverUrl}${requestUrl}`) {
requestIsIntercepted = true;
// Disabled due to false positive in StandardJS
// eslint-disable-next-line standard/no-callback-literal
callback({
redirectURL: `${serverUrl}${redirectUrl}`
});
@ -1375,8 +1373,6 @@ describe('net module', () => {
customSession.webRequest.onBeforeRequest((details, callback) => {
if (details.url === `${serverUrl}${requestUrl}`) {
requestIsIntercepted = true;
// Disabled due to false positive in StandardJS
// eslint-disable-next-line standard/no-callback-literal
callback({
redirectURL: `${serverUrl}${redirectUrl}`
});
@ -1416,8 +1412,6 @@ describe('net module', () => {
customSession.webRequest.onBeforeRequest((details, callback) => {
if (details.url === `${serverUrl}${requestUrl}`) {
requestIsIntercepted = true;
// Disabled due to false positive in StandardJS
// eslint-disable-next-line standard/no-callback-literal
callback({
redirectURL: `${serverUrl}${redirectUrl}`
});

View file

@ -141,7 +141,6 @@ describe('powerMonitor', () => {
});
describe('when powerMonitor module is loaded', () => {
// eslint-disable-next-line no-undef
let powerMonitor: typeof Electron.powerMonitor;
before(() => {
powerMonitor = require('electron').powerMonitor;

View file

@ -12,9 +12,6 @@ import { defer, listen } from './lib/spec-helpers';
import { once } from 'events';
import { setTimeout } from 'timers/promises';
/* The whole session API doesn't use standard callbacks */
/* eslint-disable standard/no-callback-literal */
describe('session module', () => {
const fixtures = path.resolve(__dirname, 'fixtures');
const url = 'http://127.0.0.1';

View file

@ -13,41 +13,33 @@ describe('utilityProcess module', () => {
describe('UtilityProcess constructor', () => {
it('throws when empty script path is provided', async () => {
expect(() => {
/* eslint-disable no-new */
utilityProcess.fork('');
/* eslint-disable no-new */
}).to.throw();
});
it('throws when options.stdio is not valid', async () => {
expect(() => {
/* eslint-disable no-new */
utilityProcess.fork(path.join(fixturesPath, 'empty.js'), [], {
execArgv: ['--test', '--test2'],
serviceName: 'test',
stdio: 'ipc'
});
/* eslint-disable no-new */
}).to.throw(/stdio must be of the following values: inherit, pipe, ignore/);
expect(() => {
/* eslint-disable no-new */
utilityProcess.fork(path.join(fixturesPath, 'empty.js'), [], {
execArgv: ['--test', '--test2'],
serviceName: 'test',
stdio: ['ignore', 'ignore']
});
/* eslint-disable no-new */
}).to.throw(/configuration missing for stdin, stdout or stderr/);
expect(() => {
/* eslint-disable no-new */
utilityProcess.fork(path.join(fixturesPath, 'empty.js'), [], {
execArgv: ['--test', '--test2'],
serviceName: 'test',
stdio: ['pipe', 'inherit', 'inherit']
});
/* eslint-disable no-new */
}).to.throw(/stdin value other than ignore is not supported/);
});
});

View file

@ -1111,29 +1111,25 @@ describe('asar package', function () {
describe('fs.exists', function () {
itremote('handles an existing file', async function () {
const p = path.join(asarDir, 'a.asar', 'file1');
// eslint-disable-next-line
const exists = await new Promise(resolve => fs.exists(p, resolve))
const exists = await new Promise(resolve => fs.exists(p, resolve));
expect(exists).to.be.true();
});
itremote('handles a non-existent file', async function () {
const p = path.join(asarDir, 'a.asar', 'not-exist');
// eslint-disable-next-line
const exists = await new Promise(resolve => fs.exists(p, resolve))
const exists = await new Promise(resolve => fs.exists(p, resolve));
expect(exists).to.be.false();
});
itremote('promisified version handles an existing file', async () => {
const p = path.join(asarDir, 'a.asar', 'file1');
// eslint-disable-next-line
const exists = await require('util').promisify(fs.exists)(p)
const exists = await require('util').promisify(fs.exists)(p);
expect(exists).to.be.true();
});
itremote('promisified version handles a non-existent file', async function () {
const p = path.join(asarDir, 'a.asar', 'not-exist');
// eslint-disable-next-line
const exists = await require('util').promisify(fs.exists)(p)
const exists = await require('util').promisify(fs.exists)(p);
expect(exists).to.be.false();
});
});

View file

@ -1 +1 @@
nonExistingFunc(); // eslint-disable-line
nonExistingFunc(); // eslint-disable-line no-undef

View file

@ -1,6 +1,7 @@
const { WebContentsView, app } = require('electron');
app.whenReady().then(function () {
new WebContentsView({}) // eslint-disable-line
// eslint-disable-next-line no-new
new WebContentsView({});
app.quit();
});

View file

@ -1,3 +1,5 @@
/* global registerPaint */
class CheckerboardPainter {
paint (ctx, geom, properties) {
const colors = ['red', 'green', 'blue'];
@ -14,5 +16,4 @@ class CheckerboardPainter {
}
}
// eslint-disable-next-line no-undef
registerPaint('checkerboard', CheckerboardPainter);

View file

@ -1,33 +1,33 @@
/* eslint-disable */
/* global chrome */
function evalInMainWorld (fn) {
const script = document.createElement('script')
script.textContent = `((${fn})())`
document.documentElement.appendChild(script)
const script = document.createElement('script');
script.textContent = `((${fn})())`;
document.documentElement.appendChild(script);
}
async function exec (name) {
let result
let result;
switch (name) {
case 'getMessage':
result = {
id: chrome.i18n.getMessage('@@extension_id'),
name: chrome.i18n.getMessage('extName'),
}
break
name: chrome.i18n.getMessage('extName')
};
break;
case 'getAcceptLanguages':
result = await new Promise(resolve => chrome.i18n.getAcceptLanguages(resolve))
break
result = await new Promise(resolve => chrome.i18n.getAcceptLanguages(resolve));
break;
}
const funcStr = `() => { require('electron').ipcRenderer.send('success', ${JSON.stringify(result)}) }`
evalInMainWorld(funcStr)
const funcStr = `() => { require('electron').ipcRenderer.send('success', ${JSON.stringify(result)}) }`;
evalInMainWorld(funcStr);
}
window.addEventListener('message', event => {
exec(event.data.name)
})
exec(event.data.name);
});
evalInMainWorld(() => {
window.exec = name => window.postMessage({ name })
})
window.exec = name => window.postMessage({ name });
});

View file

@ -1,39 +1,39 @@
/* eslint-disable */
/* global chrome */
function evalInMainWorld (fn) {
const script = document.createElement('script')
script.textContent = `((${fn})())`
document.documentElement.appendChild(script)
const script = document.createElement('script');
script.textContent = `((${fn})())`;
document.documentElement.appendChild(script);
}
async function exec (name) {
let result
let result;
switch (name) {
case 'getManifest':
result = chrome.runtime.getManifest()
break
result = chrome.runtime.getManifest();
break;
case 'id':
result = chrome.runtime.id
break
result = chrome.runtime.id;
break;
case 'getURL':
result = chrome.runtime.getURL('main.js')
break
result = chrome.runtime.getURL('main.js');
break;
case 'getPlatformInfo': {
result = await new Promise(resolve => {
chrome.runtime.sendMessage(name, resolve)
})
break
chrome.runtime.sendMessage(name, resolve);
});
break;
}
}
const funcStr = `() => { require('electron').ipcRenderer.send('success', ${JSON.stringify(result)}) }`
evalInMainWorld(funcStr)
const funcStr = `() => { require('electron').ipcRenderer.send('success', ${JSON.stringify(result)}) }`;
evalInMainWorld(funcStr);
}
window.addEventListener('message', event => {
exec(event.data.name)
})
exec(event.data.name);
});
evalInMainWorld(() => {
window.exec = name => window.postMessage({ name })
})
window.exec = name => window.postMessage({ name });
});

View file

@ -1,8 +1,8 @@
/* eslint-disable */
/* global chrome */
chrome.storage.local.set({ key: 'value' }, () => {
chrome.storage.local.get(['key'], ({ key }) => {
const script = document.createElement('script')
script.textContent = `require('electron').ipcRenderer.send('storage-success', ${JSON.stringify(key)})`
document.documentElement.appendChild(script)
})
})
const script = document.createElement('script');
script.textContent = `require('electron').ipcRenderer.send('storage-success', ${JSON.stringify(key)})`;
document.documentElement.appendChild(script);
});
});

View file

@ -1,2 +1,2 @@
// eslint-disable-next-line
chrome.devtools.panels.create('Foo', 'icon.png', 'index.html')
/* global chrome */
chrome.devtools.panels.create('Foo', 'icon.png', 'index.html');

View file

@ -1,4 +1,4 @@
// eslint-disable-next-line
chrome.devtools.inspectedWindow.eval(`require("electron").ipcRenderer.send("winning")`, (result, exc) => {
/* global chrome */
chrome.devtools.inspectedWindow.eval('require("electron").ipcRenderer.send("winning")', (result, exc) => {
console.log(result, exc);
});

View file

@ -1,4 +1,4 @@
/* eslint-disable no-undef */
/* global chrome */
chrome.runtime.onMessage.addListener((message, sender, reply) => {
window.receivedMessage = message;
reply({ message, sender });

View file

@ -1,4 +1,4 @@
/* eslint-disable no-undef */
/* global chrome */
chrome.runtime.sendMessage({ some: 'message' }, (response) => {
const script = document.createElement('script');
script.textContent = `require('electron').ipcRenderer.send('bg-page-message-response', ${JSON.stringify(response)})`;

View file

@ -1 +0,0 @@
/* eslint-disable no-undef */

View file

@ -1,4 +1,4 @@
var test = 'test' // eslint-disable-line
var test = 'test'; // eslint-disable-line no-var
const types = {
require: typeof require,

View file

@ -52,7 +52,7 @@
ipcRenderer.on('touch-the-opener', () => {
let errorMessage = null;
try {
const openerDoc = opener.document; // eslint-disable-line no-unused-vars
const openerDoc = opener.document;
} catch (error) {
errorMessage = error.message;
}

View file

@ -1,3 +1,3 @@
// taken from https://chromium.googlesource.com/v8/v8.git/+/HEAD/test/cctest/test-serialize.cc#1127
function f () { return g() * 2; } // eslint-disable-line no-unused-vars
function f () { return g() * 2; }
function g () { return 43; }

View file

@ -200,7 +200,6 @@ describe('node feature', () => {
emitter.on(eventName, listener);
});
// eslint-disable-next-line standard/no-callback-literal
callback(...args);
});
};
@ -422,9 +421,7 @@ describe('node feature', () => {
// Needed to test specific DiffieHellman ctors.
// eslint-disable-next-line no-octal
crypto.createDiffieHellman('abc', Buffer.from([2]));
// eslint-disable-next-line no-octal
crypto.createDiffieHellman('abc', '123');
});