Skip to content

Commit a2be0d6

Browse files
pdehaanphated
authored andcommitted
ESLint and JSCS plus fixup
1 parent 24119a8 commit a2be0d6

23 files changed

+383
-358
lines changed

.eslintrc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "gulp",
3+
4+
"rules": {
5+
"max-statements": 0
6+
}
7+
}

.jscsrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"preset": "gulp"
3+
}

.jshintrc

-19
This file was deleted.

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
module.exports = {
44
src: require('./lib/src'),
55
dest: require('./lib/dest'),
6-
symlink: require('./lib/symlink')
6+
symlink: require('./lib/symlink'),
77
};

lib/dest/writeContents/index.js

+11-12
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,27 @@ var writeBuffer = require('./writeBuffer');
77
var writeSymbolicLink = require('./writeSymbolicLink');
88

99
function writeContents(writePath, file, cb) {
10-
// if directory then mkdirp it
10+
// If directory then mkdirp it
1111
if (file.isDirectory()) {
1212
return writeDir(writePath, file, written);
1313
}
1414

15-
// stream it to disk yo
15+
// Stream it to disk yo
1616
if (file.isStream()) {
1717
return writeStream(writePath, file, written);
1818
}
1919

20-
// write it as a symlink
20+
// Write it as a symlink
2121
if (file.symlink) {
2222
return writeSymbolicLink(writePath, file, written);
2323
}
2424

25-
// write it like normal
25+
// Write it like normal
2626
if (file.isBuffer()) {
2727
return writeBuffer(writePath, file, written);
2828
}
2929

30-
// if no contents then do nothing
30+
// If no contents then do nothing
3131
if (file.isNull()) {
3232
return complete();
3333
}
@@ -60,17 +60,16 @@ function writeContents(writePath, file, cb) {
6060
}
6161

6262
function isErrorFatal(err) {
63+
var isFatal = true;
6364
if (!err) {
64-
return false;
65-
}
66-
67-
// Handle scenario for file overwrite failures.
68-
else if (err.code === 'EEXIST' && file.flag === 'wx') {
69-
return false; // "These aren't the droids you're looking for"
65+
isFatal = false;
66+
} else if (err.code === 'EEXIST' && file.flag === 'wx') {
67+
// Handle scenario for file overwrite failures.
68+
isFatal = false; // "These aren't the droids you're looking for"
7069
}
7170

7271
// Otherwise, this is a fatal error
73-
return true;
72+
return isFatal;
7473
}
7574
}
7675

lib/dest/writeContents/writeBuffer.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,13 @@ function writeBuffer(writePath, file, cb) {
1919
futimes(fd, stat, complete);
2020
});
2121

22-
// cleanup
22+
// Cleanup
2323
function complete(err1) {
2424
fs.close(fd, function(err2) {
2525
cb(err1 || err2);
2626
});
2727
}
2828
});
29-
3029
}
3130

3231
module.exports = writeBuffer;

lib/dest/writeContents/writeStream.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ function writeStream(writePath, file, cb) {
1010
var outStream;
1111
var outFD;
1212

13-
fs.open(writePath, 'w', file.stat.mode, function (err, fd) {
13+
fs.open(writePath, 'w', file.stat.mode, function(err, fd) {
1414
if (err) {
1515
cb(err);
1616
}
1717

1818
outFD = fd;
19-
outStream = fs.createWriteStream(null, {fd: fd});
19+
outStream = fs.createWriteStream(null, { fd: fd });
2020

2121
file.contents.once('error', complete);
2222
file.contents.once('end', readStreamEnd);
@@ -26,7 +26,7 @@ function writeStream(writePath, file, cb) {
2626
// Streams are piped with end disabled, this prevents the
2727
// WriteStream from closing the file descriptor after all
2828
// data is written.
29-
file.contents.pipe(outStream, {end: false});
29+
file.contents.pipe(outStream, { end: false });
3030
});
3131

3232
function readStreamEnd() {
@@ -35,7 +35,7 @@ function writeStream(writePath, file, cb) {
3535
return complete(error);
3636
}
3737

38-
futimes(outFD, stat, function (error) {
38+
futimes(outFD, stat, function(error) {
3939
if (error) {
4040
return complete(error);
4141
}
@@ -46,7 +46,7 @@ function writeStream(writePath, file, cb) {
4646
});
4747
}
4848

49-
// cleanup
49+
// Cleanup
5050
function complete(err) {
5151
file.contents.removeListener('error', complete);
5252
file.contents.removeListener('end', readStreamEnd);

lib/dest/writeContents/writeSymbolicLink.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
var fs = require('graceful-fs');
44

55
function writeSymbolicLink(writePath, file, cb) {
6-
fs.symlink(file.symlink, writePath, function (err) {
6+
fs.symlink(file.symlink, writePath, function(err) {
77
if (err && err.code !== 'EEXIST') {
88
return cb(err);
99
}

lib/filterSince.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = function(d) {
1010
if (!isValid) {
1111
throw new Error('expected since option to be a date or a number');
1212
}
13-
return filter.obj(function(file){
13+
return filter.obj(function(file) {
1414
return file.stat && file.stat.mtime > d;
1515
});
16-
};
16+
};

lib/prepareWrite.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function prepareWrite(outFolder, file, opt, cb) {
2626
cwd: process.cwd(),
2727
mode: (file.stat ? file.stat.mode : null),
2828
dirMode: null,
29-
overwrite: true
29+
overwrite: true,
3030
}, opt);
3131
var overwrite = booleanOrFunc(options.overwrite, file);
3232
options.flag = (overwrite ? 'w' : 'wx');
@@ -45,16 +45,16 @@ function prepareWrite(outFolder, file, opt, cb) {
4545
var writePath = path.resolve(basePath, file.relative);
4646
var writeFolder = path.dirname(writePath);
4747

48-
// wire up new properties
48+
// Wire up new properties
4949
file.stat = (file.stat || new fs.Stats());
5050
file.stat.mode = options.mode;
5151
file.flag = options.flag;
5252
file.cwd = cwd;
5353
file.base = basePath;
5454
file.path = writePath;
5555

56-
// mkdirp the folder the file is going in
57-
mkdirp(writeFolder, options.dirMode, function(err){
56+
// Mkdirp the folder the file is going in
57+
mkdirp(writeFolder, options.dirMode, function(err) {
5858
if (err) {
5959
return cb(err);
6060
}

lib/sink.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ var Writable = require('readable-stream/writable');
55
function sink(stream) {
66
var sinkStream = new Writable({
77
objectMode: true,
8-
write: function(file, enc, cb) { cb(); }
8+
write: function(file, enc, cb) {
9+
cb();
10+
},
911
});
1012

1113
return function() {

lib/src/getContents/bufferFile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function bufferFile(file, opt, cb) {
99
return cb(err);
1010
}
1111

12-
if (opt.stripBOM){
12+
if (opt.stripBOM) {
1313
file.contents = stripBom(data);
1414
} else {
1515
file.contents = data;

lib/src/getContents/index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@ var streamFile = require('./streamFile');
88

99
function getContents(opt) {
1010
return through2.obj(opt, function(file, enc, cb) {
11-
// don't fail to read a directory
11+
// Don't fail to read a directory
1212
if (file.isDirectory()) {
1313
return readDir(file, opt, cb);
1414
}
1515

16-
// process symbolic links included with `followSymlinks` option
16+
// Process symbolic links included with `followSymlinks` option
1717
if (file.stat && file.stat.isSymbolicLink()) {
1818
return readSymbolicLink(file, opt, cb);
1919
}
2020

21-
// read and pass full contents
21+
// Read and pass full contents
2222
if (opt.buffer !== false) {
2323
return bufferFile(file, opt, cb);
2424
}
2525

26-
// dont buffer anything - just pass streams
26+
// Don't buffer anything - just pass streams
2727
return streamFile(file, opt, cb);
2828
});
2929
}

lib/src/getContents/readDir.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
function readDir(file, opt, cb) {
4-
// do nothing for now
4+
// Do nothing for now
55
cb(null, file);
66
}
77

lib/src/getContents/readSymbolicLink.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
var fs = require('graceful-fs');
44

55
function readLink(file, opt, cb) {
6-
fs.readlink(file.path, function (err, target) {
6+
fs.readlink(file.path, function(err, target) {
77
if (err) {
88
return cb(err);
99
}
1010

11-
// store the link target path
11+
// Store the link target path
1212
file.symlink = target;
1313

1414
return cb(null, file);

lib/src/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function src(glob, opt) {
2424
stripBOM: true,
2525
sourcemaps: false,
2626
passthrough: false,
27-
followSymlinks: true
27+
followSymlinks: true,
2828
}, opt);
2929

3030
var inputPass;
@@ -55,7 +55,7 @@ function src(glob, opt) {
5555
}
5656
if (options.sourcemaps === true) {
5757
outputStream = outputStream
58-
.pipe(sourcemaps.init({loadMaps: true}));
58+
.pipe(sourcemaps.init({ loadMaps: true }));
5959
}
6060
globStream.on('error', outputStream.emit.bind(outputStream, 'error'));
6161
return outputStream;

lib/src/resolveSymlinks.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ var path = require('path');
66

77
function resolveSymlinks(options) {
88

9-
// a stat property is exposed on file objects as a (wanted) side effect
9+
// A stat property is exposed on file objects as a (wanted) side effect
1010
function resolveFile(globFile, enc, cb) {
11-
fs.lstat(globFile.path, function (err, stat) {
11+
fs.lstat(globFile.path, function(err, stat) {
1212
if (err) {
1313
return cb(err);
1414
}
@@ -19,15 +19,15 @@ function resolveSymlinks(options) {
1919
return cb(null, globFile);
2020
}
2121

22-
fs.realpath(globFile.path, function (err, filePath) {
22+
fs.realpath(globFile.path, function(err, filePath) {
2323
if (err) {
2424
return cb(err);
2525
}
2626

2727
globFile.base = path.dirname(filePath);
2828
globFile.path = filePath;
2929

30-
// recurse to get real file stat
30+
// Recurse to get real file stat
3131
resolveFile(globFile, enc, cb);
3232
});
3333
});

package.json

+6-2
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,21 @@
2929
"devDependencies": {
3030
"buffer-equal": "^0.0.1",
3131
"del": "^2.2.0",
32+
"eslint": "^1.10.3",
33+
"eslint-config-gulp": "^2.0.0",
3234
"istanbul": "^0.3.0",
3335
"istanbul-coveralls": "^1.0.1",
34-
"jshint": "^2.4.1",
36+
"jscs": "^2.4.0",
37+
"jscs-preset-gulp": "^1.0.0",
3538
"mocha": "^2.0.0",
3639
"mocha-lcov-reporter": "^1.0.0",
3740
"rimraf": "^2.2.5",
3841
"should": "^7.0.0",
3942
"sinon": "^1.10.3"
4043
},
4144
"scripts": {
42-
"test": "jshint lib && mocha",
45+
"lint": "eslint . && jscs index.js lib/ test/",
46+
"test": "npm run lint && mocha",
4347
"coveralls": "istanbul cover _mocha && istanbul-coveralls"
4448
},
4549
"engines": {

test/.eslintrc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "gulp/test",
3+
4+
"rules": {
5+
"max-statements": 0
6+
}
7+
}

0 commit comments

Comments
 (0)