Skip to content

Commit

Permalink
Tweak JSHint options.
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Jan 7, 2016
1 parent 575031d commit 2701b88
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 70 deletions.
6 changes: 3 additions & 3 deletions .jshintrc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"camelcase": true, "camelcase": true,
"curly": true, "curly": true,
"eqeqeq": true, "eqeqeq": true,
"es3": true,
"forin": true, "forin": true,
"immed": true, "immed": true,
"indent": 4, "indent": 4,
Expand All @@ -15,7 +16,6 @@
"undef": true, "undef": true,
"unused": true, "unused": true,
"globals": { "globals": {
"CSSLint": true, "CSSLint": true
"YUITest": true
} }
} }
3 changes: 3 additions & 0 deletions Gruntfile.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ module.exports = function(grunt) {
src: "demos/*.js" src: "demos/*.js"
}, },
tests: { tests: {
options: {
jshintrc: "tests/.jshintrc"
},
src: "tests/**/*.js" src: "tests/**/*.js"
} }
}, },
Expand Down
1 change: 1 addition & 0 deletions src/cli/common.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* provides environment-specific functionality. * provides environment-specific functionality.
*/ */


/* global JSON */
/* exported cli */ /* exported cli */


function cli(api){ function cli(api){
Expand Down
4 changes: 3 additions & 1 deletion src/worker/Worker.js
Original file line number Original file line Diff line number Diff line change
@@ -1,7 +1,9 @@
/* /*
* Web worker for CSSLint * Web worker for CSSLint
*/ */
/*global self, JSON*/
/* global self, JSON */

//message indicates to start linting //message indicates to start linting
self.onmessage = function(event){ self.onmessage = function(event){
"use strict"; "use strict";
Expand Down
3 changes: 2 additions & 1 deletion tasks/changelog.js
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,7 @@
/* jshint node:true */ /* jshint node:true */
"use strict";

module.exports = function( grunt ) { module.exports = function( grunt ) {
"use strict";
grunt.registerMultiTask("changelog", "Write the changelog file", function() { grunt.registerMultiTask("changelog", "Write the changelog file", function() {
var done = this.async(); var done = this.async();
var lastTag; var lastTag;
Expand Down
3 changes: 2 additions & 1 deletion tasks/test_rhino.js
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,7 @@
/* jshint node:true */ /* jshint node:true */
"use strict";

module.exports = function( grunt ) { module.exports = function( grunt ) {
"use strict";
// Run test suite through rhino // Run test suite through rhino
grunt.registerMultiTask("test_rhino", "Run the test suite through rhino", function() { grunt.registerMultiTask("test_rhino", "Run the test suite through rhino", function() {
var done = this.async(); var done = this.async();
Expand Down
3 changes: 2 additions & 1 deletion tasks/yuitest.js
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,7 @@
/* jshint evil:true, node:true */ /* jshint evil:true, node:true */
"use strict";

module.exports = function( grunt ) { module.exports = function( grunt ) {
"use strict";
grunt.registerMultiTask("yuitest", "Run the YUITests for the project", function() { grunt.registerMultiTask("yuitest", "Run the YUITests for the project", function() {


var YUITest = require("yuitest"); var YUITest = require("yuitest");
Expand Down
6 changes: 6 additions & 0 deletions tests/.jshintrc
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends" : "../.jshintrc",
"globals": {
"YUITest": true
}
}
9 changes: 5 additions & 4 deletions tests/all-rules.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
* to fail due to Java stack overflow. This must be run separate from other tests. * to fail due to Java stack overflow. This must be run separate from other tests.
*/ */


/*jshint loopfunc: true */ /* jshint loopfunc:true */


(function(){ (function(){
"use strict"; "use strict";
var Assert = YUITest.Assert, var Assert = YUITest.Assert,
suite = new YUITest.TestSuite("General Tests for all Rules"), suite = new YUITest.TestSuite("General Tests for all Rules"),
rules = CSSLint.getRules(), rules = CSSLint.getRules(),
len = rules.length, len = rules.length,
i; i;


for (i=0; i < len; i++){ for (i=0; i < len; i++){
Expand Down Expand Up @@ -65,3 +65,4 @@
YUITest.TestRunner.add(suite); YUITest.TestRunner.add(suite);


})(); })();

90 changes: 43 additions & 47 deletions tests/cli/assets/apiStub.js
Original file line number Original file line Diff line number Diff line change
@@ -1,58 +1,54 @@
/*jshint node:true*/ /* jshint node:true */
"use strict"; "use strict";
var
stub = {
logbook: function (log) {
this.logs.push(log);
},
readLogs: function () {
return this.logs.slice();
},


getFullPath: function (path) { var stub = {
return path; logbook: function (log) {
}, this.logs.push(log);
getFiles: function (dir) { },
var readLogs: function () {
filesobj = this.fakedFs[dir], return this.logs.slice();
fileix, },
out = [];
for (fileix in filesobj) {
if ( filesobj.hasOwnProperty(fileix) && /\.css$/.test(fileix) ) {
out.push(dir + "/" + fileix);
}
}
return out;
},
readFile: function (path) {
var
spath = path.split("/"),
spathLen = spath.length,
i,
out = this.fakedFs;


for (i = 0; i < spathLen; i += 1) { getFullPath: function (path) {
out = out[spath[i]]; return path;
},
getFiles: function (dir) {
var filesobj = this.fakedFs[dir],
fileix,
out = [];
for (fileix in filesobj) {
if (filesobj.hasOwnProperty(fileix) && /\.css$/.test(fileix)) {
out.push(dir + "/" + fileix);
} }
}
return out;
},
readFile: function (path) {
var spath = path.split("/"),
spathLen = spath.length,
i,
out = this.fakedFs;


return out; for (i = 0; i < spathLen; i += 1) {
}, out = out[spath[i]];
isDirectory: function (checkit) {
var
result = this.fakedFs[checkit];
return typeof result === "object";
},
print: function (msg) {
this.logbook(msg);
},
quit: function (signal) {
this.logbook(signal);
} }
};
return out;
},
isDirectory: function (checkit) {
var result = this.fakedFs[checkit];
return typeof result === "object";
},
print: function (msg) {
this.logbook(msg);
},
quit: function (signal) {
this.logbook(signal);
}
};


module.exports = function (setup) { module.exports = function (setup) {
var var api,
api,
setix; setix;


api = Object.create(stub); api = Object.create(stub);
Expand Down
5 changes: 3 additions & 2 deletions tests/cli/assets/data.js
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,5 @@
/*jshint node:true*/ /* jshint node:true */

module.exports = { module.exports = {
"suites": { "suites": {
"config csslintrc override": { "config csslintrc override": {
Expand Down Expand Up @@ -53,6 +54,6 @@ module.exports = {
"dir": { "dir": {
"a.css": ".a {color: red!important;}", "a.css": ".a {color: red!important;}",
"b.css": "#a {color: red;}" "b.css": "#a {color: red;}"
}, }
} }
}; };
18 changes: 8 additions & 10 deletions tests/cli/cli-common.js
Original file line number Original file line Diff line number Diff line change
@@ -1,8 +1,8 @@
/*jshint loopfunc:true, node:true */ /* jshint loopfunc:true, node:true */

"use strict"; "use strict";
function include(path, sandbox) { function include(path, sandbox) {
var var vm = require("vm"),
vm = require("vm"),
fs = require("fs"), fs = require("fs"),
file; file;


Expand All @@ -11,14 +11,13 @@ function include(path, sandbox) {
} }




(function() {


(function(){ var Assert = YUITest.Assert,

var Assert = YUITest.Assert,
suite = new YUITest.TestSuite("General Tests for CLI"), suite = new YUITest.TestSuite("General Tests for CLI"),
apiStub = require("../tests/cli/assets/apiStub.js"), apiStub = require("../tests/cli/assets/apiStub.js"),
data = require("../tests/cli/assets/data.js"), data = require("../tests/cli/assets/data.js"),
suites = data.suites, suites = data.suites,
suiteix, suiteix,
sandbox = { sandbox = {
CSSLint: CSSLint CSSLint: CSSLint
Expand All @@ -35,8 +34,7 @@ function include(path, sandbox) {
name: "Test " + suiteix, name: "Test " + suiteix,


"Outcome logs should match expected": function (){ "Outcome logs should match expected": function (){
var var it = suites[suiteix],
it = suites[suiteix],
expecting = it.expecting, expecting = it.expecting,
expectingLen = expecting.length, expectingLen = expecting.length,
outcome, outcome,
Expand Down

0 comments on commit 2701b88

Please sign in to comment.