diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..eb485b7 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,10 @@ +module.exports = { + "env": { + "node": true, + "commonjs": true + }, + "extends": "eslint:recommended", + "rules": { + "no-console": 0 + } +}; diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index f993d36..0000000 --- a/.jshintrc +++ /dev/null @@ -1,15 +0,0 @@ -{ - "curly": true, - "eqeqeq": true, - "forin": true, - "immed": true, - "latedef": true, - "newcap": true, - "noarg": true, - "noempty": true, - "undef": true, - "trailing": true, - "node": true, - "nomen": false, - "plusplus": false -} diff --git a/lib/asn1ber.js b/lib/asn1ber.js index 80dd37b..29e790a 100644 --- a/lib/asn1ber.js +++ b/lib/asn1ber.js @@ -262,7 +262,7 @@ exports.encodeSequence = function (contents) { // Encode an OctetString, which is a wrapper of type `04`. exports.encodeOctetString = function (string) { - var buf, contents; + var contents; if (typeof string === 'string') { contents = new Buffer(string); @@ -340,7 +340,7 @@ exports.encodeRequest = function (type, contents) { // Parse and return type, data length and header length. function typeAndLength(buf) { - var res, len, i; + var res, i; res = { type: buf[0], len: 0, header: 1 }; if (buf[1] < 128) { @@ -453,13 +453,12 @@ exports.parseOid = function (buf) { // This is for example an IpAddress. exports.parseArray = function (buf) { - var i, nelem, array; + var i, array; if (buf[0] !== T.IpAddress) { throw new Error('Buffer does not appear to be an array type.'); } - nelem = buf[1]; array = []; for (i = 0; i < buf[1]; i++) { diff --git a/lib/snmp.js b/lib/snmp.js index 9bcdd10..36f879e 100644 --- a/lib/snmp.js +++ b/lib/snmp.js @@ -85,8 +85,6 @@ function concatBuffers(buffers) { // Clear a pending packet when it times out or is successfully received. function clearRequest(reqs, reqid) { - var self = this; - var entry = reqs[reqid]; if (entry) { if (entry.timeout) { @@ -132,7 +130,7 @@ function parseOids(options) { // Update targ with attributes from _defs. // Any existing attributes on targ are untouched. -function defaults(targ, _defs) { +function defaults(targ) { [].slice.call(arguments, 1).forEach(function (def) { Object.keys(def).forEach(function (key) { if (!targ.hasOwnProperty(key)) { @@ -213,7 +211,7 @@ exports.encode = encode; // make us blow up. function parse(buf) { - var pkt, oid, bvb, vb, hdr, vbhdr; + var pkt, bvb, vb, hdr; pkt = new Packet(); @@ -571,7 +569,7 @@ Session.prototype.sendMsg = function (pkt, options, callback) { } // Send the message. - self.socket.send(buf, 0, buf.length, options.port, options.host, function (err, bytes) { + self.socket.send(buf, 0, buf.length, options.port, options.host, function (err) { var entry = self.reqs[reqid]; if (err) { @@ -659,7 +657,7 @@ Session.prototype.getAll = function (options, callback) { } function getOne(c) { - var oid, pkt, m, vb; + var pkt, m, vb; pkt = new Packet(); pkt.community = options.community; diff --git a/package.json b/package.json index c14b67e..f9042ab 100644 --- a/package.json +++ b/package.json @@ -15,15 +15,15 @@ "main": "lib/snmp.js", "scripts": { "test": "NODE_PATH=lib mocha -R spec", - "hint": "jshint *.js lib/*.js", + "lint": "eslint lib", "doc": "docco lib/* example.js 2>/dev/null", "cov": "jscoverage lib lib-cov && EXPRESS_COV=1 NODE_PATH=lib-cov mocha -R html-cov > docs/coverage.html" }, "dependencies": {}, "devDependencies": { "docco": "~0.6.2", + "eslint": "^3.13.1", "jscoverage": "~0.3.6", - "jshint": "~1.1.0", "mocha": "~1.9.0", "should": "~1.2.2", "snmpjs": "~0.1.3"