Skip to content

Commit

Permalink
Add eslint linting
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyruppel committed May 7, 2016
1 parent 18f3dbe commit cb68f29
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 8 deletions.
12 changes: 12 additions & 0 deletions .eslintrc.js
@@ -0,0 +1,12 @@
module.exports = {

extends: 'eslint:recommended',

env: {
node: true
},

rules: {
}

};
2 changes: 2 additions & 0 deletions .travis.yml
Expand Up @@ -4,6 +4,8 @@ node_js:
- '4.0'
- '0.12'
- '0.10'
before_script:
- npm run lint
deploy:
provider: npm
email: jeremy.ruppel@gmail.com
Expand Down
2 changes: 2 additions & 0 deletions cli.js
Expand Up @@ -3,6 +3,8 @@
// Copyright 2016 Yahoo Inc.
// Licensed under the terms of the MIT license. Please see LICENSE file in the project root for terms.

/* eslint no-console:"off" */

var http = require('http');
var path = require('path');
var PORT = 3000;
Expand Down
3 changes: 2 additions & 1 deletion hook.sh
Expand Up @@ -2,6 +2,7 @@

set -ex

npm test
npm run lint
npm run test

node package.json
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -32,7 +32,7 @@ module.exports = function (host, opts) {

return Promise.try(function () {
return require.resolve(file);
}).catch(ModuleNotFoundError, function (err) {
}).catch(ModuleNotFoundError, function (/* err */) {
return proxy(req, body, host).then(function (res) {
return record(res.req, res, file);
});
Expand Down
2 changes: 1 addition & 1 deletion lib/proxy.js
Expand Up @@ -23,7 +23,7 @@ var mods = { 'http:': http, 'https:': https };
*/

module.exports = function proxy(req, body, host) {
return new Promise(function (resolve, reject) {
return new Promise(function (resolve /*, reject */) {
var uri = url.parse(host);
var mod = mods[uri.protocol] || http;
var preq = mod.request({
Expand Down
2 changes: 2 additions & 0 deletions package.json
Expand Up @@ -4,6 +4,7 @@
"description": "Record and playback HTTP responses",
"main": "index.js",
"scripts": {
"lint": "eslint cli.js index.js lib test",
"test": "mocha"
},
"keywords": [
Expand All @@ -23,6 +24,7 @@
"author": "Jeremy Ruppel",
"license": "MIT",
"devDependencies": {
"eslint": "^2.9.0",
"mocha": "~2.3.4",
"os-tmpdir": "^1.0.1",
"rimraf": "^2.5.2",
Expand Down
2 changes: 2 additions & 0 deletions test/buffer.js
@@ -1,6 +1,8 @@
// Copyright 2016 Yahoo Inc.
// Licensed under the terms of the MIT license. Please see LICENSE file in the project root for terms.

/* eslint-env mocha */

var subject = require('../lib/buffer');
var stream = require('stream');
var assert = require('assert');
Expand Down
1 change: 0 additions & 1 deletion test/fixtures/index.js
Expand Up @@ -15,7 +15,6 @@ function read(file) {
*/

if (semver.gte(process.version, '1.5.0')) {
console
module.exports = read('v1.5.0');
} else {
module.exports = read('v0.10.x');
Expand Down
4 changes: 1 addition & 3 deletions test/helpers/server.js
Expand Up @@ -17,9 +17,7 @@ module.exports = function createServer(done) {
res.setHeader('Content-Type', 'text/html');
res.setHeader('Date', 'Sat, 26 Oct 1985 08:20:00 GMT');

req.on('data', function (data) {
// consume the request body, if any
});
req.resume(); // consume the request body, if any

req.on('end', function () {
res.end('OK');
Expand Down
2 changes: 2 additions & 0 deletions test/proxy.js
@@ -1,6 +1,8 @@
// Copyright 2016 Yahoo Inc.
// Licensed under the terms of the MIT license. Please see LICENSE file in the project root for terms.

/* eslint-env mocha */

var subject = require('../lib/proxy');
var createServer = require('./helpers/server');
var assert = require('assert');
Expand Down
4 changes: 3 additions & 1 deletion test/record.js
@@ -1,6 +1,8 @@
// Copyright 2016 Yahoo Inc.
// Licensed under the terms of the MIT license. Please see LICENSE file in the project root for terms.

/* eslint-env mocha */

var subject = require('../lib/record');
var createServer = require('./helpers/server');
var createTmpdir = require('./helpers/tmpdir');
Expand Down Expand Up @@ -32,7 +34,7 @@ describe('record', function () {
beforeEach(function () {
req = http.request({
host: server.addr,
port: server.port,
port: server.port
});
req.setHeader('User-Agent', 'My User Agent/1.0')
req.setHeader('Connection', 'close');
Expand Down
2 changes: 2 additions & 0 deletions test/yakbak.js
@@ -1,6 +1,8 @@
// Copyright 2016 Yahoo Inc.
// Licensed under the terms of the MIT license. Please see LICENSE file in the project root for terms.

/* eslint-env mocha */

var subject = require('..');
var createServer = require('./helpers/server');
var createTmpdir = require('./helpers/tmpdir');
Expand Down

0 comments on commit cb68f29

Please sign in to comment.