Skip to content

Commit

Permalink
[eslint] fix indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Sep 18, 2022
1 parent 85d86a4 commit b035590
Show file tree
Hide file tree
Showing 105 changed files with 4,738 additions and 4,739 deletions.
1 change: 0 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"array-bracket-spacing": "off",
"complexity": "off",
"func-style": "warn",
"indent": ["error", 4],
"max-lines-per-function": "warn",
"max-lines": "warn",
"max-statements-per-line": [2, { "max": 2 }],
Expand Down
62 changes: 31 additions & 31 deletions bin/tape
Original file line number Diff line number Diff line change
Expand Up @@ -5,64 +5,64 @@
var parseOpts = require('minimist');

var opts = parseOpts(process.argv.slice(2), {
alias: { r: 'require', i: 'ignore' },
string: ['require', 'ignore'],
boolean: ['only'],
default: { r: [], i: null, only: null }
alias: { r: 'require', i: 'ignore' },
string: ['require', 'ignore'],
boolean: ['only'],
default: { r: [], i: null, only: null }
});

if (typeof opts.only === 'boolean') {
process.env.NODE_TAPE_NO_ONLY_TEST = !opts.only;
process.env.NODE_TAPE_NO_ONLY_TEST = !opts.only;
}

var cwd = process.cwd();

if (typeof opts.require === 'string') {
opts.require = [opts.require];
opts.require = [opts.require];
}

var resolveModule;
opts.require.forEach(function (module) {
if (module) {
if (!resolveModule) { resolveModule = require('resolve').sync; }
// This check ensures we ignore `-r ""`, trailing `-r`, or other silly things the user might (inadvertently) be doing.
require(resolveModule(module, { basedir: cwd }));
}
if (module) {
if (!resolveModule) { resolveModule = require('resolve').sync; }
// This check ensures we ignore `-r ""`, trailing `-r`, or other silly things the user might (inadvertently) be doing.
require(resolveModule(module, { basedir: cwd }));
}
});

var resolvePath = require('path').resolve;

var matcher;
if (typeof opts.ignore === 'string') {
var readFileSync = require('fs').readFileSync;
try {
var ignoreStr = readFileSync(resolvePath(cwd, opts.ignore || '.gitignore'), 'utf-8');
} catch (e) {
console.error(e.message);
process.exit(2);
}
var ignore = require('dotignore');
matcher = ignore.createMatcher(ignoreStr);
var readFileSync = require('fs').readFileSync;
try {
var ignoreStr = readFileSync(resolvePath(cwd, opts.ignore || '.gitignore'), 'utf-8');
} catch (e) {
console.error(e.message);
process.exit(2);
}
var ignore = require('dotignore');
matcher = ignore.createMatcher(ignoreStr);
}

var glob = require('glob');

opts._.reduce(function (result, arg) {
if (glob.hasMagic(arg)) {
// If glob does not match, `files` will be an empty array. Note: `glob.sync` may throw an error and crash the node process.
var files = glob.sync(arg);
if (glob.hasMagic(arg)) {
// If glob does not match, `files` will be an empty array. Note: `glob.sync` may throw an error and crash the node process.
var files = glob.sync(arg);

if (!Array.isArray(files)) {
throw new TypeError('unknown error: glob.sync did not return an array or throw. Please report this.');
}
if (!Array.isArray(files)) {
throw new TypeError('unknown error: glob.sync did not return an array or throw. Please report this.');
}

return result.concat(files);
}
return result.concat(arg);
return result.concat(files);
}
return result.concat(arg);
}, []).filter(function (file) {
return !matcher || !matcher.shouldIgnore(file);
return !matcher || !matcher.shouldIgnore(file);
}).forEach(function (file) {
require(resolvePath(cwd, file));
require(resolvePath(cwd, file));
});

// vim: ft=javascript
52 changes: 26 additions & 26 deletions example/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,34 @@ var falafel = require('falafel');
var test = require('../');

test('array', function (t) {
t.plan(5);
t.plan(5);

var src = '(' + function () {
var xs = [ 1, 2, [ 3, 4 ] ];
var ys = [ 5, 6 ];
g([ xs, ys ]);
} + ')()';
var src = '(' + function () {
var xs = [ 1, 2, [ 3, 4 ] ];
var ys = [ 5, 6 ];
g([ xs, ys ]);
} + ')()';

var output = falafel(src, function (node) {
if (node.type === 'ArrayExpression') {
node.update('fn(' + node.source() + ')');
}
});
var output = falafel(src, function (node) {
if (node.type === 'ArrayExpression') {
node.update('fn(' + node.source() + ')');
}
});

var arrays = [
[3, 4],
[1, 2, [3, 4]],
[5, 6],
[[ 1, 2, [3, 4]], [5, 6]]
];
var arrays = [
[3, 4],
[1, 2, [3, 4]],
[5, 6],
[[ 1, 2, [3, 4]], [5, 6]]
];

Function(['fn', 'g'], output)(
function (xs) {
t.same(arrays.shift(), xs);
return xs;
},
function (xs) {
t.same(xs, [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]);
}
);
Function(['fn', 'g'], output)(
function (xs) {
t.same(arrays.shift(), xs);
return xs;
},
function (xs) {
t.same(xs, [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]);
}
);
});
52 changes: 26 additions & 26 deletions example/fail.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,34 @@ var falafel = require('falafel');
var test = require('../');

test('array', function (t) {
t.plan(5);
t.plan(5);

var src = '(' + function () {
var xs = [ 1, 2, [ 3, 4 ] ];
var ys = [ 5, 6 ];
g([ xs, ys ]);
} + ')()';
var src = '(' + function () {
var xs = [ 1, 2, [ 3, 4 ] ];
var ys = [ 5, 6 ];
g([ xs, ys ]);
} + ')()';

var output = falafel(src, function (node) {
if (node.type === 'ArrayExpression') {
node.update('fn(' + node.source() + ')');
}
});
var output = falafel(src, function (node) {
if (node.type === 'ArrayExpression') {
node.update('fn(' + node.source() + ')');
}
});

var arrays = [
[ 3, 4 ],
[ 1, 2, [ 3, 4 ] ],
[ 5, 6 ],
[ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]
];
var arrays = [
[ 3, 4 ],
[ 1, 2, [ 3, 4 ] ],
[ 5, 6 ],
[ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]
];

Function(['fn', 'g'], output)(
function (xs) {
t.same(arrays.shift(), xs);
return xs;
},
function (xs) {
t.same(xs, [ [ 1, 2, [ 3, 4444 ] ], [ 5, 6 ] ]);
}
);
Function(['fn', 'g'], output)(
function (xs) {
t.same(arrays.shift(), xs);
return xs;
},
function (xs) {
t.same(xs, [ [ 1, 2, [ 3, 4444 ] ], [ 5, 6 ] ]);
}
);
});
86 changes: 43 additions & 43 deletions example/nested.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,50 @@ var falafel = require('falafel');
var test = require('../');

test('nested array test', function (t) {
t.plan(5);

var src = '(' + function () {
var xs = [1, 2, [3, 4]];
var ys = [5, 6];
g([ xs, ys ]);
} + ')()';

var output = falafel(src, function (node) {
if (node.type === 'ArrayExpression') {
node.update('fn(' + node.source() + ')');
}
});

t.test('inside test', function (q) {
q.plan(2);
q.ok(true, 'inside ok');

setTimeout(function () {
q.ok(true, 'inside delayed');
}, 3000);
});

var arrays = [
[3, 4],
[1, 2, [3, 4]],
[5, 6],
[[ 1, 2, [3, 4]], [5, 6]]
];

Function(['fn', 'g'], output)(
function (xs) {
t.same(arrays.shift(), xs);
return xs;
},
function (xs) {
t.same(xs, [[1, 2, [3, 4]], [5, 6]]);
}
);
t.plan(5);

var src = '(' + function () {
var xs = [1, 2, [3, 4]];
var ys = [5, 6];
g([ xs, ys ]);
} + ')()';

var output = falafel(src, function (node) {
if (node.type === 'ArrayExpression') {
node.update('fn(' + node.source() + ')');
}
});

t.test('inside test', function (q) {
q.plan(2);
q.ok(true, 'inside ok');

setTimeout(function () {
q.ok(true, 'inside delayed');
}, 3000);
});

var arrays = [
[3, 4],
[1, 2, [3, 4]],
[5, 6],
[[ 1, 2, [3, 4]], [5, 6]]
];

Function(['fn', 'g'], output)(
function (xs) {
t.same(arrays.shift(), xs);
return xs;
},
function (xs) {
t.same(xs, [[1, 2, [3, 4]], [5, 6]]);
}
);
});

test('another', function (t) {
t.plan(1);
setTimeout(function () {
t.ok(true);
}, 100);
t.plan(1);
setTimeout(function () {
t.ok(true);
}, 100);
});
Loading

0 comments on commit b035590

Please sign in to comment.