-
Notifications
You must be signed in to change notification settings - Fork 319
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
Some JSHint fixes #458
Changes from all commits
ba7c0c0
dfb3dfc
207e147
2e9779d
a9668ad
59a68a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -145,7 +145,7 @@ exports.home = function (aReq, aRes) { | |
pageMetadata(options, ['Flagged Scripts', 'Moderation']); | ||
} | ||
} | ||
}; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
|
@@ -217,7 +217,7 @@ exports.register = function (aReq, aRes) { | |
var githubStrategy = _.findWhere(options.strategies, { strat: 'github' }); | ||
if (githubStrategy) | ||
githubStrategy.selected = true; | ||
}; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -253,7 +253,7 @@ exports.open = function (aReq, aRes, aNext) { | |
function preRender() { | ||
// Page metadata | ||
pageMetadata(options, ['New Issue', script.name]); | ||
}; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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(); } | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
|
@@ -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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,6 @@ var _ = require('underscore'); | |
var util = require('util'); | ||
|
||
var Comment = require('../models/comment').Comment; | ||
var Flag = require('../models/flag').Flag; | ||
var Script = require('../models/script').Script; | ||
var Strategy = require('../models/strategy').Strategy; | ||
var User = require('../models/user').User; | ||
|
@@ -97,7 +96,6 @@ var getUserPageTasks = function (aOptions) { | |
|
||
// Shortcuts | ||
var user = aOptions.user; | ||
var authedUser = aOptions.authedUser; | ||
|
||
//--- Tasks | ||
|
||
|
@@ -218,7 +216,7 @@ exports.userListPage = function (aReq, aRes, aNext) { | |
} | ||
} | ||
function render() { aRes.render('pages/userListPage', options); } | ||
function asyncComplete(err) { if (err) { return aNext(); } else { preRender(); render(); } }; | ||
function asyncComplete(err) { if (err) { return aNext(); } else { preRender(); render(); } } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 here |
||
async.parallel(tasks, asyncComplete); | ||
}; | ||
|
||
|
@@ -263,9 +261,6 @@ exports.view = function (aReq, aRes, aNext) { | |
// scriptListQuery: Defaults | ||
modelQuery.applyScriptListQueryDefaults(scriptListQuery, options, aReq); | ||
|
||
// scriptListQuery: Pagination | ||
var pagination = options.pagination; // is set in modelQuery.apply___ListQueryDefaults | ||
|
||
//--- Tasks | ||
|
||
// UserPage tasks | ||
|
@@ -461,8 +456,6 @@ exports.userScriptListPage = function (aReq, aRes, aNext) { | |
exports.userEditProfilePage = function (aReq, aRes, aNext) { | ||
var authedUser = aReq.session.user; | ||
|
||
var username = aReq.params.username; | ||
|
||
User.findOne({ | ||
_id: authedUser._id | ||
}, function (aErr, aUserData) { | ||
|
@@ -858,7 +851,6 @@ exports.userGitHubImportScriptPage = function (aReq, aRes, aNext) { | |
|
||
// | ||
var options = {}; | ||
var tasks = []; | ||
|
||
// Session | ||
authedUser = options.authedUser = modelParser.parseUser(authedUser); | ||
|
@@ -1001,7 +993,7 @@ exports.userGitHubRepoPage = function (aReq, aRes, aNext) { | |
options.repo = aRepo; | ||
options.repoAsEncoded = { | ||
default_branch: encodeURI(options.repo.default_branch) | ||
} | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 here |
||
|
||
github.gitdata.getJavascriptBlobs({ | ||
user: encodeURIComponent(aRepo.owner.login), | ||
|
@@ -1025,7 +1017,7 @@ exports.userGitHubRepoPage = function (aReq, aRes, aNext) { | |
|
||
aCallback(null); | ||
}, | ||
], aCallback) | ||
], aCallback); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 here |
||
}); | ||
|
||
//--- | ||
|
@@ -1092,7 +1084,6 @@ exports.userManageGitHubPage = function (aReq, aRes, aNext) { | |
pageMetadata(options, ['Manage', 'GitHub']); | ||
|
||
// | ||
var TOO_MANY_SCRIPTS = 'GitHub user has too many scripts to batch import.'; | ||
tasks.push(function (aCallback) { | ||
var githubUserName = aReq.query.user || authedUser.ghUsername; | ||
|
||
|
@@ -1111,7 +1102,7 @@ exports.userManageGitHubPage = function (aReq, aRes, aNext) { | |
}, | ||
function (aGithubUser, aCallback) { | ||
options.githubUser = aGithubUser; | ||
console.log(githubUser); | ||
console.log(aGithubUser); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 here |
||
User.findOne({ | ||
_id: authedUser._id | ||
}, aCallback); | ||
|
@@ -1148,7 +1139,7 @@ exports.userManageGitHubPage = function (aReq, aRes, aNext) { | |
console.log(aReq.body); | ||
_.each(aReq.body, function (aRepo, aReponame) { | ||
// Load all scripts in the repo | ||
if (typeof aRepo === 'string' && reponame.substr(-4) === '_all') { | ||
if (typeof aRepo === 'string' && aReponame.substr(-4) === '_all') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be interesting to know how this works... I don't believe I've seen this but we've all come a long way since then. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Zren There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've never used this before too, but you can access that page at https://openuserjs.org/users/marti/github There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting and thanks Jerone... might be useful to have that listed at https://openuserjs.org/user/add/scripts so it's not an orphaned route. Since this is fixing this it might be useful to have an issue with this in it. e.g. #468 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No because the logic behind that route is awful. It can go through hundreds of github api requests (Edit: which times out if the user has a lot of repos with logs of files/folders) and doesn't list all repositories if the users list of repos is paginated. The route should be removed since I rewrote it to handle pagination and the like but sizzle wanted it left there. Rather than confusing abuser with 2 ways to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Import from github, I only linked to the less resource intensive method with pagination and left the old route unlinked to in case sizzle wanted to use it to import all scripts in a repo for testing. |
||
aReponame = aRepo; | ||
aRepo = aRepos[aReponame]; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,7 @@ var githubGitDataGetBlobAsUtf8 = function (aMsg, aCallback) { | |
}, | ||
function (aBlob, aCallback) { | ||
var content = aBlob.content; | ||
if (aBlob.encoding == 'base64') { | ||
if (aBlob.encoding === 'base64') { | ||
var buf = new Buffer(content, 'base64'); | ||
content = buf.toString('utf8'); | ||
} | ||
|
@@ -69,7 +69,7 @@ var githubUserContentGetBlobAsUtf8 = function (aMsg, aCallback) { | |
request.get(url, aCallback); | ||
}, | ||
function (aResponse, aBody, aCallback) { | ||
if (aResponse.statusCode != 200) | ||
if (aResponse.statusCode !== 200) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 here since it's not a string. |
||
return aCallback(util.format('Status Code %s', aResponse.statusCode)); | ||
|
||
aCallback(null, aBody); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,6 @@ var Script = require('../models/script').Script; | |
|
||
var userRoles = require('../models/userRoles.json'); | ||
var renderMd = require('../libs/markdown').renderMd; | ||
var helpers = require('../libs/helpers'); | ||
var getRating = require('../libs/collectiveRating').getRating; | ||
var cleanFilename = require('../libs/helpers').cleanFilename; | ||
|
||
|
@@ -396,7 +395,7 @@ var canUserPostTopicToCategory = function (aUser, aCategory) { | |
return false; // Not logged in. | ||
|
||
// Check if this category requires a minimum role to post topics. | ||
console.log(aCategory.roleReqToPostTopic, _.isNumber(aCategory.roleReqToPostTopic), aUser.role, aUser.role <= aCategory.roleReqToPostTopic) | ||
console.log(aCategory.roleReqToPostTopic, _.isNumber(aCategory.roleReqToPostTopic), aUser.role, aUser.role <= aCategory.roleReqToPostTopic); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 here |
||
if (_.isNumber(aCategory.roleReqToPostTopic)) { | ||
return aUser.role <= aCategory.roleReqToPostTopic; | ||
} else { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,7 +104,7 @@ exports.destroy = function (aReq, aUser, aCallback) { | |
} | ||
}; | ||
|
||
if (!aUser || !aUser.sessionIds) { return aCb('No sessions', null); } | ||
if (!aUser || !aUser.sessionIds) { return aCallback('No sessions', null); } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably fixed a bug. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably +1 here. ;) |
||
|
||
async.each(aUser.sessionIds, function (aId, aCb) { | ||
store.set(aId, emptySess, aCb); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,4 +75,4 @@ exports.verify = function (aId, aStrategy, aUsername, aLoggedIn, aDone) { | |
} | ||
} | ||
); | ||
} | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 here |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,7 +50,7 @@ function removeable(aModel, aContent, aUser, aCallback) { | |
exports.removeable = removeable; | ||
|
||
function remove(aModel, aContent, aUser, aReason, aCallback) { | ||
var remove = new Remove({ | ||
var removeModel = new Remove({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. -0+ here... JSHint specific I think. |
||
'model': aModel.modelName, | ||
'content': aContent.toObject(), | ||
'removed': new Date(), | ||
|
@@ -60,7 +60,7 @@ function remove(aModel, aContent, aUser, aReason, aCallback) { | |
'_removerId': aUser._id | ||
}); | ||
|
||
remove.save(function (aErr, aRemove) { | ||
removeModel.save(function (aErr, aRemove) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. -0+ here... JSHint specific I think. |
||
aContent.remove(function (aErr) { aCallback(aRemove); }); | ||
}); | ||
} | ||
|
@@ -112,7 +112,7 @@ exports.findDeadorAlive = function (aModel, aQuery, aUser, aCallback) { | |
var rmQuery = { model: modelName }; | ||
|
||
if (!aErr && aContent) { return aCallback(true, aContent, null); } | ||
if (modelName != 'User' && -1 === modelNames.indexOf(modelName)) { | ||
if (modelName !== 'User' && -1 === modelNames.indexOf(modelName)) { | ||
return aCallback(null, null, null); | ||
} | ||
|
||
|
@@ -126,7 +126,7 @@ exports.findDeadorAlive = function (aModel, aQuery, aUser, aCallback) { | |
return aCallback(false, null, aRemoved); | ||
} | ||
|
||
aCallback(false, new model(aRemoved.content), aRemoved); // TODO: Ambiguous | ||
aCallback(false, new aModel(aRemoved.content), aRemoved); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 here |
||
}); | ||
}); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,11 +8,9 @@ var isDbg = require('../libs/debug').isDbg; | |
// | ||
var https = require('https'); | ||
var async = require('async'); | ||
var util = require('util'); | ||
var _ = require('underscore'); | ||
|
||
var Strategy = require('../models/strategy').Strategy; | ||
var User = require('../models/user').User; | ||
|
||
var nil = require('./helpers').nil; | ||
var github = require('../libs/githubClient'); | ||
|
@@ -38,7 +36,7 @@ function fetchRaw(aHost, aPath, aCallback) { | |
var req = https.request(options, | ||
function (aRes) { | ||
var bufs = []; | ||
if (aRes.statusCode != 200) { console.log(aRes.statusCode); return aCallback([new Buffer('')]); } | ||
if (aRes.statusCode !== 200) { console.log(aRes.statusCode); return aCallback([new Buffer('')]); } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 here since it's not a string |
||
else { | ||
aRes.on('data', function (aD) { bufs.push(aD); }); // TODO: Non-descript function parm | ||
aRes.on('end', function () { | ||
|
@@ -102,7 +100,6 @@ RepoManager.prototype.loadScripts = function (aCallback, aUpdate) { | |
var scriptStorage = require('../controllers/scriptStorage'); | ||
var arrayOfRepos = this.makeRepoArray(); | ||
var that = this; | ||
var scripts = []; | ||
|
||
// TODO: remove usage of makeRepoArray since it causes redundant looping | ||
arrayOfRepos.forEach(function (aRepo) { | ||
|
@@ -161,7 +158,6 @@ Repo.prototype.fetchUserScripts = function (aCallback) { | |
// Looks for user script in the current directory | ||
// and initiates searches on subdirectories | ||
Repo.prototype.parseTree = function (aTree, aPath, aDone) { | ||
var object; | ||
var trees = []; | ||
var that = this; | ||
var repos = this.manager.repos; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 here