2
1
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2023-12-13 21:00:40 +01:00

Remove unparam:true from jslint config in Gruntfile.js

issue #1365
- added /*jslint unparam:true*/ to functions where absolutely necessary
- added /*jslint unparam:true*/ to functions in which keeping parameter
  list added clarity to the underlying api, even when those parameters
  are not currently used
- removed unused parameters in a few places
This commit is contained in:
Ben Gladwell 2013-10-31 14:02:34 -04:00
parent 96538abd6f
commit 69d3a1460d
22 changed files with 77 additions and 15 deletions

View file

@ -141,8 +141,6 @@ var path = require('path'),
nomen: true,
// allow to do statements
todo: true,
// allow unused parameters
unparam: true,
// don't require use strict pragma
sloppy: true
},
@ -163,9 +161,7 @@ var path = require('path'),
// allow dangling underscores in var names
nomen: true,
// allow to do statements
todo: true,
// allow unused parameters
unparam: true
todo: true
},
files: {
src: 'core/client/**/*.js'
@ -538,6 +534,7 @@ var path = require('path'),
stdio: 'inherit'
}
}, function (error, result, code) {
/*jslint unparam:true*/
if (error) {
grunt.fail.fatal(result.stdout);
}
@ -666,6 +663,7 @@ var path = require('path'),
data.replace(
commitRegex,
function (wholeCommit, hash, author, email, date, message) {
/*jslint unparam:true*/
// The author name and commit message may have trailing space.
author = author.trim();
@ -776,6 +774,7 @@ var path = require('path'),
when.reduce(tags,
function (prev, tag, idx) {
/*jslint unparam:true*/
return when.promise(function (resolve) {
processTag(tag, function (releaseData) {
resolve(prev + '\n' + releaseData);

View file

@ -16,6 +16,7 @@
* @returns {boolean}
*/
$.expr[":"].containsExact = function (obj, index, meta, stack) {
/*jslint unparam:true*/
return (obj.textContent || obj.innerText || $(obj).text() || "") === meta[3];
};
@ -171,4 +172,4 @@
return (count === 1) ? base.join('') : base.concat('s').join('');
};
}());
}());

View file

@ -67,6 +67,7 @@
'X-CSRF-Token': $("meta[name='csrf-param']").attr('content')
},
add: function (e, data) {
/*jslint unparam:true*/
$dropzone.find('.js-fileupload').removeClass('right');
$dropzone.find('.js-url, button.centre').remove();
$progress.find('.js-upload-progress-bar').removeClass('fail');
@ -83,6 +84,7 @@
},
dropZone: settings.fileStorage ? $dropzone : null,
progressall: function (e, data) {
/*jslint unparam:true*/
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) {
@ -91,6 +93,7 @@
}
},
fail: function (e, data) {
/*jslint unparam:true*/
$dropzone.trigger("uploadfailure", [data.result]);
$dropzone.find('.js-upload-progress-bar').addClass('fail');
if (data.jqXHR.status === 413) {
@ -109,6 +112,7 @@
});
},
done: function (e, data) {
/*jslint unparam:true*/
self.complete(data.result);
}
});

View file

@ -8,7 +8,7 @@
type: 'action',
style: ["wide"],
animation: 'fade',
afterRender: function (id) {
afterRender: function () {
var filestorage = $('#' + this.options.model.id).data('filestorage');
this.$('.js-drop-zone').upload({fileStorage: filestorage});
},

View file

@ -207,6 +207,7 @@
},
url: Ghost.settings.apiRoot + '/notifications/' + $(self).find('.close').data('id')
}).done(function (result) {
/*jslint unparam:true*/
bbSelf.$el.slideUp(250, function () {
$(this).show().css({height: "auto"});
$(self).remove();
@ -239,6 +240,7 @@
},
url: Ghost.settings.apiRoot + '/notifications/' + $(self).data('id')
}).done(function (result) {
/*jslint unparam:true*/
var height = bbSelf.$('.js-notification').outerHeight(true),
$parent = $(self).parent();
bbSelf.$el.css({height: height});

View file

@ -10,6 +10,7 @@
// ----------
Ghost.Views.Blog = Ghost.View.extend({
initialize: function (options) {
/*jslint unparam:true*/
this.listenTo(this.collection, 'request', function () {
NProgress.start();
});
@ -32,7 +33,7 @@
'click .content-list-content' : 'scrollHandler'
},
initialize: function (options) {
initialize: function () {
this.$('.content-list-content').scrollClass({target: '.content-list', offset: 10});
this.listenTo(this.collection, 'remove', this.showNext);
this.listenTo(this.collection, 'add', this.renderPost);
@ -97,6 +98,7 @@
orderBy: ['updated_at', 'DESC']
}
}).then(function onSuccess(response) {
/*jslint unparam:true*/
self.render();
self.isLoading = false;
}, function onError(e) {
@ -197,7 +199,7 @@
'click .unfeatured' : 'toggleFeatured'
},
initialize: function (options) {
initialize: function () {
this.listenTo(Backbone, 'blog:activeItem', this.setActivePreview);
},
@ -224,7 +226,7 @@
model.save({
featured: featured
}, {
success : function (model, response, options) {
success : function () {
featuredEl.removeClass("featured unfeatured").addClass(featured ? "featured" : "unfeatured");
Ghost.notifications.addItem({
type: 'success',
@ -233,6 +235,7 @@
});
},
error : function (model, xhr) {
/*jslint unparam:true*/
Ghost.notifications.addItem({
type: 'error',
message: Ghost.Views.Utils.getRequestErrorMessage(xhr),

View file

@ -84,7 +84,7 @@
});
}
$(".tag-input").one("blur", function (e) {
$(".tag-input").one("blur", function () {
if (publishBar.hasClass("extended-tags") && !$(':hover').last().hasClass("tag")) {
publishBar.css("top", "auto").animate({"height": "40px"}, 300, "swing", function () {

View file

@ -650,6 +650,7 @@
var value = editor.getValue();
_.each(markerMgr.markers, function (marker, id) {
/*jslint unparam:true*/
value = value.replace(markerMgr.getMarkerRegexForId(id), '');
});
@ -664,6 +665,7 @@
// initialise
editor.on('change', function (cm, changeObj) {
/*jslint unparam:true*/
var linesChanged = _.range(changeObj.from.line, changeObj.from.line + changeObj.text.length);
_.each(linesChanged, function (ln) {

View file

@ -70,6 +70,7 @@
slug: newSlug
}, {
success : function (model, response, options) {
/*jslint unparam:true*/
// Repopulate slug in case it changed on the server (e.g. 'new-slug-2')
slugEl.value = model.get('slug');
Ghost.notifications.addItem({
@ -79,6 +80,7 @@
});
},
error : function (model, xhr) {
/*jslint unparam:true*/
Ghost.notifications.addItem({
type: 'error',
message: Ghost.Views.Utils.getRequestErrorMessage(xhr),
@ -131,6 +133,7 @@
published_at: newPubDateMoment.hour(12).toDate()
}, {
success : function (model, response, options) {
/*jslint unparam:true*/
pubDateEl.value = moment(model.get('published_at'), parseDateFormats).format(displayDateFormat);
Ghost.notifications.addItem({
type: 'success',
@ -139,6 +142,7 @@
});
},
error : function (model, xhr) {
/*jslint unparam:true*/
Ghost.notifications.addItem({
type: 'error',
message: Ghost.Views.Utils.getRequestErrorMessage(xhr),
@ -158,6 +162,7 @@
page: page
}, {
success : function (model, response, options) {
/*jslint unparam:true*/
pageEl.prop('checked', page);
Ghost.notifications.addItem({
type: 'success',
@ -166,6 +171,7 @@
});
},
error : function (model, xhr) {
/*jslint unparam:true*/
Ghost.notifications.addItem({
type: 'error',
message: Ghost.Views.Utils.getRequestErrorMessage(xhr),

View file

@ -116,6 +116,7 @@
});
},
saveSuccess: function (model, response, options) {
/*jslint unparam:true*/
Ghost.notifications.clearEverything();
// TODO: better messaging here?
Ghost.notifications.addItem({
@ -125,6 +126,7 @@
});
},
saveError: function (model, xhr) {
/*jslint unparam:true*/
Ghost.notifications.clearEverything();
Ghost.notifications.addItem({
type: 'error',

View file

@ -24,12 +24,14 @@ function writeConfigFile() {
// Copy config.example.js => config.js
read = fs.createReadStream(configexample);
read.on('error', function (err) {
/*jslint unparam:true*/
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(config);
write.on('error', function (err) {
/*jslint unparam:true*/
return errors.logError(new Error('Could not open config.js for write.'), appRoot, 'Please check your deployment for config.js or config.example.js.');
});

View file

@ -157,6 +157,7 @@ Ghost.prototype.init = function () {
self.dbHash = dbhash.attributes.value;
return dbhash.attributes.value;
}).otherwise(function (error) {
/*jslint unparam:true*/
// this is where all the "first run" functionality should go
var dbhash = uuid.v4();
return when(models.Settings.add({key: 'dbHash', value: dbhash, type: 'core'})).then(function () {

View file

@ -70,6 +70,7 @@ function redirectToDashboard(req, res, next) {
}
function redirectToSignup(req, res, next) {
/*jslint unparam:true*/
api.users.browse().then(function (users) {
if (users.length === 0) {
return res.redirect('/ghost/signup/');
@ -85,6 +86,7 @@ function redirectToSignup(req, res, next) {
// plus the local messages, as they have already been added at this point
// otherwise they'd appear one too many times
function cleanNotifications(req, res, next) {
/*jslint unparam:true*/
ghost.notifications = _.reject(ghost.notifications, function (notification) {
return notification.status === 'passive';
});
@ -141,6 +143,7 @@ function ghostLocals(req, res, next) {
// ### DisableCachedResult Middleware
// Disable any caching until it can be done properly
function disableCachedResult(req, res, next) {
/*jslint unparam:true*/
res.set({
'Cache-Control': 'no-cache, must-revalidate',
'Expires': 'Sat, 26 Jul 1997 05:00:00 GMT'
@ -165,6 +168,7 @@ function whenEnabled(setting, fn) {
// ### InitViews Middleware
// Initialise Theme or Admin Views
function initViews(req, res, next) {
/*jslint unparam:true*/
var hbsOptions;
if (!res.isAdmin) {
@ -189,7 +193,7 @@ function initViews(req, res, next) {
// ### Activate Theme
// Helper for manageAdminAndTheme
function activateTheme() {
var stackLocation = _.indexOf(server.stack, _.find(server.stack, function (stackItem, key) {
var stackLocation = _.indexOf(server.stack, _.find(server.stack, function (stackItem) {
return stackItem.route === '' && stackItem.handle.name === 'settingEnabled';
}));
@ -341,10 +345,12 @@ when(ghost.init()).then(function () {
// ### Admin routes
/* TODO: put these somewhere in admin */
server.get(/^\/logout\/?$/, function redirect(req, res) {
/*jslint unparam:true*/
res.redirect(301, '/signout/');
});
server.get(/^\/signout\/?$/, admin.logout);
server.get('/ghost/login/', function redirect(req, res) {
/*jslint unparam:true*/
res.redirect(301, '/ghost/signin/');
});
server.get('/ghost/signin/', redirectToSignup, redirectToDashboard, admin.login);
@ -365,9 +371,11 @@ when(ghost.init()).then(function () {
// redirect to /ghost and let that do the authentication to prevent redirects to /ghost//admin etc.
server.get(/^\/((ghost-admin|admin|wp-admin|dashboard|signin)\/?)/, function (req, res) {
/*jslint unparam:true*/
res.redirect('/ghost/');
});
server.get(/^\/(ghost$\/?)/, auth, function (req, res) {
/*jslint unparam:true*/
res.redirect('/ghost/');
});
server.get('/ghost/', redirectToSignup, auth, admin.index);
@ -455,6 +463,7 @@ when(ghost.init()).then(function () {
if (getSocket()) {
// Make sure the socket is gone before trying to create another
fs.unlink(getSocket(), function (err) {
/*jslint unparam:true*/
server.listen(
getSocket(),
startGhost

View file

@ -13,6 +13,7 @@ var Ghost = require('../../ghost'),
db = {
export: function (req, res) {
/*jslint unparam:true*/
return dataExport().then(function (exportedData) {
// Save the exported data to the file system for download
var fileName = path.resolve(__dirname + '/../../server/data/export/exported-' + (new Date().getTime()) + '.json');
@ -154,4 +155,4 @@ db = {
},
};
module.exports.db = db;
module.exports.db = db;

View file

@ -79,6 +79,7 @@ adminControllers = {
});
},
'login': function (req, res) {
/*jslint unparam:true*/
res.render('login', {
bodyClass: 'ghost-login',
hideNavbar: true,
@ -122,6 +123,7 @@ adminControllers = {
},
'signup': function (req, res) {
/*jslint unparam:true*/
res.render('signup', {
bodyClass: 'ghost-signup',
hideNavbar: true,
@ -152,6 +154,7 @@ adminControllers = {
},
'forgotten': function (req, res) {
/*jslint unparam:true*/
res.render('forgotten', {
bodyClass: 'ghost-forgotten',
hideNavbar: true,
@ -204,6 +207,7 @@ adminControllers = {
});
},
'index': function (req, res) {
/*jslint unparam:true*/
res.render('content', {
bodyClass: 'manage',
adminNav: setSelected(adminNavbar, 'content')
@ -223,6 +227,7 @@ adminControllers = {
}
},
'content': function (req, res) {
/*jslint unparam:true*/
res.render('content', {
bodyClass: 'manage',
adminNav: setSelected(adminNavbar, 'content')
@ -246,6 +251,7 @@ adminControllers = {
},
'debug': { /* ugly temporary stuff for managing the app before it's properly finished */
index: function (req, res) {
/*jslint unparam:true*/
res.render('debug', {
bodyClass: 'settings',
adminNav: setSelected(adminNavbar, 'settings')

View file

@ -128,11 +128,13 @@ frontendControllers = {
//set img src to absolute url
content = content.replace(/src=["|'|\s]?([\w\/\?\$\.\+\-;%:@&=,_]+)["|'|\s]?/gi, function (match, p1) {
/*jslint unparam:true*/
p1 = url.resolve(siteUrl, p1);
return "src='" + p1 + "' ";
});
//set a href to absolute url
content = content.replace(/href=["|'|\s]?([\w\/\?\$\.\+\-;%:@&=,_]+)["|'|\s]?/gi, function (match, p1) {
/*jslint unparam:true*/
p1 = url.resolve(siteUrl, p1);
return "href='" + p1 + "' ";
});

View file

@ -95,6 +95,7 @@ errors = {
},
logErrorWithRedirect: function (msg, context, help, redirectTo, req, res) {
/*jslint unparam:true*/
var self = this;
return function () {
@ -107,6 +108,7 @@ errors = {
},
renderErrorPage: function (code, err, req, res, next) {
/*jslint unparam:true*/
function parseStack(stack) {
if (!_.isString(stack)) {

View file

@ -66,6 +66,7 @@ coreHelpers.encode = function (context, str) {
// context.
//
coreHelpers.pageUrl = function (context, block) {
/*jslint unparam:true*/
return context === 1 ? '/' : ('/page/' + context + '/');
};
@ -101,6 +102,7 @@ coreHelpers.url = function (options) {
// if the author could not be determined.
//
coreHelpers.author = function (context, options) {
/*jslint unparam:true*/
return this.author ? this.author.name : '';
};
@ -196,6 +198,7 @@ coreHelpers.excerpt = function (options) {
//
// Returns the config value for fileStorage.
coreHelpers.fileStorage = function (context, options) {
/*jslint unparam:true*/
if (coreHelpers.ghost.config().hasOwnProperty('fileStorage')) {
return coreHelpers.ghost.config().fileStorage.toString();
}
@ -232,6 +235,7 @@ coreHelpers.ghostScriptTags = function () {
*/
coreHelpers.body_class = function (options) {
/*jslint unparam:true*/
var classes = [],
tags = this.post && this.post.tags ? this.post.tags : this.tags || [],
page = this.post && this.post.page ? this.post.page : this.page || false;
@ -259,6 +263,7 @@ coreHelpers.body_class = function (options) {
};
coreHelpers.post_class = function (options) {
/*jslint unparam:true*/
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,
@ -283,6 +288,7 @@ coreHelpers.post_class = function (options) {
};
coreHelpers.ghost_head = function (options) {
/*jslint unparam:true*/
var head = [],
majorMinor = /^(\d+\.)?(\d+)/,
trimmedVersion = this.version;
@ -299,6 +305,7 @@ coreHelpers.ghost_head = function (options) {
};
coreHelpers.ghost_foot = function (options) {
/*jslint unparam:true*/
var foot = [];
foot.push('<script src="/shared/vendor/jquery/jquery.js"></script>');
@ -309,6 +316,7 @@ coreHelpers.ghost_foot = function (options) {
};
coreHelpers.meta_title = function (options) {
/*jslint unparam:true*/
var title,
blog;
if (_.isString(this.path)) {
@ -327,6 +335,7 @@ coreHelpers.meta_title = function (options) {
};
coreHelpers.meta_description = function (options) {
/*jslint unparam:true*/
var description,
blog;
@ -366,6 +375,7 @@ coreHelpers.e = function (key, defaultString, options) {
};
coreHelpers.json = function (object, options) {
/*jslint unparam:true*/
return JSON.stringify(object);
};
@ -447,6 +457,7 @@ coreHelpers.paginationTemplate = null;
// `{{pagination}}`
// Outputs previous and next buttons, along with info about the current page
coreHelpers.pagination = function (options) {
/*jslint unparam:true*/
if (!_.isObject(this.pagination) || _.isFunction(this.pagination)) {
errors.logAndThrowError('pagination data is not an object or is a function');
return;

View file

@ -121,6 +121,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*/
// Return the added user as expected
return when.resolve(userData);
@ -157,6 +158,7 @@ User = ghostBookshelf.Model.extend({
return user;
}, errors.logAndThrowError);
}, function (error) {
/*jslint unparam:true*/
return when.reject(new Error('There is no user with that email address.'));
});
},
@ -211,6 +213,7 @@ User = ghostBookshelf.Model.extend({
user.save({password: hash});
return { user: user, newPassword: newPassword };
}, function (error) {
/*jslint unparam:true*/
return when.reject(new Error('There is no user by that email address. Check again.'));
});
},

View file

@ -17,6 +17,7 @@ function hasActionsMap() {
// Just need to find one key in the actionsMap
return _.any(exported.actionsMap, function (val, key) {
/*jslint unparam:true*/
return Object.hasOwnProperty(key);
});
}
@ -181,4 +182,4 @@ module.exports = exported = {
refresh: refresh,
canThis: canThis,
actionsMap: {}
};
};

View file

@ -16,6 +16,7 @@ GhostPlugin = function (ghost) {
* @parameter {Ghost} The current Ghost app instance
*/
GhostPlugin.prototype.install = function (ghost) {
/*jslint unparam:true*/
return;
};
@ -25,6 +26,7 @@ GhostPlugin.prototype.install = function (ghost) {
* @parameter {Ghost} The current Ghost app instance
*/
GhostPlugin.prototype.uninstall = function (ghost) {
/*jslint unparam:true*/
return;
};
@ -34,6 +36,7 @@ GhostPlugin.prototype.uninstall = function (ghost) {
* @parameter {Ghost} The current Ghost app instance
*/
GhostPlugin.prototype.activate = function (ghost) {
/*jslint unparam:true*/
return;
};
@ -43,6 +46,7 @@ GhostPlugin.prototype.activate = function (ghost) {
* @parameter {Ghost} The current Ghost app instance
*/
GhostPlugin.prototype.deactivate = function (ghost) {
/*jslint unparam:true*/
return;
};

View file

@ -41,6 +41,7 @@ var when = require('when'),
fpath = path.join(dir, file);
subtree[name] = filePromise;
fs.lstat(fpath, function (error, result) {
/*jslint unparam:true*/
if (result.isDirectory()) {
fileDeferred.resolve(readDir(fpath, options, depth + 1));
} else {
@ -64,4 +65,4 @@ var when = require('when'),
});
};
module.exports = readAll;
module.exports = readAll;