Permalink
Browse files

JSHint conformance.

  • Loading branch information...
1 parent 975722e commit 9903a1c8b1cff9f95982afd9aae783ae920d5de6 @csnover committed Nov 6, 2011
Showing with 167 additions and 93 deletions.
  1. +67 −0 jshint.config
  2. +16 −14 lib/File.js
  3. +2 −2 lib/Module.js
  4. +10 −7 lib/Scope.js
  5. +3 −3 lib/Value.js
  6. +61 −48 lib/bdParser.js
  7. +2 −14 lib/callHandlers.js
  8. +2 −2 lib/env.js
  9. +4 −3 parse.js
View
@@ -0,0 +1,67 @@
+{
+"asi": false, // if automatic semicolon insertion should be tolerated
+"bitwise": false, // if bitwise operators should not be allowed
+"boss": true, // if advanced usage of assignments should be allowed
+"browser": false, // if the standard browser globals should be predefined
+"couch": false, // if CouchDB globals should be predefined
+"curly": true, // if curly braces around all blocks should be required
+"debug": false, // if debugger statements should be allowed
+"devel": true, // if logging globals should be predefined (console,
+ // alert, etc.)
+"dojo": true, // if Dojo Toolkit globals should be predefined
+"eqeqeq": true, // if === should be required
+"eqnull": true, // if == null comparisons should be tolerated
+"es5": true, // if ES5 syntax should be allowed
+"evil": true, // if eval should be allowed
+"expr": true, // if ExpressionStatement should be allowed as Programs
+"forin": true, // if for in statements must filter
+"globalstrict": false, // if global "use strict"; should be allowed (also
+ // enables 'strict')
+"immed": true, // if immediate invocations must be wrapped in parens
+"iterator": true, // if the `__iterator__` property should be disallowed
+"jquery": false, // if jQuery globals should be predefined
+"lastsemic": false, // if semicolons may be ommitted for the trailing
+ // statements inside of a one-line blocks.
+"latedef": false, // if the use before definition should not be tolerated
+"laxbreak": true, // if line breaks should not be checked
+"loopfunc": true, // if functions should be allowed to be defined within
+ // loops
+"maxerr": 32767, // how many errors should be allowed to occur before
+ // processing is cancelled
+"mootools": false, // if MooTools globals should be predefined
+"newcap": true, // if constructor names must be capitalized
+"noarg": true, // if arguments.caller and arguments.callee should be
+ // disallowed
+"node": true, // if the Node.js environment globals should be
+ // predefined
+"noempty": false, // if empty blocks should be disallowed
+"nonew": true, // if using `new` for side-effects should be disallowed
+"nonstandard": false, // if non-standard (but widely adopted) globals should
+ // be predefined
+"nomen": false, // if names should be checked
+"onevar": false, // if only one var statement per function should be
+ // allowed
+"onecase": false, // if one case switch statements should be allowed
+"passfail": false, // if the scan should stop on first error
+"plusplus": false, // if increment/decrement should not be allowed
+"proto": true, // if the `__proto__` property should be disallowed
+"prototypejs": false, // if Prototype and Scriptaculous globals should be
+ // predefined
+"regexdash": true, // if unescaped last dash (-) inside brackets should be
+ // tolerated
+"regexp": false, // if the . should not be allowed in regexp literals
+"rhino": true, // if the Rhino environment globals should be predefined
+"undef": true, // if variables should be declared before used
+"scripturl": true, // if script-targeted URLs should be tolerated
+"shadow": false, // if variable shadowing should be tolerated
+"strict": false, // require the "use strict"; pragma
+"sub": true, // if all forms of subscript notation are tolerated
+"supernew": true, // if `new function () { ... };` and `new Object;`
+ // should be tolerated
+"trailing": true, // if trailing whitespace rules apply
+"validthis": true, // if 'this' inside a non-constructor function is valid.
+ // This is a function scoped option only.
+"white": true, // if strict whitespace rules apply
+"wsh": false // if the Windows Scripting Host environment globals
+ // should be predefined
+}
View
@@ -5,10 +5,10 @@ define([ './env', './node!fs' ], function (env, fs) {
path = path.split('/');
while (path.length) {
segment = path.shift();
- if (segment === '..' && result.length && lastSegment != '..') {
+ if (segment === '..' && result.length && lastSegment !== '..') {
result.pop();
}
- else if(segment != '.') {
+ else if (segment !== '.') {
result.push((lastSegment = segment));
} // else ignore '.'
}
@@ -21,17 +21,19 @@ define([ './env', './node!fs' ], function (env, fs) {
match = false;
for (var module in env.config.prefixMap) {
- var pathPrefix = env.config.baseUrl + env.config.prefixMap[module];
-
- // avoid accidental matching of partial paths
- if (pathPrefix.charAt(-1) !== '/') {
- pathPrefix += '/';
- }
-
- if (result.indexOf(pathPrefix) === 0) {
- result = result.substr(pathPrefix.length);
- match = true;
- break;
+ if (env.config.prefixMap.hasOwnProperty(module)) {
+ var pathPrefix = env.config.baseUrl + env.config.prefixMap[module];
+
+ // avoid accidental matching of partial paths
+ if (pathPrefix.charAt(-1) !== '/') {
+ pathPrefix += '/';
+ }
+
+ if (result.indexOf(pathPrefix) === 0) {
+ result = result.substr(pathPrefix.length);
+ match = true;
+ break;
+ }
}
}
@@ -43,7 +45,7 @@ define([ './env', './node!fs' ], function (env, fs) {
function File(filename) {
if (!(this instanceof File)) {
- throw Error('File is a constructor');
+ throw new Error('File is a constructor');
}
this.filename = filename;
View
@@ -8,11 +8,11 @@ define([ 'dojo/_base/lang', './Value', './env' ], function (lang, Value, env) {
*/
function Module(/**string*/ id, /**Value?*/ value) {
if (!(this instanceof Module)) {
- throw Error('Module is a constructor');
+ throw new Error('Module is a constructor');
}
if (_moduleMap[id]) {
- throw Error('Module with id "' + id + '" already exists');
+ throw new Error('Module with id "' + id + '" already exists');
}
this.id = id;
View
@@ -33,11 +33,11 @@ define([ 'dojo/_base/lang', './env', './Value', './node!util' ], function (lang,
*/
function Scope(/**Scope*/ parent, /**Value*/ relatedFunction) {
if (!(this instanceof Scope)) {
- throw Error('Scope is a constructor');
+ throw new Error('Scope is a constructor');
}
if (!relatedFunction && env.globalScope) {
- throw Error('All scopes except global scope must have a related function value');
+ throw new Error('All scopes except global scope must have a related function value');
}
if (!parent) {
@@ -94,9 +94,9 @@ define([ 'dojo/_base/lang', './env', './Value', './node!util' ], function (lang,
value.comments = value.comments.concat(comments);
}
- return this.vars[name] = value || new Value({
+ return (this.vars[name] = value || new Value({
comments: comments
- });
+ }));
},
/**
@@ -119,7 +119,7 @@ define([ 'dojo/_base/lang', './env', './Value', './node!util' ], function (lang,
variable;
if (!(value instanceof Value)) {
- throw Error(name.join('.') + ': "' + value + '" is not a value');
+ throw new Error(name.join('.') + ': "' + value + '" is not a value');
}
if (name[0] === 'this') {
@@ -141,7 +141,7 @@ define([ 'dojo/_base/lang', './env', './Value', './node!util' ], function (lang,
if (name.length === 1) {
if (name[0] === 'this') {
- throw Error('Cannot assign to "this"');
+ throw new Error('Cannot assign to "this"');
}
if (this.vars[name[0]] && this.vars[name[0]].type !== 'undefined' && this.vars[name[0]] !== value) {
@@ -152,7 +152,10 @@ define([ 'dojo/_base/lang', './env', './Value', './node!util' ], function (lang,
}
else {
// Attempt to set a complex expression
- if (name.some(function (value) { return value === undefined || typeof value === 'object'; })) {
+ if (name.some(function (value) {
+ return (value === undefined || typeof value === 'object');
+ })) {
+
console.warn('Attempt to set a variable using a complex expression');
return;
}
View
@@ -4,7 +4,7 @@ define([ 'dojo/_base/lang', './env' ], function (lang, env) {
*/
function Value(/** Object? */ kwArgs) {
if (!(this instanceof Value)) {
- throw Error('Value is a constructor');
+ throw new Error('Value is a constructor');
}
this.properties = {};
@@ -108,7 +108,7 @@ define([ 'dojo/_base/lang', './env' ], function (lang, env) {
* @param value The value to set on the property.
*/
setProperty: function (/**Array.<string>*/ name, /**Value*/ value) {
- var assumeKeyExists = this.type === 'parameter';
+ var assumeKeyExists = this.type === 'function' || this.type === 'parameter';
for (var obj = this, i = 0, j = name.length - 1, key; i < j && (key = name[i]); ++i) {
if (!obj.properties[key]) {
@@ -128,7 +128,7 @@ define([ 'dojo/_base/lang', './env' ], function (lang, env) {
});
}
else {
- throw Error('Attempt to set property of undefined object ' + key + ' on ' + obj);
+ throw new Error('Attempt to set property of undefined object ' + key + ' on ' + obj);
}
}
Oops, something went wrong.

0 comments on commit 9903a1c

Please sign in to comment.