diff --git a/Gruntfile.js b/Gruntfile.js index ed5777da3d..b347a0bd09 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -113,21 +113,39 @@ var path = require('path'), } }, - // ### Config for grunt-jslint - // JSLint all the things! - jslint: { + // ### Config for grunt-contrib-jshint + // JSHint all the things! + jshint: { server: { - directives: { + options: { // node environment node: true, // browser environment browser: false, // allow dangling underscores in var names - nomen: true, - // allow to do statements - todo: true, + nomen: false, // don't require use strict pragma - sloppy: true + strict: false, + sub: true, + eqeqeq: true, + laxbreak: true, + bitwise: true, + curly: true, + forin: true, + immed: true, + latedef: true, + newcap: true, + noarg: true, + noempty: true, + nonew: true, + plusplus: true, + regexp: true, + undef: true, + unused: true, + trailing: true, + indent: 4, + onevar: true, + white: true }, files: { src: [ @@ -138,47 +156,88 @@ var path = require('path'), } }, client: { - directives: { + options: { + "predef": { + "document": true, + "window": true, + "location": true, + "setTimeout": true, + "Ember": true, + "Em": true, + "DS": true, + "$": true + }, // node environment node: false, // browser environment browser: true, // allow dangling underscores in var names - nomen: true, - // allow to do statements - todo: true + nomen: false, + bitwise: true, + curly: true, + eqeqeq: true, + forin: true, + immed: true, + latedef: true, + newcap: true, + noarg: true, + noempty: true, + nonew: true, + plusplus: true, + regexp: true, + undef: true, + unused: true, + trailing: true, + indent: 4, + esnext: true, + onevar: true, + white: true }, files: { - src: 'core/client/**/*.js' - }, - exclude: [ - 'core/client/assets/vendor/**/*.js', - 'core/client/tpl/**/*.js' - ] + src: [ + 'core/client/**/*.js', + // Ignore files + '!core/client/assets/vendor/**/*.js', + '!core/client/tpl/**/*.js' + ] + } }, shared: { - directives: { + options: { // node environment node: true, // browser environment browser: false, - // allow dangling underscores in var names - nomen: true, - // allow to do statements - todo: true, - // allow unused parameters - unparam: true, // don't require use strict pragma - sloppy: true + strict: false, + // allow dangling underscores in var names + nomen: false, + bitwise: true, + curly: true, + eqeqeq: true, + forin: true, + immed: true, + latedef: true, + newcap: true, + noarg: true, + noempty: true, + nonew: true, + plusplus: true, + regexp: true, + undef: true, + unused: true, + trailing: true, + indent: 4, + onevar: true, + white: true }, files: { src: [ - 'core/shared/**/*.js' + 'core/shared/**/*.js', + // Ignore files + '!core/shared/vendor/**/*.js' ] - }, - exclude: [ - 'core/shared/vendor/**/*.js' - ] + } } }, @@ -520,7 +579,7 @@ var path = require('path'), stdio: 'inherit' } }, function (error, result, code) { - /*jslint unparam:true*/ + /*jshint unused:false*/ if (error) { grunt.fail.fatal(result.stdout); } @@ -649,7 +708,7 @@ var path = require('path'), data.replace( commitRegex, function (wholeCommit, hash, author, email, date, message) { - /*jslint unparam:true*/ + /*jshint unused:false*/ // The author name and commit message may have trailing space. author = author.trim(); @@ -760,7 +819,7 @@ var path = require('path'), when.reduce(tags, function (prev, tag, idx) { - /*jslint unparam:true*/ + /*jshint unused:false*/ return when.promise(function (resolve) { processTag(tag, function (releaseData) { resolve(prev + '\n' + releaseData); @@ -824,7 +883,7 @@ var path = require('path'), grunt.registerTask('test-routes', 'Run functional route tests (mocha)', ['clean:test', 'setTestEnv', 'loadConfig', 'express:test', 'mochacli:routes', 'express:test:stop']); - grunt.registerTask('validate', 'Run tests and lint code', ['jslint', 'test-routes', 'test-unit', 'test-api', 'test-integration', 'test-functional']); + grunt.registerTask('validate', 'Run tests and lint code', ['jshint', 'test-routes', 'test-unit', 'test-api', 'test-integration', 'test-functional']); // ### Coverage report for Unit and Integration Tests diff --git a/core/bootstrap.js b/core/bootstrap.js index 1d39cd8675..6fcbb35ebf 100644 --- a/core/bootstrap.js +++ b/core/bootstrap.js @@ -7,7 +7,6 @@ var fs = require('fs'), url = require('url'), when = require('when'), - path = require('path'), errors = require('./server/errorHandling'), config = require('./server/config'), @@ -36,14 +35,14 @@ function writeConfigFile() { // Copy config.example.js => config.js read = fs.createReadStream(configExample); read.on('error', function (err) { - /*jslint unparam:true*/ + /*jshint unused:false*/ return errors.logError(new Error('Could not open config.example.js for read.'), appRoot, 'Please check your deployment for config.js or config.example.js.'); }); read.on('end', written.resolve); write = fs.createWriteStream(configFile); write.on('error', function (err) { - /*jslint unparam:true*/ + /*jshint unused:false*/ return errors.logError(new Error('Could not open config.js for write.'), appRoot, 'Please check your deployment for config.js or config.example.js.'); }); diff --git a/core/client/assets/lib/jquery-utils.js b/core/client/assets/lib/jquery-utils.js index e4249fecdb..b1dd088c1e 100644 --- a/core/client/assets/lib/jquery-utils.js +++ b/core/client/assets/lib/jquery-utils.js @@ -16,7 +16,7 @@ * @returns {boolean} */ $.expr[":"].containsExact = function (obj, index, meta, stack) { - /*jslint unparam:true*/ + /*jshint unused:false*/ return (obj.textContent || obj.innerText || $(obj).text() || "") === meta[3]; }; diff --git a/core/client/assets/lib/uploader.js b/core/client/assets/lib/uploader.js index a1ce7880c6..f25b3bcc8b 100644 --- a/core/client/assets/lib/uploader.js +++ b/core/client/assets/lib/uploader.js @@ -1,4 +1,4 @@ -/*global jQuery, Ghost, document, Image, window */ +/*global jQuery, Ghost */ (function ($) { "use strict"; @@ -68,7 +68,7 @@ 'X-CSRF-Token': $("meta[name='csrf-param']").attr('content') }, add: function (e, data) { - /*jslint unparam:true*/ + /*jshint unused:false*/ $('.js-button-accept').prop('disabled', true); $dropzone.find('.js-fileupload').removeClass('right'); $dropzone.find('.js-url').remove(); @@ -86,7 +86,7 @@ }, dropZone: settings.fileStorage ? $dropzone : null, progressall: function (e, data) { - /*jslint unparam:true*/ + /*jshint unused:false*/ var progress = parseInt(data.loaded / data.total * 100, 10); if (!settings.editor) {$progress.find('div.js-progress').css({"position": "absolute", "top": "40px"}); } if (settings.progressbar) { @@ -95,7 +95,7 @@ } }, fail: function (e, data) { - /*jslint unparam:true*/ + /*jshint unused:false*/ $('.js-button-accept').prop('disabled', false); $dropzone.trigger("uploadfailure", [data.result]); $dropzone.find('.js-upload-progress-bar').addClass('fail'); @@ -115,7 +115,7 @@ }); }, done: function (e, data) { - /*jslint unparam:true*/ + /*jshint unused:false*/ self.complete(data.result); } }); diff --git a/core/client/markdown-actions.js b/core/client/markdown-actions.js index 16e194cf18..0d62700037 100644 --- a/core/client/markdown-actions.js +++ b/core/client/markdown-actions.js @@ -1,6 +1,6 @@ // # Surrounds given text with Markdown syntax -/*global $, window, CodeMirror, Showdown, moment */ +/*global $, CodeMirror, Showdown, moment */ (function () { 'use strict'; var Markdown = { diff --git a/core/client/models/base.js b/core/client/models/base.js index d7196a2e09..bd7c179e64 100644 --- a/core/client/models/base.js +++ b/core/client/models/base.js @@ -1,4 +1,4 @@ -/*global window, document, setTimeout, Ghost, $, _, Backbone, JST, shortcut, NProgress */ +/*global Ghost, _, Backbone, NProgress */ (function () { "use strict"; @@ -10,8 +10,10 @@ if (options !== undefined && _.isObject(options)) { NProgress.start(); + /*jshint validthis:true */ var self = this, oldSuccess = options.success; + /*jshint validthis:false */ options.success = function () { NProgress.done(); @@ -19,6 +21,7 @@ }; } + /*jshint validthis:true */ return Backbone.sync.call(this, method, model, options); } @@ -29,4 +32,4 @@ Ghost.ProgressCollection = Backbone.Collection.extend({ sync: wrapSync }); -}()); \ No newline at end of file +}()); diff --git a/core/client/models/post.js b/core/client/models/post.js index b4318ebd95..157eb8e59d 100644 --- a/core/client/models/post.js +++ b/core/client/models/post.js @@ -1,4 +1,4 @@ -/*global window, document, Ghost, $, _, Backbone */ +/*global Ghost, _, Backbone */ (function () { 'use strict'; diff --git a/core/client/models/settings.js b/core/client/models/settings.js index b6a58a177e..f5b2c93710 100644 --- a/core/client/models/settings.js +++ b/core/client/models/settings.js @@ -1,4 +1,4 @@ -/*global window, document, Ghost, $, _, Backbone */ +/*global Ghost */ (function () { 'use strict'; //id:0 is used to issue PUT requests diff --git a/core/client/models/tag.js b/core/client/models/tag.js index 4661480578..879396a056 100644 --- a/core/client/models/tag.js +++ b/core/client/models/tag.js @@ -1,4 +1,4 @@ -/*global window, document, Ghost, $, _, Backbone */ +/*global Ghost */ (function () { 'use strict'; diff --git a/core/client/models/themes.js b/core/client/models/themes.js index cf76c1d806..63e5f57931 100644 --- a/core/client/models/themes.js +++ b/core/client/models/themes.js @@ -1,4 +1,4 @@ -/*global window, document, Ghost, $, _, Backbone */ +/*global Ghost, Backbone */ (function () { 'use strict'; diff --git a/core/client/models/user.js b/core/client/models/user.js index 47aa87ca5b..0413792023 100644 --- a/core/client/models/user.js +++ b/core/client/models/user.js @@ -1,4 +1,4 @@ -/*global window, document, Ghost, $, _, Backbone */ +/*global Ghost */ (function () { 'use strict'; diff --git a/core/client/models/widget.js b/core/client/models/widget.js index f26cf79c93..c9cc8f5c6c 100644 --- a/core/client/models/widget.js +++ b/core/client/models/widget.js @@ -1,4 +1,4 @@ -/*global window, document, Ghost, $, _, Backbone */ +/*global Ghost */ (function () { 'use strict'; diff --git a/core/client/router.js b/core/client/router.js index 1293247b33..460f129c7a 100644 --- a/core/client/router.js +++ b/core/client/router.js @@ -1,4 +1,4 @@ -/*global window, document, Ghost, Backbone, $, _, NProgress */ +/*global Ghost, Backbone, NProgress */ (function () { "use strict"; diff --git a/core/client/views/base.js b/core/client/views/base.js index a4bc1636b6..b72a99b3e9 100644 --- a/core/client/views/base.js +++ b/core/client/views/base.js @@ -215,7 +215,7 @@ }, url: Ghost.paths.apiRoot + '/notifications/' + $(self).find('.close').data('id') }).done(function (result) { - /*jslint unparam:true*/ + /*jshint unused:false*/ bbSelf.$el.slideUp(250, function () { $(this).show().css({height: "auto"}); $(self).remove(); @@ -249,7 +249,7 @@ }, url: Ghost.paths.apiRoot + '/notifications/' + $(self).data('id') }).done(function (result) { - /*jslint unparam:true*/ + /*jshint unused:false*/ var height = bbSelf.$('.js-notification').outerHeight(true), $parent = $(self).parent(); bbSelf.$el.css({height: height}); diff --git a/core/client/views/blog.js b/core/client/views/blog.js index 0cd360273d..a6256bc438 100644 --- a/core/client/views/blog.js +++ b/core/client/views/blog.js @@ -1,4 +1,4 @@ -/*global window, document, Ghost, $, _, Backbone, JST, NProgress */ +/*global window, Ghost, $, _, Backbone, NProgress */ (function () { "use strict"; @@ -10,7 +10,7 @@ // ---------- Ghost.Views.Blog = Ghost.View.extend({ initialize: function (options) { - /*jslint unparam:true*/ + /*jshint unused:false*/ var self = this, finishProgress = function () { NProgress.done(); @@ -108,7 +108,7 @@ staticPages: 'all' } }).then(function onSuccess(response) { - /*jslint unparam:true*/ + /*jshint unused:false*/ self.render(); self.isLoading = false; }, function onError(e) { @@ -245,7 +245,7 @@ }); }, error : function (model, xhr) { - /*jslint unparam:true*/ + /*jshint unused:false*/ Ghost.notifications.addItem({ type: 'error', message: Ghost.Views.Utils.getRequestErrorMessage(xhr), diff --git a/core/client/views/debug.js b/core/client/views/debug.js index fb989af43b..e08e2b5c8a 100644 --- a/core/client/views/debug.js +++ b/core/client/views/debug.js @@ -1,4 +1,4 @@ -/*global window, document, Ghost, $, _, Backbone, JST */ +/*global Ghost, $ */ (function () { "use strict"; @@ -25,7 +25,7 @@ }, dataType: 'json', add: function (e, data) { - /*jslint unparam:true*/ + /*jshint unused:false*/ // Bind the upload data to the view, so it is // available to the click handler, and enable the @@ -34,7 +34,7 @@ data.context = view.uploadButton.removeProp('disabled'); }, done: function (e, data) { - /*jslint unparam:true*/ + /*jshint unused:false*/ $('#startupload').text('Import'); if (!data.result) { throw new Error('No response received from server.'); diff --git a/core/client/views/editor-tag-widget.js b/core/client/views/editor-tag-widget.js index 33d3b7226a..aa12f468ed 100644 --- a/core/client/views/editor-tag-widget.js +++ b/core/client/views/editor-tag-widget.js @@ -1,6 +1,6 @@ // The Tag UI area associated with a post -/*global window, document, setTimeout, $, _, Backbone, Ghost */ +/*global window, document, setTimeout, $, _, Ghost */ (function () { "use strict"; diff --git a/core/client/views/editor.js b/core/client/views/editor.js index fcccbd9468..aeb26f5873 100644 --- a/core/client/views/editor.js +++ b/core/client/views/editor.js @@ -1,6 +1,6 @@ // # Article Editor -/*global window, document, setTimeout, navigator, $, _, Backbone, Ghost, Showdown, CodeMirror, shortcut, Countable, JST */ +/*global window, document, setTimeout, navigator, $, _, Backbone, Ghost, Showdown, CodeMirror, shortcut, Countable */ (function () { "use strict"; @@ -78,7 +78,7 @@ }, //TODO: This has to be moved to the I18n localization file. - //This structure is supposed to be close to the i18n-localization which will be used soon. + //This structure is supposed to be close to the i18n-localization which will be used soon. messageMap: { errors: { post: { @@ -704,7 +704,7 @@ var value = editor.getValue(); _.each(markerMgr.markers, function (marker, id) { - /*jslint unparam:true*/ + /*jshint unused:false*/ value = value.replace(markerMgr.getMarkerRegexForId(id), ''); }); @@ -720,7 +720,7 @@ // initialise editor.on('change', function (cm, changeObj) { - /*jslint unparam:true*/ + /*jshint unused:false*/ var linesChanged = _.range(changeObj.from.line, changeObj.from.line + changeObj.text.length); _.each(linesChanged, function (ln) { diff --git a/core/client/views/login.js b/core/client/views/login.js index b73f872312..6f0c946a1c 100644 --- a/core/client/views/login.js +++ b/core/client/views/login.js @@ -1,4 +1,4 @@ -/*global window, document, Ghost, $, _, Backbone, JST */ +/*global window, Ghost, $ */ (function () { "use strict"; diff --git a/core/client/views/post-settings.js b/core/client/views/post-settings.js index 6b58f11a5f..397df86eaf 100644 --- a/core/client/views/post-settings.js +++ b/core/client/views/post-settings.js @@ -1,6 +1,6 @@ // The Post Settings Menu available in the content preview screen, as well as the post editor. -/*global window, document, $, _, Backbone, Ghost, moment */ +/*global window, $, _, Ghost, moment */ (function () { "use strict"; @@ -124,7 +124,7 @@ slug: newSlug }, { success : function (model, response, options) { - /*jslint unparam:true*/ + /*jshint unused:false*/ // Repopulate slug in case it changed on the server (e.g. 'new-slug-2') slugEl.value = model.get('slug'); Ghost.notifications.addItem({ @@ -134,7 +134,7 @@ }); }, error : function (model, xhr) { - /*jslint unparam:true*/ + /*jshint unused:false*/ slugEl.value = model.previous('slug'); Ghost.notifications.addItem({ type: 'error', @@ -244,7 +244,7 @@ }); }, error : function (model, xhr) { - /*jslint unparam:true*/ + /*jshint unused:false*/ // Reset back to original value pubDateEl.value = pubDateMoment ? pubDateMoment.format(displayDateFormat) : ''; Ghost.notifications.addItem({ @@ -275,7 +275,7 @@ page: page }, { success : function (model, response, options) { - /*jslint unparam:true*/ + /*jshint unused:false*/ pageEl.prop('checked', page); Ghost.notifications.addItem({ type: 'success', @@ -284,7 +284,7 @@ }); }, error : function (model, xhr) { - /*jslint unparam:true*/ + /*jshint unused:false*/ pageEl.prop('checked', model.previous('page')); Ghost.notifications.addItem({ type: 'error', diff --git a/core/client/views/settings.js b/core/client/views/settings.js index bc40977f99..d6e745a7e2 100644 --- a/core/client/views/settings.js +++ b/core/client/views/settings.js @@ -1,4 +1,4 @@ -/*global window, document, Ghost, $, _, Backbone, Countable */ +/*global document, Ghost, $, _, Countable */ (function () { "use strict"; @@ -112,7 +112,7 @@ this.$el.addClass('active'); }, saveSuccess: function (model, response, options) { - /*jslint unparam:true*/ + /*jshint unused:false*/ Ghost.notifications.clearEverything(); Ghost.notifications.addItem({ type: 'success', @@ -121,7 +121,7 @@ }); }, saveError: function (model, xhr) { - /*jslint unparam:true*/ + /*jshint unused:false*/ Ghost.notifications.clearEverything(); Ghost.notifications.addItem({ type: 'error', diff --git a/core/server/api/db.js b/core/server/api/db.js index bde548c53e..117768197e 100644 --- a/core/server/api/db.js +++ b/core/server/api/db.js @@ -2,12 +2,10 @@ var dataExport = require('../data/export'), dataImport = require('../data/import'), dataProvider = require('../models'), fs = require('fs-extra'), - path = require('path'), when = require('when'), nodefn = require('when/node/function'), _ = require('lodash'), validation = require('../data/validation'), - config = require('../config'), errors = require('../../server/errorHandling'), api = {}, db; diff --git a/core/server/api/index.js b/core/server/api/index.js index ccea747840..8228ff8544 100644 --- a/core/server/api/index.js +++ b/core/server/api/index.js @@ -4,7 +4,6 @@ var _ = require('lodash'), when = require('when'), config = require('../config'), - errors = require('../errorHandling'), db = require('./db'), settings = require('./settings'), notifications = require('./notifications'), diff --git a/core/server/apps/sandbox.js b/core/server/apps/sandbox.js index dc08bea55d..2a5f0079c1 100644 --- a/core/server/apps/sandbox.js +++ b/core/server/apps/sandbox.js @@ -1,6 +1,5 @@ -var fs = require('fs'), - path = require('path'), +var path = require('path'), Module = require('module'), _ = require('lodash'); @@ -88,4 +87,4 @@ AppSandbox.defaults = { blacklist: ['knex', 'fs', 'http', 'sqlite3', 'pg', 'mysql', 'ghost'] }; -module.exports = AppSandbox; \ No newline at end of file +module.exports = AppSandbox; diff --git a/core/server/config/index.js b/core/server/config/index.js index c63ec43163..8bcfa90d0a 100644 --- a/core/server/config/index.js +++ b/core/server/config/index.js @@ -100,7 +100,7 @@ function config() { if (_.isEmpty(ghostConfig)) { try { ghostConfig = require(path.resolve(__dirname, '../../../', 'config.js'))[process.env.NODE_ENV] || {}; - } catch (ignore) {/*jslint sloppy: true */} + } catch (ignore) {/*jslint strict: true */} ghostConfig = updateConfig(ghostConfig); } @@ -111,4 +111,4 @@ module.exports = config; module.exports.init = initConfig; module.exports.theme = theme; module.exports.urlFor = configUrl.urlFor; -module.exports.urlForPost = configUrl.urlForPost; \ No newline at end of file +module.exports.urlForPost = configUrl.urlForPost; diff --git a/core/server/controllers/frontend.js b/core/server/controllers/frontend.js index 90310596cd..e984ab2183 100644 --- a/core/server/controllers/frontend.js +++ b/core/server/controllers/frontend.js @@ -13,7 +13,6 @@ var moment = require('moment'), api = require('../api'), config = require('../config'), - errors = require('../errorHandling'), filters = require('../../server/filters'), template = require('../helpers/template'), diff --git a/core/server/data/fixtures/index.js b/core/server/data/fixtures/index.js index 902538f8ea..e7d4c5de2f 100644 --- a/core/server/data/fixtures/index.js +++ b/core/server/data/fixtures/index.js @@ -3,8 +3,7 @@ var sequence = require('when/sequence'), Post = require('../../models/post').Post, Tag = require('../../models/tag').Tag, Role = require('../../models/role').Role, - Permission = require('../../models/permission').Permission, - uuid = require('node-uuid'); + Permission = require('../../models/permission').Permission; var fixtures = { posts: [ @@ -102,4 +101,4 @@ module.exports = { return sequence(ops); } -}; \ No newline at end of file +}; diff --git a/core/server/data/import/000.js b/core/server/data/import/000.js index 8a5eb63aff..9c6b208c81 100644 --- a/core/server/data/import/000.js +++ b/core/server/data/import/000.js @@ -1,7 +1,6 @@ var when = require('when'), _ = require('lodash'), models = require('../../models'), - errors = require('../../errorHandling'), Importer000; @@ -197,4 +196,4 @@ module.exports = { importData: function (data) { return new Importer000().importData(data); } -}; \ No newline at end of file +}; diff --git a/core/server/data/validation/index.js b/core/server/data/validation/index.js index 25dd00f7ff..306b959680 100644 --- a/core/server/data/validation/index.js +++ b/core/server/data/validation/index.js @@ -1,7 +1,6 @@ var schema = require('../schema').tables, _ = require('lodash'), validator = require('validator'), - when = require('when'), validateSchema, validateSettings, @@ -74,10 +73,11 @@ validate = function (value, key, validations) { if (validationOptions === true) { validationOptions = null; } + /* jshint ignore:start */ if (typeof validationOptions !== 'array') { validationOptions = [validationOptions]; } - + /* jshint ignore:end */ // equivalent of validation.isSomething(option1, option2) validation[validationName].apply(validation, validationOptions); }, this); @@ -86,4 +86,4 @@ validate = function (value, key, validations) { module.exports = { validateSchema: validateSchema, validateSettings: validateSettings -}; \ No newline at end of file +}; diff --git a/core/server/errorHandling.js b/core/server/errorHandling.js index 881a562fb7..cc3b0afd80 100644 --- a/core/server/errorHandling.js +++ b/core/server/errorHandling.js @@ -1,7 +1,6 @@ /*jslint regexp: true */ var _ = require('lodash'), colors = require('colors'), - fs = require('fs'), config = require('./config'), path = require('path'), when = require('when'), @@ -15,6 +14,9 @@ var _ = require('lodash'), ONE_HOUR_S = 60 * 60; +// This is not useful but required for jshint +colors.setTheme({silly: 'rainbow'}); + /** * Basic error handling helpers */ @@ -107,7 +109,7 @@ errors = { }, logErrorWithRedirect: function (msg, context, help, redirectTo, req, res) { - /*jslint unparam:true*/ + /*jshint unused:false*/ var self = this; return function () { @@ -120,7 +122,7 @@ errors = { }, renderErrorPage: function (code, err, req, res, next) { - /*jslint unparam:true*/ + /*jshint unused:false*/ var self = this; diff --git a/core/server/helpers/index.js b/core/server/helpers/index.js index 3004b5b164..37ca5067e5 100644 --- a/core/server/helpers/index.js +++ b/core/server/helpers/index.js @@ -1,7 +1,6 @@ var downsize = require('downsize'), hbs = require('express-hbs'), moment = require('moment'), - path = require('path'), polyglot = require('node-polyglot').instance, _ = require('lodash'), when = require('when'), @@ -96,7 +95,7 @@ coreHelpers.encode = function (context, str) { // context. // coreHelpers.page_url = function (context, block) { - /*jslint unparam:true*/ + /*jshint unused:false*/ var url = config().paths.subdir; if (this.tagSlug !== undefined) { @@ -125,7 +124,7 @@ coreHelpers.pageUrl = function (context, block) { 'The helper pageUrl has been replaced with page_url in Ghost 0.5, and will be removed entirely in Ghost 0.6\n' + 'In your theme\'s pagination.hbs file, pageUrl should be renamed to page_url'); - /*jslint unparam:true*/ + /*jshint unused:false*/ var self = this; return coreHelpers.page_url.call(self, context, block); @@ -198,7 +197,7 @@ coreHelpers.asset = function (context, options) { // if the author could not be determined. // coreHelpers.author = function (context, options) { - /*jslint unparam:true*/ + /*jshint unused:false*/ return this.author ? this.author.name : ''; }; @@ -320,7 +319,7 @@ coreHelpers.excerpt = function (options) { // // Returns the config value for fileStorage. coreHelpers.file_storage = function (context, options) { - /*jslint unparam:true*/ + /*jshint unused:false*/ if (config().hasOwnProperty('fileStorage')) { return config().fileStorage.toString(); } @@ -345,7 +344,7 @@ coreHelpers.ghost_script_tags = function () { */ coreHelpers.body_class = function (options) { - /*jslint unparam:true*/ + /*jshint unused:false*/ var classes = [], post = this.post, tags = this.post && this.post.tags ? this.post.tags : this.tags || [], @@ -391,7 +390,7 @@ coreHelpers.body_class = function (options) { }; coreHelpers.post_class = function (options) { - /*jslint unparam:true*/ + /*jshint unused:false*/ var classes = ['post'], tags = this.post && this.post.tags ? this.post.tags : this.tags || [], featured = this.post && this.post.featured ? this.post.featured : this.featured || false, @@ -416,7 +415,7 @@ coreHelpers.post_class = function (options) { }; coreHelpers.ghost_head = function (options) { - /*jslint unparam:true*/ + /*jshint unused:false*/ var self = this, blog = config.theme(), head = [], @@ -441,7 +440,7 @@ coreHelpers.ghost_head = function (options) { }; coreHelpers.ghost_foot = function (options) { - /*jslint unparam:true*/ + /*jshint unused:false*/ var foot = []; foot.push(scriptTemplate({ @@ -456,7 +455,7 @@ coreHelpers.ghost_foot = function (options) { }; coreHelpers.meta_title = function (options) { - /*jslint unparam:true*/ + /*jshint unused:false*/ var title = "", blog; @@ -478,7 +477,7 @@ coreHelpers.meta_title = function (options) { }; coreHelpers.meta_description = function (options) { - /*jslint unparam:true*/ + /*jshint unused:false*/ var description, blog; @@ -627,7 +626,7 @@ coreHelpers.has = function (options) { // `{{pagination}}` // Outputs previous and next buttons, along with info about the current page coreHelpers.pagination = function (options) { - /*jslint unparam:true*/ + /*jshint unused:false*/ if (!_.isObject(this.pagination) || _.isFunction(this.pagination)) { errors.logAndThrowError('pagination data is not an object or is a function'); return; diff --git a/core/server/index.js b/core/server/index.js index ab99aa82cd..e417a990ed 100644 --- a/core/server/index.js +++ b/core/server/index.js @@ -247,7 +247,7 @@ function setup(server) { if (getSocket()) { // Make sure the socket is gone before trying to create another fs.unlink(getSocket(), function (err) { - /*jslint unparam:true*/ + /*jshint unused:false*/ server.listen( getSocket(), startGhost diff --git a/core/server/mail.js b/core/server/mail.js index 80263d7f3c..347720a9a2 100644 --- a/core/server/mail.js +++ b/core/server/mail.js @@ -1,5 +1,4 @@ var cp = require('child_process'), - url = require('url'), _ = require('lodash'), when = require('when'), nodefn = require('when/node/function'), diff --git a/core/server/middleware/index.js b/core/server/middleware/index.js index c90a49af01..223c477c6f 100644 --- a/core/server/middleware/index.js +++ b/core/server/middleware/index.js @@ -10,7 +10,6 @@ var api = require('../api'), fs = require('fs'), hbs = require('express-hbs'), middleware = require('./middleware'), - models = require('../models'), packageInfo = require('../../../package.json'), path = require('path'), slashes = require('connect-slashes'), diff --git a/core/server/models/permission.js b/core/server/models/permission.js index f84f5be610..2357f44112 100644 --- a/core/server/models/permission.js +++ b/core/server/models/permission.js @@ -1,7 +1,6 @@ var ghostBookshelf = require('./base'), User = require('./user').User, Role = require('./role').Role, - validation = require('../data/validation'), Permission, Permissions; @@ -26,4 +25,4 @@ Permissions = ghostBookshelf.Collection.extend({ module.exports = { Permission: Permission, Permissions: Permissions -}; \ No newline at end of file +}; diff --git a/core/server/models/post.js b/core/server/models/post.js index 2fb6c86c2e..5c6cab4e82 100644 --- a/core/server/models/post.js +++ b/core/server/models/post.js @@ -42,7 +42,7 @@ Post = ghostBookshelf.Model.extend({ }, saving: function (newPage, attr, options) { - /*jslint unparam:true*/ + /*jshint unused:false*/ var self = this; // keep tags for 'saved' event @@ -76,7 +76,7 @@ Post = ghostBookshelf.Model.extend({ }, creating: function (newPage, attr, options) { - /*jslint unparam:true*/ + /*jshint unused:false*/ // set any dynamic default properties if (!this.get('author_id')) { @@ -87,7 +87,7 @@ Post = ghostBookshelf.Model.extend({ }, updateTags: function (newPost, attr, options) { - /*jslint unparam:true*/ + /*jshint unused:false*/ var self = this; options = options || {}; diff --git a/core/server/models/session.js b/core/server/models/session.js index 298a021a0e..9b0cb60891 100644 --- a/core/server/models/session.js +++ b/core/server/models/session.js @@ -10,8 +10,8 @@ Session = ghostBookshelf.Model.extend({ }, { destroyAll: function (options) { options = options || {}; - return ghostBookshelf.Collection.forge([], {model: this}).fetch(). - then(function (collection) { + return ghostBookshelf.Collection.forge([], {model: this}).fetch() + .then(function (collection) { collection.invokeThen('destroy', options); }); } @@ -24,4 +24,4 @@ Sessions = ghostBookshelf.Collection.extend({ module.exports = { Session: Session, Sessions: Sessions -}; \ No newline at end of file +}; diff --git a/core/server/models/user.js b/core/server/models/user.js index 0405ae6f50..cf6c544d58 100644 --- a/core/server/models/user.js +++ b/core/server/models/user.js @@ -1,5 +1,4 @@ var _ = require('lodash'), - uuid = require('node-uuid'), when = require('when'), errors = require('../errorHandling'), nodefn = require('when/node/function'), @@ -112,7 +111,7 @@ User = ghostBookshelf.Model.extend({ // Add this user to the admin role (assumes admin = role_id: 1) return userData.roles().attach(1); }).then(function (addedUserRole) { - /*jslint unparam:true*/ + /*jshint unused:false*/ // Return the added user as expected return when.resolve(userData); diff --git a/core/server/storage/base.js b/core/server/storage/base.js index fb344d60cc..ac04c601b7 100644 --- a/core/server/storage/base.js +++ b/core/server/storage/base.js @@ -1,5 +1,4 @@ -var _ = require('lodash'), - moment = require('moment'), +var moment = require('moment'), path = require('path'), when = require('when'), baseStore; @@ -50,4 +49,4 @@ baseStore = { } }; -module.exports = baseStore; \ No newline at end of file +module.exports = baseStore; diff --git a/package.json b/package.json index c422c7f152..b4362fff59 100644 --- a/package.json +++ b/package.json @@ -66,12 +66,12 @@ "grunt-contrib-concat": "~0.3.0", "grunt-contrib-copy": "~0.4.1", "grunt-contrib-handlebars": "~0.6.0", + "grunt-contrib-jshint": "~0.8.0", "grunt-contrib-sass": "~0.5.0", "grunt-contrib-uglify": "~0.2.5", "grunt-contrib-watch": "~0.5.3", "grunt-express-server": "~0.4.11", "grunt-groc": "~0.4.0", - "grunt-jslint": "~1.1.1", "grunt-mocha-cli": "~1.4.0", "grunt-shell": "~0.6.1", "grunt-update-submodules": "~0.2.1",