Permalink
Browse files

jshint-901598: Fix JSHint issues

Signed-off-by: Joe Walker <jwalker@mozilla.com>
  • Loading branch information...
1 parent dd8030b commit 9fc8cd94372611d637f146c81af831fb7054d2d3 @joewalker joewalker committed Aug 5, 2013
Showing with 229 additions and 162 deletions.
  1. +26 −0 .jshintrc
  2. +6 −4 gcli.js
  3. +1 −1 lib/demo/commands/bugs.js
  4. +4 −4 lib/demo/commands/git.js
  5. +3 −1 lib/demo/commands/hg.js
  6. +2 −2 lib/gcli/argument.js
  7. +1 −1 lib/gcli/canon.js
  8. +5 −5 lib/gcli/cli.js
  9. +1 −1 lib/gcli/commands/connect.js
  10. +2 −2 lib/gcli/commands/test.js
  11. +2 −2 lib/gcli/converters.js
  12. +1 −1 lib/gcli/converters/basic.js
  13. +3 −0 lib/gcli/nls/strings.js
  14. +1 −1 lib/gcli/types/command.js
  15. +2 −2 lib/gcli/types/date.js
  16. +5 −5 lib/gcli/types/javascript.js
  17. +1 −1 lib/gcli/types/node.js
  18. +9 −8 lib/gcli/types/number.js
  19. +1 −1 lib/gcli/types/resource.js
  20. +2 −2 lib/gcli/types/selection.js
  21. +3 −3 lib/gcli/ui/arg_fetch.js
  22. +2 −2 lib/gcli/ui/completer.js
  23. +3 −3 lib/gcli/ui/fields.js
  24. +11 −5 lib/gcli/ui/fields/basic.js
  25. +1 −1 lib/gcli/ui/fields/selection.js
  26. +23 −20 lib/gclitest/helpers.js
  27. +1 −1 lib/gclitest/index.js
  28. +11 −9 lib/gclitest/mockCommands.js
  29. +2 −2 lib/gclitest/testCanon.js
  30. +2 −2 lib/gclitest/testFileparser.js
  31. +2 −2 lib/gclitest/testInputter.js
  32. +1 −1 lib/gclitest/testJs.js
  33. +1 −1 lib/gclitest/testKeyboard3.js
  34. +1 −1 lib/gclitest/testResource.js
  35. +1 −1 lib/gclitest/testScratchpad.js
  36. +2 −0 lib/server/commands/exit.js
  37. +4 −2 lib/server/commands/firefox.js
  38. +5 −3 lib/server/commands/server.js
  39. +3 −1 lib/server/commands/standard.js
  40. +8 −5 lib/server/commands/test.js
  41. +2 −0 lib/server/commands/unamd.js
  42. +15 −14 lib/server/unamd.js
  43. +1 −0 lib/util/connect/connector.js
  44. +6 −5 lib/util/domtemplate.js
  45. +1 −1 lib/util/host.js
  46. +4 −4 lib/util/l10n.js
  47. +2 −2 lib/util/legacy.js
  48. +3 −3 lib/util/promise.js
  49. +9 −9 lib/util/util.js
  50. +1 −1 lib/util/xhr.js
  51. +3 −0 mozilla/gcli/commands/strings.js
  52. +1 −1 mozilla/gcli/index.js
  53. +6 −5 mozilla/gcli/settings.js
  54. +1 −1 mozilla/util/connect/connector.js
  55. +4 −4 mozilla/util/filesystem.js
  56. +2 −2 mozilla/util/l10n.js
  57. +1 −1 mozilla/util/promise.js
  58. +2 −0 phantom-test.js
View
@@ -0,0 +1,26 @@
+{
+ "undef": true,
+ "camelcase": true,
+ "curly": true,
+ "noarg": true,
+ "quotmark": "single",
+ "strict": true,
+ "eqnull": true,
+ "evil": true,
+ "eqnull": true,
+ "browser": true,
+ "devel": true,
+ "node": true,
+ "phantom": true,
+ "laxbreak": true,
+ "globals": {
+ "define": false,
+ "Components": false,
+ "Event": false,
+ "CSSRule": false,
+ "Proxy": false,
+ "info": false,
+ "io": false,
+ "ok": false
+ }
+}
View
@@ -15,6 +15,8 @@
* limitations under the License.
*/
+'use strict';
+
exports.gcliHome = __dirname;
/**
@@ -116,12 +118,12 @@ var Requisition = exports.require('gcli/cli').Requisition;
var Status = exports.require('gcli/types').Status;
var jsdom = require('jsdom').jsdom;
-var document = jsdom('<html><head></head><body></body></html>');
+var doc = jsdom('<html><head></head><body></body></html>');
var environment = {
- document: document,
- window: document.defaultView
+ document: doc,
+ window: doc.defaultView
};
-var requisition = new Requisition(environment, document);
+var requisition = new Requisition(environment, doc);
var command, extraActions;
@@ -84,7 +84,7 @@ function queryBugzilla(args, context) {
deferred.reject('Invalid response: ' + ex + ': ' + req.responseText);
}
}
- }.bind(this);
+ };
req.send();
return deferred.promise;
@@ -122,7 +122,7 @@ exports.items = [
}
],
exec: function(args, context) {
- return "This is only a demo of UI generation.";
+ return 'This is only a demo of UI generation.';
}
},
{
@@ -228,7 +228,7 @@ exports.items = [
}
],
exec: function(args, context) {
- return "This is only a demo of UI generation.";
+ return 'This is only a demo of UI generation.';
}
},
{
@@ -252,7 +252,7 @@ exports.items = [
}
],
exec: function(args, context) {
- return "This is only a demo of UI generation.";
+ return 'This is only a demo of UI generation.';
}
},
{
@@ -272,7 +272,7 @@ exports.items = [
}
],
exec: function(args, context) {
- return "This is only a demo of UI generation.";
+ return 'This is only a demo of UI generation.';
}
}
];
@@ -18,6 +18,8 @@ define(function(require, exports, module) {
'use strict';
+var host = require('util/host');
+
exports.items = [
{
// Top level 'hg' command
@@ -31,7 +33,7 @@ exports.items = [
item: 'converter',
from: 'patches',
to: 'view',
- exec: function(patches, conversionContext) {
+ exec: function(patches, context) {
return context.createView({
html: require('text!demo/commands/patches.html'),
data: {
@@ -93,7 +93,7 @@ Argument.prototype.beget = function(options) {
// We need to add quotes when the replacement string has spaces or is empty
if (!options.dontQuote) {
- var needsQuote = text.indexOf(' ') >= 0 || text.length == 0;
+ var needsQuote = text.indexOf(' ') >= 0 || text.length === 0;
var hasQuote = /['"]$/.test(prefix);
if (needsQuote && !hasQuote) {
prefix = prefix + '\'';
@@ -586,7 +586,7 @@ ArrayArgument.prototype.equals = function(that) {
return false;
}
- if (!(that.type === 'ArrayArgument')) {
+ if (that.type !== 'ArrayArgument') {
return false;
}
View
@@ -247,7 +247,7 @@ function Parameter(paramSpec, command, groupName) {
// All parameters that can only be set via a named parameter must have a
// non-undefined default value
if (!this.isPositionalAllowed && this.paramSpec.defaultValue === undefined &&
- this.type.getBlank == null && !(this.type.name === 'boolean')) {
+ this.type.getBlank == null && this.type.name !== 'boolean') {
throw new Error('In ' + this.command.name + '/' + this.name +
': Missing defaultValue for optional parameter.');
}
View
@@ -665,7 +665,7 @@ Requisition.prototype.getStatusMessage = function() {
}
var assignments = this.getAssignments();
- for (var i = 0; i < asiignments.length; i++) {
+ for (var i = 0; i < assignments.length; i++) {
if (assignments[i].getStatus() !== Status.VALID) {
return assignments[i].message;
}
@@ -1146,7 +1146,7 @@ Requisition.prototype.getInputStatusMarkup = function(cursor) {
}
// De-dupe: merge entries where 2 adjacent have same status
- var i = 0;
+ i = 0;
while (i < markup.length - 1) {
if (markup[i].status === markup[i + 1].status) {
markup[i].string += markup[i + 1].string;
@@ -1505,8 +1505,8 @@ exports.tokenize = function(typed) {
.replace(/\uF001/g, '\\ ')
.replace(/\uF002/g, '\\\'')
.replace(/\uF003/g, '\\\"')
- .replace(/\uF004/g, '\\\{')
- .replace(/\uF005/g, '\\\}');
+ .replace(/\uF004/g, '\\{')
+ .replace(/\uF005/g, '\\}');
}
var i = 0; // The index of the current character
@@ -1659,7 +1659,7 @@ Requisition.prototype._split = function(args) {
// Handle the special case of the user typing { javascript(); }
// We use the hidden 'eval' command directly rather than shift()ing one of
// the parameters, and parse()ing it.
- var conversion = undefined;
+ var conversion;
if (args[0].type === 'ScriptArgument') {
// Special case: if the user enters { console.log('foo'); } then we need to
// use the hidden 'eval' command
@@ -103,7 +103,7 @@ var connect = {
// If we've been called using a 'context' then there will be no prefix
// otherwise we need to remove it
if (typed.indexOf(prefix) === 0) {
- typed = typed.substring(prefix.length).replace(/^ */, "");
+ typed = typed.substring(prefix.length).replace(/^ */, '');
}
return connection.execute(typed, cmdArgs).then(function(reply) {
@@ -18,9 +18,9 @@ define(function(require, exports, module) {
'use strict';
-var examiner = require("test/examiner");
+var examiner = require('test/examiner');
-var testCss = require("text!gcli/commands/test.css");
+var testCss = require('text!gcli/commands/test.css');
var testHtml = require('text!gcli/commands/test.html');
exports.options = {};
@@ -135,13 +135,13 @@ function getConverter(from, to) {
// conversion but for now the only 2 step conversion is foo->view->dom,
// which we are going to special case.
if (to === 'dom') {
- converter = fromMatch['view'];
+ converter = fromMatch.view;
if (converter != null) {
return getChainConverter(converter, viewDomConverter);
}
}
if (to === 'string') {
- converter = fromMatch['view'];
+ converter = fromMatch.view;
if (converter != null) {
return getChainConverter(converter, viewStringConverter);
}
@@ -62,7 +62,7 @@ exports.items = [
to: 'dom',
exec: function(ex, conversionContext) {
var node = util.createElement(conversionContext.document, 'p');
- node.className = "gcli-error";
+ node.className = 'gcli-error';
node.textContent = ex;
return node;
}
@@ -1,5 +1,8 @@
define(function(require, exports, module) {
+
+'use strict';
+
/**
* This file has detailed comments as to the usage of these strings so when
* translators work on these strings separately from the code, (but with the
@@ -43,7 +43,7 @@ exports.items = [
if (command != null) {
command.params.forEach(function(param) {
var arg = this.requisition.getAssignment(param.name).arg;
- if (!param.isPositionalAllowed && arg.type === "BlankArgument") {
+ if (!param.isPositionalAllowed && arg.type === 'BlankArgument') {
displayedParams.push({ name: '--' + param.name, value: param });
}
}, this);
@@ -169,7 +169,7 @@ DateType.prototype.parse = function(arg, context) {
// First, if the user explicitly includes a timezone, then we assume they
// know what they are doing with timezones
- if (arg.text.indexOf("Z") !== -1) {
+ if (arg.text.indexOf('Z') !== -1) {
value = new Date(arg.text);
}
else {
@@ -243,7 +243,7 @@ function toDate(str) {
function isDate(thing) {
return Object.prototype.toString.call(thing) === '[object Date]'
&& !isNaN(thing.getTime());
-};
+}
});
@@ -30,7 +30,7 @@ var Status = types.Status;
* The object against which we complete, which is usually 'window' if it exists
* but could be something else in non-web-content environments.
*/
-var globalObject = undefined;
+var globalObject;
if (typeof window !== 'undefined') {
globalObject = window;
}
@@ -120,7 +120,7 @@ JavascriptType.prototype.parse = function(arg, context) {
var completionPart = typed.substring(beginning.startPos);
var properties = completionPart.split('.');
var matchProp;
- var prop = undefined;
+ var prop;
if (properties.length > 1) {
matchProp = properties.pop().trimLeft();
@@ -166,8 +166,8 @@ JavascriptType.prototype.parse = function(arg, context) {
// However if the prop was a simple string, it is an error
if (scope == null) {
- var message = l10n.lookupFormat('jstypeParseMissing', [ prop ]);
- return promise.resolve(new Conversion(typed, arg, Status.ERROR, message));
+ var msg = l10n.lookupFormat('jstypeParseMissing', [ prop ]);
+ return promise.resolve(new Conversion(typed, arg, Status.ERROR, msg));
}
// If the thing we're looking for isn't a simple string, then we're not going
@@ -512,7 +512,7 @@ JavascriptType.prototype._isSafeProperty = function(scope, prop) {
// Walk up the prototype chain of 'scope' looking for a property descriptor
// for 'prop'
- var propDesc = undefined;
+ var propDesc;
while (scope) {
try {
propDesc = Object.getOwnPropertyDescriptor(scope, prop);
@@ -30,7 +30,7 @@ var BlankArgument = require('gcli/argument').BlankArgument;
* The object against which we complete, which is usually 'window' if it exists
* but could be something else in non-web-content environments.
*/
-var doc = undefined;
+var doc;
if (typeof document !== 'undefined') {
doc = document;
}
@@ -76,13 +76,14 @@ exports.items = [
},
parse: function(arg, context) {
+ var msg;
if (arg.text.replace(/^\s*-?/, '').length === 0) {
return promise.resolve(new Conversion(undefined, arg, Status.INCOMPLETE, ''));
}
if (!this.allowFloat && (arg.text.indexOf('.') !== -1)) {
- var message = l10n.lookupFormat('typesNumberNotInt2', [ arg.text ]);
- return promise.resolve(new Conversion(undefined, arg, Status.ERROR, message));
+ msg = l10n.lookupFormat('typesNumberNotInt2', [ arg.text ]);
+ return promise.resolve(new Conversion(undefined, arg, Status.ERROR, msg));
}
var value;
@@ -94,20 +95,20 @@ exports.items = [
}
if (isNaN(value)) {
- var message = l10n.lookupFormat('typesNumberNan', [ arg.text ]);
- return promise.resolve(new Conversion(undefined, arg, Status.ERROR, message));
+ msg = l10n.lookupFormat('typesNumberNan', [ arg.text ]);
+ return promise.resolve(new Conversion(undefined, arg, Status.ERROR, msg));
}
var max = this.getMax(context);
if (max != null && value > max) {
- var message = l10n.lookupFormat('typesNumberMax', [ value, max ]);
- return promise.resolve(new Conversion(undefined, arg, Status.ERROR, message));
+ msg = l10n.lookupFormat('typesNumberMax', [ value, max ]);
+ return promise.resolve(new Conversion(undefined, arg, Status.ERROR, msg));
}
var min = this.getMin(context);
if (min != null && value < min) {
- var message = l10n.lookupFormat('typesNumberMin', [ value, min ]);
- return promise.resolve(new Conversion(undefined, arg, Status.ERROR, message));
+ msg = l10n.lookupFormat('typesNumberMin', [ value, min ]);
+ return promise.resolve(new Conversion(undefined, arg, Status.ERROR, msg));
}
return promise.resolve(new Conversion(value, arg));
@@ -30,7 +30,7 @@ exports.clearResourceCache = function() {
* The object against which we complete, which is usually 'window' if it exists
* but could be something else in non-web-content environments.
*/
-var doc = undefined;
+var doc;
if (typeof document !== 'undefined') {
doc = document;
}
@@ -169,8 +169,8 @@ function dataToLookup(data) {
return data.map(function(option) {
return { name: option, value: option };
- }, this);
-};
+ });
+}
/**
* Return a list of possible completions for the given arg.
Oops, something went wrong.

0 comments on commit 9fc8cd9

Please sign in to comment.