Skip to content

Commit 130eca3

Browse files
committed
Complete switch from JSHint to ESLint
Convert all the JSHint rules to the ESLint equivalents where possible. The no-undef rule in ESLint caught a few cases of undefined usages in the tests, so they were also fixed.
1 parent 1e186e4 commit 130eca3

10 files changed

+34
-39
lines changed

.eslintrc.json

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
11
{
2+
"root": true,
3+
"parserOptions": {
4+
"ecmaVersion": 6
5+
},
26
"env": {
3-
"es6": true
7+
"es6": true,
8+
"node": true
49
},
510
"rules": {
6-
"indent": [2,2]
11+
"comma-style": "error",
12+
"dot-notation": "error",
13+
"indent": ["error", 2],
14+
"no-control-regex": "error",
15+
"no-div-regex": "error",
16+
"no-eval": "error",
17+
"no-implied-eval": "error",
18+
"no-invalid-regexp": "error",
19+
"no-trailing-spaces": "error",
20+
"no-undef": "error",
21+
"no-unused-vars": "error"
722
}
8-
}
23+
}

.jshintrc

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

test/.eslintrc.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"env": {
3+
"mocha": true
4+
}
5+
}

test/async_sign.tests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ describe('signing a token asynchronously', function() {
1919
});
2020

2121
it('should work with empty options', function (done) {
22-
jwt.sign({abc: 1}, "secret", {}, function (err, res) {
22+
jwt.sign({abc: 1}, "secret", {}, function (err) {
2323
expect(err).to.be.null();
2424
done();
2525
});
2626
});
2727

2828
it('should work without options object at all', function (done) {
29-
jwt.sign({abc: 1}, "secret", function (err, res) {
29+
jwt.sign({abc: 1}, "secret", function (err) {
3030
expect(err).to.be.null();
3131
done();
3232
});

test/decoding.tests.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
var jwt = require('../index');
22
var expect = require('chai').expect;
3-
var atob = require('atob');
43

54
describe('decoding', function() {
65

test/invalid_exp.tests.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
var jwt = require('../index');
22
var expect = require('chai').expect;
3-
var assert = require('chai').assert;
43

54
describe('invalid expiration', function() {
65

76
it('should fail with string', function (done) {
87
var broken_token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOiIxMjMiLCJmb28iOiJhZGFzIn0.cDa81le-pnwJMcJi3o3PBwB7cTJMiXCkizIhxbXAKRg';
98

10-
jwt.verify(broken_token, '123', function (err, decoded) {
9+
jwt.verify(broken_token, '123', function (err) {
1110
expect(err.name).to.equal('JsonWebTokenError');
1211
done();
1312
});

test/issue_304.tests.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,35 @@ var expect = require('chai').expect;
44
describe('issue 304 - verifying values other than strings', function() {
55

66
it('should fail with numbers', function (done) {
7-
jwt.verify(123, 'foo', function (err, decoded) {
7+
jwt.verify(123, 'foo', function (err) {
88
expect(err.name).to.equal('JsonWebTokenError');
99
done();
1010
});
1111
});
1212

1313
it('should fail with objects', function (done) {
14-
jwt.verify({ foo: 'bar' }, 'biz', function (err, decoded) {
14+
jwt.verify({ foo: 'bar' }, 'biz', function (err) {
1515
expect(err.name).to.equal('JsonWebTokenError');
1616
done();
1717
});
1818
});
1919

2020
it('should fail with arrays', function (done) {
21-
jwt.verify(['foo'], 'bar', function (err, decoded) {
21+
jwt.verify(['foo'], 'bar', function (err) {
2222
expect(err.name).to.equal('JsonWebTokenError');
2323
done();
2424
});
2525
});
2626

2727
it('should fail with functions', function (done) {
28-
jwt.verify(function() {}, 'foo', function (err, decoded) {
28+
jwt.verify(function() {}, 'foo', function (err) {
2929
expect(err.name).to.equal('JsonWebTokenError');
3030
done();
3131
});
3232
});
3333

3434
it('should fail with booleans', function (done) {
35-
jwt.verify(true, 'foo', function (err, decoded) {
35+
jwt.verify(true, 'foo', function (err) {
3636
expect(err.name).to.equal('JsonWebTokenError');
3737
done();
3838
});

test/jwt.hs.tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ describe('HS256', function() {
102102

103103
it('should return the "invalid token" error', function(done) {
104104
var malformedToken = token + ' '; // corrupt the token by adding a space
105-
jwt.verify(malformedToken, secret, { algorithm: 'HS256', ignoreExpiration: true }, function(err, decoded) {
105+
jwt.verify(malformedToken, secret, { algorithm: 'HS256', ignoreExpiration: true }, function(err) {
106106
assert.isNotNull(err);
107107
assert.equal('JsonWebTokenError', err.name);
108108
assert.equal('invalid token', err.message);

test/undefined_secretOrPublickey.tests.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
var fs = require('fs');
21
var jwt = require('../index');
32
var JsonWebTokenError = require('../lib/JsonWebTokenError');
43
var expect = require('chai').expect;

test/verify.tests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ describe('verify', function() {
308308
var clockTimestamp = 1000000000;
309309
it('should verify unexpired token relative to user-provided clockTimestamp', function (done) {
310310
var token = jwt.sign({foo: 'bar', iat: clockTimestamp, exp: clockTimestamp + 1}, key);
311-
jwt.verify(token, key, {clockTimestamp: clockTimestamp}, function (err, p) {
311+
jwt.verify(token, key, {clockTimestamp: clockTimestamp}, function (err) {
312312
assert.isNull(err);
313313
done();
314314
});
@@ -340,7 +340,7 @@ describe('verify', function() {
340340
nbf: clockTimestamp + 1,
341341
exp: clockTimestamp + 2
342342
}, key);
343-
jwt.verify(token, key, {clockTimestamp: clockTimestamp + 1}, function (err, p) {
343+
jwt.verify(token, key, {clockTimestamp: clockTimestamp + 1}, function (err) {
344344
assert.isNull(err);
345345
done();
346346
});

0 commit comments

Comments
 (0)