From d26dcd04a147a52047efbe66a0fc99d08049265e Mon Sep 17 00:00:00 2001 From: David Mehren Date: Sun, 1 May 2022 21:14:27 +0200 Subject: [PATCH] Adapt code for eslint-config-standard 17 Signed-off-by: David Mehren --- app.js | 4 +-- lib/config/index.js | 6 ++-- lib/errors.js | 6 ++-- lib/history.js | 8 +++--- lib/models/index.js | 2 +- lib/models/note.js | 4 +-- lib/models/revision.js | 8 +++--- lib/realtime.js | 54 +++++++++++++++++------------------ lib/response.js | 14 ++++----- lib/web/auth/email/index.js | 2 +- lib/web/auth/index.js | 2 +- lib/web/auth/ldap/index.js | 2 +- lib/web/auth/oauth2/index.js | 4 +-- lib/web/auth/utils.js | 4 +-- lib/web/note/actions.js | 4 +-- lib/web/note/controller.js | 4 +-- lib/web/note/util.js | 6 ++-- lib/web/statusRouter.js | 2 +- lib/workers/dmpWorker.js | 4 +-- public/js/history.js | 2 +- public/js/index.js | 8 +++--- public/js/lib/editor/index.js | 4 +-- public/js/render.js | 4 +-- public/js/reveal-markdown.js | 6 ++-- 24 files changed, 82 insertions(+), 82 deletions(-) diff --git a/app.js b/app.js index 53859a277..34a107ae1 100644 --- a/app.js +++ b/app.js @@ -46,7 +46,7 @@ if (config.useSSL) { const options = { key: fs.readFileSync(config.sslKeyPath, 'utf8'), cert: fs.readFileSync(config.sslCertPath, 'utf8'), - ca: ca, + ca, dhparam: fs.readFileSync(config.dhParamPath, 'utf8'), requestCert: false, rejectUnauthorized: false @@ -242,7 +242,7 @@ app.get('*', function (req, res) { io.use(realtime.secure) // socket.io auth io.use(passportSocketIo.authorize({ - cookieParser: cookieParser, + cookieParser, key: config.sessionName, secret: config.sessionSecret, store: sessionStore, diff --git a/lib/config/index.js b/lib/config/index.js index 29cd84135..d4b5f7e44 100644 --- a/lib/config/index.js +++ b/lib/config/index.js @@ -24,10 +24,10 @@ const sourceURL = getGitHubURL(repository.url, commitID || version) const fullversion = commitID ? `${version}-${commitID}` : version const packageConfig = { - version: version, + version, minimumCompatibleVersion: '0.5.0', - fullversion: fullversion, - sourceURL: sourceURL + fullversion, + sourceURL } const configFilePath = path.resolve(appRootPath, process.env.CMD_CONFIG_FILE || diff --git a/lib/errors.js b/lib/errors.js index 599f54b25..371601269 100644 --- a/lib/errors.js +++ b/lib/errors.js @@ -37,9 +37,9 @@ module.exports = { function responseError (res, code, detail, msg) { res.status(code).render('error.ejs', { title: code + ' ' + detail + ' ' + msg, - code: code, - detail: detail, - msg: msg, + code, + detail, + msg, opengraph: [] }) } diff --git a/lib/history.js b/lib/history.js index e4ce92216..e0c16da5e 100644 --- a/lib/history.js +++ b/lib/history.js @@ -10,10 +10,10 @@ const errors = require('./errors') // public const History = { - historyGet: historyGet, - historyPost: historyPost, - historyDelete: historyDelete, - updateHistory: updateHistory + historyGet, + historyPost, + historyDelete, + updateHistory } function getHistory (userid, callback) { diff --git a/lib/models/index.js b/lib/models/index.js index a8a972f97..f40079f55 100644 --- a/lib/models/index.js +++ b/lib/models/index.js @@ -73,7 +73,7 @@ const umzug = new Umzug({ }, storage: 'sequelize', storageOptions: { - sequelize: sequelize + sequelize } }) diff --git a/lib/models/note.js b/lib/models/note.js index 0c268e2e4..0db636745 100644 --- a/lib/models/note.js +++ b/lib/models/note.js @@ -207,7 +207,7 @@ module.exports = function (sequelize, DataTypes) { const title = Note.parseNoteTitle(body) if (fsModifiedTime.isAfter(dbModifiedTime) && note.content !== body) { note.update({ - title: title, + title, content: body, lastchangeAt: fsModifiedTime }).then(function (note) { @@ -221,7 +221,7 @@ module.exports = function (sequelize, DataTypes) { authorship = Note.updateAuthorshipByOperation(operations[i], null, authorship) } note.update({ - authorship: authorship + authorship }).then(function (note) { return callback(null, note.id) }).catch(function (err) { diff --git a/lib/models/revision.js b/lib/models/revision.js index 80136c68f..0a3cfa608 100644 --- a/lib/models/revision.js +++ b/lib/models/revision.js @@ -47,7 +47,7 @@ function sendDmpWorker (data, callback) { const cacheKey = Date.now() + '_' + shortId.generate() dmpCallbackCache[cacheKey] = callback data = Object.assign(data, { - cacheKey: cacheKey + cacheKey }) dmpWorker.send(data) } @@ -151,8 +151,8 @@ module.exports = function (sequelize, DataTypes) { if (count <= 0) return callback(null, null) sendDmpWorker({ msg: 'get revision', - revisions: revisions, - count: count + revisions, + count }, callback) }).catch(function (err) { return callback(err, null) @@ -272,7 +272,7 @@ module.exports = function (sequelize, DataTypes) { } else { Revision.create({ noteId: note.id, - patch: patch, + patch, content: note.content, length: note.content.length, authorship: note.authorship diff --git a/lib/realtime.js b/lib/realtime.js index abea7165c..1269e4116 100644 --- a/lib/realtime.js +++ b/lib/realtime.js @@ -21,12 +21,12 @@ const ot = require('./ot') // public const realtime = { io: null, - onAuthorizeSuccess: onAuthorizeSuccess, - onAuthorizeFail: onAuthorizeFail, - secure: secure, - connection: connection, - getStatus: getStatus, - isReady: isReady, + onAuthorizeSuccess, + onAuthorizeFail, + secure, + connection, + getStatus, + isReady, maintenance: true } @@ -160,7 +160,7 @@ function finishUpdateNote (note, _note, callback) { const body = note.server.document const title = note.title = models.Note.parseNoteTitle(body) const values = { - title: title, + title, content: body, authorship: note.authorship, lastchangeuserId: note.lastchangeuser, @@ -242,7 +242,7 @@ function getStatus (callback) { }) models.User.count().then(function (regcount) { return callback - // eslint-disable-next-line node/no-callback-literal + // eslint-disable-next-line n/no-callback-literal ? callback({ onlineNotes: Object.keys(notes).length, onlineUsers: Object.keys(users).length, @@ -251,9 +251,9 @@ function getStatus (callback) { registeredUsers: regcount, onlineRegisteredUsers: regaddresses.length, distinctOnlineRegisteredUsers: distinctregaddresses.length, - isConnectionBusy: isConnectionBusy, + isConnectionBusy, connectionSocketQueueLength: connectionSocketQueue.length, - isDisconnectBusy: isDisconnectBusy, + isDisconnectBusy, disconnectSocketQueueLength: disconnectSocketQueue.length }) : null @@ -303,7 +303,7 @@ function emitOnlineUsers (socket) { if (user) { users.push(buildUserOutData(user)) } }) const out = { - users: users + users } realtime.io.to(noteId).emit('online users', out) } @@ -458,7 +458,7 @@ function startConnection (socket) { where: { id: noteId }, - include: include + include }).then(function (note) { if (!note) { return failConnection(404, 'note not found', socket) @@ -492,18 +492,18 @@ function startConnection (socket) { id: noteId, alias: note.alias, title: note.title, - owner: owner, - ownerprofile: ownerprofile, + owner, + ownerprofile, permission: note.permission, - lastchangeuser: lastchangeuser, - lastchangeuserprofile: lastchangeuserprofile, + lastchangeuser, + lastchangeuserprofile, socks: [], users: {}, tempUsers: {}, createtime: moment(createtime).valueOf(), updatetime: moment(updatetime).valueOf(), - server: server, - authors: authors, + server, + authors, authorship: note.authorship } @@ -523,7 +523,7 @@ function failConnection (code, err, socket) { connectNextSocket() // emit error info socket.emit('info', { - code: code + code }) return socket.disconnect(true) } @@ -665,12 +665,12 @@ function operationCallback (socket, operation) { if (!note.authors[userId]) { models.Author.findOrCreate({ where: { - noteId: noteId, - userId: userId + noteId, + userId }, defaults: { - noteId: noteId, - userId: userId, + noteId, + userId, color: user.color } }).spread(function (author, created) { @@ -739,7 +739,7 @@ function connection (socket) { id: socket.id, address: socket.handshake.headers['x-forwarded-for'] || socket.handshake.address, 'user-agent': socket.handshake.headers['user-agent'], - color: color, + color, cursor: null, login: false, userid: null, @@ -784,7 +784,7 @@ function connection (socket) { if (permission === 'freely' && !config.allowAnonymous && !config.allowAnonymousEdits) return note.permission = permission models.Note.update({ - permission: permission + permission }, { where: { id: noteId @@ -794,7 +794,7 @@ function connection (socket) { return } const out = { - permission: permission + permission } realtime.io.to(note.id).emit('permission', out) for (let i = 0, l = note.socks.length; i < l; i++) { @@ -870,7 +870,7 @@ function connection (socket) { if (user) { users.push(buildUserOutData(user)) } }) const out = { - users: users + users } socket.emit('online users', out) }) diff --git a/lib/response.js b/lib/response.js index f6bb6efd6..853f80a4e 100644 --- a/lib/response.js +++ b/lib/response.js @@ -13,9 +13,9 @@ const errors = require('./errors') // public const response = { - showIndex: showIndex, - githubActions: githubActions, - gitlabActions: gitlabActions + showIndex, + githubActions, + gitlabActions } function showIndex (req, res, next) { @@ -29,7 +29,7 @@ function showIndex (req, res, next) { imprint: fs.existsSync(path.join(config.docsPath, 'imprint.md')), privacyStatement: fs.existsSync(path.join(config.docsPath, 'privacy.md')), termsOfUse: fs.existsSync(path.join(config.docsPath, 'terms-of-use.md')), - deleteToken: deleteToken + deleteToken } if (authStatus) { @@ -72,8 +72,8 @@ function githubActionGist (req, res, note) { const data = { client_id: config.github.clientID, client_secret: config.github.clientSecret, - code: code, - state: state + code, + state } const authUrl = 'https://github.com/login/oauth/access_token' fetch(authUrl, { @@ -100,7 +100,7 @@ function githubActionGist (req, res, note) { files: {} } gist.files[filename] = { - content: content + content } const gistUrl = 'https://api.github.com/gists' return fetch(gistUrl, { diff --git a/lib/web/auth/email/index.js b/lib/web/auth/email/index.js index 74922966e..2ca0cec76 100644 --- a/lib/web/auth/email/index.js +++ b/lib/web/auth/email/index.js @@ -18,7 +18,7 @@ passport.use(new LocalStrategy({ if (!validator.isEmail(email)) return done(null, false) models.User.findOne({ where: { - email: email + email } }).then(function (user) { if (!user) return done(null, false) diff --git a/lib/web/auth/index.js b/lib/web/auth/index.js index 86ab4b28e..f2496180e 100644 --- a/lib/web/auth/index.js +++ b/lib/web/auth/index.js @@ -18,7 +18,7 @@ passport.serializeUser(function (user, done) { passport.deserializeUser(function (id, done) { models.User.findOne({ where: { - id: id + id } }).then(function (user) { // Don't die on non-existent user diff --git a/lib/web/auth/ldap/index.js b/lib/web/auth/ldap/index.js index 4142194fd..a780df2b3 100644 --- a/lib/web/auth/ldap/index.js +++ b/lib/web/auth/ldap/index.js @@ -41,7 +41,7 @@ passport.use(new LDAPStrategy({ const profile = { id: 'LDAP-' + uuid, - username: username, + username, displayName: user.displayName, emails: user.mail ? Array.isArray(user.mail) ? user.mail : [user.mail] : [], avatarUrl: null, diff --git a/lib/web/auth/oauth2/index.js b/lib/web/auth/oauth2/index.js index feef5e7f9..e7c93067d 100644 --- a/lib/web/auth/oauth2/index.js +++ b/lib/web/auth/oauth2/index.js @@ -60,8 +60,8 @@ function parseProfile (data) { return { id: id || username, - username: username, - displayName: displayName, + username, + displayName, emails: email ? [email] : [] } } diff --git a/lib/web/auth/utils.js b/lib/web/auth/utils.js index bb69f15f5..565c7fb12 100644 --- a/lib/web/auth/utils.js +++ b/lib/web/auth/utils.js @@ -11,8 +11,8 @@ exports.passportGeneralCallback = function callback (accessToken, refreshToken, }, defaults: { profile: stringifiedProfile, - accessToken: accessToken, - refreshToken: refreshToken + accessToken, + refreshToken } }).spread(function (user, created) { if (user) { diff --git a/lib/web/note/actions.js b/lib/web/note/actions.js index d92d2443e..3c10887d5 100644 --- a/lib/web/note/actions.js +++ b/lib/web/note/actions.js @@ -18,8 +18,8 @@ exports.getInfo = function getInfo (req, res, note) { title: meta.title || title, description: meta.description || (markdown ? models.Note.generateDescription(markdown) : null), viewcount: note.viewcount, - createtime: createtime, - updatetime: updatetime + createtime, + updatetime } res.set({ 'Access-Control-Allow-Origin': '*', // allow CORS as API diff --git a/lib/web/note/controller.js b/lib/web/note/controller.js index 94bfa0e2c..af7507934 100644 --- a/lib/web/note/controller.js +++ b/lib/web/note/controller.js @@ -75,8 +75,8 @@ exports.showNote = function (req, res, next) { 'X-Robots-Tag': 'noindex, nofollow' // prevent crawling }) return res.render('hedgedoc.ejs', { - title: title, - opengraph: opengraph + title, + opengraph }) }) } diff --git a/lib/web/note/util.js b/lib/web/note/util.js index 5df1e820e..556460958 100644 --- a/lib/web/note/util.js +++ b/lib/web/note/util.js @@ -98,12 +98,12 @@ exports.getPublishData = function (req, res, note, callback) { title = models.Note.generateWebTitle(meta.title || title) const ogdata = models.Note.parseOpengraph(meta, title) const data = { - title: title, + title, description: meta.description || (markdown ? models.Note.generateDescription(markdown) : null), lang: meta.lang || null, viewcount: note.viewcount, - createtime: createtime, - updatetime: updatetime, + createtime, + updatetime, body: markdown, theme: meta.slideOptions && isRevealTheme(meta.slideOptions.theme), meta: JSON.stringify(extracted.meta), diff --git a/lib/web/statusRouter.js b/lib/web/statusRouter.js index d939a3fee..f2d0bddf0 100644 --- a/lib/web/statusRouter.js +++ b/lib/web/statusRouter.js @@ -70,7 +70,7 @@ statusRouter.post('/temp', urlencodedParser, function (req, res) { } else { logger.debug(`SERVER received temp from [${host}]: ${req.body.data}`) models.Temp.create({ - data: data + data }).then(function (temp) { if (temp) { res.header('Access-Control-Allow-Origin', '*') diff --git a/lib/workers/dmpWorker.js b/lib/workers/dmpWorker.js index 7b5439c7d..51e9c5524 100644 --- a/lib/workers/dmpWorker.js +++ b/lib/workers/dmpWorker.js @@ -49,7 +49,7 @@ process.on('message', function (data) { const result = getRevision(data.revisions, data.count) process.send({ msg: 'check', - result: result, + result, cacheKey: data.cacheKey }) } catch (err) { @@ -128,7 +128,7 @@ function getRevision (revisions, count) { const data = { content: finalContent, patch: dmp.patch_fromText(lastPatch), - authorship: authorship + authorship } const msEnd = new Date().getTime() logger.debug(msEnd - msStart + 'ms') diff --git a/public/js/history.js b/public/js/history.js index b8935eb3c..0dc3e5e5c 100644 --- a/public/js/history.js +++ b/public/js/history.js @@ -220,7 +220,7 @@ export function getStorageHistory (callback) { if (typeof data === 'string') { data = JSON.parse(data) } callback(data) } - // eslint-disable-next-line node/no-callback-literal + // eslint-disable-next-line n/no-callback-literal callback([]) } diff --git a/public/js/index.js b/public/js/index.js index c74aea66a..5bd4d2b99 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -1230,7 +1230,7 @@ ui.toolbar.export.dropbox.click(function (event) { files: [ { url: noteurl + '/download', - filename: filename + filename } ], error: function (errorMessage) { @@ -1538,7 +1538,7 @@ function initRevisionViewer () { const revisionViewerTextArea = document.getElementById('revisionViewer') revisionViewer = CodeMirror.fromTextArea(revisionViewerTextArea, { mode: defaultEditorMode, - viewportMargin: viewportMargin, + viewportMargin, lineNumbers: true, lineWrapping: true, showCursorWhenSelecting: true, @@ -2005,7 +2005,7 @@ function importFromUrl (url) { } $.ajax({ method: 'GET', - url: url, + url, success: function (data) { const extension = url.split('.').pop() if (extension === 'html') { @@ -2999,7 +2999,7 @@ function emitUserStatus (force) { const userStatus = { idle: idle.isAway, - type: type + type } if (force || JSON.stringify(userStatus) !== JSON.stringify(userStatusCache)) { diff --git a/public/js/lib/editor/index.js b/public/js/lib/editor/index.js index da15a29dd..0f2181177 100644 --- a/public/js/lib/editor/index.js +++ b/public/js/lib/editor/index.js @@ -99,7 +99,7 @@ export default class Editor { const ch = match[1].length const pos = { line: cursor.line, - ch: ch + ch } if (cm.getOption('indentWithTabs')) { cm.replaceRange(tab, pos, pos, '+input') @@ -618,7 +618,7 @@ export default class Editor { mode: defaultEditorMode, backdrop: defaultEditorMode, keyMap: 'sublime', - viewportMargin: viewportMargin, + viewportMargin, styleActiveLine: true, lineNumbers: true, lineWrapping: true, diff --git a/public/js/render.js b/public/js/render.js index af6fb3d4a..634bd1dbd 100644 --- a/public/js/render.js +++ b/public/js/render.js @@ -36,7 +36,7 @@ whiteList.figcaption = [] const filterXSSOptions = { allowCommentTag: true, - whiteList: whiteList, + whiteList, escapeHtml: function (html) { // allow html comment in multiple lines return html.replace(/<(?!!--)/g, '<').replace(/-->/g, '__HTML_COMMENT_END__').replace(/>/g, '>').replace(/__HTML_COMMENT_END__/g, '-->') @@ -73,6 +73,6 @@ function preventXSS (html) { window.preventXSS = preventXSS module.exports = { - preventXSS: preventXSS, + preventXSS, escapeAttrValue: filterXSS.escapeAttrValue } diff --git a/public/js/reveal-markdown.js b/public/js/reveal-markdown.js index 89cd08871..484c7ac8e 100644 --- a/public/js/reveal-markdown.js +++ b/public/js/reveal-markdown.js @@ -348,8 +348,8 @@ import { md } from './extra' convertSlides() }, // TODO: Do these belong in the API? - processSlides: processSlides, - convertSlides: convertSlides, - slidify: slidify + processSlides, + convertSlides, + slidify } }))