Replace JSLint with JSHint.

closes #2277
- Added ES6 linting to core/client/
- Fix typeof array comparison
This commit is contained in:
Fabian Becker 2014-02-27 02:44:09 +00:00
parent c4bf3052e1
commit 1a9e91f120
40 changed files with 177 additions and 127 deletions

View File

@ -113,21 +113,39 @@ var path = require('path'),
} }
}, },
// ### Config for grunt-jslint // ### Config for grunt-contrib-jshint
// JSLint all the things! // JSHint all the things!
jslint: { jshint: {
server: { server: {
directives: { options: {
// node environment // node environment
node: true, node: true,
// browser environment // browser environment
browser: false, browser: false,
// allow dangling underscores in var names // allow dangling underscores in var names
nomen: true, nomen: false,
// allow to do statements
todo: true,
// don't require use strict pragma // 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: { files: {
src: [ src: [
@ -138,47 +156,88 @@ var path = require('path'),
} }
}, },
client: { client: {
directives: { options: {
"predef": {
"document": true,
"window": true,
"location": true,
"setTimeout": true,
"Ember": true,
"Em": true,
"DS": true,
"$": true
},
// node environment // node environment
node: false, node: false,
// browser environment // browser environment
browser: true, browser: true,
// allow dangling underscores in var names // allow dangling underscores in var names
nomen: true, nomen: false,
// allow to do statements bitwise: true,
todo: 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: { files: {
src: 'core/client/**/*.js' src: [
}, 'core/client/**/*.js',
exclude: [ // Ignore files
'core/client/assets/vendor/**/*.js', '!core/client/assets/vendor/**/*.js',
'core/client/tpl/**/*.js' '!core/client/tpl/**/*.js'
] ]
}
}, },
shared: { shared: {
directives: { options: {
// node environment // node environment
node: true, node: true,
// browser environment // browser environment
browser: false, 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 // 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: { files: {
src: [ 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' stdio: 'inherit'
} }
}, function (error, result, code) { }, function (error, result, code) {
/*jslint unparam:true*/ /*jshint unused:false*/
if (error) { if (error) {
grunt.fail.fatal(result.stdout); grunt.fail.fatal(result.stdout);
} }
@ -649,7 +708,7 @@ var path = require('path'),
data.replace( data.replace(
commitRegex, commitRegex,
function (wholeCommit, hash, author, email, date, message) { function (wholeCommit, hash, author, email, date, message) {
/*jslint unparam:true*/ /*jshint unused:false*/
// The author name and commit message may have trailing space. // The author name and commit message may have trailing space.
author = author.trim(); author = author.trim();
@ -760,7 +819,7 @@ var path = require('path'),
when.reduce(tags, when.reduce(tags,
function (prev, tag, idx) { function (prev, tag, idx) {
/*jslint unparam:true*/ /*jshint unused:false*/
return when.promise(function (resolve) { return when.promise(function (resolve) {
processTag(tag, function (releaseData) { processTag(tag, function (releaseData) {
resolve(prev + '\n' + 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('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 // ### Coverage report for Unit and Integration Tests

5
core/bootstrap.js vendored
View File

@ -7,7 +7,6 @@
var fs = require('fs'), var fs = require('fs'),
url = require('url'), url = require('url'),
when = require('when'), when = require('when'),
path = require('path'),
errors = require('./server/errorHandling'), errors = require('./server/errorHandling'),
config = require('./server/config'), config = require('./server/config'),
@ -36,14 +35,14 @@ function writeConfigFile() {
// Copy config.example.js => config.js // Copy config.example.js => config.js
read = fs.createReadStream(configExample); read = fs.createReadStream(configExample);
read.on('error', function (err) { 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.'); 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); read.on('end', written.resolve);
write = fs.createWriteStream(configFile); write = fs.createWriteStream(configFile);
write.on('error', function (err) { 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.'); 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

@ -16,7 +16,7 @@
* @returns {boolean} * @returns {boolean}
*/ */
$.expr[":"].containsExact = function (obj, index, meta, stack) { $.expr[":"].containsExact = function (obj, index, meta, stack) {
/*jslint unparam:true*/ /*jshint unused:false*/
return (obj.textContent || obj.innerText || $(obj).text() || "") === meta[3]; return (obj.textContent || obj.innerText || $(obj).text() || "") === meta[3];
}; };

View File

@ -1,4 +1,4 @@
/*global jQuery, Ghost, document, Image, window */ /*global jQuery, Ghost */
(function ($) { (function ($) {
"use strict"; "use strict";
@ -68,7 +68,7 @@
'X-CSRF-Token': $("meta[name='csrf-param']").attr('content') 'X-CSRF-Token': $("meta[name='csrf-param']").attr('content')
}, },
add: function (e, data) { add: function (e, data) {
/*jslint unparam:true*/ /*jshint unused:false*/
$('.js-button-accept').prop('disabled', true); $('.js-button-accept').prop('disabled', true);
$dropzone.find('.js-fileupload').removeClass('right'); $dropzone.find('.js-fileupload').removeClass('right');
$dropzone.find('.js-url').remove(); $dropzone.find('.js-url').remove();
@ -86,7 +86,7 @@
}, },
dropZone: settings.fileStorage ? $dropzone : null, dropZone: settings.fileStorage ? $dropzone : null,
progressall: function (e, data) { progressall: function (e, data) {
/*jslint unparam:true*/ /*jshint unused:false*/
var progress = parseInt(data.loaded / data.total * 100, 10); var progress = parseInt(data.loaded / data.total * 100, 10);
if (!settings.editor) {$progress.find('div.js-progress').css({"position": "absolute", "top": "40px"}); } if (!settings.editor) {$progress.find('div.js-progress').css({"position": "absolute", "top": "40px"}); }
if (settings.progressbar) { if (settings.progressbar) {
@ -95,7 +95,7 @@
} }
}, },
fail: function (e, data) { fail: function (e, data) {
/*jslint unparam:true*/ /*jshint unused:false*/
$('.js-button-accept').prop('disabled', false); $('.js-button-accept').prop('disabled', false);
$dropzone.trigger("uploadfailure", [data.result]); $dropzone.trigger("uploadfailure", [data.result]);
$dropzone.find('.js-upload-progress-bar').addClass('fail'); $dropzone.find('.js-upload-progress-bar').addClass('fail');
@ -115,7 +115,7 @@
}); });
}, },
done: function (e, data) { done: function (e, data) {
/*jslint unparam:true*/ /*jshint unused:false*/
self.complete(data.result); self.complete(data.result);
} }
}); });

View File

@ -1,6 +1,6 @@
// # Surrounds given text with Markdown syntax // # Surrounds given text with Markdown syntax
/*global $, window, CodeMirror, Showdown, moment */ /*global $, CodeMirror, Showdown, moment */
(function () { (function () {
'use strict'; 'use strict';
var Markdown = { var Markdown = {

View File

@ -1,4 +1,4 @@
/*global window, document, setTimeout, Ghost, $, _, Backbone, JST, shortcut, NProgress */ /*global Ghost, _, Backbone, NProgress */
(function () { (function () {
"use strict"; "use strict";
@ -10,8 +10,10 @@
if (options !== undefined && _.isObject(options)) { if (options !== undefined && _.isObject(options)) {
NProgress.start(); NProgress.start();
/*jshint validthis:true */
var self = this, var self = this,
oldSuccess = options.success; oldSuccess = options.success;
/*jshint validthis:false */
options.success = function () { options.success = function () {
NProgress.done(); NProgress.done();
@ -19,6 +21,7 @@
}; };
} }
/*jshint validthis:true */
return Backbone.sync.call(this, method, model, options); return Backbone.sync.call(this, method, model, options);
} }
@ -29,4 +32,4 @@
Ghost.ProgressCollection = Backbone.Collection.extend({ Ghost.ProgressCollection = Backbone.Collection.extend({
sync: wrapSync sync: wrapSync
}); });
}()); }());

View File

@ -1,4 +1,4 @@
/*global window, document, Ghost, $, _, Backbone */ /*global Ghost, _, Backbone */
(function () { (function () {
'use strict'; 'use strict';

View File

@ -1,4 +1,4 @@
/*global window, document, Ghost, $, _, Backbone */ /*global Ghost */
(function () { (function () {
'use strict'; 'use strict';
//id:0 is used to issue PUT requests //id:0 is used to issue PUT requests

View File

@ -1,4 +1,4 @@
/*global window, document, Ghost, $, _, Backbone */ /*global Ghost */
(function () { (function () {
'use strict'; 'use strict';

View File

@ -1,4 +1,4 @@
/*global window, document, Ghost, $, _, Backbone */ /*global Ghost, Backbone */
(function () { (function () {
'use strict'; 'use strict';

View File

@ -1,4 +1,4 @@
/*global window, document, Ghost, $, _, Backbone */ /*global Ghost */
(function () { (function () {
'use strict'; 'use strict';

View File

@ -1,4 +1,4 @@
/*global window, document, Ghost, $, _, Backbone */ /*global Ghost */
(function () { (function () {
'use strict'; 'use strict';

View File

@ -1,4 +1,4 @@
/*global window, document, Ghost, Backbone, $, _, NProgress */ /*global Ghost, Backbone, NProgress */
(function () { (function () {
"use strict"; "use strict";

View File

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

View File

@ -1,4 +1,4 @@
/*global window, document, Ghost, $, _, Backbone, JST, NProgress */ /*global window, Ghost, $, _, Backbone, NProgress */
(function () { (function () {
"use strict"; "use strict";
@ -10,7 +10,7 @@
// ---------- // ----------
Ghost.Views.Blog = Ghost.View.extend({ Ghost.Views.Blog = Ghost.View.extend({
initialize: function (options) { initialize: function (options) {
/*jslint unparam:true*/ /*jshint unused:false*/
var self = this, var self = this,
finishProgress = function () { finishProgress = function () {
NProgress.done(); NProgress.done();
@ -108,7 +108,7 @@
staticPages: 'all' staticPages: 'all'
} }
}).then(function onSuccess(response) { }).then(function onSuccess(response) {
/*jslint unparam:true*/ /*jshint unused:false*/
self.render(); self.render();
self.isLoading = false; self.isLoading = false;
}, function onError(e) { }, function onError(e) {
@ -245,7 +245,7 @@
}); });
}, },
error : function (model, xhr) { error : function (model, xhr) {
/*jslint unparam:true*/ /*jshint unused:false*/
Ghost.notifications.addItem({ Ghost.notifications.addItem({
type: 'error', type: 'error',
message: Ghost.Views.Utils.getRequestErrorMessage(xhr), message: Ghost.Views.Utils.getRequestErrorMessage(xhr),

View File

@ -1,4 +1,4 @@
/*global window, document, Ghost, $, _, Backbone, JST */ /*global Ghost, $ */
(function () { (function () {
"use strict"; "use strict";
@ -25,7 +25,7 @@
}, },
dataType: 'json', dataType: 'json',
add: function (e, data) { add: function (e, data) {
/*jslint unparam:true*/ /*jshint unused:false*/
// Bind the upload data to the view, so it is // Bind the upload data to the view, so it is
// available to the click handler, and enable the // available to the click handler, and enable the
@ -34,7 +34,7 @@
data.context = view.uploadButton.removeProp('disabled'); data.context = view.uploadButton.removeProp('disabled');
}, },
done: function (e, data) { done: function (e, data) {
/*jslint unparam:true*/ /*jshint unused:false*/
$('#startupload').text('Import'); $('#startupload').text('Import');
if (!data.result) { if (!data.result) {
throw new Error('No response received from server.'); throw new Error('No response received from server.');

View File

@ -1,6 +1,6 @@
// The Tag UI area associated with a post // The Tag UI area associated with a post
/*global window, document, setTimeout, $, _, Backbone, Ghost */ /*global window, document, setTimeout, $, _, Ghost */
(function () { (function () {
"use strict"; "use strict";

View File

@ -1,6 +1,6 @@
// # Article Editor // # 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 () { (function () {
"use strict"; "use strict";
@ -78,7 +78,7 @@
}, },
//TODO: This has to be moved to the I18n localization file. //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: { messageMap: {
errors: { errors: {
post: { post: {
@ -704,7 +704,7 @@
var value = editor.getValue(); var value = editor.getValue();
_.each(markerMgr.markers, function (marker, id) { _.each(markerMgr.markers, function (marker, id) {
/*jslint unparam:true*/ /*jshint unused:false*/
value = value.replace(markerMgr.getMarkerRegexForId(id), ''); value = value.replace(markerMgr.getMarkerRegexForId(id), '');
}); });
@ -720,7 +720,7 @@
// initialise // initialise
editor.on('change', function (cm, changeObj) { editor.on('change', function (cm, changeObj) {
/*jslint unparam:true*/ /*jshint unused:false*/
var linesChanged = _.range(changeObj.from.line, changeObj.from.line + changeObj.text.length); var linesChanged = _.range(changeObj.from.line, changeObj.from.line + changeObj.text.length);
_.each(linesChanged, function (ln) { _.each(linesChanged, function (ln) {

View File

@ -1,4 +1,4 @@
/*global window, document, Ghost, $, _, Backbone, JST */ /*global window, Ghost, $ */
(function () { (function () {
"use strict"; "use strict";

View File

@ -1,6 +1,6 @@
// The Post Settings Menu available in the content preview screen, as well as the post editor. // 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 () { (function () {
"use strict"; "use strict";
@ -124,7 +124,7 @@
slug: newSlug slug: newSlug
}, { }, {
success : function (model, response, options) { 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') // Repopulate slug in case it changed on the server (e.g. 'new-slug-2')
slugEl.value = model.get('slug'); slugEl.value = model.get('slug');
Ghost.notifications.addItem({ Ghost.notifications.addItem({
@ -134,7 +134,7 @@
}); });
}, },
error : function (model, xhr) { error : function (model, xhr) {
/*jslint unparam:true*/ /*jshint unused:false*/
slugEl.value = model.previous('slug'); slugEl.value = model.previous('slug');
Ghost.notifications.addItem({ Ghost.notifications.addItem({
type: 'error', type: 'error',
@ -244,7 +244,7 @@
}); });
}, },
error : function (model, xhr) { error : function (model, xhr) {
/*jslint unparam:true*/ /*jshint unused:false*/
// Reset back to original value // Reset back to original value
pubDateEl.value = pubDateMoment ? pubDateMoment.format(displayDateFormat) : ''; pubDateEl.value = pubDateMoment ? pubDateMoment.format(displayDateFormat) : '';
Ghost.notifications.addItem({ Ghost.notifications.addItem({
@ -275,7 +275,7 @@
page: page page: page
}, { }, {
success : function (model, response, options) { success : function (model, response, options) {
/*jslint unparam:true*/ /*jshint unused:false*/
pageEl.prop('checked', page); pageEl.prop('checked', page);
Ghost.notifications.addItem({ Ghost.notifications.addItem({
type: 'success', type: 'success',
@ -284,7 +284,7 @@
}); });
}, },
error : function (model, xhr) { error : function (model, xhr) {
/*jslint unparam:true*/ /*jshint unused:false*/
pageEl.prop('checked', model.previous('page')); pageEl.prop('checked', model.previous('page'));
Ghost.notifications.addItem({ Ghost.notifications.addItem({
type: 'error', type: 'error',

View File

@ -1,4 +1,4 @@
/*global window, document, Ghost, $, _, Backbone, Countable */ /*global document, Ghost, $, _, Countable */
(function () { (function () {
"use strict"; "use strict";
@ -112,7 +112,7 @@
this.$el.addClass('active'); this.$el.addClass('active');
}, },
saveSuccess: function (model, response, options) { saveSuccess: function (model, response, options) {
/*jslint unparam:true*/ /*jshint unused:false*/
Ghost.notifications.clearEverything(); Ghost.notifications.clearEverything();
Ghost.notifications.addItem({ Ghost.notifications.addItem({
type: 'success', type: 'success',
@ -121,7 +121,7 @@
}); });
}, },
saveError: function (model, xhr) { saveError: function (model, xhr) {
/*jslint unparam:true*/ /*jshint unused:false*/
Ghost.notifications.clearEverything(); Ghost.notifications.clearEverything();
Ghost.notifications.addItem({ Ghost.notifications.addItem({
type: 'error', type: 'error',

View File

@ -2,12 +2,10 @@ var dataExport = require('../data/export'),
dataImport = require('../data/import'), dataImport = require('../data/import'),
dataProvider = require('../models'), dataProvider = require('../models'),
fs = require('fs-extra'), fs = require('fs-extra'),
path = require('path'),
when = require('when'), when = require('when'),
nodefn = require('when/node/function'), nodefn = require('when/node/function'),
_ = require('lodash'), _ = require('lodash'),
validation = require('../data/validation'), validation = require('../data/validation'),
config = require('../config'),
errors = require('../../server/errorHandling'), errors = require('../../server/errorHandling'),
api = {}, api = {},
db; db;

View File

@ -4,7 +4,6 @@
var _ = require('lodash'), var _ = require('lodash'),
when = require('when'), when = require('when'),
config = require('../config'), config = require('../config'),
errors = require('../errorHandling'),
db = require('./db'), db = require('./db'),
settings = require('./settings'), settings = require('./settings'),
notifications = require('./notifications'), notifications = require('./notifications'),

View File

@ -1,6 +1,5 @@
var fs = require('fs'), var path = require('path'),
path = require('path'),
Module = require('module'), Module = require('module'),
_ = require('lodash'); _ = require('lodash');
@ -88,4 +87,4 @@ AppSandbox.defaults = {
blacklist: ['knex', 'fs', 'http', 'sqlite3', 'pg', 'mysql', 'ghost'] blacklist: ['knex', 'fs', 'http', 'sqlite3', 'pg', 'mysql', 'ghost']
}; };
module.exports = AppSandbox; module.exports = AppSandbox;

View File

@ -100,7 +100,7 @@ function config() {
if (_.isEmpty(ghostConfig)) { if (_.isEmpty(ghostConfig)) {
try { try {
ghostConfig = require(path.resolve(__dirname, '../../../', 'config.js'))[process.env.NODE_ENV] || {}; ghostConfig = require(path.resolve(__dirname, '../../../', 'config.js'))[process.env.NODE_ENV] || {};
} catch (ignore) {/*jslint sloppy: true */} } catch (ignore) {/*jslint strict: true */}
ghostConfig = updateConfig(ghostConfig); ghostConfig = updateConfig(ghostConfig);
} }
@ -111,4 +111,4 @@ module.exports = config;
module.exports.init = initConfig; module.exports.init = initConfig;
module.exports.theme = theme; module.exports.theme = theme;
module.exports.urlFor = configUrl.urlFor; module.exports.urlFor = configUrl.urlFor;
module.exports.urlForPost = configUrl.urlForPost; module.exports.urlForPost = configUrl.urlForPost;

View File

@ -13,7 +13,6 @@ var moment = require('moment'),
api = require('../api'), api = require('../api'),
config = require('../config'), config = require('../config'),
errors = require('../errorHandling'),
filters = require('../../server/filters'), filters = require('../../server/filters'),
template = require('../helpers/template'), template = require('../helpers/template'),

View File

@ -3,8 +3,7 @@ var sequence = require('when/sequence'),
Post = require('../../models/post').Post, Post = require('../../models/post').Post,
Tag = require('../../models/tag').Tag, Tag = require('../../models/tag').Tag,
Role = require('../../models/role').Role, Role = require('../../models/role').Role,
Permission = require('../../models/permission').Permission, Permission = require('../../models/permission').Permission;
uuid = require('node-uuid');
var fixtures = { var fixtures = {
posts: [ posts: [
@ -102,4 +101,4 @@ module.exports = {
return sequence(ops); return sequence(ops);
} }
}; };

View File

@ -1,7 +1,6 @@
var when = require('when'), var when = require('when'),
_ = require('lodash'), _ = require('lodash'),
models = require('../../models'), models = require('../../models'),
errors = require('../../errorHandling'),
Importer000; Importer000;
@ -197,4 +196,4 @@ module.exports = {
importData: function (data) { importData: function (data) {
return new Importer000().importData(data); return new Importer000().importData(data);
} }
}; };

View File

@ -1,7 +1,6 @@
var schema = require('../schema').tables, var schema = require('../schema').tables,
_ = require('lodash'), _ = require('lodash'),
validator = require('validator'), validator = require('validator'),
when = require('when'),
validateSchema, validateSchema,
validateSettings, validateSettings,
@ -74,10 +73,11 @@ validate = function (value, key, validations) {
if (validationOptions === true) { if (validationOptions === true) {
validationOptions = null; validationOptions = null;
} }
/* jshint ignore:start */
if (typeof validationOptions !== 'array') { if (typeof validationOptions !== 'array') {
validationOptions = [validationOptions]; validationOptions = [validationOptions];
} }
/* jshint ignore:end */
// equivalent of validation.isSomething(option1, option2) // equivalent of validation.isSomething(option1, option2)
validation[validationName].apply(validation, validationOptions); validation[validationName].apply(validation, validationOptions);
}, this); }, this);
@ -86,4 +86,4 @@ validate = function (value, key, validations) {
module.exports = { module.exports = {
validateSchema: validateSchema, validateSchema: validateSchema,
validateSettings: validateSettings validateSettings: validateSettings
}; };

View File

@ -1,7 +1,6 @@
/*jslint regexp: true */ /*jslint regexp: true */
var _ = require('lodash'), var _ = require('lodash'),
colors = require('colors'), colors = require('colors'),
fs = require('fs'),
config = require('./config'), config = require('./config'),
path = require('path'), path = require('path'),
when = require('when'), when = require('when'),
@ -15,6 +14,9 @@ var _ = require('lodash'),
ONE_HOUR_S = 60 * 60; ONE_HOUR_S = 60 * 60;
// This is not useful but required for jshint
colors.setTheme({silly: 'rainbow'});
/** /**
* Basic error handling helpers * Basic error handling helpers
*/ */
@ -107,7 +109,7 @@ errors = {
}, },
logErrorWithRedirect: function (msg, context, help, redirectTo, req, res) { logErrorWithRedirect: function (msg, context, help, redirectTo, req, res) {
/*jslint unparam:true*/ /*jshint unused:false*/
var self = this; var self = this;
return function () { return function () {
@ -120,7 +122,7 @@ errors = {
}, },
renderErrorPage: function (code, err, req, res, next) { renderErrorPage: function (code, err, req, res, next) {
/*jslint unparam:true*/ /*jshint unused:false*/
var self = this; var self = this;

View File

@ -1,7 +1,6 @@
var downsize = require('downsize'), var downsize = require('downsize'),
hbs = require('express-hbs'), hbs = require('express-hbs'),
moment = require('moment'), moment = require('moment'),
path = require('path'),
polyglot = require('node-polyglot').instance, polyglot = require('node-polyglot').instance,
_ = require('lodash'), _ = require('lodash'),
when = require('when'), when = require('when'),
@ -96,7 +95,7 @@ coreHelpers.encode = function (context, str) {
// context. // context.
// //
coreHelpers.page_url = function (context, block) { coreHelpers.page_url = function (context, block) {
/*jslint unparam:true*/ /*jshint unused:false*/
var url = config().paths.subdir; var url = config().paths.subdir;
if (this.tagSlug !== undefined) { 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' + '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'); 'In your theme\'s pagination.hbs file, pageUrl should be renamed to page_url');
/*jslint unparam:true*/ /*jshint unused:false*/
var self = this; var self = this;
return coreHelpers.page_url.call(self, context, block); return coreHelpers.page_url.call(self, context, block);
@ -198,7 +197,7 @@ coreHelpers.asset = function (context, options) {
// if the author could not be determined. // if the author could not be determined.
// //
coreHelpers.author = function (context, options) { coreHelpers.author = function (context, options) {
/*jslint unparam:true*/ /*jshint unused:false*/
return this.author ? this.author.name : ''; return this.author ? this.author.name : '';
}; };
@ -320,7 +319,7 @@ coreHelpers.excerpt = function (options) {
// //
// Returns the config value for fileStorage. // Returns the config value for fileStorage.
coreHelpers.file_storage = function (context, options) { coreHelpers.file_storage = function (context, options) {
/*jslint unparam:true*/ /*jshint unused:false*/
if (config().hasOwnProperty('fileStorage')) { if (config().hasOwnProperty('fileStorage')) {
return config().fileStorage.toString(); return config().fileStorage.toString();
} }
@ -345,7 +344,7 @@ coreHelpers.ghost_script_tags = function () {
*/ */
coreHelpers.body_class = function (options) { coreHelpers.body_class = function (options) {
/*jslint unparam:true*/ /*jshint unused:false*/
var classes = [], var classes = [],
post = this.post, post = this.post,
tags = this.post && this.post.tags ? this.post.tags : this.tags || [], 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) { coreHelpers.post_class = function (options) {
/*jslint unparam:true*/ /*jshint unused:false*/
var classes = ['post'], var classes = ['post'],
tags = this.post && this.post.tags ? this.post.tags : this.tags || [], tags = this.post && this.post.tags ? this.post.tags : this.tags || [],
featured = this.post && this.post.featured ? this.post.featured : this.featured || false, 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) { coreHelpers.ghost_head = function (options) {
/*jslint unparam:true*/ /*jshint unused:false*/
var self = this, var self = this,
blog = config.theme(), blog = config.theme(),
head = [], head = [],
@ -441,7 +440,7 @@ coreHelpers.ghost_head = function (options) {
}; };
coreHelpers.ghost_foot = function (options) { coreHelpers.ghost_foot = function (options) {
/*jslint unparam:true*/ /*jshint unused:false*/
var foot = []; var foot = [];
foot.push(scriptTemplate({ foot.push(scriptTemplate({
@ -456,7 +455,7 @@ coreHelpers.ghost_foot = function (options) {
}; };
coreHelpers.meta_title = function (options) { coreHelpers.meta_title = function (options) {
/*jslint unparam:true*/ /*jshint unused:false*/
var title = "", var title = "",
blog; blog;
@ -478,7 +477,7 @@ coreHelpers.meta_title = function (options) {
}; };
coreHelpers.meta_description = function (options) { coreHelpers.meta_description = function (options) {
/*jslint unparam:true*/ /*jshint unused:false*/
var description, var description,
blog; blog;
@ -627,7 +626,7 @@ coreHelpers.has = function (options) {
// `{{pagination}}` // `{{pagination}}`
// Outputs previous and next buttons, along with info about the current page // Outputs previous and next buttons, along with info about the current page
coreHelpers.pagination = function (options) { coreHelpers.pagination = function (options) {
/*jslint unparam:true*/ /*jshint unused:false*/
if (!_.isObject(this.pagination) || _.isFunction(this.pagination)) { if (!_.isObject(this.pagination) || _.isFunction(this.pagination)) {
errors.logAndThrowError('pagination data is not an object or is a function'); errors.logAndThrowError('pagination data is not an object or is a function');
return; return;

View File

@ -247,7 +247,7 @@ function setup(server) {
if (getSocket()) { if (getSocket()) {
// Make sure the socket is gone before trying to create another // Make sure the socket is gone before trying to create another
fs.unlink(getSocket(), function (err) { fs.unlink(getSocket(), function (err) {
/*jslint unparam:true*/ /*jshint unused:false*/
server.listen( server.listen(
getSocket(), getSocket(),
startGhost startGhost

View File

@ -1,5 +1,4 @@
var cp = require('child_process'), var cp = require('child_process'),
url = require('url'),
_ = require('lodash'), _ = require('lodash'),
when = require('when'), when = require('when'),
nodefn = require('when/node/function'), nodefn = require('when/node/function'),

View File

@ -10,7 +10,6 @@ var api = require('../api'),
fs = require('fs'), fs = require('fs'),
hbs = require('express-hbs'), hbs = require('express-hbs'),
middleware = require('./middleware'), middleware = require('./middleware'),
models = require('../models'),
packageInfo = require('../../../package.json'), packageInfo = require('../../../package.json'),
path = require('path'), path = require('path'),
slashes = require('connect-slashes'), slashes = require('connect-slashes'),

View File

@ -1,7 +1,6 @@
var ghostBookshelf = require('./base'), var ghostBookshelf = require('./base'),
User = require('./user').User, User = require('./user').User,
Role = require('./role').Role, Role = require('./role').Role,
validation = require('../data/validation'),
Permission, Permission,
Permissions; Permissions;
@ -26,4 +25,4 @@ Permissions = ghostBookshelf.Collection.extend({
module.exports = { module.exports = {
Permission: Permission, Permission: Permission,
Permissions: Permissions Permissions: Permissions
}; };

View File

@ -42,7 +42,7 @@ Post = ghostBookshelf.Model.extend({
}, },
saving: function (newPage, attr, options) { saving: function (newPage, attr, options) {
/*jslint unparam:true*/ /*jshint unused:false*/
var self = this; var self = this;
// keep tags for 'saved' event // keep tags for 'saved' event
@ -76,7 +76,7 @@ Post = ghostBookshelf.Model.extend({
}, },
creating: function (newPage, attr, options) { creating: function (newPage, attr, options) {
/*jslint unparam:true*/ /*jshint unused:false*/
// set any dynamic default properties // set any dynamic default properties
if (!this.get('author_id')) { if (!this.get('author_id')) {
@ -87,7 +87,7 @@ Post = ghostBookshelf.Model.extend({
}, },
updateTags: function (newPost, attr, options) { updateTags: function (newPost, attr, options) {
/*jslint unparam:true*/ /*jshint unused:false*/
var self = this; var self = this;
options = options || {}; options = options || {};

View File

@ -10,8 +10,8 @@ Session = ghostBookshelf.Model.extend({
}, { }, {
destroyAll: function (options) { destroyAll: function (options) {
options = options || {}; options = options || {};
return ghostBookshelf.Collection.forge([], {model: this}).fetch(). return ghostBookshelf.Collection.forge([], {model: this}).fetch()
then(function (collection) { .then(function (collection) {
collection.invokeThen('destroy', options); collection.invokeThen('destroy', options);
}); });
} }
@ -24,4 +24,4 @@ Sessions = ghostBookshelf.Collection.extend({
module.exports = { module.exports = {
Session: Session, Session: Session,
Sessions: Sessions Sessions: Sessions
}; };

View File

@ -1,5 +1,4 @@
var _ = require('lodash'), var _ = require('lodash'),
uuid = require('node-uuid'),
when = require('when'), when = require('when'),
errors = require('../errorHandling'), errors = require('../errorHandling'),
nodefn = require('when/node/function'), 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) // Add this user to the admin role (assumes admin = role_id: 1)
return userData.roles().attach(1); return userData.roles().attach(1);
}).then(function (addedUserRole) { }).then(function (addedUserRole) {
/*jslint unparam:true*/ /*jshint unused:false*/
// Return the added user as expected // Return the added user as expected
return when.resolve(userData); return when.resolve(userData);

View File

@ -1,5 +1,4 @@
var _ = require('lodash'), var moment = require('moment'),
moment = require('moment'),
path = require('path'), path = require('path'),
when = require('when'), when = require('when'),
baseStore; baseStore;
@ -50,4 +49,4 @@ baseStore = {
} }
}; };
module.exports = baseStore; module.exports = baseStore;

View File

@ -66,12 +66,12 @@
"grunt-contrib-concat": "~0.3.0", "grunt-contrib-concat": "~0.3.0",
"grunt-contrib-copy": "~0.4.1", "grunt-contrib-copy": "~0.4.1",
"grunt-contrib-handlebars": "~0.6.0", "grunt-contrib-handlebars": "~0.6.0",
"grunt-contrib-jshint": "~0.8.0",
"grunt-contrib-sass": "~0.5.0", "grunt-contrib-sass": "~0.5.0",
"grunt-contrib-uglify": "~0.2.5", "grunt-contrib-uglify": "~0.2.5",
"grunt-contrib-watch": "~0.5.3", "grunt-contrib-watch": "~0.5.3",
"grunt-express-server": "~0.4.11", "grunt-express-server": "~0.4.11",
"grunt-groc": "~0.4.0", "grunt-groc": "~0.4.0",
"grunt-jslint": "~1.1.1",
"grunt-mocha-cli": "~1.4.0", "grunt-mocha-cli": "~1.4.0",
"grunt-shell": "~0.6.1", "grunt-shell": "~0.6.1",
"grunt-update-submodules": "~0.2.1", "grunt-update-submodules": "~0.2.1",