Adapt code for eslint-config-standard 17

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2022-05-01 21:14:27 +02:00
parent 66ab5ab51b
commit d26dcd04a1
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3
24 changed files with 82 additions and 82 deletions

4
app.js
View file

@ -46,7 +46,7 @@ if (config.useSSL) {
const options = { const options = {
key: fs.readFileSync(config.sslKeyPath, 'utf8'), key: fs.readFileSync(config.sslKeyPath, 'utf8'),
cert: fs.readFileSync(config.sslCertPath, 'utf8'), cert: fs.readFileSync(config.sslCertPath, 'utf8'),
ca: ca, ca,
dhparam: fs.readFileSync(config.dhParamPath, 'utf8'), dhparam: fs.readFileSync(config.dhParamPath, 'utf8'),
requestCert: false, requestCert: false,
rejectUnauthorized: false rejectUnauthorized: false
@ -242,7 +242,7 @@ app.get('*', function (req, res) {
io.use(realtime.secure) io.use(realtime.secure)
// socket.io auth // socket.io auth
io.use(passportSocketIo.authorize({ io.use(passportSocketIo.authorize({
cookieParser: cookieParser, cookieParser,
key: config.sessionName, key: config.sessionName,
secret: config.sessionSecret, secret: config.sessionSecret,
store: sessionStore, store: sessionStore,

View file

@ -24,10 +24,10 @@ const sourceURL = getGitHubURL(repository.url, commitID || version)
const fullversion = commitID ? `${version}-${commitID}` : version const fullversion = commitID ? `${version}-${commitID}` : version
const packageConfig = { const packageConfig = {
version: version, version,
minimumCompatibleVersion: '0.5.0', minimumCompatibleVersion: '0.5.0',
fullversion: fullversion, fullversion,
sourceURL: sourceURL sourceURL
} }
const configFilePath = path.resolve(appRootPath, process.env.CMD_CONFIG_FILE || const configFilePath = path.resolve(appRootPath, process.env.CMD_CONFIG_FILE ||

View file

@ -37,9 +37,9 @@ module.exports = {
function responseError (res, code, detail, msg) { function responseError (res, code, detail, msg) {
res.status(code).render('error.ejs', { res.status(code).render('error.ejs', {
title: code + ' ' + detail + ' ' + msg, title: code + ' ' + detail + ' ' + msg,
code: code, code,
detail: detail, detail,
msg: msg, msg,
opengraph: [] opengraph: []
}) })
} }

View file

@ -10,10 +10,10 @@ const errors = require('./errors')
// public // public
const History = { const History = {
historyGet: historyGet, historyGet,
historyPost: historyPost, historyPost,
historyDelete: historyDelete, historyDelete,
updateHistory: updateHistory updateHistory
} }
function getHistory (userid, callback) { function getHistory (userid, callback) {

View file

@ -73,7 +73,7 @@ const umzug = new Umzug({
}, },
storage: 'sequelize', storage: 'sequelize',
storageOptions: { storageOptions: {
sequelize: sequelize sequelize
} }
}) })

View file

@ -207,7 +207,7 @@ module.exports = function (sequelize, DataTypes) {
const title = Note.parseNoteTitle(body) const title = Note.parseNoteTitle(body)
if (fsModifiedTime.isAfter(dbModifiedTime) && note.content !== body) { if (fsModifiedTime.isAfter(dbModifiedTime) && note.content !== body) {
note.update({ note.update({
title: title, title,
content: body, content: body,
lastchangeAt: fsModifiedTime lastchangeAt: fsModifiedTime
}).then(function (note) { }).then(function (note) {
@ -221,7 +221,7 @@ module.exports = function (sequelize, DataTypes) {
authorship = Note.updateAuthorshipByOperation(operations[i], null, authorship) authorship = Note.updateAuthorshipByOperation(operations[i], null, authorship)
} }
note.update({ note.update({
authorship: authorship authorship
}).then(function (note) { }).then(function (note) {
return callback(null, note.id) return callback(null, note.id)
}).catch(function (err) { }).catch(function (err) {

View file

@ -47,7 +47,7 @@ function sendDmpWorker (data, callback) {
const cacheKey = Date.now() + '_' + shortId.generate() const cacheKey = Date.now() + '_' + shortId.generate()
dmpCallbackCache[cacheKey] = callback dmpCallbackCache[cacheKey] = callback
data = Object.assign(data, { data = Object.assign(data, {
cacheKey: cacheKey cacheKey
}) })
dmpWorker.send(data) dmpWorker.send(data)
} }
@ -151,8 +151,8 @@ module.exports = function (sequelize, DataTypes) {
if (count <= 0) return callback(null, null) if (count <= 0) return callback(null, null)
sendDmpWorker({ sendDmpWorker({
msg: 'get revision', msg: 'get revision',
revisions: revisions, revisions,
count: count count
}, callback) }, callback)
}).catch(function (err) { }).catch(function (err) {
return callback(err, null) return callback(err, null)
@ -272,7 +272,7 @@ module.exports = function (sequelize, DataTypes) {
} else { } else {
Revision.create({ Revision.create({
noteId: note.id, noteId: note.id,
patch: patch, patch,
content: note.content, content: note.content,
length: note.content.length, length: note.content.length,
authorship: note.authorship authorship: note.authorship

View file

@ -21,12 +21,12 @@ const ot = require('./ot')
// public // public
const realtime = { const realtime = {
io: null, io: null,
onAuthorizeSuccess: onAuthorizeSuccess, onAuthorizeSuccess,
onAuthorizeFail: onAuthorizeFail, onAuthorizeFail,
secure: secure, secure,
connection: connection, connection,
getStatus: getStatus, getStatus,
isReady: isReady, isReady,
maintenance: true maintenance: true
} }
@ -160,7 +160,7 @@ function finishUpdateNote (note, _note, callback) {
const body = note.server.document const body = note.server.document
const title = note.title = models.Note.parseNoteTitle(body) const title = note.title = models.Note.parseNoteTitle(body)
const values = { const values = {
title: title, title,
content: body, content: body,
authorship: note.authorship, authorship: note.authorship,
lastchangeuserId: note.lastchangeuser, lastchangeuserId: note.lastchangeuser,
@ -242,7 +242,7 @@ function getStatus (callback) {
}) })
models.User.count().then(function (regcount) { models.User.count().then(function (regcount) {
return callback return callback
// eslint-disable-next-line node/no-callback-literal // eslint-disable-next-line n/no-callback-literal
? callback({ ? callback({
onlineNotes: Object.keys(notes).length, onlineNotes: Object.keys(notes).length,
onlineUsers: Object.keys(users).length, onlineUsers: Object.keys(users).length,
@ -251,9 +251,9 @@ function getStatus (callback) {
registeredUsers: regcount, registeredUsers: regcount,
onlineRegisteredUsers: regaddresses.length, onlineRegisteredUsers: regaddresses.length,
distinctOnlineRegisteredUsers: distinctregaddresses.length, distinctOnlineRegisteredUsers: distinctregaddresses.length,
isConnectionBusy: isConnectionBusy, isConnectionBusy,
connectionSocketQueueLength: connectionSocketQueue.length, connectionSocketQueueLength: connectionSocketQueue.length,
isDisconnectBusy: isDisconnectBusy, isDisconnectBusy,
disconnectSocketQueueLength: disconnectSocketQueue.length disconnectSocketQueueLength: disconnectSocketQueue.length
}) })
: null : null
@ -303,7 +303,7 @@ function emitOnlineUsers (socket) {
if (user) { users.push(buildUserOutData(user)) } if (user) { users.push(buildUserOutData(user)) }
}) })
const out = { const out = {
users: users users
} }
realtime.io.to(noteId).emit('online users', out) realtime.io.to(noteId).emit('online users', out)
} }
@ -458,7 +458,7 @@ function startConnection (socket) {
where: { where: {
id: noteId id: noteId
}, },
include: include include
}).then(function (note) { }).then(function (note) {
if (!note) { if (!note) {
return failConnection(404, 'note not found', socket) return failConnection(404, 'note not found', socket)
@ -492,18 +492,18 @@ function startConnection (socket) {
id: noteId, id: noteId,
alias: note.alias, alias: note.alias,
title: note.title, title: note.title,
owner: owner, owner,
ownerprofile: ownerprofile, ownerprofile,
permission: note.permission, permission: note.permission,
lastchangeuser: lastchangeuser, lastchangeuser,
lastchangeuserprofile: lastchangeuserprofile, lastchangeuserprofile,
socks: [], socks: [],
users: {}, users: {},
tempUsers: {}, tempUsers: {},
createtime: moment(createtime).valueOf(), createtime: moment(createtime).valueOf(),
updatetime: moment(updatetime).valueOf(), updatetime: moment(updatetime).valueOf(),
server: server, server,
authors: authors, authors,
authorship: note.authorship authorship: note.authorship
} }
@ -523,7 +523,7 @@ function failConnection (code, err, socket) {
connectNextSocket() connectNextSocket()
// emit error info // emit error info
socket.emit('info', { socket.emit('info', {
code: code code
}) })
return socket.disconnect(true) return socket.disconnect(true)
} }
@ -665,12 +665,12 @@ function operationCallback (socket, operation) {
if (!note.authors[userId]) { if (!note.authors[userId]) {
models.Author.findOrCreate({ models.Author.findOrCreate({
where: { where: {
noteId: noteId, noteId,
userId: userId userId
}, },
defaults: { defaults: {
noteId: noteId, noteId,
userId: userId, userId,
color: user.color color: user.color
} }
}).spread(function (author, created) { }).spread(function (author, created) {
@ -739,7 +739,7 @@ function connection (socket) {
id: socket.id, id: socket.id,
address: socket.handshake.headers['x-forwarded-for'] || socket.handshake.address, address: socket.handshake.headers['x-forwarded-for'] || socket.handshake.address,
'user-agent': socket.handshake.headers['user-agent'], 'user-agent': socket.handshake.headers['user-agent'],
color: color, color,
cursor: null, cursor: null,
login: false, login: false,
userid: null, userid: null,
@ -784,7 +784,7 @@ function connection (socket) {
if (permission === 'freely' && !config.allowAnonymous && !config.allowAnonymousEdits) return if (permission === 'freely' && !config.allowAnonymous && !config.allowAnonymousEdits) return
note.permission = permission note.permission = permission
models.Note.update({ models.Note.update({
permission: permission permission
}, { }, {
where: { where: {
id: noteId id: noteId
@ -794,7 +794,7 @@ function connection (socket) {
return return
} }
const out = { const out = {
permission: permission permission
} }
realtime.io.to(note.id).emit('permission', out) realtime.io.to(note.id).emit('permission', out)
for (let i = 0, l = note.socks.length; i < l; i++) { for (let i = 0, l = note.socks.length; i < l; i++) {
@ -870,7 +870,7 @@ function connection (socket) {
if (user) { users.push(buildUserOutData(user)) } if (user) { users.push(buildUserOutData(user)) }
}) })
const out = { const out = {
users: users users
} }
socket.emit('online users', out) socket.emit('online users', out)
}) })

View file

@ -13,9 +13,9 @@ const errors = require('./errors')
// public // public
const response = { const response = {
showIndex: showIndex, showIndex,
githubActions: githubActions, githubActions,
gitlabActions: gitlabActions gitlabActions
} }
function showIndex (req, res, next) { function showIndex (req, res, next) {
@ -29,7 +29,7 @@ function showIndex (req, res, next) {
imprint: fs.existsSync(path.join(config.docsPath, 'imprint.md')), imprint: fs.existsSync(path.join(config.docsPath, 'imprint.md')),
privacyStatement: fs.existsSync(path.join(config.docsPath, 'privacy.md')), privacyStatement: fs.existsSync(path.join(config.docsPath, 'privacy.md')),
termsOfUse: fs.existsSync(path.join(config.docsPath, 'terms-of-use.md')), termsOfUse: fs.existsSync(path.join(config.docsPath, 'terms-of-use.md')),
deleteToken: deleteToken deleteToken
} }
if (authStatus) { if (authStatus) {
@ -72,8 +72,8 @@ function githubActionGist (req, res, note) {
const data = { const data = {
client_id: config.github.clientID, client_id: config.github.clientID,
client_secret: config.github.clientSecret, client_secret: config.github.clientSecret,
code: code, code,
state: state state
} }
const authUrl = 'https://github.com/login/oauth/access_token' const authUrl = 'https://github.com/login/oauth/access_token'
fetch(authUrl, { fetch(authUrl, {
@ -100,7 +100,7 @@ function githubActionGist (req, res, note) {
files: {} files: {}
} }
gist.files[filename] = { gist.files[filename] = {
content: content content
} }
const gistUrl = 'https://api.github.com/gists' const gistUrl = 'https://api.github.com/gists'
return fetch(gistUrl, { return fetch(gistUrl, {

View file

@ -18,7 +18,7 @@ passport.use(new LocalStrategy({
if (!validator.isEmail(email)) return done(null, false) if (!validator.isEmail(email)) return done(null, false)
models.User.findOne({ models.User.findOne({
where: { where: {
email: email email
} }
}).then(function (user) { }).then(function (user) {
if (!user) return done(null, false) if (!user) return done(null, false)

View file

@ -18,7 +18,7 @@ passport.serializeUser(function (user, done) {
passport.deserializeUser(function (id, done) { passport.deserializeUser(function (id, done) {
models.User.findOne({ models.User.findOne({
where: { where: {
id: id id
} }
}).then(function (user) { }).then(function (user) {
// Don't die on non-existent user // Don't die on non-existent user

View file

@ -41,7 +41,7 @@ passport.use(new LDAPStrategy({
const profile = { const profile = {
id: 'LDAP-' + uuid, id: 'LDAP-' + uuid,
username: username, username,
displayName: user.displayName, displayName: user.displayName,
emails: user.mail ? Array.isArray(user.mail) ? user.mail : [user.mail] : [], emails: user.mail ? Array.isArray(user.mail) ? user.mail : [user.mail] : [],
avatarUrl: null, avatarUrl: null,

View file

@ -60,8 +60,8 @@ function parseProfile (data) {
return { return {
id: id || username, id: id || username,
username: username, username,
displayName: displayName, displayName,
emails: email ? [email] : [] emails: email ? [email] : []
} }
} }

View file

@ -11,8 +11,8 @@ exports.passportGeneralCallback = function callback (accessToken, refreshToken,
}, },
defaults: { defaults: {
profile: stringifiedProfile, profile: stringifiedProfile,
accessToken: accessToken, accessToken,
refreshToken: refreshToken refreshToken
} }
}).spread(function (user, created) { }).spread(function (user, created) {
if (user) { if (user) {

View file

@ -18,8 +18,8 @@ exports.getInfo = function getInfo (req, res, note) {
title: meta.title || title, title: meta.title || title,
description: meta.description || (markdown ? models.Note.generateDescription(markdown) : null), description: meta.description || (markdown ? models.Note.generateDescription(markdown) : null),
viewcount: note.viewcount, viewcount: note.viewcount,
createtime: createtime, createtime,
updatetime: updatetime updatetime
} }
res.set({ res.set({
'Access-Control-Allow-Origin': '*', // allow CORS as API 'Access-Control-Allow-Origin': '*', // allow CORS as API

View file

@ -75,8 +75,8 @@ exports.showNote = function (req, res, next) {
'X-Robots-Tag': 'noindex, nofollow' // prevent crawling 'X-Robots-Tag': 'noindex, nofollow' // prevent crawling
}) })
return res.render('hedgedoc.ejs', { return res.render('hedgedoc.ejs', {
title: title, title,
opengraph: opengraph opengraph
}) })
}) })
} }

View file

@ -98,12 +98,12 @@ exports.getPublishData = function (req, res, note, callback) {
title = models.Note.generateWebTitle(meta.title || title) title = models.Note.generateWebTitle(meta.title || title)
const ogdata = models.Note.parseOpengraph(meta, title) const ogdata = models.Note.parseOpengraph(meta, title)
const data = { const data = {
title: title, title,
description: meta.description || (markdown ? models.Note.generateDescription(markdown) : null), description: meta.description || (markdown ? models.Note.generateDescription(markdown) : null),
lang: meta.lang || null, lang: meta.lang || null,
viewcount: note.viewcount, viewcount: note.viewcount,
createtime: createtime, createtime,
updatetime: updatetime, updatetime,
body: markdown, body: markdown,
theme: meta.slideOptions && isRevealTheme(meta.slideOptions.theme), theme: meta.slideOptions && isRevealTheme(meta.slideOptions.theme),
meta: JSON.stringify(extracted.meta), meta: JSON.stringify(extracted.meta),

View file

@ -70,7 +70,7 @@ statusRouter.post('/temp', urlencodedParser, function (req, res) {
} else { } else {
logger.debug(`SERVER received temp from [${host}]: ${req.body.data}`) logger.debug(`SERVER received temp from [${host}]: ${req.body.data}`)
models.Temp.create({ models.Temp.create({
data: data data
}).then(function (temp) { }).then(function (temp) {
if (temp) { if (temp) {
res.header('Access-Control-Allow-Origin', '*') res.header('Access-Control-Allow-Origin', '*')

View file

@ -49,7 +49,7 @@ process.on('message', function (data) {
const result = getRevision(data.revisions, data.count) const result = getRevision(data.revisions, data.count)
process.send({ process.send({
msg: 'check', msg: 'check',
result: result, result,
cacheKey: data.cacheKey cacheKey: data.cacheKey
}) })
} catch (err) { } catch (err) {
@ -128,7 +128,7 @@ function getRevision (revisions, count) {
const data = { const data = {
content: finalContent, content: finalContent,
patch: dmp.patch_fromText(lastPatch), patch: dmp.patch_fromText(lastPatch),
authorship: authorship authorship
} }
const msEnd = new Date().getTime() const msEnd = new Date().getTime()
logger.debug(msEnd - msStart + 'ms') logger.debug(msEnd - msStart + 'ms')

View file

@ -220,7 +220,7 @@ export function getStorageHistory (callback) {
if (typeof data === 'string') { data = JSON.parse(data) } if (typeof data === 'string') { data = JSON.parse(data) }
callback(data) callback(data)
} }
// eslint-disable-next-line node/no-callback-literal // eslint-disable-next-line n/no-callback-literal
callback([]) callback([])
} }

View file

@ -1230,7 +1230,7 @@ ui.toolbar.export.dropbox.click(function (event) {
files: [ files: [
{ {
url: noteurl + '/download', url: noteurl + '/download',
filename: filename filename
} }
], ],
error: function (errorMessage) { error: function (errorMessage) {
@ -1538,7 +1538,7 @@ function initRevisionViewer () {
const revisionViewerTextArea = document.getElementById('revisionViewer') const revisionViewerTextArea = document.getElementById('revisionViewer')
revisionViewer = CodeMirror.fromTextArea(revisionViewerTextArea, { revisionViewer = CodeMirror.fromTextArea(revisionViewerTextArea, {
mode: defaultEditorMode, mode: defaultEditorMode,
viewportMargin: viewportMargin, viewportMargin,
lineNumbers: true, lineNumbers: true,
lineWrapping: true, lineWrapping: true,
showCursorWhenSelecting: true, showCursorWhenSelecting: true,
@ -2005,7 +2005,7 @@ function importFromUrl (url) {
} }
$.ajax({ $.ajax({
method: 'GET', method: 'GET',
url: url, url,
success: function (data) { success: function (data) {
const extension = url.split('.').pop() const extension = url.split('.').pop()
if (extension === 'html') { if (extension === 'html') {
@ -2999,7 +2999,7 @@ function emitUserStatus (force) {
const userStatus = { const userStatus = {
idle: idle.isAway, idle: idle.isAway,
type: type type
} }
if (force || JSON.stringify(userStatus) !== JSON.stringify(userStatusCache)) { if (force || JSON.stringify(userStatus) !== JSON.stringify(userStatusCache)) {

View file

@ -99,7 +99,7 @@ export default class Editor {
const ch = match[1].length const ch = match[1].length
const pos = { const pos = {
line: cursor.line, line: cursor.line,
ch: ch ch
} }
if (cm.getOption('indentWithTabs')) { if (cm.getOption('indentWithTabs')) {
cm.replaceRange(tab, pos, pos, '+input') cm.replaceRange(tab, pos, pos, '+input')
@ -618,7 +618,7 @@ export default class Editor {
mode: defaultEditorMode, mode: defaultEditorMode,
backdrop: defaultEditorMode, backdrop: defaultEditorMode,
keyMap: 'sublime', keyMap: 'sublime',
viewportMargin: viewportMargin, viewportMargin,
styleActiveLine: true, styleActiveLine: true,
lineNumbers: true, lineNumbers: true,
lineWrapping: true, lineWrapping: true,

View file

@ -36,7 +36,7 @@ whiteList.figcaption = []
const filterXSSOptions = { const filterXSSOptions = {
allowCommentTag: true, allowCommentTag: true,
whiteList: whiteList, whiteList,
escapeHtml: function (html) { escapeHtml: function (html) {
// allow html comment in multiple lines // allow html comment in multiple lines
return html.replace(/<(?!!--)/g, '&lt;').replace(/-->/g, '__HTML_COMMENT_END__').replace(/>/g, '&gt;').replace(/__HTML_COMMENT_END__/g, '-->') return html.replace(/<(?!!--)/g, '&lt;').replace(/-->/g, '__HTML_COMMENT_END__').replace(/>/g, '&gt;').replace(/__HTML_COMMENT_END__/g, '-->')
@ -73,6 +73,6 @@ function preventXSS (html) {
window.preventXSS = preventXSS window.preventXSS = preventXSS
module.exports = { module.exports = {
preventXSS: preventXSS, preventXSS,
escapeAttrValue: filterXSS.escapeAttrValue escapeAttrValue: filterXSS.escapeAttrValue
} }

View file

@ -348,8 +348,8 @@ import { md } from './extra'
convertSlides() convertSlides()
}, },
// TODO: Do these belong in the API? // TODO: Do these belong in the API?
processSlides: processSlides, processSlides,
convertSlides: convertSlides, convertSlides,
slidify: slidify slidify
} }
})) }))