Skip to content

Commit 8abf63f

Browse files
committed
enable noImplicitReturns
1 parent 23d25e6 commit 8abf63f

File tree

5 files changed

+26
-11
lines changed

5 files changed

+26
-11
lines changed

lib/models/revision.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ function createDmpWorker() {
2323
if (config.debug) logger.info('dmp worker process started')
2424
worker.on('message', function (data) {
2525
if (!data || !data.msg || !data.cacheKey) {
26-
return logger.error('dmp worker error: not enough data on message')
26+
logger.error('dmp worker error: not enough data on message')
27+
return
2728
}
2829
var cacheKey = data.cacheKey
2930
switch (data.msg) {

lib/realtime/realtime.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,10 @@ export function queueForDisconnect(socket) {
533533
if (Object.keys(note.users).length === 0) {
534534
if (note.server.isDirty) {
535535
exports.updateNote(note, function (err, _note) {
536-
if (err) return logger.error('disconnect note failed: ' + err)
536+
if (err) {
537+
logger.error('disconnect note failed: ' + err)
538+
return
539+
}
537540
// clear server before delete to avoid memory leaks
538541
note.server.document = ''
539542
note.server.operations = []
@@ -657,7 +660,7 @@ function operationCallback(socket, operation) {
657660
}
658661

659662
// TODO: test it
660-
export function updateHistory(userId, note, time) {
663+
export function updateHistory(userId, note, time?: any) {
661664
var noteId = note.alias ? note.alias : models.Note.encodeNoteId(note.id)
662665
if (note.server) history.updateHistory(userId, noteId, note.server.document, time)
663666
}
@@ -687,7 +690,7 @@ function getUniqueColorPerNote(noteId, maxAttempt = 10) {
687690
function queueForConnect(socket) {
688691
connectProcessQueue.push(socket.id, async function () {
689692
try {
690-
const noteId = await exports.parseNoteIdFromSocketAsync(socket)
693+
const noteId = await exports.parseNoteIdFromSocketAsync(socket) as string
691694
if (!noteId) {
692695
return exports.failConnection(404, 'note id not found', socket)
693696
}

lib/realtime/realtimeCleanDanglingUserJob.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ export class CleanDanglingUserJob {
4545
}
4646
return callback(null, null)
4747
}, function (err) {
48-
if (err) return logger.error('cleaner error', err)
48+
if (err) {
49+
logger.error('cleaner error', err)
50+
}
4951
})
5052
}
5153
}

lib/realtime/realtimeSaveRevisionJob.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ export class SaveRevisionJob {
3030
saveRevision() {
3131
if (this.getSaverSleep()) return
3232
models.Revision.saveAllNotesRevision((err, notes) => {
33-
if (err) return logger.error('revision saver failed: ' + err)
33+
if (err) {
34+
logger.error('revision saver failed: ' + err)
35+
}
3436
if (notes && notes.length <= 0) {
3537
this.setSaverSleep(true)
3638
}

lib/workers/dmpWorker.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ import * as logger from "../logger";
88
var dmp = new DiffMatchPatch()
99
process.on('message', function (data) {
1010
if (!data || !data.msg || !data.cacheKey) {
11-
return logger.error('dmp worker error: not enough data')
11+
logger.error('dmp worker error: not enough data')
12+
return null
1213
}
1314
switch (data.msg) {
1415
case 'create patch':
1516
if (!Object.hasOwnProperty.call(data, 'lastDoc') || !Object.hasOwnProperty.call(data, 'currDoc')) {
16-
return logger.error('dmp worker error: not enough data on create patch')
17+
logger.error('dmp worker error: not enough data on create patch')
18+
return null
1719
}
1820
try {
1921
var patch = createPatch(data.lastDoc, data.currDoc)
@@ -52,9 +54,10 @@ process.on('message', function (data) {
5254
}
5355
break
5456
}
57+
return null
5558
})
5659

57-
function createPatch (lastDoc, currDoc) {
60+
function createPatch(lastDoc, currDoc) {
5861
var msStart = (new Date()).getTime()
5962
var diff = dmp.diff_main(lastDoc, currDoc)
6063
var patch = dmp.patch_make(lastDoc, diff)
@@ -67,7 +70,7 @@ function createPatch (lastDoc, currDoc) {
6770
return patch
6871
}
6972

70-
function getRevision (revisions, count) {
73+
function getRevision(revisions, count) {
7174
var msStart = (new Date()).getTime()
7275
var startContent = null
7376
var lastPatch = []
@@ -91,7 +94,11 @@ function getRevision (revisions, count) {
9194
for (let i = 0, l = applyPatches.length; i < l; i++) {
9295
for (let j = 0, m = applyPatches[i].diffs.length; j < m; j++) {
9396
var diff = applyPatches[i].diffs[j]
94-
if (diff[0] === DiffMatchPatch.DIFF_INSERT) { diff[0] = DiffMatchPatch.DIFF_DELETE } else if (diff[0] === DiffMatchPatch.DIFF_DELETE) { diff[0] = DiffMatchPatch.DIFF_INSERT }
97+
if (diff[0] === DiffMatchPatch.DIFF_INSERT) {
98+
diff[0] = DiffMatchPatch.DIFF_DELETE
99+
} else if (diff[0] === DiffMatchPatch.DIFF_DELETE) {
100+
diff[0] = DiffMatchPatch.DIFF_INSERT
101+
}
95102
}
96103
}
97104
} else {

0 commit comments

Comments
 (0)