Skip to content

Commit 07f32f5

Browse files
committed
Fix standard
Signed-off-by: James Tsai <[email protected]>
1 parent 2973bfb commit 07f32f5

File tree

13 files changed

+51
-52
lines changed

13 files changed

+51
-52
lines changed

.vscode/settings.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
123,125

lib/auth/gitlab/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ const gitlabAuthStrategy = new GitlabStrategy({
1818
callbackURL: config.serverURL + '/auth/gitlab/callback'
1919
}, passportGeneralCallback)
2020

21-
if (process.env['https_proxy']) {
22-
const httpsProxyAgent = new HttpsProxyAgent(process.env['https_proxy'])
21+
if (process.env.https_proxy) {
22+
const httpsProxyAgent = new HttpsProxyAgent(process.env.https_proxy)
2323
gitlabAuthStrategy._oauth2.setAgent(httpsProxyAgent)
2424
}
2525

lib/history/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ function historyPost (req, res) {
131131
if (req.isAuthenticated()) {
132132
var noteId = req.params.noteId
133133
if (!noteId) {
134-
if (typeof req.body['history'] === 'undefined') return response.errorBadRequest(req, res)
134+
if (typeof req.body.history === 'undefined') return response.errorBadRequest(req, res)
135135
if (config.debug) { logger.info('SERVER received history from [' + req.user.id + ']: ' + req.body.history) }
136136
try {
137137
var history = JSON.parse(req.body.history)
@@ -147,7 +147,7 @@ function historyPost (req, res) {
147147
return response.errorBadRequest(req, res)
148148
}
149149
} else {
150-
if (typeof req.body['pinned'] === 'undefined') return response.errorBadRequest(req, res)
150+
if (typeof req.body.pinned === 'undefined') return response.errorBadRequest(req, res)
151151
getHistory(req.user.id, function (err, history) {
152152
if (err) return response.errorInternalError(req, res)
153153
if (!history) return response.errorNotFound(req, res)

lib/note/index.js

+6-8
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ async function noteActions (req, res) {
189189
}
190190
}
191191

192-
async function getMyNoteList(userid, callback) {
192+
async function getMyNoteList (userid, callback) {
193193
const myNotes = await Note.findAll({
194194
where: {
195195
ownerId: userid
@@ -199,7 +199,7 @@ async function getMyNoteList(userid, callback) {
199199
return callback(null, null)
200200
}
201201
try {
202-
let myNoteList = []
202+
const myNoteList = []
203203
for (let i = 0; i < myNotes.length; i++) {
204204
const note = myNotes[i]
205205
myNoteList[i] = {
@@ -215,13 +215,13 @@ async function getMyNoteList(userid, callback) {
215215
logger.info('Parse myNoteList success: ' + userid)
216216
}
217217
return callback(null, myNoteList)
218-
} catch (err){
219-
logger.error('Parse myNoteList failed')
220-
return callback(err, null)
218+
} catch (err) {
219+
logger.error('Parse myNoteList failed')
220+
return callback(err, null)
221221
}
222222
}
223223

224-
function listMyNotes(req, res) {
224+
function listMyNotes (req, res) {
225225
if (req.isAuthenticated()) {
226226
getMyNoteList(req.user.id, (err, myNoteList) => {
227227
if (err) return errorInternalError(req, res)
@@ -239,5 +239,3 @@ exports.showNote = showNote
239239
exports.showPublishNote = showPublishNote
240240
exports.noteActions = noteActions
241241
exports.listMyNotes = listMyNotes
242-
243-

public/js/extra.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ export function finishView (view) {
464464
const { lat, lon } = data[0]
465465
position = [lat, lon]
466466
}
467-
$elem.html(`<div class="geo-map"></div>`)
467+
$elem.html('<div class="geo-map"></div>')
468468
const map = L.map($elem.find('.geo-map')[0]).setView(position, zoom || 16)
469469

470470
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
@@ -975,7 +975,7 @@ export function deduplicatedHeaderId (view) {
975975
if (window.linkifyHeaderStyle === 'gfm') {
976976
// consistent with GitHub, GitLab, Pandoc & co.
977977
// all headers contained in the document, in order of appearance
978-
const allHeaders = view.find(`:header`).toArray()
978+
const allHeaders = view.find(':header').toArray()
979979
// list of finaly assigned header IDs
980980
const headerIds = new Set()
981981
for (let j = 0; j < allHeaders.length; j++) {
@@ -1133,7 +1133,7 @@ md.use(markdownitContainer, 'spoiler', {
11331133
if (summary) {
11341134
return `<details><summary>${md.renderInline(summary)}</summary>\n`
11351135
} else {
1136-
return `<details>\n`
1136+
return '<details>\n'
11371137
}
11381138
} else {
11391139
// closing tag

public/js/index.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1789,7 +1789,7 @@ socket.on('reconnect', function (data) {
17891789
socket.on('connect', function (data) {
17901790
clearInterval(retryTimer)
17911791
retryTimer = null
1792-
personalInfo['id'] = socket.id
1792+
personalInfo.id = socket.id
17931793
showStatus(statusType.connected)
17941794
socket.emit('version')
17951795
})
@@ -2359,8 +2359,8 @@ function emitUserStatus (force) {
23592359
var type = null
23602360
if (visibleXS) { type = 'xs' } else if (visibleSM) { type = 'sm' } else if (visibleMD) { type = 'md' } else if (visibleLG) { type = 'lg' }
23612361

2362-
personalInfo['idle'] = idle.isAway
2363-
personalInfo['type'] = type
2362+
personalInfo.idle = idle.isAway
2363+
personalInfo.type = type
23642364

23652365
for (var i = 0; i < onlineUsers.length; i++) {
23662366
if (onlineUsers[i].id === personalInfo.id) {
@@ -2637,7 +2637,7 @@ editorInstance.on('focus', function (editor) {
26372637
onlineUsers[i].cursor = editor.getCursor()
26382638
}
26392639
}
2640-
personalInfo['cursor'] = editor.getCursor()
2640+
personalInfo.cursor = editor.getCursor()
26412641
socket.emit('cursor focus', editor.getCursor())
26422642
})
26432643

@@ -2650,7 +2650,7 @@ function cursorActivityInner (editor) {
26502650
onlineUsers[i].cursor = editor.getCursor()
26512651
}
26522652
}
2653-
personalInfo['cursor'] = editor.getCursor()
2653+
personalInfo.cursor = editor.getCursor()
26542654
socket.emit('cursor activity', editor.getCursor())
26552655
}
26562656
}
@@ -2697,7 +2697,7 @@ editorInstance.on('blur', function (cm) {
26972697
onlineUsers[i].cursor = null
26982698
}
26992699
}
2700-
personalInfo['cursor'] = null
2700+
personalInfo.cursor = null
27012701
socket.emit('cursor blur')
27022702
})
27032703

public/js/lib/editor/constants.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ export const availableThemes = [
1616
{ name: 'Tomorror Night Eighties', value: 'tomorrow-night-eighties' }
1717
]
1818

19-
export const emojifyImageDir = window.USE_CDN ? `https://cdn.jsdelivr.net/npm/@hackmd/[email protected]/dist/images/basic` : `${serverurl}/build/emojify.js/dist/images/basic`
19+
export const emojifyImageDir = window.USE_CDN ? 'https://cdn.jsdelivr.net/npm/@hackmd/[email protected]/dist/images/basic' : `${serverurl}/build/emojify.js/dist/images/basic`

public/js/lib/editor/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ export default class Editor {
587587
if (lang) {
588588
this.statusIndicators.find(`.status-spellcheck li[value="${lang}"]`).addClass('active')
589589
} else {
590-
this.statusIndicators.find(`.status-spellcheck li[value="disabled"]`).addClass('active')
590+
this.statusIndicators.find('.status-spellcheck li[value="disabled"]').addClass('active')
591591
}
592592
}
593593

@@ -627,7 +627,7 @@ export default class Editor {
627627
}
628628

629629
const self = this
630-
this.statusIndicators.find(`.status-spellcheck li`).click(function () {
630+
this.statusIndicators.find('.status-spellcheck li').click(function () {
631631
const lang = $(this).attr('value')
632632

633633
if (lang === 'disabled') {

public/js/lib/editor/spellcheck.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -23,35 +23,35 @@ export const supportLanguages = [
2323
value: 'de',
2424
aff: {
2525
url: `${serverurl}/build/dictionary-de/index.aff`,
26-
cdnUrl: `https://cdn.jsdelivr.net/npm/[email protected]/index.aff`
26+
cdnUrl: 'https://cdn.jsdelivr.net/npm/[email protected]/index.aff'
2727
},
2828
dic: {
2929
url: `${serverurl}/build/dictionary-de/index.dic`,
30-
cdnUrl: `https://cdn.jsdelivr.net/npm/[email protected]/index.dic`
30+
cdnUrl: 'https://cdn.jsdelivr.net/npm/[email protected]/index.dic'
3131
}
3232
},
3333
{
3434
name: 'German (Austria)',
3535
value: 'de_AT',
3636
aff: {
3737
url: `${serverurl}/build/dictionary-de-at/index.aff`,
38-
cdnUrl: `https://cdn.jsdelivr.net/npm/[email protected]/index.aff`
38+
cdnUrl: 'https://cdn.jsdelivr.net/npm/[email protected]/index.aff'
3939
},
4040
dic: {
4141
url: `${serverurl}/build/dictionary-de-at/index.dic`,
42-
cdnUrl: `https://cdn.jsdelivr.net/npm/[email protected]/index.dic`
42+
cdnUrl: 'https://cdn.jsdelivr.net/npm/[email protected]/index.dic'
4343
}
4444
},
4545
{
4646
name: 'German (Switzerland)',
4747
value: 'de_CH',
4848
aff: {
4949
url: `${serverurl}/build/dictionary-de-ch/index.aff`,
50-
cdnUrl: `https://cdn.jsdelivr.net/npm/[email protected]/index.aff`
50+
cdnUrl: 'https://cdn.jsdelivr.net/npm/[email protected]/index.aff'
5151
},
5252
dic: {
5353
url: `${serverurl}/build/dictionary-de-ch/index.dic`,
54-
cdnUrl: `https://cdn.jsdelivr.net/npm/[email protected]/index.dic`
54+
cdnUrl: 'https://cdn.jsdelivr.net/npm/[email protected]/index.dic'
5555
}
5656
}
5757
]

public/js/lib/markdown/utils.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ export function parseFenceCodeParams (lang) {
77
paraMatch && paraMatch.forEach(param => {
88
param = param.trim()
99
if (param[0] === '#') {
10-
params['id'] = param.slice(1)
10+
params.id = param.slice(1)
1111
} else if (param[0] === '.') {
12-
if (params['class']) params['class'] = []
13-
params['class'] = params['class'].concat(param.slice(1))
12+
if (params.class) params.class = []
13+
params.class = params.class.concat(param.slice(1))
1414
} else {
1515
const offset = param.indexOf('=')
1616
const id = param.substring(0, offset).trim().toLowerCase()
@@ -21,8 +21,8 @@ export function parseFenceCodeParams (lang) {
2121
val = val.substring(1, val.length - 1)
2222
}
2323
if (id === 'class') {
24-
if (params['class']) params['class'] = []
25-
params['class'] = params['class'].concat(val)
24+
if (params.class) params.class = []
25+
params.class = params.class.concat(val)
2626
} else {
2727
params[id] = val
2828
}

public/js/render.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,27 @@ var dataUriRegex = /^\s*data:([a-z]+\/[a-z0-9-+.]+(;[a-z-]+=[a-z0-9-]+)?)?(;base
1212
// custom white list
1313
var whiteList = filterXSS.whiteList
1414
// allow ol specify start number
15-
whiteList['ol'] = ['start']
15+
whiteList.ol = ['start']
1616
// allow li specify value number
17-
whiteList['li'] = ['value']
17+
whiteList.li = ['value']
1818
// allow style tag
19-
whiteList['style'] = []
19+
whiteList.style = []
2020
// allow kbd tag
21-
whiteList['kbd'] = []
21+
whiteList.kbd = []
2222
// allow ifram tag with some safe attributes
23-
whiteList['iframe'] = ['allowfullscreen', 'name', 'referrerpolicy', 'src', 'width', 'height']
23+
whiteList.iframe = ['allowfullscreen', 'name', 'referrerpolicy', 'src', 'width', 'height']
2424
// allow summary tag
25-
whiteList['summary'] = []
25+
whiteList.summary = []
2626
// allow ruby tag
27-
whiteList['ruby'] = []
27+
whiteList.ruby = []
2828
// allow rp tag for ruby
29-
whiteList['rp'] = []
29+
whiteList.rp = []
3030
// allow rt tag for ruby
31-
whiteList['rt'] = []
31+
whiteList.rt = []
3232
// allow figure tag
33-
whiteList['figure'] = []
33+
whiteList.figure = []
3434
// allow figcaption tag
35-
whiteList['figcaption'] = []
35+
whiteList.figcaption = []
3636

3737
var filterXSSOptions = {
3838
allowCommentTag: true,

test/realtime/dirtyNoteUpdate.test.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ describe('realtime#update note is dirty timer', function () {
5050
callback(null, note)
5151
})
5252

53-
realtime.notes['note1'] = {
53+
realtime.notes.note1 = {
5454
server: {
5555
isDirty: false
5656
},
@@ -64,7 +64,7 @@ describe('realtime#update note is dirty timer', function () {
6464
socks: []
6565
}
6666

67-
realtime.notes['note2'] = note2
67+
realtime.notes.note2 = note2
6868

6969
clock.tick(1000)
7070
setTimeout(() => {
@@ -75,7 +75,7 @@ describe('realtime#update note is dirty timer', function () {
7575

7676
it('should not do anything when note missing', function (done) {
7777
sinon.stub(realtime, 'updateNote').callsFake(function (note, callback) {
78-
delete realtime.notes['note']
78+
delete realtime.notes.note
7979
callback(null, note)
8080
})
8181

@@ -85,7 +85,7 @@ describe('realtime#update note is dirty timer', function () {
8585
},
8686
socks: [makeMockSocket()]
8787
}
88-
realtime.notes['note'] = note
88+
realtime.notes.note = note
8989

9090
clock.tick(1000)
9191

@@ -115,7 +115,7 @@ describe('realtime#update note is dirty timer', function () {
115115
},
116116
socks: [makeMockSocket(), undefined, makeMockSocket()]
117117
}
118-
realtime.notes['note'] = note
118+
realtime.notes.note = note
119119

120120
clock.tick(1000)
121121

utils/string.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict'
22

33
function stripTags (s) {
4-
return s.replace(RegExp(`</?[^<>]*>`, 'gi'), '')
4+
return s.replace(RegExp('</?[^<>]*>', 'gi'), '')
55
}
66

77
exports.stripTags = stripTags

0 commit comments

Comments
 (0)