Skip to content

Commit

Permalink
Made jshint more strict (undefined globals)
Browse files Browse the repository at this point in the history
  • Loading branch information
dallonf committed Sep 12, 2012
1 parent 35a2b5b commit dacf05f
Show file tree
Hide file tree
Showing 14 changed files with 126 additions and 46 deletions.
16 changes: 0 additions & 16 deletions .jshintignore

This file was deleted.

3 changes: 2 additions & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"expr": true,
"proto": true,
"lastsemic": true,
"laxbreak": true
"laxbreak": true,
"strict": false
}
25 changes: 25 additions & 0 deletions bin/.jshintrc
Original file line number Diff line number Diff line change
@@ -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
}
}
16 changes: 16 additions & 0 deletions clib/.jshintrc
Original file line number Diff line number Diff line change
@@ -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
}
}
4 changes: 3 additions & 1 deletion clib/dpd.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/*global _dpd:true, io:true*/

(function (undefined) {

if (!window._dpd) window._dpd = {};
Expand Down Expand Up @@ -35,7 +37,7 @@
return parts;
}

normalizePath = function(path) {
var normalizePath = function(path) {
var isAbsolute = path.charAt(0) === '/',
trailingSlash = path.slice(-1) === '/';

Expand Down
4 changes: 4 additions & 0 deletions lib/.jshintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resources/collection/dashboard
resources/dashboard

util/uuid.js
11 changes: 11 additions & 0 deletions lib/.jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"laxcomma": true,
"expr": true,
"proto": true,
"lastsemic": true,
"laxbreak": true,
"strict": false,

"undef": true,
"node": true
}
4 changes: 2 additions & 2 deletions lib/internal-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand All @@ -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) === '/';

Expand Down
2 changes: 1 addition & 1 deletion lib/keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/resources/collection/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
52 changes: 29 additions & 23 deletions make.js
Original file line number Diff line number Diff line change
@@ -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');
};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"chai": "*",
"node-markdown": "*",
"dox": "*",
"less": "*"
"less": "*",
"jshint": "*"
},
"bin": { "dpd": "./bin/dpd" },
"scripts": {
Expand Down
5 changes: 5 additions & 0 deletions test-app/.jshintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
public/chai.js
public/mocha.js
public/jquery.js
resources
25 changes: 25 additions & 0 deletions test-app/.jshintrc
Original file line number Diff line number Diff line change
@@ -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.