diff --git a/.eslintrc b/.eslintrc index 4f7d4e2413..ef9f48dedc 100644 --- a/.eslintrc +++ b/.eslintrc @@ -32,6 +32,9 @@ "no-prototype-builtins": "off", "new-cap": "off", "no-plusplus": ["error", { "allowForLoopAfterthoughts": true }], + "object-curly-newline": "off", + "no-restricted-globals": "off", + "function-paren-newline": "off", "import/no-unresolved": "error", // ES6 @@ -42,6 +45,7 @@ "no-var": "off", "object-shorthand": "off", "vars-on-top": "off", + "prefer-destructuring": "off", // TODO "import/no-extraneous-dependencies": "off", diff --git a/package.json b/package.json index 1ffc42720e..0707481f2e 100644 --- a/package.json +++ b/package.json @@ -19,27 +19,27 @@ "dependencies": { "ace-builds": "^1.2.8", "async": "2.5.0", - "autoprefixer": "7.1.3", + "autoprefixer": "7.1.4", "bcryptjs": "2.4.3", - "benchpressjs": "^1.0.3", - "body-parser": "^1.17.2", + "benchpressjs": "^1.1.0", + "body-parser": "^1.18.2", "bootstrap": "^3.3.7", "chart.js": "^2.6.0", "colors": "^1.1.2", - "compression": "^1.7.0", + "compression": "^1.7.1", "connect-ensure-login": "^0.1.1", "connect-flash": "^0.1.1", "connect-mongo": "1.3.2", "connect-multiparty": "^2.0.0", - "connect-redis": "3.3.0", + "connect-redis": "3.3.2", "cookie-parser": "^1.4.3", "cron": "^1.2.1", - "cropperjs": "^0.8.1", + "cropperjs": "^1.0.0", "csurf": "^1.9.0", "daemon": "^1.1.0", - "express": "^4.15.4", - "express-session": "^1.15.5", - "express-useragent": "1.0.7", + "express": "^4.16.1", + "express-session": "^1.15.6", + "express-useragent": "1.0.8", "html-to-text": "3.3.0", "ipaddr.js": "^1.5.2", "jimp": "0.2.28", @@ -49,13 +49,13 @@ "lodash": "^4.17.4", "logrotate-stream": "^0.2.5", "lru-cache": "4.1.1", - "mime": "^1.4.0", + "mime": "^2.0.3", "minimist": "^1.2.0", "mkdirp": "^0.5.1", "mongodb": "2.2.31", - "morgan": "^1.8.2", + "morgan": "^1.9.0", "mousetrap": "^1.6.1", - "nconf": "^0.8.4", + "nconf": "^0.8.5", "nodebb-plugin-composer-default": "6.0.0", "nodebb-plugin-dbsearch": "2.0.6", "nodebb-plugin-emoji-extended": "1.1.1", @@ -70,20 +70,20 @@ "nodebb-theme-slick": "1.1.1", "nodebb-theme-vanilla": "7.0.1", "nodebb-widget-essentials": "3.0.5", - "nodemailer": "4.1.0", - "passport": "^0.3.0", + "nodemailer": "4.1.1", + "passport": "^0.4.0", "passport-local": "1.0.0", - "postcss": "6.0.10", - "postcss-clean": "1.0.3", + "postcss": "6.0.12", + "postcss-clean": "1.1.0", "promise-polyfill": "^6.0.2", "prompt": "^1.0.0", "redis": "2.8.0", - "request": "2.81.0", - "rimraf": "2.6.1", + "request": "2.83.0", + "rimraf": "2.6.2", "rss": "^1.2.2", - "sanitize-html": "^1.14.0", + "sanitize-html": "^1.14.1", "semver": "^5.4.1", - "serve-favicon": "^2.4.3", + "serve-favicon": "^2.4.5", "sitemap": "^1.13.0", "socket.io": "2.0.3", "socket.io-client": "2.0.3", @@ -92,24 +92,24 @@ "spdx-license-list": "^3.0.1", "string": "^3.3.3", "toobusy-js": "^0.5.1", - "uglify-js": "^3.0.28", - "validator": "8.1.0", + "uglify-js": "^3.1.3", + "validator": "9.0.0", "winston": "^2.3.1", "xml": "^1.0.1", "xregexp": "3.2.0", "zxcvbn": "^4.4.2" }, "devDependencies": { - "coveralls": "^2.11.14", - "eslint": "^3.12.0", - "eslint-config-airbnb-base": "^11.1.0", - "eslint-plugin-import": "^2.2.0", + "coveralls": "^3.0.0", + "eslint": "^4.8.0", + "eslint-config-airbnb-base": "^12.0.1", + "eslint-plugin-import": "^2.7.0", "grunt": "^1.0.1", "grunt-contrib-watch": "^1.0.0", - "istanbul": "^0.4.2", - "jsdom": "^11.2.0", - "mocha": "^3.5.0", - "mocha-lcov-reporter": "^1.2.0", + "istanbul": "^0.4.5", + "jsdom": "^11.3.0", + "mocha": "^3.5.3", + "mocha-lcov-reporter": "^1.3.0", "xmlhttprequest": "1.8.0", "xmlhttprequest-ssl": "1.5.3" }, @@ -136,4 +136,4 @@ "url": "https://github.com/barisusakli" } ] -} \ No newline at end of file +} diff --git a/public/src/admin/appearance/skins.js b/public/src/admin/appearance/skins.js index 7ec56349f7..b42f3991a3 100644 --- a/public/src/admin/appearance/skins.js +++ b/public/src/admin/appearance/skins.js @@ -72,8 +72,8 @@ define('admin/appearance/skins', ['translator', 'benchpress'], function (transla if (config['theme:src']) { var skin = config['theme:src'] - .match(/latest\/(\S+)\/bootstrap.min.css/)[1] - .replace(/(^|\s)([a-z])/g, function (m, p1, p2) { return p1 + p2.toUpperCase(); }); + .match(/latest\/(\S+)\/bootstrap.min.css/)[1] + .replace(/(^|\s)([a-z])/g, function (m, p1, p2) { return p1 + p2.toUpperCase(); }); highlightSelectedTheme(skin); } @@ -105,9 +105,9 @@ define('admin/appearance/skins', ['translator', 'benchpress'], function (transla $('[data-theme="' + themeId + '"]') .addClass('selected') .find('[data-action="use"]') - .html(current) - .removeClass('btn-primary') - .addClass('btn-success'); + .html(current) + .removeClass('btn-primary') + .addClass('btn-success'); }); } diff --git a/public/src/admin/appearance/themes.js b/public/src/admin/appearance/themes.js index 64d7a202fd..c0a96831bb 100644 --- a/public/src/admin/appearance/themes.js +++ b/public/src/admin/appearance/themes.js @@ -94,16 +94,16 @@ define('admin/appearance/themes', ['translator', 'benchpress'], function (transl $('[data-theme]') .removeClass('selected') .find('[data-action="use"]') - .html(select) - .removeClass('btn-success') - .addClass('btn-primary'); + .html(select) + .removeClass('btn-success') + .addClass('btn-primary'); $('[data-theme="' + themeId + '"]') .addClass('selected') .find('[data-action="use"]') - .html(current) - .removeClass('btn-primary') - .addClass('btn-success'); + .html(current) + .removeClass('btn-primary') + .addClass('btn-success'); }); } diff --git a/public/src/admin/extend/widgets.js b/public/src/admin/extend/widgets.js index be7bf72e83..f6d02ab420 100644 --- a/public/src/admin/extend/widgets.js +++ b/public/src/admin/extend/widgets.js @@ -148,8 +148,7 @@ define('admin/extend/widgets', ['jqueryui'], function () { .addClass(btn.attr('data-class')); container.attr('data-container-html', container.attr('data-container-html') - .replace(/class="[a-zA-Z0-9-\s]+"/, 'class="' + container[0].className.replace(' pointer ui-draggable', '') + '"') - ); + .replace(/class="[a-zA-Z0-9-\s]+"/, 'class="' + container[0].className.replace(' pointer ui-draggable', '') + '"')); }); } diff --git a/public/src/admin/general/dashboard.js b/public/src/admin/general/dashboard.js index e0c17ef25e..3b448a4de8 100644 --- a/public/src/admin/general/dashboard.js +++ b/public/src/admin/general/dashboard.js @@ -472,8 +472,7 @@ define('admin/general/dashboard', ['semver', 'Chart', 'translator', 'benchpress' var topic = topics[tids[i]]; var label = topic.value === '0' ? topic.title : ' ' + topic.title + ''; - legend.append( - '
  • ' + + legend.append('
  • ' + '
    ' + '' + label + '' + '
  • '); diff --git a/public/src/admin/modules/search.js b/public/src/admin/modules/search.js index 0df7b7b385..2a5798c18a 100644 --- a/public/src/admin/modules/search.js +++ b/public/src/admin/modules/search.js @@ -36,7 +36,7 @@ define('admin/modules/search', ['mousetrap'], function (mousetrap) { '' + title + '
    ' + (!results ? '' : - ('' + + ('' + results + '')) + '
    ' + diff --git a/public/src/client/account/header.js b/public/src/client/account/header.js index e88eda06f0..5c16a45a95 100644 --- a/public/src/client/account/header.js +++ b/public/src/client/account/header.js @@ -73,7 +73,8 @@ define('forum/account/header', [ } function setupCoverPhoto() { - coverPhoto.init(components.get('account/cover'), + coverPhoto.init( + components.get('account/cover'), function (imageData, position, callback) { socket.emit('user.updateCover', { uid: ajaxify.data.uid, diff --git a/public/src/client/chats/messages.js b/public/src/client/chats/messages.js index 8f8caa2a1f..fc4a327021 100644 --- a/public/src/client/chats/messages.js +++ b/public/src/client/chats/messages.js @@ -96,9 +96,7 @@ define('forum/chats/messages', ['components', 'sounds', 'translator', 'benchpres messages.scrollToBottom = function (containerEl) { if (containerEl.length) { - containerEl.scrollTop( - containerEl[0].scrollHeight - containerEl.height() - ); + containerEl.scrollTop(containerEl[0].scrollHeight - containerEl.height()); } }; diff --git a/public/src/client/chats/search.js b/public/src/client/chats/search.js index f9504e78a4..1b76d665d8 100644 --- a/public/src/client/chats/search.js +++ b/public/src/client/chats/search.js @@ -63,8 +63,8 @@ define('forum/chats/search', ['components'], function (components) { } var chatEl = $('
  • ') - .attr('data-uid', userObj.uid) - .appendTo(chatsListEl); + .attr('data-uid', userObj.uid) + .appendTo(chatsListEl); chatEl.append(createUserImage()); return chatEl; diff --git a/public/src/client/groups/details.js b/public/src/client/groups/details.js index e7225bb16c..65534df0aa 100644 --- a/public/src/client/groups/details.js +++ b/public/src/client/groups/details.js @@ -21,7 +21,8 @@ define('forum/groups/details', [ if (ajaxify.data.group.isOwner) { Details.prepareSettings(); - coverPhoto.init(components.get('groups/cover'), + coverPhoto.init( + components.get('groups/cover'), function (imageData, position, callback) { socket.emit('groups.cover.update', { groupName: groupName, diff --git a/src/controllers/admin/uploads.js b/src/controllers/admin/uploads.js index 42cade14cc..dc5bd7ce37 100644 --- a/src/controllers/admin/uploads.js +++ b/src/controllers/admin/uploads.js @@ -89,7 +89,7 @@ uploadsController.uploadLogo = function (req, res, next) { uploadsController.uploadSound = function (req, res, next) { var uploadedFile = req.files.files[0]; - var mimeType = mime.lookup(uploadedFile.name); + var mimeType = mime.getType(uploadedFile.name); if (!/^audio\//.test(mimeType)) { return next(Error('[[error:invalid-data]]')); } diff --git a/src/file.js b/src/file.js index 31806d6252..ec86c624b1 100644 --- a/src/file.js +++ b/src/file.js @@ -45,7 +45,7 @@ file.saveFileToLocal = function (filename, folder, tempPath, callback) { }; file.base64ToLocal = function (imageData, uploadPath, callback) { - var buffer = new Buffer(imageData.slice(imageData.indexOf('base64') + 7), 'base64'); + var buffer = Buffer.from(imageData.slice(imageData.indexOf('base64') + 7), 'base64'); uploadPath = path.join(nconf.get('upload_path'), uploadPath); fs.writeFile(uploadPath, buffer, { @@ -141,7 +141,7 @@ file.linkDirs = function linkDirs(sourceDir, destDir, callback) { file.typeToExtension = function (type) { var extension; if (type) { - extension = '.' + mime.extension(type); + extension = '.' + mime.getExtension(type); } return extension; }; diff --git a/src/flags.js b/src/flags.js index 9e3059d2a4..10635ee435 100644 --- a/src/flags.js +++ b/src/flags.js @@ -240,7 +240,7 @@ Flags.validate = function (payload, callback) { } var minimumReputation = utils.isNumber(meta.config['privileges:flag']) ? parseInt(meta.config['privileges:flag'], 10) : 1; - // Check if reporter meets rep threshold (or can edit the target post, in which case threshold does not apply) + // Check if reporter meets rep threshold (or can edit the target post, in which case threshold does not apply) if (!editable.flag && parseInt(data.reporter.reputation, 10) < minimumReputation) { return callback(new Error('[[error:not-enough-reputation-to-flag]]')); } @@ -256,7 +256,7 @@ Flags.validate = function (payload, callback) { } var minimumReputation = utils.isNumber(meta.config['privileges:flag']) ? parseInt(meta.config['privileges:flag'], 10) : 1; - // Check if reporter meets rep threshold (or can edit the target user, in which case threshold does not apply) + // Check if reporter meets rep threshold (or can edit the target user, in which case threshold does not apply) if (!editable && parseInt(data.reporter.reputation, 10) < minimumReputation) { return callback(new Error('[[error:not-enough-reputation-to-flag]]')); } diff --git a/src/groups/cover.js b/src/groups/cover.js index 66cac228bf..289ee16302 100644 --- a/src/groups/cover.js +++ b/src/groups/cover.js @@ -26,7 +26,7 @@ module.exports = function (Groups) { var tempPath = data.file ? data.file : ''; var url; - var type = data.file ? mime.lookup(data.file) : 'image/png'; + var type = data.file ? mime.getType(data.file) : 'image/png'; async.waterfall([ function (next) { diff --git a/src/image.js b/src/image.js index 4d3be47e6f..fc3ddd5e76 100644 --- a/src/image.js +++ b/src/image.js @@ -141,7 +141,7 @@ image.writeImageDataToTempFile = function (imageData, callback) { var filepath = path.join(os.tmpdir(), filename + extension); - var buffer = new Buffer(imageData.slice(imageData.indexOf('base64') + 7), 'base64'); + var buffer = Buffer.from(imageData.slice(imageData.indexOf('base64') + 7), 'base64'); fs.writeFile(filepath, buffer, { encoding: 'base64', diff --git a/src/meta/minifier.js b/src/meta/minifier.js index a3e40d195a..3b26f99ec5 100644 --- a/src/meta/minifier.js +++ b/src/meta/minifier.js @@ -282,9 +282,9 @@ function buildCSS(data, callback) { processImportFrom: ['local'], }), ] : [autoprefixer]).process(lessOutput.css).then(function (result) { - callback(null, { code: result.css }); + process.nextTick(callback, null, { code: result.css }); }, function (err) { - callback(err); + process.nextTick(callback, err); }); }); } diff --git a/src/plugins/hooks.js b/src/plugins/hooks.js index ba52cd5f40..63e3cfaec1 100644 --- a/src/plugins/hooks.js +++ b/src/plugins/hooks.js @@ -39,8 +39,7 @@ module.exports = function (Plugins) { (Plugins.deprecatedHooks[data.hook] ? 'please use `' + Plugins.deprecatedHooks[data.hook] + '` instead.' : 'there is no alternative.' - ) - ); + )); } else { // handle hook's startsWith, i.e. action:homepage.get var parts = data.hook.split(':'); @@ -61,7 +60,7 @@ module.exports = function (Plugins) { if (memo && memo[prop]) { return memo[prop]; } - // Couldn't find method by path, aborting + // Couldn't find method by path, aborting return null; }, Plugins.libraries[data.id]); diff --git a/src/topics/thumb.js b/src/topics/thumb.js index 92963f70df..cfd13f3fb8 100644 --- a/src/topics/thumb.js +++ b/src/topics/thumb.js @@ -35,7 +35,7 @@ module.exports = function (Topics) { var extension = path.extname(data.thumb); if (!extension) { - extension = '.' + mime.extension(type); + extension = '.' + mime.getExtension(type); } filename = Date.now() + '-topic-thumb' + extension; pathToUpload = path.join(nconf.get('upload_path'), 'files', filename); diff --git a/src/user/picture.js b/src/user/picture.js index 817073163b..820d4b12ce 100644 --- a/src/user/picture.js +++ b/src/user/picture.js @@ -28,7 +28,7 @@ module.exports = function (User) { var uploadSize = parseInt(meta.config.maximumProfileImageSize, 10) || 256; var size = res.headers['content-length']; var type = res.headers['content-type']; - var extension = mime.extension(type); + var extension = mime.getExtension(type); if (['png', 'jpeg', 'jpg', 'gif'].indexOf(extension) === -1) { return callback(new Error('[[error:invalid-image-extension]]')); diff --git a/test/build.js b/test/build.js index 1287165a17..1c346ad621 100644 --- a/test/build.js +++ b/test/build.js @@ -114,7 +114,7 @@ describe('minifier', function () { it('.css.bundle() should minify styles', function (done) { minifier.css.bundle(styles, paths, true, false, function (err, bundle) { assert.ifError(err); - assert.strictEqual(bundle.code, '.help{margin:10px;display:block}.yellow{background:#ff0}.help .blue{background:#00f}'); + assert.strictEqual(bundle.code, '.help{margin:10px}.yellow{background:#ff0}.help{display:block}.help .blue{background:#00f}'); done(); }); }); diff --git a/test/search-admin.js b/test/search-admin.js index f885b2bbf9..3c2620dfc1 100644 --- a/test/search-admin.js +++ b/test/search-admin.js @@ -46,20 +46,20 @@ describe('admin search', function () { describe('sanitize', function () { it('should strip out scripts', function (done) { assert.equal( - search.sanitize('Pellentesque tristique senectus' + - ' habitant morbi'), - 'Pellentesque tristique senectus' + - ' habitant morbi' - ); + search.sanitize('Pellentesque tristique senectus' + + ' habitant morbi'), + 'Pellentesque tristique senectus' + + ' habitant morbi' + ); done(); }); it('should remove all tags', function (done) { assert.equal( - search.sanitize('

    Pellentesque habitant morbi tristique senectus' + - 'Aenean vitae est.Mauris eleifend leo.

    '), - 'Pellentesque habitant morbi tristique senectus' + - 'Aenean vitae est.Mauris eleifend leo.' - ); + search.sanitize('

    Pellentesque habitant morbi tristique senectus' + + 'Aenean vitae est.Mauris eleifend leo.

    '), + 'Pellentesque habitant morbi tristique senectus' + + 'Aenean vitae est.Mauris eleifend leo.' + ); done(); }); }); @@ -67,24 +67,20 @@ describe('admin search', function () { describe('simplify', function () { it('should remove all mustaches', function (done) { assert.equal( - search.simplify( - 'Pellentesque tristique {{senectus}}habitant morbi' + - 'liquam tincidunt {mauris.eu}risus' - ), - 'Pellentesque tristique habitant morbi' + - 'liquam tincidunt risus' - ); + search.simplify('Pellentesque tristique {{senectus}}habitant morbi' + + 'liquam tincidunt {mauris.eu}risus'), + 'Pellentesque tristique habitant morbi' + + 'liquam tincidunt risus' + ); done(); }); it('should collapse all whitespace', function (done) { assert.equal( - search.simplify( - 'Pellentesque tristique habitant morbi' + - ' \n\n liquam tincidunt mauris eu risus.' - ), - 'Pellentesque tristique habitant morbi' + - '\nliquam tincidunt mauris eu risus.' - ); + search.simplify('Pellentesque tristique habitant morbi' + + ' \n\n liquam tincidunt mauris eu risus.'), + 'Pellentesque tristique habitant morbi' + + '\nliquam tincidunt mauris eu risus.' + ); done(); }); }); diff --git a/test/socket.io.js b/test/socket.io.js index 76f7ae6a72..eb7489ef8a 100644 --- a/test/socket.io.js +++ b/test/socket.io.js @@ -72,7 +72,8 @@ describe('socket.io', function () { helpers.connectSocketIO(res, function (err, _io) { io = _io; assert.ifError(err); - done(err); + + done(); }); }); }); diff --git a/test/topics.js b/test/topics.js index 0592b9d030..f8c1ee5d16 100644 --- a/test/topics.js +++ b/test/topics.js @@ -654,8 +654,8 @@ describe('Topic\'s', function () { function (next) { topicPids = replies.map(function (reply) { return reply.pid; }); socketTopics.bookmark({ uid: topic.userId }, { tid: newTopic.tid, index: originalBookmark }, next); - }], - done); + }, + ], done); }); it('should fail with invalid data', function (done) { @@ -711,7 +711,8 @@ describe('Topic\'s', function () { 'Fork test, no bookmark update', topicPids.slice(1, 3), newTopic.tid, - next); + next + ); }, function (forkedTopicData, next) { topics.getUserBookmark(newTopic.tid, topic.userId, next);