From d4a630902d8d250b67fcd0ce2b49240786b40368 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 4 Apr 2020 08:46:54 +0900 Subject: [PATCH] refactor: Use === --- src/boot/master.ts | 2 +- src/client/app.vue | 4 ++-- src/client/mios.ts | 2 +- src/client/scripts/hotkey.ts | 6 +++--- src/client/scripts/keycode.ts | 2 +- src/client/scripts/paging.ts | 2 +- src/client/scripts/search.ts | 4 ++-- src/client/scripts/stream.ts | 6 +++--- src/client/store.ts | 2 +- src/client/widgets/activity.calendar.vue | 6 +++--- src/client/widgets/activity.vue | 4 ++-- src/client/widgets/calendar.vue | 4 ++-- src/client/widgets/photos.vue | 4 ++-- src/config/load.ts | 2 +- src/games/reversi/core.ts | 4 ++-- src/mfm/fromHtml.ts | 10 +++++----- src/mfm/language.ts | 4 ++-- src/mfm/normalize.ts | 2 +- src/mfm/parse.ts | 4 ++-- src/models/repositories/note.ts | 2 +- src/remote/activitypub/kernel/accept/follow.ts | 2 +- src/remote/activitypub/kernel/follow.ts | 2 +- src/remote/activitypub/kernel/reject/follow.ts | 2 +- src/remote/activitypub/kernel/undo/block.ts | 2 +- src/remote/activitypub/kernel/undo/follow.ts | 2 +- src/remote/activitypub/models/note.ts | 2 +- src/remote/activitypub/models/person.ts | 4 ++-- src/remote/activitypub/models/question.ts | 2 +- src/remote/activitypub/renderer/announce.ts | 4 ++-- src/remote/activitypub/renderer/note.ts | 6 +++--- src/server/activitypub/outbox.ts | 2 +- src/server/api/2fa.ts | 2 +- src/server/api/api-handler.ts | 2 +- src/server/api/endpoints/admin/drive/files.ts | 4 ++-- src/server/api/endpoints/i/update.ts | 16 ++++++++-------- src/server/api/streaming.ts | 2 +- src/server/index.ts | 2 +- src/services/push-notification.ts | 2 +- webpack.config.ts | 2 +- 39 files changed, 69 insertions(+), 69 deletions(-) diff --git a/src/boot/master.ts b/src/boot/master.ts index 39d198195..f1a8b9f6a 100644 --- a/src/boot/master.ts +++ b/src/boot/master.ts @@ -99,7 +99,7 @@ async function isPortAvailable(port: number): Promise { function showEnvironment(): void { const env = process.env.NODE_ENV; const logger = bootLogger.createSubLogger('env'); - logger.info(typeof env == 'undefined' ? 'NODE_ENV is not set' : `NODE_ENV: ${env}`); + logger.info(typeof env === 'undefined' ? 'NODE_ENV is not set' : `NODE_ENV: ${env}`); if (env !== 'production') { logger.warn('The environment is not in production mode.'); diff --git a/src/client/app.vue b/src/client/app.vue index fc40b6973..5523e1e75 100644 --- a/src/client/app.vue +++ b/src/client/app.vue @@ -310,7 +310,7 @@ export default Vue.extend({ title: this.$t('search'), input: true }).then(async ({ canceled, result: query }) => { - if (canceled || query == null || query == '') return; + if (canceled || query == null || query === '') return; this.searching = true; search(this, query).finally(() => { @@ -320,7 +320,7 @@ export default Vue.extend({ }, searchKeypress(e) { - if (e.keyCode == 13) { + if (e.keyCode === 13) { this.searchWait = true; search(this, this.searchQuery).finally(() => { this.searchWait = false; diff --git a/src/client/mios.ts b/src/client/mios.ts index 63d9f7d3a..ba42f3a16 100644 --- a/src/client/mios.ts +++ b/src/client/mios.ts @@ -197,7 +197,7 @@ export default class MiOS extends EventEmitter { // When subscribe failed .catch(async (err: Error) => { // 通知が許可されていなかったとき - if (err.name == 'NotAllowedError') { + if (err.name === 'NotAllowedError') { return; } diff --git a/src/client/scripts/hotkey.ts b/src/client/scripts/hotkey.ts index 672dbedde..7d1bb16e7 100644 --- a/src/client/scripts/hotkey.ts +++ b/src/client/scripts/hotkey.ts @@ -57,9 +57,9 @@ const ignoreElemens = ['input', 'textarea']; function match(e: KeyboardEvent, patterns: action['patterns']): boolean { const key = e.code.toLowerCase(); return patterns.some(pattern => pattern.which.includes(key) && - pattern.ctrl == e.ctrlKey && - pattern.shift == e.shiftKey && - pattern.alt == e.altKey && + pattern.ctrl === e.ctrlKey && + pattern.shift === e.shiftKey && + pattern.alt === e.altKey && !e.metaKey ); } diff --git a/src/client/scripts/keycode.ts b/src/client/scripts/keycode.ts index 5786c1dc0..c127d54bb 100644 --- a/src/client/scripts/keycode.ts +++ b/src/client/scripts/keycode.ts @@ -1,5 +1,5 @@ export default (input: string): string[] => { - if (Object.keys(aliases).some(a => a.toLowerCase() == input.toLowerCase())) { + if (Object.keys(aliases).some(a => a.toLowerCase() === input.toLowerCase())) { const codes = aliases[input]; return Array.isArray(codes) ? codes : [codes]; } else { diff --git a/src/client/scripts/paging.ts b/src/client/scripts/paging.ts index 1656e263f..048c79775 100644 --- a/src/client/scripts/paging.ts +++ b/src/client/scripts/paging.ts @@ -20,7 +20,7 @@ export default (opts) => ({ computed: { empty(): boolean { - return this.items.length == 0 && !this.fetching && this.inited; + return this.items.length === 0 && !this.fetching && this.inited; }, error(): boolean { diff --git a/src/client/scripts/search.ts b/src/client/scripts/search.ts index 02dd39b03..16057dfd3 100644 --- a/src/client/scripts/search.ts +++ b/src/client/scripts/search.ts @@ -47,9 +47,9 @@ export async function search(v: any, q: string) { uri: q }); dialog.close(); - if (res.type == 'User') { + if (res.type === 'User') { v.$router.push(`/@${res.object.username}@${res.object.host}`); - } else if (res.type == 'Note') { + } else if (res.type === 'Note') { v.$router.push(`/notes/${res.object.id}`); } } catch (e) { diff --git a/src/client/scripts/stream.ts b/src/client/scripts/stream.ts index 18bb7c13d..4dcd3f1b2 100644 --- a/src/client/scripts/stream.ts +++ b/src/client/scripts/stream.ts @@ -68,7 +68,7 @@ export default class Stream extends EventEmitter { */ @autobind private onOpen() { - const isReconnect = this.state == 'reconnecting'; + const isReconnect = this.state === 'reconnecting'; this.state = 'connected'; this.emit('_connected_'); @@ -87,7 +87,7 @@ export default class Stream extends EventEmitter { */ @autobind private onClose() { - if (this.state == 'connected') { + if (this.state === 'connected') { this.state = 'reconnecting'; this.emit('_disconnected_'); } @@ -100,7 +100,7 @@ export default class Stream extends EventEmitter { private onMessage(message) { const { type, body } = JSON.parse(message.data); - if (type == 'channel') { + if (type === 'channel') { const id = body.id; let connections: Connection[]; diff --git a/src/client/store.ts b/src/client/store.ts index 5e98092c2..b2aea3839 100644 --- a/src/client/store.ts +++ b/src/client/store.ts @@ -257,7 +257,7 @@ export default () => new Vuex.Store({ }, updateWidget(state, x) { - const w = state.widgets.find(w => w.id == x.id); + const w = state.widgets.find(w => w.id === x.id); if (w) { w.data = x.data; } diff --git a/src/client/widgets/activity.calendar.vue b/src/client/widgets/activity.calendar.vue index dfc0d29d3..334c2ea56 100644 --- a/src/client/widgets/activity.calendar.vue +++ b/src/client/widgets/activity.calendar.vue @@ -51,14 +51,14 @@ export default Vue.extend({ weekday: date.getDay() }; - d.v = peak == 0 ? 0 : d.total / (peak / 2); + d.v = peak === 0 ? 0 : d.total / (peak / 2); if (d.v > 1) d.v = 1; - const ch = d.date.weekday == 0 || d.date.weekday == 6 ? 275 : 170; + const ch = d.date.weekday === 0 || d.date.weekday === 6 ? 275 : 170; const cs = d.v * 100; const cl = 15 + ((1 - d.v) * 80); d.color = `hsl(${ch}, ${cs}%, ${cl}%)`; - if (d.date.weekday == 0) x--; + if (d.date.weekday === 0) x--; }); } }); diff --git a/src/client/widgets/activity.vue b/src/client/widgets/activity.vue index e08676c9a..6c32642bb 100644 --- a/src/client/widgets/activity.vue +++ b/src/client/widgets/activity.vue @@ -60,7 +60,7 @@ export default define({ }, methods: { func() { - if (this.props.design == 2) { + if (this.props.design === 2) { this.props.design = 0; } else { this.props.design++; @@ -68,7 +68,7 @@ export default define({ this.save(); }, toggleView() { - if (this.props.view == 1) { + if (this.props.view === 1) { this.props.view = 0; } else { this.props.view++; diff --git a/src/client/widgets/calendar.vue b/src/client/widgets/calendar.vue index b7d577c37..c041734a4 100644 --- a/src/client/widgets/calendar.vue +++ b/src/client/widgets/calendar.vue @@ -65,7 +65,7 @@ export default define({ }, methods: { func() { - if (this.props.design == 2) { + if (this.props.design === 2) { this.props.design = 0; } else { this.props.design++; @@ -102,7 +102,7 @@ export default define({ this.monthP = monthNumer / monthDenom * 100; this.yearP = yearNumer / yearDenom * 100; - this.isHoliday = now.getDay() == 0 || now.getDay() == 6; + this.isHoliday = now.getDay() === 0 || now.getDay() === 6; } } }); diff --git a/src/client/widgets/photos.vue b/src/client/widgets/photos.vue index fb2e6de0b..1deb6de62 100644 --- a/src/client/widgets/photos.vue +++ b/src/client/widgets/photos.vue @@ -1,6 +1,6 @@