Skip to content
This repository has been archived by the owner on Jan 2, 2021. It is now read-only.

Commit

Permalink
Adding jshint; jshinted js file; add more ignores; add node modules
Browse files Browse the repository at this point in the history
  • Loading branch information
basti1253 committed Aug 26, 2012
1 parent 81a2dbc commit 072314c
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ dwsync.xml
.svn
publish
.idea

## nodejs dependencies
node_modules
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## config
JS_ENGINE ?= `which node nodejs 2>/dev/null`

all: test
## test against jshint
test:
@@if test ! -z ${JS_ENGINE}; then \
echo "Checking files against JSHint..."; \
${JS_ENGINE} tests/jshint-check.js || return -1 \
else \
echo "You must have NodeJS installed in order to test js files against JSHint."; \
fi
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "ui-coverflow-ii",
"version": "2.3.0",
"private": true,
"dependencies": {
"jshint" : ">=0.5.8"
}
}
13 changes: 6 additions & 7 deletions src/js/ui.coverflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
options: {
items: "> *",
// scale left/right images - 0>x<1
itemscale : .73,
itemscale : 0.73,
orientation: "horizontal",
active: 0,
duration : 200,
Expand All @@ -55,8 +55,7 @@
this.currentIndex = o.active;

if( $.isArray( o.trigger ) ) {
// TODO: jshint doesn't like the assignment
for( i = 0; binding = o.trigger[ i++ ]; ) {
for( i = 0; !! ( binding = o.trigger[ i++ ] ); ) {
itemBindings[ binding ] = this._select;
}

Expand All @@ -73,7 +72,7 @@
this.origElementDimensions = {
width: this.element.width(),
height: this.element.height()
}
};
this._on( this.items, itemBindings );

},
Expand All @@ -85,14 +84,14 @@
if( o.orientation === "vertical" ) {
this._topOrLeft = "top";
this._widthOrHeight = "height";
if( this._orientation != null && this._orientation == "horizontal" ) {
if( this._orientation != null && this._orientation === "horizontal" ) {
this._trigger( "orientationchange", null, this._ui() );
}
this._orientation = "vertical";
} else {
this._topOrLeft = "left";
this._widthOrHeight = "width";
if( this._orientation != null && this._orientation == "vertical" ) {
if( this._orientation != null && this._orientation === "vertical" ) {
this._trigger( "orientationchange", null, this._ui() );
}
this._orientation = "horizontal";
Expand All @@ -101,7 +100,7 @@
o.itemscale = parseFloat( o.itemscale );
o.itemscale = o.itemscale < 1 && o.itemscale > 0
? o.itemscale
: .73;
: 0.73;

this.itemSize = o.itemscale * this.items.innerWidth();

Expand Down
69 changes: 69 additions & 0 deletions tests/jshint-check.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
var fs = require("fs"),
jshint = require("jshint").JSHINT,
targets = [
"src/js/ui.coverflow.js"
],
config = {
// unfiltered forin
forin : true,
// allow the new keyword
nonew : false,
evil : true,
browser : true,
// allow == null
eqnull : true,
expr : true,
curly : true,
// no trailing ws
trailing : true,
// sloppy ws
sloppy : true,
// don't tell me how to format my code buddy..
strict : false,
// crockfords whitespace settings - NOPE
white : false,
// no undefined vars
undef : true,
smarttabs : true,
noarg : true,
noempty : true,
// require ===
eqeqeq : true,
// no bitwise operators plz
bitwise : true,
indent : 4,
eqeq : false,
nomen : false,
laxbreak : true,
loopfunc : true,
predef : [
"jQuery"
],
maxerr: 100
},
content = "";

(function() {
if( typeof jshint == "undefined") {
console.log("Install JSHint first - run `npm install -g jshint` as root.");
return;
}

targets.forEach( function( file, key ) {
content = fs.readFileSync( file , "utf8");
if ( !! content && jshint( content, config ) ) {
console.log( "JSHint check passed for file: " + file );
} else {
console.log( "JSHint found errors." );
jshint.errors.forEach(function( e ) {
if ( !e ) { return; }
var str = e.evidence ? e.evidence : "",
character = e.character === true ? "EOL" : "C" + e.character;
if ( str ) {
str = str.replace( /\t/g, " " ).trim();
console.log( file + ": [line " + e.line + ":" + character + "] " + e.reason + "\n " + str + "\n");
}
});
}
});
})();

0 comments on commit 072314c

Please sign in to comment.