Skip to content

Commit a72be47

Browse files
committed
cleanup
1 parent 9455446 commit a72be47

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ var loadConfigFile = require('jscs/lib/cli-config');
66
var assign = require('object-assign');
77

88
module.exports = function (options) {
9-
if (!options) {
10-
options = './.jscsrc';
11-
}
9+
options = options || '.jscsrc';
10+
1211
if (typeof options === 'string') {
1312
options = {configPath: options};
1413
}
14+
1515
options = assign({esnext: false}, options);
1616

1717
var out = [];
@@ -27,6 +27,7 @@ module.exports = function (options) {
2727
if (Object.keys(options).length) {
2828
throw new Error('configPath option is not compatible with code style options');
2929
}
30+
3031
checker.configure(loadConfigFile.load(configPath));
3132
} else {
3233
checker.configure(options);

readme.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# [gulp](http://gulpjs.com)-jscs [![Build Status](https://travis-ci.org/jscs-dev/gulp-jscs.svg?branch=master)](https://travis-ci.org/jscs-dev/gulp-jscs)
1+
# gulp-jscs [![Build Status](https://travis-ci.org/jscs-dev/gulp-jscs.svg?branch=master)](https://travis-ci.org/jscs-dev/gulp-jscs)
22

33
> Check JavaScript code style with [jscs](https://github.com/jscs-dev/node-jscs)
44
@@ -29,25 +29,20 @@ gulp.task('default', function () {
2929

3030
## API
3131

32-
### jscs(configPath | options)
33-
34-
#### configPath
35-
36-
Type: `string`
37-
Default: `'./.jscsrc'`
38-
39-
Path to the [.jscsrc](https://github.com/jscs-dev/node-jscs#configuration).
32+
### jscs(options)
4033

4134
#### options
4235

4336
Type: `object`
4437

4538
See the jscs [options](https://github.com/jscs-dev/node-jscs#options).
46-
You may instead set a `configPath: 'path/to/.jscsrc'` option.
39+
40+
Alternatively you can set the `configPath` *(default: `'.jscsrc'`)* option to the path of a [.jscsrc](https://github.com/jscs-dev/node-jscs#configuration) file.
4741

4842
Set `esnext: true` if you want your code to be parsed as ES6 using the harmony
4943
version of the esprima parser.
5044

45+
5146
## License
5247

5348
MIT © [Sindre Sorhus](http://sindresorhus.com)

test.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ it('should check code style of JS files', function (cb) {
3131
it('should check code style of JS files using a preset', function (cb) {
3232
var stream = jscs({preset: 'google'});
3333

34-
stream.on('error', function (err) {
34+
stream.once('error', function (err) {
3535
if (/Missing line feed at file end/.test(err)) {
3636
assert(true);
3737
cb();
@@ -92,7 +92,7 @@ it('should accept both esnext and configPath options', function(cb) {
9292
configPath: '.jscsrc'
9393
});
9494

95-
stream.on('error', function (err) {
95+
stream.once('error', function (err) {
9696
assert(!/Unexpected reserved word/.test(err) && /Multiple var declaration/.test(err));
9797
cb();
9898
});
@@ -106,8 +106,11 @@ it('should accept both esnext and configPath options', function(cb) {
106106
stream.end();
107107
});
108108

109-
it('should throw when passing both configPath and code style options', function() {
110-
assert.throws(jscs.bind(null, {configPath: '.jscsrc', preset: 'airbnb'}), /configPath/);
109+
it('should throw when passing both configPath and code style options', function () {
110+
assert.throws(jscs.bind(null, {
111+
configPath: '.jscsrc',
112+
preset: 'airbnb'
113+
}), /configPath/);
111114
});
112115

113116
it('should not mutate the options object passed as argument', function () {

0 commit comments

Comments
 (0)