Permalink
Browse files

Made jshint more strict (undefined globals)

  • Loading branch information...
1 parent 35a2b5b commit dacf05fce6b8b6ff230a4a63506ee2c7064c80ed @dallonf dallonf committed Sep 12, 2012
Showing with 126 additions and 46 deletions.
  1. +0 −16 .jshintignore
  2. +2 −1 .jshintrc
  3. +25 −0 bin/.jshintrc
  4. +16 −0 clib/.jshintrc
  5. +3 −1 clib/dpd.js
  6. +4 −0 lib/.jshintignore
  7. +11 −0 lib/.jshintrc
  8. +2 −2 lib/internal-client.js
  9. +1 −1 lib/keys.js
  10. +1 −1 lib/resources/collection/index.js
  11. +29 −23 make.js
  12. +2 −1 package.json
  13. +5 −0 test-app/.jshintignore
  14. +25 −0 test-app/.jshintrc
View
@@ -1,16 +0,0 @@
-node_modules
-lib/util/uuid.js
-clib/socket.io.js
-clib/socket.io.min.js
-
-test-app/node_modules/request
-test-app/public/mocha.js
-test-app/public/jquery.js
-test-app/public/chai.js
-
-lib/resources/dashboard/js/lib
-lib/resources/collection/dashboard/js/lib
-lib/resources/dashboard/bootstrap
-
-clib/socket.io.js
-clib/socket.io.min.js
View
@@ -3,5 +3,6 @@
"expr": true,
"proto": true,
"lastsemic": true,
- "laxbreak": true
+ "laxbreak": true,
+ "strict": false
}
View
@@ -0,0 +1,25 @@
+{
+ "laxcomma": true,
+ "expr": true,
+ "proto": true,
+ "lastsemic": true,
+ "laxbreak": true,
+ "strict": false,
+
+ "undef": true,
+ "browser": true,
+ "globals": {
+
+ "describe": true
+ , "it": true
+ , "afterEach": true
+ , "beforeEach": true
+
+ , "expect": true
+
+ , "dpd": true
+
+ , "chain": true
+ , "cleanCollection": true
+ }
+}
View
@@ -0,0 +1,16 @@
+{
+ "laxcomma": true,
+ "expr": true,
+ "proto": true,
+ "lastsemic": true,
+ "laxbreak": true,
+ "strict": false,
+
+ "undef": true,
+ "browser": true,
+ "devel": true,
+ "globals": {
+ "io": true
+ , "_dpd": true
+ }
+}
View
@@ -1,3 +1,5 @@
+/*global _dpd:true, io:true*/
+
(function (undefined) {
if (!window._dpd) window._dpd = {};
@@ -35,7 +37,7 @@
return parts;
}
- normalizePath = function(path) {
+ var normalizePath = function(path) {
var isAbsolute = path.charAt(0) === '/',
trailingSlash = path.slice(-1) === '/';
View
@@ -0,0 +1,4 @@
+resources/collection/dashboard
+resources/dashboard
+
+util/uuid.js
View
@@ -0,0 +1,11 @@
+{
+ "laxcomma": true,
+ "expr": true,
+ "proto": true,
+ "lastsemic": true,
+ "laxbreak": true,
+ "strict": false,
+
+ "undef": true,
+ "node": true
+}
View
@@ -6,7 +6,7 @@ function normalizeArray(parts, allowAboveRoot) {
for (var i = parts.length - 1; i >= 0; i--) {
var last = parts[i];
if (last == '.') {
- parts.splice(i, 1);
+ parts.splice(i, 1);
} else if (last === '..') {
parts.splice(i, 1);
up++;
@@ -26,7 +26,7 @@ function normalizeArray(parts, allowAboveRoot) {
return parts;
}
-normalizePath = function(path) {
+var normalizePath = function(path) {
var isAbsolute = path.charAt(0) === '/',
trailingSlash = path.slice(-1) === '/';
View
@@ -76,7 +76,7 @@ Keys.prototype.writeFile = function(data, fn) {
try {
str = JSON.stringify(data);
} catch(e) {
- return fn(r);
+ return fn(e);
}
fs.writeFile(this.path, str, fn);
@@ -424,7 +424,7 @@ Collection.prototype.save = function (ctx, fn) {
var id = query.id;
store.first({id: query.id, $fields: query.$fields}, function(err, obj) {
if(!obj) return done(new Error('You can\'t update an object that does not exist.'));
- if(err) return done(rerr);
+ if(err) return done(err);
// merge changes
Object.keys(item).forEach(function (key) {
View
52 make.js
@@ -1,34 +1,40 @@
require('shelljs/make');
-var less = require('less');
+var path = require('path');
target.all = function() {
- target.dashboard();
+ target.jshint();
};
-target.dashboard = function() {
- cd(__dirname);
-
- var lessSource = cat('lib/resources/dashboard/stylesheets/style.less');
-
- if (lessSource) {
- var parser = new(less.Parser)({
- paths: ['lib/resources/dashboard/stylesheets'], // Specify search paths for @import directives
- filename: 'style.less' // Specify a filename, for better error messages
- });
+target.jshint = function() {
+ target.jshintLib();
+ target.jshintTest();
+ target.jshintDpdJs();
+ target.jshintCli();
+};
- parser.parse(lessSource, function (e, tree) {
- if (e) return console.error(e.message);
- tree.toCSS().to('lib/resources/dashboard/stylesheets/style.css');
- });
+function hint(pathName, fileName) {
+ var lastPath = process.cwd();
+ cd(pathName);
+ echo("Linting " + pathName + (fileName ? ("/" + fileName) : "") + "...");
+ exec('jshint ' + (fileName || '.'));
+ echo();
+ cd(lastPath);
+}
+
+target.jshintLib = function() {
+ hint('lib');
+};
- }
+target.jshintTest = function() {
+ hint('test');
+ hint('test-app');
+};
+target.jshintDpdJs = function() {
+ hint('clib', 'dpd.js');
+};
- // var result = exec('lessc lib/resources/dashboard/stylesheets/style.less', {silent: true});
- // if (result.code) {
- // console.error(result.output);
- // } else {
- // result.output.to('lib/resources/dashboard/stylesheets/style.css')
- // }
+target.jshintCli = function() {
+ hint('bin', 'dpd');
};
View
@@ -36,7 +36,8 @@
"chai": "*",
"node-markdown": "*",
"dox": "*",
- "less": "*"
+ "less": "*",
+ "jshint": "*"
},
"bin": { "dpd": "./bin/dpd" },
"scripts": {
View
@@ -0,0 +1,5 @@
+node_modules
+public/chai.js
+public/mocha.js
+public/jquery.js
+resources
View
@@ -0,0 +1,25 @@
+{
+ "laxcomma": true,
+ "expr": true,
+ "proto": true,
+ "lastsemic": true,
+ "laxbreak": true,
+ "strict": false,
+
+ "undef": true,
+ "browser": true,
+ "globals": {
+
+ "describe": true
+ , "it": true
+ , "afterEach": true
+ , "beforeEach": true
+
+ , "expect": true
+
+ , "dpd": true
+
+ , "chain": true
+ , "cleanCollection": true
+ }
+}

0 comments on commit dacf05f

Please sign in to comment.