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 075e7f9 commit e965df9
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 6 deletions.
20 changes: 20 additions & 0 deletions .eslintrc
@@ -0,0 +1,20 @@
{
"root": true,

"extends": "@ljharb",

"rules": {
"array-bracket-newline": 0,
"array-bracket-spacing": 1,
"indent": [2, 4],
},

"overrides": [
{
"files": "example/**",
"rules": {
"no-console": 0,
},
},
],
}
2 changes: 2 additions & 0 deletions example/map.js
@@ -1,3 +1,5 @@
'use strict';

var concatMap = require('../');
var xs = [ 1, 2, 3, 4, 5, 6 ];
var ys = concatMap(xs, function (x) {
Expand Down
17 changes: 11 additions & 6 deletions index.js
@@ -1,13 +1,18 @@
'use strict';

var isArray = Array.isArray || function (xs) {
return Object.prototype.toString.call(xs) === '[object Array]';
};

module.exports = function (xs, fn) {
var res = [];
for (var i = 0; i < xs.length; i++) {
var x = fn(xs[i], i);
if (isArray(x)) res.push.apply(res, x);
else res.push(x);
if (isArray(x)) {
res.push.apply(res, x);
} else {
res.push(x);
}
}
return res;
};

var isArray = Array.isArray || function (xs) {
return Object.prototype.toString.call(xs) === '[object Array]';
};
4 changes: 4 additions & 0 deletions package.json
Expand Up @@ -19,12 +19,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"
},
"license": "MIT",
Expand Down
2 changes: 2 additions & 0 deletions test/map.js
@@ -1,3 +1,5 @@
'use strict';

var concatMap = require('../');
var test = require('tape');

Expand Down

0 comments on commit e965df9

Please sign in to comment.