Skip to content

Commit 629897b

Browse files
committed
1 parent 843c413 commit 629897b

File tree

5 files changed

+33
-38
lines changed

5 files changed

+33
-38
lines changed

.jshintrc

Lines changed: 0 additions & 12 deletions
This file was deleted.

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module.exports = function (options) {
1616

1717
options = assign({esnext: false}, options);
1818

19-
var checker = new Checker({esnext: !!options.esnext});
19+
var checker = new Checker({esnext: Boolean(options.esnext)});
2020

2121
checker.registerDefaultRules();
2222

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
},
1515
"scripts": {
1616
"pretest": "jscs *.js reporters",
17-
"test": "mocha"
17+
"test": "xo && mocha"
1818
},
1919
"files": [
2020
"index.js"
@@ -43,5 +43,6 @@
4343
"devDependencies": {
4444
"mocha": "*",
4545
"stream-assert": "^2.0.2",
46+
"xo": "*"
4647
}
4748
}

reporters/loadReporter.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ var getReporter = require('jscs/lib/cli-config').getReporter;
33

44
module.exports = function (reporter) {
55
// we want the function
6-
if (typeof reporter === 'function') return reporter;
6+
if (typeof reporter === 'function') {
7+
return reporter;
8+
}
79

810
// load JSCS built-in or absolute path or module reporters
911
return getReporter(reporter).writer;

test.js

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1+
/* eslint-env mocha */
12
'use strict';
3+
var path = require('path');
24
var assert = require('assert');
35
var gutil = require('gulp-util');
4-
var jscs = require('./');
56
var streamAssert = require('stream-assert');
7+
var jscs = require('./');
68

79
var stdoutWrite = process.stdout.write;
810
var stdoutStub;
911

1012
function stubStdout() {
1113
stdoutStub = '';
12-
process.stdout.write = function(str) {
14+
process.stdout.write = function (str) {
1315
stdoutStub += str;
1416
};
1517
}
@@ -37,13 +39,13 @@ it('should check code style of JS files', function (cb) {
3739

3840
stream.write(new gutil.File({
3941
base: __dirname,
40-
path: __dirname + '/fixture.js',
42+
path: path.join(__dirname, 'fixture.js'),
4143
contents: new Buffer('var x = 1,y = 2;')
4244
}));
4345

4446
stream.write(new gutil.File({
4547
base: __dirname,
46-
path: __dirname + '/fixture2.js',
48+
path: path.join(__dirname, 'fixture2.js'),
4749
contents: new Buffer('var x = { a: 1 };')
4850
}));
4951

@@ -62,7 +64,7 @@ it('should check code style of JS files using a preset', function (cb) {
6264

6365
stream.write(new gutil.File({
6466
base: __dirname,
65-
path: __dirname + '/fixture.js',
67+
path: path.join(__dirname, 'fixture.js'),
6668
contents: new Buffer('var x = 1,y = 2;')
6769
}));
6870

@@ -77,7 +79,7 @@ it('should pass valid files', function (cb) {
7779
}).on('end', cb).resume();
7880

7981
stream.write(new gutil.File({
80-
path: __dirname + '/fixture.js',
82+
path: path.join(__dirname, 'fixture.js'),
8183
contents: new Buffer('var x = 1; var y = 2;')
8284
}));
8385

@@ -93,14 +95,14 @@ it('should respect "excludeFiles" from config', function (cb) {
9395

9496
stream.write(new gutil.File({
9597
base: __dirname,
96-
path: __dirname + '/excluded.js',
98+
path: path.join(__dirname, 'excluded.js'),
9799
contents: new Buffer('var x = { a: 1 };')
98100
}));
99101

100102
stream.end();
101103
});
102104

103-
it('should accept both esnext and configPath options', function(cb) {
105+
it('should accept both esnext and configPath options', function (cb) {
104106
var stream = jscs({
105107
esnext: true,
106108
configPath: '.jscsrc'
@@ -116,16 +118,14 @@ it('should accept both esnext and configPath options', function(cb) {
116118

117119
stream.write(new gutil.File({
118120
base: __dirname,
119-
path: __dirname + '/fixture.js',
121+
path: path.join(__dirname, 'fixture.js'),
120122
contents: new Buffer('import x from \'x\'; var x = 1, y = 2;')
121123
}));
122124

123125
stream.end();
124126
});
125127

126128
it('should accept the fix option', function (cb) {
127-
var data = '';
128-
129129
var stream = jscs({
130130
fix: true,
131131
configPath: '.jscsrc'
@@ -139,7 +139,7 @@ it('should accept the fix option', function (cb) {
139139

140140
stream.write(new gutil.File({
141141
base: __dirname,
142-
path: __dirname + '/fixture.js',
142+
path: path.join(__dirname, 'fixture.js'),
143143
contents: new Buffer('var x = { a: 1, b: 2 }')
144144
}));
145145

@@ -164,15 +164,15 @@ describe('Reporter', function () {
164164
stubStdout();
165165
var stream = jscs();
166166

167-
stream.pipe(jscs.reporter()).on('end', function (err) {
167+
stream.pipe(jscs.reporter()).on('end', function () {
168168
assert(/Multiple var declaration[^]*---\^/.test(stdoutStub));
169169
teardown();
170170
cb();
171171
}).resume();
172172

173173
stream.write(new gutil.File({
174174
base: __dirname,
175-
path: __dirname + '/fixture.js',
175+
path: path.join(__dirname, 'fixture.js'),
176176
contents: new Buffer('var x = 1,y = 2;')
177177
}));
178178

@@ -183,15 +183,15 @@ describe('Reporter', function () {
183183
stubStdout();
184184
var stream = jscs();
185185

186-
stream.pipe(jscs.reporter('inlinesingle')).on('end', function (err) {
186+
stream.pipe(jscs.reporter('inlinesingle')).on('end', function () {
187187
assert(/line 1, col 0, Multiple var declaration/.test(stdoutStub));
188188
teardown();
189189
cb();
190190
}).resume();
191191

192192
stream.write(new gutil.File({
193193
base: __dirname,
194-
path: __dirname + '/fixture.js',
194+
path: path.join(__dirname, 'fixture.js'),
195195
contents: new Buffer('var x = 1,y = 2;')
196196
}));
197197

@@ -210,7 +210,7 @@ describe('Reporter', function () {
210210

211211
stream.write(new gutil.File({
212212
base: __dirname,
213-
path: __dirname + '/fixture.js',
213+
path: path.join(__dirname, 'fixture.js'),
214214
contents: new Buffer('var x = 1,y = 2;')
215215
}));
216216

@@ -236,20 +236,24 @@ describe('Reporter', function () {
236236
assert(file.jscs.success);
237237
}))
238238
.pipe(streamAssert.end(function (err) {
239-
if (err) return cb(err);
239+
if (err) {
240+
cb(err);
241+
return;
242+
}
243+
240244
assert(passedErrorAssertion, 'Did not emit an error');
241245
cb();
242246
}));
243247

244248
stream.write(new gutil.File({
245249
base: __dirname,
246-
path: __dirname + '/fixture.js',
250+
path: path.join(__dirname, 'fixture.js'),
247251
contents: new Buffer('var x = 1,y = 2;')
248252
}));
249253

250254
stream.write(new gutil.File({
251255
base: __dirname,
252-
path: __dirname + '/passing.js',
256+
path: path.join(__dirname, 'passing.js'),
253257
contents: new Buffer('var x = 1; var y = 2;')
254258
}));
255259

@@ -265,20 +269,20 @@ describe('Reporter', function () {
265269
assert(err instanceof Error && /JSCS/.test(err.message));
266270
cb();
267271
})
268-
.pipe(streamAssert.second(function (file) {
272+
.pipe(streamAssert.second(function () {
269273
cb(new Error('Did not emit an error immediately'));
270274
}))
271275
.pipe(streamAssert.end());
272276

273277
stream.write(new gutil.File({
274278
base: __dirname,
275-
path: __dirname + '/fixture.js',
279+
path: path.join(__dirname, 'fixture.js'),
276280
contents: new Buffer('var x = 1,y = 2;')
277281
}));
278282

279283
stream.write(new gutil.File({
280284
base: __dirname,
281-
path: __dirname + '/passing.js',
285+
path: path.join(__dirname, 'passing.js'),
282286
contents: new Buffer('var x = 1; var y = 2;')
283287
}));
284288

0 commit comments

Comments
 (0)