From 625a0aa0a36f644d74e75fe943232457ebcfe164 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 3 Mar 2017 00:36:23 -0500 Subject: [PATCH] lint: use standard style --- .eslintignore | 2 ++ .eslintrc | 3 +++ .travis.yml | 1 + index.js | 6 +++--- package.json | 5 +++++ test/.eslintrc | 5 +++++ test/test.js | 8 ++++---- 7 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 .eslintignore create mode 100644 .eslintrc create mode 100644 test/.eslintrc diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..62562b7 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +coverage +node_modules diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..e3578aa --- /dev/null +++ b/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": "standard" +} diff --git a/.travis.yml b/.travis.yml index cdc3f33..8748792 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,6 +19,7 @@ before_install: - "test $TRAVIS_NODE_VERSION != '0.8' || npm install -g npm@1.2.8000" # Setup Node.js version-specific dependencies - "test $TRAVIS_NODE_VERSION != '0.8' || npm rm --save-dev istanbul" + - "test $(echo $TRAVIS_NODE_VERSION | cut -d. -f1) -ge 4 || npm rm --save-dev eslint eslint-config-standard eslint-plugin-promise eslint-plugin-standard" # Update Node.js modules - "test ! -d node_modules || npm prune" - "test ! -d node_modules || npm rebuild" diff --git a/index.js b/index.js index 6da2d26..223e41e 100644 --- a/index.js +++ b/index.js @@ -28,7 +28,7 @@ module.exports = destroy * @public */ -function destroy(stream) { +function destroy (stream) { if (stream instanceof ReadStream) { return destroyReadStream(stream) } @@ -51,7 +51,7 @@ function destroy(stream) { * @private */ -function destroyReadStream(stream) { +function destroyReadStream (stream) { stream.destroy() if (typeof stream.close === 'function') { @@ -67,7 +67,7 @@ function destroyReadStream(stream) { * @private */ -function onOpenClose() { +function onOpenClose () { if (typeof this.fd === 'number') { // actually close down the fd this.close() diff --git a/package.json b/package.json index 8637aa4..4b6702b 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,10 @@ "license": "MIT", "repository": "stream-utils/destroy", "devDependencies": { + "eslint": "3.16.1", + "eslint-config-standard": "7.0.0", + "eslint-plugin-promise": "3.5.0", + "eslint-plugin-standard": "2.1.1", "istanbul": "0.4.5", "mocha": "2.5.3" }, @@ -22,6 +26,7 @@ "npm": "1.2.8000 || >= 1.4.16" }, "scripts": { + "lint": "eslint .", "test": "mocha --reporter spec", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot" diff --git a/test/.eslintrc b/test/.eslintrc new file mode 100644 index 0000000..29c15b0 --- /dev/null +++ b/test/.eslintrc @@ -0,0 +1,5 @@ +{ + "env": { + "mocha": true + } +} diff --git a/test/test.js b/test/test.js index 7b40a27..cdb2763 100644 --- a/test/test.js +++ b/test/test.js @@ -28,18 +28,18 @@ describe('destroy', function () { var _open = fs.open var waitclose = false - function cleanup() { + function cleanup () { fs.close = _close fs.open = _open } - fs.close = function close() { + fs.close = function close () { _close.apply(this, arguments) cleanup() done() } - fs.open = function open() { + fs.open = function open () { waitclose = true _open.apply(this, arguments) } @@ -74,7 +74,7 @@ describe('destroy', function () { }) }) -function isdestroyed(stream) { +function isdestroyed (stream) { // readable for 0.8, destroyed for 0.10+ return stream.readable === false || stream.destroyed === true }