From aec8f67b813513387aff592852ed7ef314dec72a Mon Sep 17 00:00:00 2001 From: AkiraFukushima Date: Sun, 17 May 2020 16:31:37 +0900 Subject: [PATCH] Fix lexical scope --- package-lock.json | 9 ++++++--- .../store/TimelineSpace/Contents/Lists/Edit.spec.ts | 2 +- .../store/TimelineSpace/Contents/Lists/Index.spec.ts | 2 +- .../TimelineSpace/Contents/Search/Account.spec.ts | 2 +- .../store/TimelineSpace/Contents/Search/Tag.spec.ts | 2 +- .../store/TimelineSpace/Contents/Search/Toots.spec.ts | 2 +- src/main/index.ts | 10 +++++----- src/renderer/components/TimelineSpace/SideMenu.vue | 3 ++- src/renderer/components/organisms/Toot.vue | 5 +++-- src/renderer/utils/suggestText.js | 4 ++-- 10 files changed, 23 insertions(+), 18 deletions(-) diff --git a/package-lock.json b/package-lock.json index 40fd81ba..7ddfccac 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8680,7 +8680,7 @@ "dependencies": { "resolve": { "version": "1.1.7", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", + "resolved": "http://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=", "dev": true } @@ -27663,6 +27663,7 @@ "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.9.tgz", "integrity": "sha512-8CJsbKOtEbnJsTyv6LE6m6ZKniqMiFWmm9sRbopbkGs3gMPPfd3Fh8iIA4Ykv5MgaTbqHr4BaoGLJLZNhsrW1Q==", "dev": true, + "optional": true, "requires": { "commander": "~2.17.1", "source-map": "~0.6.1" @@ -27672,13 +27673,15 @@ "version": "2.17.1", "resolved": "https://registry.npmjs.org/commander/-/commander-2.17.1.tgz", "integrity": "sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg==", - "dev": true + "dev": true, + "optional": true }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true + "dev": true, + "optional": true } } }, diff --git a/spec/renderer/integration/store/TimelineSpace/Contents/Lists/Edit.spec.ts b/spec/renderer/integration/store/TimelineSpace/Contents/Lists/Edit.spec.ts index 231355ca..8b0b32bd 100644 --- a/spec/renderer/integration/store/TimelineSpace/Contents/Lists/Edit.spec.ts +++ b/spec/renderer/integration/store/TimelineSpace/Contents/Lists/Edit.spec.ts @@ -57,7 +57,7 @@ const account: Entity.Account = { bot: false } -let state = (): EditState => { +const state = (): EditState => { return { members: [] } diff --git a/spec/renderer/integration/store/TimelineSpace/Contents/Lists/Index.spec.ts b/spec/renderer/integration/store/TimelineSpace/Contents/Lists/Index.spec.ts index 99182168..c33e7b54 100644 --- a/spec/renderer/integration/store/TimelineSpace/Contents/Lists/Index.spec.ts +++ b/spec/renderer/integration/store/TimelineSpace/Contents/Lists/Index.spec.ts @@ -39,7 +39,7 @@ const list: Entity.List = { title: 'list1' } -let state = (): IndexState => { +const state = (): IndexState => { return { lists: [] } diff --git a/spec/renderer/integration/store/TimelineSpace/Contents/Search/Account.spec.ts b/spec/renderer/integration/store/TimelineSpace/Contents/Search/Account.spec.ts index a43105bb..59f2e9fe 100644 --- a/spec/renderer/integration/store/TimelineSpace/Contents/Search/Account.spec.ts +++ b/spec/renderer/integration/store/TimelineSpace/Contents/Search/Account.spec.ts @@ -45,7 +45,7 @@ jest.mock('megalodon', () => ({ __esModule: true })) -let state = (): AccountState => { +const state = (): AccountState => { return { results: [] } diff --git a/spec/renderer/integration/store/TimelineSpace/Contents/Search/Tag.spec.ts b/spec/renderer/integration/store/TimelineSpace/Contents/Search/Tag.spec.ts index 1af5f607..9067d2c9 100644 --- a/spec/renderer/integration/store/TimelineSpace/Contents/Search/Tag.spec.ts +++ b/spec/renderer/integration/store/TimelineSpace/Contents/Search/Tag.spec.ts @@ -33,7 +33,7 @@ jest.mock('megalodon', () => ({ __esModule: true })) -let state = (): TagState => { +const state = (): TagState => { return { results: [] } diff --git a/spec/renderer/integration/store/TimelineSpace/Contents/Search/Toots.spec.ts b/spec/renderer/integration/store/TimelineSpace/Contents/Search/Toots.spec.ts index 5a0aaf7c..f11dd0b1 100644 --- a/spec/renderer/integration/store/TimelineSpace/Contents/Search/Toots.spec.ts +++ b/spec/renderer/integration/store/TimelineSpace/Contents/Search/Toots.spec.ts @@ -83,7 +83,7 @@ const status: Entity.Status = { quote: false } -let state = (): TootsState => { +const state = (): TootsState => { return { results: [] } diff --git a/src/main/index.ts b/src/main/index.ts index d97e042c..370f7c70 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -119,7 +119,7 @@ const userData = app.getPath('userData') const appPath = app.getPath('exe') const accountDBPath = process.env.NODE_ENV === 'production' ? userData + '/db/account.db' : 'account.db' -let accountDB = new Datastore({ +const accountDB = new Datastore({ filename: accountDBPath, autoload: true }) @@ -127,7 +127,7 @@ const accountManager = new Account(accountDB) accountManager.initialize().catch((err: Error) => log.error(err)) const hashtagsDBPath = process.env.NODE_ENV === 'production' ? userData + '/db/hashtags.db' : 'hashtags.db' -let hashtagsDB = new Datastore({ +const hashtagsDB = new Datastore({ filename: hashtagsDBPath, autoload: true }) @@ -250,7 +250,7 @@ async function createWindow() { /** * Initial window options */ - let mainWindowState = windowStateKeeper({ + const mainWindowState = windowStateKeeper({ defaultWidth: 1000, defaultHeight: 563 }) @@ -365,7 +365,7 @@ app.on('activate', () => { } }) -let auth = new Authentication(accountManager) +const auth = new Authentication(accountManager) type AuthRequest = { instance: string @@ -553,7 +553,7 @@ ipcMain.handle( ) // user streaming -let userStreamings: { [key: string]: UserStreaming | null } = {} +const userStreamings: { [key: string]: UserStreaming | null } = {} ipcMain.on('start-all-user-streamings', (event: IpcMainEvent, accounts: Array) => { accounts.map(async account => { diff --git a/src/renderer/components/TimelineSpace/SideMenu.vue b/src/renderer/components/TimelineSpace/SideMenu.vue index d7ac381a..a8a18f32 100644 --- a/src/renderer/components/TimelineSpace/SideMenu.vue +++ b/src/renderer/components/TimelineSpace/SideMenu.vue @@ -185,10 +185,11 @@ export default { case 'edit': window.shell.openExternal(this.account.baseURL + '/settings/profile') break - case 'settings': + case 'settings': { const url = `/${this.id()}/settings` this.$router.push(url) break + } } }, doCollapse() { diff --git a/src/renderer/components/organisms/Toot.vue b/src/renderer/components/organisms/Toot.vue index b9c072bc..933fdda5 100644 --- a/src/renderer/components/organisms/Toot.vue +++ b/src/renderer/components/organisms/Toot.vue @@ -331,7 +331,7 @@ export default { return this.$store.state.TimelineSpace.account.accountId === this.originalMessage.account.id }, application: function () { - let msg = this.originalMessage + const msg = this.originalMessage if (msg.application !== undefined && msg.application !== null) { return msg.application.name } @@ -615,13 +615,14 @@ export default { case 'profile': this.openUser(this.originalMessage.account) break - case 'image': + case 'image': { const images = this.mediaAttachments if (images.length === 0) { return 0 } this.openImage(images[0].url, images) break + } case 'cw': this.showContent = !this.showContent this.showAttachments = !this.showAttachments diff --git a/src/renderer/utils/suggestText.js b/src/renderer/utils/suggestText.js index a1e42526..d5a81b4d 100644 --- a/src/renderer/utils/suggestText.js +++ b/src/renderer/utils/suggestText.js @@ -2,8 +2,8 @@ const textAtCursorMatch = (str, cursorPosition, separators = ['@', '#', ':']) => { let word - let left = str.slice(0, cursorPosition).search(/\S+$/) - let right = str.slice(cursorPosition).search(/\s/) + const left = str.slice(0, cursorPosition).search(/\S+$/) + const right = str.slice(cursorPosition).search(/\s/) if (right < 0) { word = str.slice(left)