Skip to content

Commit 89694cf

Browse files
committed
[lint] switch to eslint
1 parent 8b06730 commit 89694cf

File tree

4 files changed

+79
-14
lines changed

4 files changed

+79
-14
lines changed

.eslintrc

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"root": true,
3+
4+
"extends": "@ljharb",
5+
6+
"globals": {
7+
"Uint8Array": "readonly",
8+
"Uint16Array": "readonly",
9+
"Uint32Array": "readonly",
10+
"Int8Array": "readonly",
11+
"Int16Array": "readonly",
12+
"Int32Array": "readonly",
13+
"Float32Array": "readonly",
14+
"Float64Array": "readonly",
15+
"BigInt64Array": "readonly",
16+
"BigUint64Array": "readonly",
17+
},
18+
19+
"rules": {
20+
"consistent-return": "warn",
21+
"curly": "warn",
22+
"dot-notation": [2, { "allowKeywords": true, "allowPattern": "throws" }],
23+
"func-style": "warn",
24+
"function-paren-newline": "warn",
25+
"id-denylist": "warn",
26+
"indent": ["error", 2],
27+
"max-params": "warn",
28+
"max-statements-per-line": "warn",
29+
"multiline-comment-style": "off",
30+
"no-else-return": "warn",
31+
"no-extra-parens": "warn",
32+
"no-param-reassign": "warn",
33+
"no-use-before-define": "warn",
34+
"semi": ["error", "never"],
35+
"sort-keys": "warn",
36+
"space-before-function-paren": "warn",
37+
"strict": "warn",
38+
},
39+
40+
"ignorePatterns": [
41+
"test/bundle.js",
42+
],
43+
44+
"overrides": [
45+
{
46+
"files": "bench/*",
47+
"extends": "@ljharb/eslint-config/node/4",
48+
"rules": {
49+
"curly": "warn",
50+
"func-style": "warn",
51+
"indent": ["error", 2],
52+
"max-params": "warn",
53+
"no-extra-parens": "warn",
54+
"no-mixed-operators": "warn",
55+
"no-param-reassign": "warn",
56+
"no-use-before-define": "warn",
57+
"no-var": "off",
58+
"prefer-arrow-callback": "off",
59+
"prefer-template": "off",
60+
"semi": ["error", "never"],
61+
"space-before-function-paren": "warn",
62+
"strict": "warn",
63+
},
64+
},
65+
],
66+
}

index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var checkParameters = require('./lib/precondition')
44
var defaultEncoding = require('./lib/default-encoding')
55
var toBuffer = require('./lib/to-buffer')
66

7-
function nativePBKDF2 (password, salt, iterations, keylen, digest, callback) {
7+
function nativePBKDF2(password, salt, iterations, keylen, digest, callback) {
88
checkParameters(iterations, keylen)
99
password = toBuffer(password, defaultEncoding, 'Password')
1010
salt = toBuffer(salt, defaultEncoding, 'Salt')
@@ -13,12 +13,12 @@ function nativePBKDF2 (password, salt, iterations, keylen, digest, callback) {
1313
callback = digest
1414
digest = 'sha1'
1515
}
16-
if (typeof callback !== 'function') throw new Error('No callback provided to pbkdf2')
16+
if (typeof callback !== 'function') { throw new Error('No callback provided to pbkdf2') }
1717

1818
return native.pbkdf2(password, salt, iterations, keylen, digest, callback)
1919
}
2020

21-
function nativePBKDF2Sync (password, salt, iterations, keylen, digest) {
21+
function nativePBKDF2Sync(password, salt, iterations, keylen, digest) {
2222
checkParameters(iterations, keylen)
2323
password = toBuffer(password, defaultEncoding, 'Password')
2424
salt = toBuffer(salt, defaultEncoding, 'Salt')
@@ -28,6 +28,7 @@ function nativePBKDF2Sync (password, salt, iterations, keylen, digest) {
2828

2929
/* istanbul ignore next */
3030
if (!native.pbkdf2Sync || native.pbkdf2Sync.toString().indexOf('keylen, digest') === -1) {
31+
/* eslint global-require: 0 */
3132
exports.pbkdf2Sync = require('./lib/sync')
3233
exports.pbkdf2 = require('./lib/async')
3334

package.json

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,19 @@
3333
"coverage-report": "nyc report --reporter=lcov",
3434
"coverage-html": "nyc report --reporter=html",
3535
"coverage": "nyc --check-coverage --branches 95 --functions 95 tape test/*.js",
36-
"lint": "standard",
37-
"test": "npm run lint && npm run unit",
36+
"lint": "eslint --ext=js,mjs .",
37+
"pretest": "npm run lint",
38+
"tests-only": "tape test/*.js",
39+
"test": "npm run tests-only",
3840
"bundle-test": "browserify test/index.js > test/bundle.js",
39-
"unit": "tape test/*.js",
4041
"bench": "node bench/"
4142
},
4243
"devDependencies": {
44+
"@ljharb/eslint-config": "^21.1.1",
4345
"benchmark": "^2.1.4",
4446
"browserify": "*",
47+
"eslint": "=8.8.0",
4548
"nyc": "^6.4.0",
46-
"standard": "*",
4749
"tape": "^4.5.1"
4850
},
4951
"dependencies": {
@@ -53,11 +55,6 @@
5355
"safe-buffer": "^5.0.1",
5456
"sha.js": "^2.4.8"
5557
},
56-
"standard": {
57-
"ignore": [
58-
"test/bundle.js"
59-
]
60-
},
6158
"engines": {
6259
"node": ">=0.12"
6360
},

test/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ if (pVersionMajor >= 6 || process.browser) {
7676
})
7777
}
7878

79-
function runTests (name, compat) {
79+
function runTests(name, compat) {
8080
tape(name + ' defaults to sha1 and handles buffers', function (t) {
8181
t.plan(3)
8282

@@ -183,7 +183,7 @@ function runTests (name, compat) {
183183
tape(name + ' async w/ ' + description, function (t) {
184184
t.plan(1)
185185
/* istanbul ignore next */
186-
function noop () {}
186+
function noop() {}
187187
t.throws(function () {
188188
compat.pbkdf2(f.key, f.salt, f.iterations, f.dkLen, f.algo, noop)
189189
}, new RegExp(f.exception))
@@ -205,6 +205,7 @@ runTests('JavaScript pbkdf2', js)
205205

206206
/* istanbul ignore next */
207207
if (!process.browser) {
208+
/* eslint global-require: 0 */
208209
var browser = Object.assign({}, js)
209210
browser.pbkdf2Sync = require('../lib/sync-browser')
210211
runTests('browser pbkdf2', {

0 commit comments

Comments
 (0)