Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some JSHint fixes #458

Merged
merged 6 commits into from
Dec 2, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ var passport = require('passport');

var app = express();

var statusCodePage = require('./libs/templateHelpers').statusCodePage;
var modifySessions = require('./libs/modifySessions');

var settings = require('./models/settings.json');
Expand Down
6 changes: 1 addition & 5 deletions controllers/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ var userRoles = require('../models/userRoles.json');
var strategies = require('./strategies.json');
var loadPassport = require('../libs/passportLoader').loadPassport;
var strategyInstances = require('../libs/passportLoader').strategyInstances;
var scriptStorage = require('./scriptStorage');
var modelParser = require('../libs/modelParser');
var helpers = require('../libs/helpers');
var statusCodePage = require('../libs/templateHelpers').statusCodePage;
Expand Down Expand Up @@ -66,7 +65,6 @@ exports.userAdmin = function (aReq, aRes, aNext) {

// You can only see users with a role less than yours
User.find({ role: { $gt: thisUser.role } }, function (aErr, aUsers) { // TODO: STYLEGUIDE.md conformance needed here
var i = 0;
options.users = [];

aUsers.forEach(function (aUser) {
Expand Down Expand Up @@ -168,7 +166,6 @@ exports.adminUserUpdate = function (aReq, aRes, aNext) {

//
var options = {};
var tasks = [];

// Session
authedUser = options.authedUser = modelParser.parseUser(authedUser);
Expand All @@ -184,7 +181,7 @@ exports.adminUserUpdate = function (aReq, aRes, aNext) {

// User
var user = options.user = modelParser.parseUser(aUserData);
options.isYou = authedUser && user && authedUser._id == user._id;
options.isYou = authedUser && user && authedUser._id === user._id;

//---

Expand Down Expand Up @@ -428,7 +425,6 @@ exports.authAsUser = function (aReq, aRes, aNext) {

//
var options = {};
var tasks = [];

// Session
authedUser = options.authedUser = modelParser.parseUser(authedUser);
Expand Down
3 changes: 1 addition & 2 deletions controllers/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ var loadPassport = require('../libs/passportLoader').loadPassport;
var strategyInstances = require('../libs/passportLoader').strategyInstances;
var Strategy = require('../models/strategy.js').Strategy;
var User = require('../models/user').User;
var userRoles = require('../models/userRoles.json');
var verifyPassport = require('../libs/passportVerify').verify;
var cleanFilename = require('../libs/helpers').cleanFilename;
var addSession = require('../libs/modifySessions').add;
Expand Down Expand Up @@ -122,7 +121,7 @@ exports.callback = function (aReq, aRes, aNext) {
if (openIdStrategies[strategy]) {
strategyInstance._verify = function (aId, aDone) {
verifyPassport(aId, strategy, username, aReq.session.user, aDone);
}
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 here

} else {
strategyInstance._verify =
function (aToken, aRefreshOrSecretToken, aProfile, aDone) {
Expand Down
1 change: 0 additions & 1 deletion controllers/discussion.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,6 @@ exports.createComment = function (aReq, aRes, aNext) {
var topic = aReq.params.topic;
var user = aReq.session.user;
var content = aReq.body['comment-content'];
var commentId = aReq.body['comment-id']; // for editing

if (!user) { return aNext(); }

Expand Down
1 change: 0 additions & 1 deletion controllers/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ exports.list = function (aReq, aRes) {

var setupGroupSidePanel = function (aOptions) {
// Shortcuts
var group = aOptions.group;
var authedUser = aOptions.authedUser;

// Mod
Expand Down
4 changes: 2 additions & 2 deletions controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ exports.home = function (aReq, aRes) {
pageMetadata(options, ['Flagged Scripts', 'Moderation']);
}
}
};
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 here

function render() { aRes.render('pages/scriptListPage', options); }
function asyncComplete() { preRender(); render(); }
async.parallel(tasks, asyncComplete);
Expand Down Expand Up @@ -217,7 +217,7 @@ exports.register = function (aReq, aRes) {
var githubStrategy = _.findWhere(options.strategies, { strat: 'github' });
if (githubStrategy)
githubStrategy.selected = true;
};
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 here

function render() { aRes.render('pages/loginPage', options); }
function asyncComplete() { preRender(); render(); }
async.parallel(tasks, asyncComplete);
Expand Down
12 changes: 6 additions & 6 deletions controllers/issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ exports.list = function (aReq, aRes, aNext) {

// Script
var script = options.script = modelParser.parseScript(scriptData);
options.isOwner = authedUser && authedUser._id == script._authorId;
options.isOwner = authedUser && authedUser._id === script._authorId;

// Category
var category = {};
Expand Down Expand Up @@ -167,7 +167,7 @@ exports.view = function (aReq, aRes, aNext) {

// Script
var script = options.script = modelParser.parseScript(aScriptData);
options.isOwner = authedUser && authedUser._id == script._authorId;
options.isOwner = authedUser && authedUser._id === script._authorId;

// Category
var category = {};
Expand All @@ -185,8 +185,8 @@ exports.view = function (aReq, aRes, aNext) {
// Discussion
var discussion = options.discussion = modelParser.parseDiscussion(aDiscussionData);
modelParser.parseIssue(discussion);
options.canClose = authedUser && (authedUser._id == script._authorId || authedUser._id == discussion._authorId);
options.canOpen = authedUser && authedUser._id == script._authorId;
options.canClose = authedUser && (authedUser._id === script._authorId || authedUser._id === discussion._authorId);
options.canOpen = authedUser && authedUser._id === script._authorId;

// commentListQuery
var commentListQuery = Comment.find();
Expand Down Expand Up @@ -255,7 +255,7 @@ exports.open = function (aReq, aRes, aNext) {
function preRender() {
// Page metadata
pageMetadata(options, ['New Issue', script.name]);
};
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 here

function render() { aRes.render('pages/scriptNewIssuePage', options); }
function asyncComplete() { preRender(); render(); }

Expand All @@ -273,7 +273,7 @@ exports.open = function (aReq, aRes, aNext) {

// Script
var script = options.script = modelParser.parseScript(aScriptData);
options.isOwner = authedUser && authedUser._id == script._authorId;
options.isOwner = authedUser && authedUser._id === script._authorId;

// Category
var category = {};
Expand Down
1 change: 0 additions & 1 deletion controllers/moderation.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ exports.removedItemPage = function (aReq, aRes, aNext) {

//
var options = {};
var tasks = [];

// Session
authedUser = options.authedUser = modelParser.parseUser(authedUser);
Expand Down
15 changes: 3 additions & 12 deletions controllers/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ var isDev = require('../libs/debug').isDev;
var isDbg = require('../libs/debug').isDbg;

//
var fs = require('fs');
var formidable = require('formidable');
var async = require('async');
var _ = require('underscore');
var sanitizeHtml = require('sanitize-html');
Expand Down Expand Up @@ -266,7 +264,6 @@ var getScriptPageTasks = function (aOptions) {

var setupScriptSidePanel = function (aOptions) {
// Shortcuts
var script = aOptions.script;
var authedUser = aOptions.authedUser;

// User
Expand All @@ -292,8 +289,6 @@ exports.view = function (aReq, aRes, aNext) {
var authedUser = aReq.session.user;

var installNameSlug = scriptStorage.getInstallName(aReq);
var scriptAuthor = aReq.params.username;
var scriptNameSlug = aReq.params.scriptname;
var isLib = aReq.params.isLib;

Script.findOne({
Expand Down Expand Up @@ -322,7 +317,7 @@ exports.view = function (aReq, aRes, aNext) {

// Script
var script = options.script = modelParser.parseScript(aScriptData);
options.isOwner = authedUser && authedUser._id == script._authorId;
options.isOwner = authedUser && authedUser._id === script._authorId;
modelParser.renderScript(script);
script.installNameSlug = installNameSlug;
script.scriptPermalinkInstallPageUrl = 'http://' + aReq.get('host') + script.scriptInstallPageUrl;
Expand Down Expand Up @@ -357,8 +352,6 @@ exports.edit = function (aReq, aRes, aNext) {
aReq.params.username = authedUser.name.toLowerCase();

var installNameSlug = scriptStorage.getInstallName(aReq);
var scriptAuthor = aReq.params.username;
var scriptNameSlug = aReq.params.scriptname;
var isLib = aReq.params.isLib;

Script.findOne({
Expand Down Expand Up @@ -389,7 +382,7 @@ exports.edit = function (aReq, aRes, aNext) {

// Page metadata
var script = options.script = modelParser.parseScript(aScriptData);
options.isOwner = authedUser && authedUser._id == script._authorId;
options.isOwner = authedUser && authedUser._id === script._authorId;
pageMetadata(options, ['Edit', script.name, (script.isLib ? 'Libraries' : 'Scripts')],
script.name);

Expand All @@ -400,8 +393,6 @@ exports.edit = function (aReq, aRes, aNext) {
options.searchBarPlaceholder = modelQuery.scriptListQueryDefaults.searchBarPlaceholder;
options.searchBarFormAction = modelQuery.scriptListQueryDefaults.searchBarFormAction;

var baseUrl = script && script.isLib ? '/libs/' : '/scripts/';

if (aReq.body.remove) {
// POST
scriptStorage.deleteScript(aScriptData.installName, function () {
Expand Down Expand Up @@ -486,7 +477,7 @@ exports.vote = function (aReq, aRes, aNext) {
if (!aScript.rating) { aScript.rating = 0; }
if (!aScript.votes) { aScript.votes = 0; }

if (user._id == aScript._authorId || (!aVoteModel && unvote)) {
if (user._id === aScript._authorId || (!aVoteModel && unvote)) {
return aRes.redirect(url);
} else if (!aVoteModel) {
aVoteModel = new Vote({
Expand Down
8 changes: 3 additions & 5 deletions controllers/scriptStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ exports.getSource = function (aReq, aCallback) {

exports.sendScript = function (aReq, aRes, aNext) {
var accept = aReq.headers.accept;
var installName = null;

if (0 !== aReq.url.indexOf('/libs/') && accept === 'text/x-userscript-meta') {
return exports.sendMeta(aReq, aRes, aNext);
Expand Down Expand Up @@ -234,7 +233,6 @@ exports.getMeta = function (aChunks, aCallback) {
// get the user script header.
var str = '';
var i = 0;
var len = aChunks.length;
var header = null;

for (; i < aChunks.length; ++i) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just as a FYI I see an incomplete optimization from someone here which is why JSHint plucked line 237 out.

Expand Down Expand Up @@ -270,7 +268,7 @@ exports.storeScript = function (aUser, aMeta, aBuf, aCallback, aUpdate) {
if (!scriptName) { return aCallback(null); }

if (!isLibrary && aMeta.oujs && aMeta.oujs.author
&& aMeta.oujs.author != aUser.name && aMeta.oujs.collaborator) {
&& aMeta.oujs.author !== aUser.name && aMeta.oujs.collaborator) {
collaborators = aMeta.oujs.collaborator;
if ((typeof collaborators === 'string'
&& collaborators === aUser.name)
Expand Down Expand Up @@ -329,8 +327,8 @@ exports.storeScript = function (aUser, aMeta, aBuf, aCallback, aUpdate) {
} else {
// Script already exists.
if (!aScript.isLib) {
if (collaborators && (aScript.meta.oujs && aScript.meta.oujs.author != aMeta.oujs.author
|| (aScript.meta.oujs && JSON.stringify(aScript.meta.oujs.collaborator) !=
if (collaborators && (aScript.meta.oujs && aScript.meta.oujs.author !== aMeta.oujs.author
|| (aScript.meta.oujs && JSON.stringify(aScript.meta.oujs.collaborator) !==
JSON.stringify(aMeta.oujs.collaborator)))) {
return aCallback(null);
}
Expand Down
Loading