Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use semistandard #2513

Merged
merged 1 commit into from
Oct 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
129 changes: 0 additions & 129 deletions .eslintrc

This file was deleted.

3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
"extends": "semistandard"
};
60 changes: 30 additions & 30 deletions bin/_mocha
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ program._name = 'mocha';
program
.command('init <path>')
.description('initialize a client-side mocha setup at <path>')
.action(function(path) {
.action(function (path) {
var mkdir = require('mkdirp');
mkdir.sync(path);
var css = fs.readFileSync(join(__dirname, '..', 'mocha.css'));
Expand All @@ -129,13 +129,13 @@ program

// --globals

program.on('globals', function(val) {
program.on('globals', function (val) {
globals = globals.concat(list(val));
});

// --reporters

program.on('reporters', function() {
program.on('reporters', function () {
console.log();
console.log(' dot - dot matrix');
console.log(' doc - html documentation');
Expand All @@ -156,9 +156,9 @@ program.on('reporters', function() {

// --interfaces

program.on('interfaces', function() {
program.on('interfaces', function () {
console.log('');
interfaceNames.forEach(function(interfaceName) {
interfaceNames.forEach(function (interfaceName) {
console.log(' ' + interfaceName);
});
console.log('');
Expand All @@ -169,7 +169,7 @@ program.on('interfaces', function() {

module.paths.push(cwd, join(cwd, 'node_modules'));

program.on('require', function(mod) {
program.on('require', function (mod) {
var abs = exists(mod) || exists(mod + '.js');
if (abs) {
mod = resolve(mod);
Expand All @@ -194,7 +194,7 @@ Error.stackTraceLimit = Infinity; // TODO: config

var reporterOptions = {};
if (program.reporterOptions !== undefined) {
program.reporterOptions.split(',').forEach(function(opt) {
program.reporterOptions.split(',').forEach(function (opt) {
var L = opt.split('=');
if (L.length > 2 || L.length === 0) {
throw new Error("invalid reporter option '" + opt + "'");
Expand Down Expand Up @@ -324,7 +324,7 @@ if (program.retries) {
// custom compiler support

var extensions = ['js'];
program.compilers.forEach(function(c) {
program.compilers.forEach(function (c) {
var idx = c.indexOf(':');
var ext = c.slice(0, idx);
var mod = c.slice(idx + 1);
Expand All @@ -339,7 +339,7 @@ program.compilers.forEach(function(c) {

// requires

requires.forEach(function(mod) {
requires.forEach(function (mod) {
require(mod);
});

Expand All @@ -357,7 +357,7 @@ if (!args.length) {
args.push('test');
}

args.forEach(function(arg) {
args.forEach(function (arg) {
var newFiles;
try {
newFiles = utils.lookupFiles(arg, extensions, program.recursive);
Expand All @@ -380,7 +380,7 @@ if (!files.length) {

// resolve

files = files.map(function(path) {
files = files.map(function (path) {
return resolve(path);
});

Expand All @@ -398,7 +398,7 @@ var rerun;
if (program.watch) {
console.log();
hideCursor();
process.on('SIGINT', function() {
process.on('SIGINT', function () {
showCursor();
console.log('\n');
process.exit(130);
Expand All @@ -407,11 +407,11 @@ if (program.watch) {
var watchFiles = utils.files(cwd, [ 'js' ].concat(program.watchExtensions));
var runAgain = false;

loadAndRun = function loadAndRun() {
loadAndRun = function loadAndRun () {
try {
mocha.files = files;
runAgain = false;
runner = mocha.run(function() {
runner = mocha.run(function () {
runner = null;
if (runAgain) {
rerun();
Expand All @@ -422,15 +422,15 @@ if (program.watch) {
}
};

purge = function purge() {
watchFiles.forEach(function(file) {
purge = function purge () {
watchFiles.forEach(function (file) {
delete require.cache[file];
});
};

loadAndRun();

rerun = function rerun() {
rerun = function rerun () {
purge();
stop();
if (!program.grep) {
Expand All @@ -442,7 +442,7 @@ if (program.watch) {
loadAndRun();
};

utils.watch(watchFiles, function() {
utils.watch(watchFiles, function () {
runAgain = true;
if (runner) {
runner.abort();
Expand All @@ -457,17 +457,17 @@ if (program.watch) {
runner = mocha.run(program.exit ? exit : exitLater);
}

function exitLater(code) {
process.on('exit', function() {
function exitLater (code) {
process.on('exit', function () {
process.exit(Math.min(code, 255));
});
}

function exit(code) {
function exit (code) {
// flush output for Node.js Windows pipe bug
// https://github.com/joyent/node/issues/6247 is just one bug example
// https://github.com/visionmedia/mocha/issues/333 has a good discussion
function done() {
function done () {
if (!(draining--)) {
process.exit(Math.min(code, 255));
}
Expand All @@ -476,7 +476,7 @@ function exit(code) {
var draining = 0;
var streams = [process.stdout, process.stderr];

streams.forEach(function(stream) {
streams.forEach(function (stream) {
// submit empty write request and wait for completion
draining += 1;
stream.write('', done);
Expand All @@ -485,7 +485,7 @@ function exit(code) {
done();
}

process.on('SIGINT', function() {
process.on('SIGINT', function () {
runner.abort();

// This is a hack:
Expand All @@ -498,31 +498,31 @@ process.on('SIGINT', function() {
* Parse list.
*/

function list(str) {
function list (str) {
return str.split(/ *, */);
}

/**
* Hide the cursor.
*/

function hideCursor() {
function hideCursor () {
process.stdout.write('\u001b[?25l');
}

/**
* Show the cursor.
*/

function showCursor() {
function showCursor () {
process.stdout.write('\u001b[?25h');
}

/**
* Stop play()ing.
*/

function stop() {
function stop () {
process.stdout.write('\u001b[2K');
clearInterval(play.timer);
}
Expand All @@ -531,12 +531,12 @@ function stop() {
* Play the given array of strings.
*/

function play(arr, interval) {
function play (arr, interval) {
var len = arr.length;
interval = interval || 100;
var i = 0;

play.timer = setInterval(function() {
play.timer = setInterval(function () {
var str = arr[i++ % len];
process.stdout.write('\u001b[0G' + str);
}, interval);
Expand Down
8 changes: 4 additions & 4 deletions bin/mocha
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var args = [path.join(__dirname, '_mocha')];
// Must be loaded here to handle node-specific options
getOptions();

process.argv.slice(2).forEach(function(arg) {
process.argv.slice(2).forEach(function (arg) {
var flag = arg.split('=')[0];

switch (flag) {
Expand Down Expand Up @@ -64,8 +64,8 @@ process.argv.slice(2).forEach(function(arg) {
});

var proc = spawn(process.execPath, args, { stdio: 'inherit' });
proc.on('exit', function(code, signal) {
process.on('exit', function() {
proc.on('exit', function (code, signal) {
process.on('exit', function () {
if (signal) {
process.kill(process.pid, signal);
} else {
Expand All @@ -75,7 +75,7 @@ proc.on('exit', function(code, signal) {
});

// terminate children.
process.on('SIGINT', function() {
process.on('SIGINT', function () {
proc.kill('SIGINT'); // calls runner.abort()
proc.kill('SIGTERM'); // if that didn't work, we're probably in an infinite loop, so make it die.
});