Skip to content

Commit

Permalink
[eslint] add eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Oct 12, 2022
1 parent b108d28 commit 084e09e
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 7 deletions.
22 changes: 22 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"root": true,

"extends": "@ljharb",

"rules": {
"array-bracket-newline": 0,
"comma-spacing": 1,
"indent": [2, 4],
"max-statements-per-line": 1,
},

"overrides": [
{
"files": "example/**",
"rules": {
"no-buffer-constructor": 0,
"no-console": 0,
},
},
],
}
2 changes: 2 additions & 0 deletions example/eq.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

var bufferEqual = require('../');

console.dir(bufferEqual(
Expand Down
15 changes: 8 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
'use strict';

var Buffer = require('buffer').Buffer; // for use with browserify

module.exports = function (a, b) {
if (!Buffer.isBuffer(a)) return undefined;
if (!Buffer.isBuffer(b)) return undefined;
if (typeof a.equals === 'function') return a.equals(b);
if (a.length !== b.length) return false;

if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { return undefined; }
if (typeof a.equals === 'function') { return a.equals(b); }
if (a.length !== b.length) { return false; }

for (var i = 0; i < a.length; i++) {
if (a[i] !== b[i]) return false;
if (a[i] !== b[i]) { return false; }
}

return true;
};
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@
"test": "test"
},
"scripts": {
"lint": "eslint --ext=js,mjs .",
"pretest": "npm run lint",
"tests-only": "tape 'test/**/*.js'",
"test": "npm run tests-only",
"posttest": "aud --production"
},
"devDependencies": {
"@ljharb/eslint-config": "^21.0.0",
"aud": "^2.0.1",
"eslint": "=8.8.0",
"tape": "^5.6.1"
},
"engines": {
Expand Down

0 comments on commit 084e09e

Please sign in to comment.