Skip to content
This repository was archived by the owner on Dec 29, 2020. It is now read-only.

Commit 0c86a48

Browse files
committed
Use new "Checker#execute" method
Which is introduced in 2.4.0 Fixes #96 Fixes #95 Closes gh-97
1 parent 6011f05 commit 0c86a48

File tree

6 files changed

+18
-53
lines changed

6 files changed

+18
-53
lines changed

.jscsrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"preset": "jquery"
2+
"preset": "jquery"
33
}

README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,12 @@ jscs: {
4747
config: ".jscsrc",
4848
esnext: true, // If you use ES6 http://jscs.info/overview.html#esnext
4949
verbose: true, // If you need output with rule names http://jscs.info/overview.html#verbose
50+
fix: true, // Autofix code style violations when possible.
5051
requireCurlyBraces: [ "if" ]
5152
}
5253
}
5354
```
5455

55-
#### fix
56-
Type: `Boolean`
57-
Default value: `false`
58-
59-
Auto-fix code style violations when possible.
60-
6156
#### force
6257
Type: `Boolean`
6358
Default value: `false`

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
},
1515
"dependencies": {
1616
"hooker": "~0.2.3",
17-
"jscs": "~2.1.0",
17+
"jscs": "~2.4.0",
1818
"lodash": "~3.10.0",
1919
"vow": "~0.4.1"
2020
},

tasks/jscs.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@ module.exports = function( grunt ) {
1313

1414
// `null` is a default value, but its equivalent to `true`,
1515
// With this way it's easy to distinguish specified value
16-
config: null,
17-
18-
fix: false
16+
config: null
1917
} ),
2018

2119
jscs = new JSCS( options ),
22-
checks = this.filesSrc.map( options.fix ? jscs.fix : jscs.check, jscs );
20+
runs = this.filesSrc.map( jscs.checker.execute, jscs.checker );
2321

24-
Vow.allResolved( checks ).spread( function() {
22+
Vow.allResolved( runs ).spread( function() {
2523
var results = [];
2624

2725
// Filter unsuccessful promises

tasks/lib/jscs.js

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ var Checker = require( "jscs" ),
99
exports.init = function( grunt ) {
1010

1111
// Task specific options
12-
var taskOptions = [ "config", "force", "reporter", "reporterOutput", "fix" ];
12+
var taskOptions = [ "config", "force", "reporter", "reporterOutput" ];
1313

1414
/**
1515
* @see jQuery.isEmptyObject
@@ -58,29 +58,16 @@ exports.init = function( grunt ) {
5858
}
5959

6060
/**
61-
* @see Checker#checkPath
61+
* @see Checker#execute
6262
*/
63-
JSCS.prototype.check = function( path ) {
64-
var checkPath = this.checker.checkPath( path );
63+
JSCS.prototype.execute = function( path ) {
64+
var run = this.checker.execute( path );
6565

66-
checkPath.fail( function( error ) {
66+
run.fail( function( error ) {
6767
grunt.warn( error );
6868
} );
6969

70-
return checkPath;
71-
};
72-
73-
/**
74-
* @see Checker#fixPath
75-
*/
76-
JSCS.prototype.fix = function( path ) {
77-
var fixPath = this.checker.fixPath( path );
78-
79-
fixPath.fail( function( error ) {
80-
grunt.warn( error );
81-
} );
82-
83-
return fixPath;
70+
return run;
8471
};
8572

8673
/**

test/methods.js

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module.exports = {
2626
config: "test/configs/fail.json"
2727
} );
2828

29-
fixture.check( "test/fixtures/fixture.js" ).then( function( collection ) {
29+
fixture.execute( "test/fixtures/fixture.js" ).then( function( collection ) {
3030
fixture.setErrors( errors = collection );
3131
done();
3232
} );
@@ -230,7 +230,7 @@ module.exports = {
230230
"requireCurlyBraces": [ "while" ]
231231
} );
232232

233-
jscs.check( "test/fixtures/fixture.js" ).then( function( errorsCollection ) {
233+
jscs.execute( "test/fixtures/fixture.js" ).then( function( errorsCollection ) {
234234

235235
// "grunt-contrib-nodeunit" package through which these tests are run,
236236
// Mutes grunt log actions so it wouldn't interfeare with tests output,
@@ -269,7 +269,7 @@ module.exports = {
269269
"excludeFiles": [ "test/fixtures/exclude.js" ]
270270
} );
271271

272-
jscs.check( "test/fixtures/exclude.js" ).then( function( errors ) {
272+
jscs.execute( "test/fixtures/exclude.js" ).then( function( errors ) {
273273
test.equal( jscs.setErrors( errors ).count(), 0,
274274
"should not find any errors in excluded file" );
275275
test.done();
@@ -283,7 +283,7 @@ module.exports = {
283283
config: "empty"
284284
} );
285285

286-
jscs.check( "test/fixtures/fixture.js" ).then( function( errorsCollection ) {
286+
jscs.execute( "test/fixtures/fixture.js" ).then( function( errorsCollection ) {
287287
errorsCollection.forEach( function( errors ) {
288288
errors.getErrorList().forEach( function( error ) {
289289
test.equal( error.message, "test", "should add additional rule" );
@@ -300,7 +300,7 @@ module.exports = {
300300
reporterOutput: "test.xml"
301301
} );
302302

303-
jscs.check( "test/fixtures/fixture.js" ).then( function( errorsCollection ) {
303+
jscs.execute( "test/fixtures/fixture.js" ).then( function( errorsCollection ) {
304304
jscs.setErrors( errorsCollection ).report();
305305

306306
test.ok( grunt.file.exists( "test.xml" ), "test.xml should exist" );
@@ -317,7 +317,7 @@ module.exports = {
317317
"requireCurlyBraces": [ "while" ]
318318
} );
319319

320-
jscs.check( "test/fixtures/broken.js" ).then( function( errorsCollection ) {
320+
jscs.execute( "test/fixtures/broken.js" ).then( function( errorsCollection ) {
321321
errorsCollection.forEach( function( errors ) {
322322
test.equal(
323323
errors.getErrorList()[ 0 ].message,
@@ -328,20 +328,5 @@ module.exports = {
328328
test.done();
329329
} );
330330
} ).fail( test.done );
331-
},
332-
333-
"#fix send it's path to the jscs checker": function( test ) {
334-
var jscs = new JSCS( {} );
335-
336-
hooker.hook( jscs.checker, "fixPath", function( path ) {
337-
test.equal( path, "path" );
338-
test.done();
339-
340-
return hooker.override( {
341-
fail: function() {}
342-
} );
343-
} );
344-
345-
jscs.fix( "path" );
346331
}
347332
};

0 commit comments

Comments
 (0)