Skip to content

Commit a6036cb

Browse files
committed
refactor: back to use js-standard
Signed-off-by: BoHong Li <[email protected]>
1 parent 1ac6434 commit a6036cb

16 files changed

+346
-281
lines changed

.eslintignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

.eslintrc.js

Lines changed: 0 additions & 21 deletions
This file was deleted.

lib/realtime.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ function getNotePoolSize () {
116116
return Object.keys(notes).length
117117
}
118118

119-
function deleteNoteFromPool(noteId) {
119+
function deleteNoteFromPool (noteId) {
120120
delete notes[noteId]
121121
}
122122

123-
function deleteAllNoteFromPool() {
123+
function deleteAllNoteFromPool () {
124124
Object.keys(notes).forEach(noteId => {
125125
delete notes[noteId]
126126
})
@@ -289,8 +289,8 @@ function getStatus (callback) {
289289
registeredUsers: regcount,
290290
onlineRegisteredUsers: regaddresses.length,
291291
distinctOnlineRegisteredUsers: distinctregaddresses.length,
292-
isConnectionBusy: isConnectionBusy,
293-
connectionSocketQueueLength: connectionSocketQueue.length,
292+
isConnectionBusy: connectProcessQueue.lock,
293+
connectionSocketQueueLength: connectProcessQueue.queue.length,
294294
isDisconnectBusy: disconnectProcessQueue.lock,
295295
disconnectSocketQueueLength: disconnectProcessQueue.queue.length
296296
}) : null
@@ -306,7 +306,6 @@ function getStatus (callback) {
306306
function isReady () {
307307
return realtime.io &&
308308
Object.keys(notes).length === 0 && Object.keys(users).length === 0 &&
309-
!isConnectionBusy &&
310309
connectProcessQueue.queue.length === 0 && !connectProcessQueue.lock &&
311310
disconnectProcessQueue.queue.length === 0 && !disconnectProcessQueue.lock
312311
}
@@ -442,8 +441,6 @@ function checkViewPermission (req, note) {
442441
}
443442
}
444443

445-
var isConnectionBusy = false
446-
447444
// TODO: test it
448445
async function fetchFullNoteAsync (noteId) {
449446
return models.Note.findOne({
@@ -669,7 +666,7 @@ function updateHistory (userId, note, time) {
669666
if (note.server) history.updateHistory(userId, noteId, note.server.document, time)
670667
}
671668

672-
function getUniqueColorPerNote(noteId, maxAttempt = 10) {
669+
function getUniqueColorPerNote (noteId, maxAttempt = 10) {
673670
// random color
674671
let color = randomcolor()
675672
if (!notes[noteId]) return color
@@ -682,7 +679,7 @@ function getUniqueColorPerNote(noteId, maxAttempt = 10) {
682679
if (notes[noteId].users[userId].color === color) {
683680
found = true
684681
}
685-
});
682+
})
686683
if (found) {
687684
color = randomcolor()
688685
randomAttemp++

package.json

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,12 @@
1818
"build": "webpack --config webpack.prod.js --progress --colors --bail",
1919
"dev": "webpack --config webpack.dev.js --progress --colors --watch",
2020
"doctoc": "doctoc --title='# Table of Contents' README.md",
21-
"eslint": "eslint lib public test app.js",
21+
"lint": "standard",
2222
"jsonlint": "find . -not -path './node_modules/*' -type f -name '*.json' -o -type f -name '*.json.example' | while read json; do echo $json ; jq . $json; done",
23-
"standard": "echo 'standard is no longer being used, use `npm run eslint` instead!' && exit 1",
2423
"start": "sequelize db:migrate && node app.js",
2524
"mocha": "mocha --require intelli-espower-loader --exit ./test --recursive",
26-
"cov": "nyc mocha --require intelli-espower-loader --exit --recursive ./test",
27-
"test": "npm run-script eslint && npm run-script jsonlint && npm run-script mocha"
25+
"coverage": "nyc mocha --require intelli-espower-loader --exit --recursive ./test",
26+
"test": "npm run-script lint && npm run-script jsonlint && npm run-script coverage"
2827
},
2928
"dependencies": {
3029
"@hackmd/codemirror": "~5.41.2",
@@ -65,7 +64,7 @@
6564
"highlight.js": "~9.12.0",
6665
"i18n": "~0.8.3",
6766
"ionicons": "~2.0.1",
68-
"isomorphic-fetch": "^2.2.1",
67+
"isomorphic-fetch": "~2.2.1",
6968
"jquery": "~3.1.1",
7069
"jquery-mousewheel": "~3.1.13",
7170
"jquery-ui": "~1.12.1",
@@ -90,7 +89,7 @@
9089
"markdown-it-sup": "~1.0.0",
9190
"markdown-pdf": "~9.0.0",
9291
"mathjax": "~2.7.0",
93-
"mattermost-redux": "^5.9.0",
92+
"mattermost-redux": "~5.9.0",
9493
"mermaid": "~7.1.0",
9594
"method-override": "~2.3.7",
9695
"minimist": "~1.2.0",
@@ -153,30 +152,25 @@
153152
"css-loader": "~1.0.0",
154153
"doctoc": "~1.4.0",
155154
"ejs-loader": "~0.3.1",
156-
"eslint": "~5.16.0",
157-
"eslint-config-standard": "~12.0.0",
158-
"eslint-plugin-import": "~2.17.1",
159-
"eslint-plugin-node": "~8.0.1",
160-
"eslint-plugin-promise": "~4.1.1",
161-
"eslint-plugin-standard": "~4.0.0",
162155
"exports-loader": "~0.7.0",
163156
"expose-loader": "~0.7.5",
164157
"file-loader": "~2.0.0",
165158
"html-webpack-plugin": "~4.0.0-beta.2",
166159
"imports-loader": "~0.8.0",
167-
"intelli-espower-loader": "^1.0.1",
160+
"intelli-espower-loader": "~1.0.1",
168161
"jsonlint": "~1.6.2",
169162
"less": "~3.9.0",
170163
"less-loader": "~4.1.0",
171164
"mini-css-extract-plugin": "~0.4.1",
172165
"mocha": "~5.2.0",
173166
"mock-require": "~3.0.3",
174-
"nyc": "^14.0.0",
167+
"nyc": "~14.0.0",
175168
"optimize-css-assets-webpack-plugin": "~5.0.0",
176-
"power-assert": "^1.6.1",
169+
"power-assert": "~1.6.1",
177170
"script-loader": "~0.7.2",
178171
"sequelize-cli": "~5.4.0",
179-
"sinon": "^7.3.2",
172+
"sinon": "~7.3.2",
173+
"standard": "~12.0.1",
180174
"string-loader": "~0.0.1",
181175
"style-loader": "~0.21.0",
182176
"uglifyjs-webpack-plugin": "~1.2.7",
@@ -203,6 +197,13 @@
203197
"email": "[email protected]"
204198
}
205199
],
200+
"standard": {
201+
"ignore": [
202+
"/public/build",
203+
"/public/vendor",
204+
"/lib/ot"
205+
]
206+
},
206207
"nyc": {
207208
"all": true,
208209
"include": [

public/js/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-env browser, jquery */
22
/* global CodeMirror, Cookies, moment, Spinner, serverurl,
3-
key, Dropbox, ot, hex2rgb, Visibility */
3+
key, Dropbox, ot, hex2rgb, Visibility, inlineAttachment */
44

55
import TurndownService from 'turndown'
66

public/js/lib/editor/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* global CodeMirror, $, editor, Cookies */
12
import * as utils from './utils'
23
import config from './config'
34
import statusBarTemplate from './statusbar.html'

public/js/lib/editor/ui-elements.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
22
* Global UI elements references
33
*/
4+
/* global $ */
45

56
export const getUIElements = () => ({
67
spinner: $('.ui-spinner'),

public/js/lib/editor/utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* global CodeMirror, editor */
12
const wrapSymbols = ['*', '_', '~', '^', '+', '=']
23
export function wrapTextWith (editor, cm, symbol) {
34
if (!cm.getSelection()) {

test/connectionQueue.test.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ describe('ProcessQueue', function () {
2323

2424
it('should not accept more than maximum task', () => {
2525
const queue = new ProcessQueue({ maximumLength: 2 })
26-
const task = {
27-
id: 1,
28-
processingFunc: async () => {
29-
}
30-
}
3126

3227
queue.start()
3328
assert(queue.push(1, () => (Promise.resolve())))

test/realtime/ifMayEdit.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe('realtime#ifMayEdit', function () {
5454
{ role: Role.Guest, permission: Permission.Locked, canEdit: false },
5555
{ role: Role.LoggedIn, permission: Permission.Locked, canEdit: false },
5656
{ role: Role.Owner, permission: Permission.Locked, canEdit: true },
57-
{ role: Role.Guest, permission: Permission.Protected, canEdit: false},
57+
{ role: Role.Guest, permission: Permission.Protected, canEdit: false },
5858
{ role: Role.LoggedIn, permission: Permission.Protected, canEdit: false },
5959
{ role: Role.Owner, permission: Permission.Protected, canEdit: true },
6060
{ role: Role.Guest, permission: Permission.Private, canEdit: false },

0 commit comments

Comments
 (0)