From 3f8b933d05e2b1630783333e9a656c71e0464c26 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Wed, 5 Feb 2020 15:16:31 +0300 Subject: [PATCH] lint --- app/lib/app.ts | 5 +++-- app/lib/cli.ts | 10 +++++----- app/lib/index.ts | 4 ++-- app/lib/lru.ts | 12 +++++++----- app/lib/sentry.ts | 42 +++++++++++++++++++++--------------------- app/lib/window.ts | 12 ++++++------ 6 files changed, 44 insertions(+), 41 deletions(-) diff --git a/app/lib/app.ts b/app/lib/app.ts index 89ae86c8..c8b0652f 100644 --- a/app/lib/app.ts +++ b/app/lib/app.ts @@ -1,4 +1,5 @@ import { app, ipcMain, Menu, Tray, shell } from 'electron' +// eslint-disable-next-line no-duplicate-imports import * as electron from 'electron' import { loadConfig } from './config' import { Window, WindowOptions } from './window' @@ -75,7 +76,7 @@ export class Application { this.tray = new Tray(`${app.getAppPath()}/assets/tray.png`) } - this.tray.on('click', () => setTimeout(() => this.focus())); + this.tray.on('click', () => setTimeout(() => this.focus())) const contextMenu = Menu.buildFromTemplate([{ label: 'Show', @@ -186,7 +187,7 @@ export class Application { }, }, ], - } + }, ] Menu.setApplicationMenu(Menu.buildFromTemplate(template)) diff --git a/app/lib/cli.ts b/app/lib/cli.ts index d1cfcf75..856d3ccf 100644 --- a/app/lib/cli.ts +++ b/app/lib/cli.ts @@ -20,25 +20,25 @@ export function parseArgs (argv, cwd) { return yargs.option('escape', { alias: 'e', type: 'boolean', - describe: 'Perform shell escaping' + describe: 'Perform shell escaping', }).positional('text', { - type: 'string' + type: 'string', }) }) .version('version', '', app.getVersion()) .option('debug', { alias: 'd', describe: 'Show DevTools on start', - type: 'boolean' + type: 'boolean', }) .option('hidden', { describe: 'Start minimized', - type: 'boolean' + type: 'boolean', }) .option('version', { alias: 'v', describe: 'Show version and exit', - type: 'boolean' + type: 'boolean', }) .help('help') .parse(argv.slice(1)) diff --git a/app/lib/index.ts b/app/lib/index.ts index d055d9b1..9d2d1239 100644 --- a/app/lib/index.ts +++ b/app/lib/index.ts @@ -59,8 +59,8 @@ app.on('ready', () => { label: 'New window', click () { this.app.newWindow() - } - } + }, + }, ])) } application.init() diff --git a/app/lib/lru.ts b/app/lib/lru.ts index 695db686..683d1e11 100644 --- a/app/lib/lru.ts +++ b/app/lib/lru.ts @@ -1,13 +1,15 @@ -let lru = require('lru-cache')({ max: 256, maxAge: 250 }) - -let fs = require('fs') -let origLstat = fs.realpathSync.bind(fs) +import createLRU from 'lru-cache' +import * as fs from 'fs' +const lru = createLRU({ max: 256, maxAge: 250 }) +const origLstat = fs.realpathSync.bind(fs) // NB: The biggest offender of thrashing realpathSync is the node module system // itself, which we can't get into via any sane means. require('fs').realpathSync = function (p) { let r = lru.get(p) - if (r) return r + if (r) { + return r + } r = origLstat(p) lru.set(p, r) diff --git a/app/lib/sentry.ts b/app/lib/sentry.ts index 649b9694..051381c8 100755 --- a/app/lib/sentry.ts +++ b/app/lib/sentry.ts @@ -1,21 +1,21 @@ -const { init } = process.type === 'main' ? require('@sentry/electron/dist/main') : require('@sentry/electron/dist/renderer') -import * as isDev from 'electron-is-dev' - - -const SENTRY_DSN = 'https://4717a0a7ee0b4429bd3a0f06c3d7eec3@sentry.io/181876' -let release -try { - release = require('electron').app.getVersion() -} catch { - release = require('electron').remote.app.getVersion() -} - -if (!isDev) { - init({ - dsn: SENTRY_DSN, - release, - integrations (integrations) { - return integrations.filter(integration => integration.name !== 'Breadcrumbs') - }, - }) -} +const { init } = process.type === 'main' ? require('@sentry/electron/dist/main') : require('@sentry/electron/dist/renderer') +import * as isDev from 'electron-is-dev' + + +const SENTRY_DSN = 'https://4717a0a7ee0b4429bd3a0f06c3d7eec3@sentry.io/181876' +let release +try { + release = require('electron').app.getVersion() +} catch { + release = require('electron').remote.app.getVersion() +} + +if (!isDev) { + init({ + dsn: SENTRY_DSN, + release, + integrations (integrations) { + return integrations.filter(integration => integration.name !== 'Breadcrumbs') + }, + }) +} diff --git a/app/lib/window.ts b/app/lib/window.ts index 559ea0c4..bdc818aa 100644 --- a/app/lib/window.ts +++ b/app/lib/window.ts @@ -56,14 +56,14 @@ export class Window { if (this.windowBounds) { Object.assign(bwOptions, this.windowBounds) - const closestDisplay = screen.getDisplayNearestPoint( {x: this.windowBounds.x, y: this.windowBounds.y} ) + const closestDisplay = screen.getDisplayNearestPoint( { x: this.windowBounds.x, y: this.windowBounds.y } ) - const [left1, top1, right1, bottom1] = [this.windowBounds.x, this.windowBounds.y, this.windowBounds.x + this.windowBounds.width, this.windowBounds.y + this.windowBounds.height]; - const [left2, top2, right2, bottom2] = [closestDisplay.bounds.x, closestDisplay.bounds.y, closestDisplay.bounds.x + closestDisplay.bounds.width, closestDisplay.bounds.y + closestDisplay.bounds.height]; + const [left1, top1, right1, bottom1] = [this.windowBounds.x, this.windowBounds.y, this.windowBounds.x + this.windowBounds.width, this.windowBounds.y + this.windowBounds.height] + const [left2, top2, right2, bottom2] = [closestDisplay.bounds.x, closestDisplay.bounds.y, closestDisplay.bounds.x + closestDisplay.bounds.width, closestDisplay.bounds.y + closestDisplay.bounds.height] if ((left2 > right1 || right2 < left1 || top2 > bottom1 || bottom2 < top1) && !maximized) { - bwOptions.x = closestDisplay.bounds.width / 2 - bwOptions.width / 2; - bwOptions.y = closestDisplay.bounds.height / 2 - bwOptions.height / 2; + bwOptions.x = closestDisplay.bounds.width / 2 - bwOptions.width / 2 + bwOptions.y = closestDisplay.bounds.height / 2 - bwOptions.height / 2 } } @@ -150,7 +150,7 @@ export class Window { } isDestroyed () { - return !this.window || this.window.isDestroyed(); + return !this.window || this.window.isDestroyed() } private setupWindowManagement () {