Skip to content
This repository has been archived by the owner on Oct 14, 2020. It is now read-only.

Commit

Permalink
[ESLint] Add options to 'indent' rule
Browse files Browse the repository at this point in the history
 - Align declarations
 - Indent `case`
  • Loading branch information
kazk committed Apr 26, 2017
1 parent e3588bc commit 570a05b
Show file tree
Hide file tree
Showing 43 changed files with 390 additions and 384 deletions.
6 changes: 6 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ rules:
indent:
- error
- 2
- VariableDeclarator:
var: 2
let: 2
const: 3
SwitchCase: 1

brace-style:
- error
- stroustrup
Expand Down
4 changes: 2 additions & 2 deletions frameworks/javascript/chai-display.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
var display = require('./display'),
chai = require('chai');
chai = require('chai');

// setup chai to render success messages, which it normally doesn't do when used with CW-2
chai.use(function(_chai, util) {
chai.Assertion.prototype.assert = function(expr, msg, negateMsg, expected, _actual, showDiff) {
var ok = util.test(this, arguments),
result = ok ? 'passed' : 'failed';
result = ok ? 'passed' : 'failed';

display.write(result, util.getMessage(this, arguments));

Expand Down
56 changes: 28 additions & 28 deletions frameworks/javascript/cw-2.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@

try {
var util = require('util'),
deepEquals = require('lodash').isEqual,
Promise = require("bluebird");
deepEquals = require('lodash').isEqual,
Promise = require("bluebird");

require('./chai-display');

var fnToString = Function.toString;
Function.prototype.toString = function() {
switch (this) {
case Test.expect:
case Test.randomNumber:
case Test.randomize:
case Test.randomToken:
return '[Codewars Code]';

default:
return fnToString.call(this);
case Test.expect:
case Test.randomNumber:
case Test.randomize:
case Test.randomToken:
return '[Codewars Code]';

default:
return fnToString.call(this);
}
};

var describing = [],
async = false,
asyncIts = null,
asyncDone = null,
failed = [],
beforeCallbacks = [],
afterCallbacks = [],
alwaysExplain = false;
async = false,
asyncIts = null,
asyncDone = null,
failed = [],
beforeCallbacks = [],
afterCallbacks = [],
alwaysExplain = false;

process.on('uncaughtException', function(err) {
if (async) {
Expand Down Expand Up @@ -180,21 +180,21 @@ try {
});

var start = new Date(),
timeout,
done = function() {
if (timeout) clearTimeout(timeout);
timeout,
done = function() {
if (timeout) clearTimeout(timeout);

var ms = new Date() - start;
Test.display.write("COMPLETEDIN", ms);
var ms = new Date() - start;
Test.display.write("COMPLETEDIN", ms);

afterCallbacks.forEach(function(cb) {
cb();
});
afterCallbacks.forEach(function(cb) {
cb();
});

done = null;
done = null;

if (asyncIt) describeNext();
};
if (asyncIt) describeNext();
};

if (asyncIt) {
timeout = setTimeout(function() {
Expand Down
6 changes: 3 additions & 3 deletions frameworks/javascript/display.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

var util = require('util'),
isEqual = require('underscore').isEqual,
display = module.exports;
isEqual = require('underscore').isEqual,
display = module.exports;

// prevent anyone from peeking at the code we passed in
if (global.process) {
Expand Down Expand Up @@ -165,7 +165,7 @@ module.exports.explain = function explain(actual, expected, options) {

options = options || {};
var collapsed = options.collapsed ? "-" : "",
diff = true;
diff = true;

if (options.mode) {
if (typeof(options.mode) == 'string') {
Expand Down
16 changes: 8 additions & 8 deletions lib/runners/arm.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var shovel = require('../shovel'),
util = require('../util'),
path = require('path'),
temp = require('temp');
util = require('../util'),
path = require('path'),
temp = require('temp');

module.exports.run = function run(opts, cb) {
temp.track();
Expand All @@ -10,12 +10,12 @@ module.exports.run = function run(opts, cb) {
shovel.start(opts, cb, {
solutionOnly: function(run) {
var executable = path.join(dir, 'solution'),
solutionFile = util.codeWriteSync('arm', opts.solution + '\n', dir, 'solution.s'),
objectFile = solutionFile.replace(/\.[^\.]+$/, '.o'),
armCommand = ['arm-linux-gnueabi-as', solutionFile, '-o', objectFile].join(' '),
solutionFile = util.codeWriteSync('arm', opts.solution + '\n', dir, 'solution.s'),
objectFile = solutionFile.replace(/\.[^\.]+$/, '.o'),
armCommand = ['arm-linux-gnueabi-as', solutionFile, '-o', objectFile].join(' '),
// Check for whether we need to link against libc
linker = opts.solution.search(/\.glob[a]?l\W+_start/) == -1 ? "arm-linux-gnueabi-gcc-4.7" : "arm-linux-gnueabi-ld",
linkerCommand = [linker, objectFile, '-o', executable].join(' ');
linker = opts.solution.search(/\.glob[a]?l\W+_start/) == -1 ? "arm-linux-gnueabi-gcc-4.7" : "arm-linux-gnueabi-ld",
linkerCommand = [linker, objectFile, '-o', executable].join(' ');
util.exec(armCommand, function() {
util.exec(linkerCommand, function() {
run({'name': 'qemu-arm', 'args': ['-L', '/usr/arm-linux-gnueabi/', executable]});
Expand Down
16 changes: 8 additions & 8 deletions lib/runners/c.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
var shovel = require('../shovel'),
util = require('../util'),
exec = require('child_process').exec,
path = require('path');
util = require('../util'),
exec = require('child_process').exec,
path = require('path');

module.exports.run = function run(opts, cb) {
shovel.start(opts, cb, {
solutionOnly: function(runCode, fail) {
var executable = path.join(opts.dir, 'solution'),
solutionFile = util.codeWriteSync('c', opts.solution, opts.dir, 'solution.c'),
args = ['clang-3.6', '-std=c11', solutionFile, '-o', executable, '-lm'];
solutionFile = util.codeWriteSync('c', opts.solution, opts.dir, 'solution.c'),
args = ['clang-3.6', '-std=c11', solutionFile, '-o', executable, '-lm'];
if (opts.setup) {
var setupFile = util.codeWriteSync('c', opts.setup, opts.dir, 'setup.c');
args.push(setupFile);
Expand All @@ -21,9 +21,9 @@ module.exports.run = function run(opts, cb) {
},
testIntegration: function(runCode, fail) {
var executable = path.join(opts.dir, 'solution'),
solutionFile = util.codeWriteSync('c', opts.solution, opts.dir, 'solution.c'),
fixtureFile = util.codeWriteSync('c', opts.fixture, opts.dir, 'fixture.c'),
args = ['clang-3.6', '-std=c11', fixtureFile, solutionFile, '-o', executable, './frameworks/c/criterion.c', '-I./frameworks/c', '-lcriterion', '-lm'];
solutionFile = util.codeWriteSync('c', opts.solution, opts.dir, 'solution.c'),
fixtureFile = util.codeWriteSync('c', opts.fixture, opts.dir, 'fixture.c'),
args = ['clang-3.6', '-std=c11', fixtureFile, solutionFile, '-o', executable, './frameworks/c/criterion.c', '-I./frameworks/c', '-lcriterion', '-lm'];
if (opts.setup) {
var setupFile = util.codeWriteSync('c', opts.setup, opts.dir, 'setup.c');
args.push(setupFile);
Expand Down
2 changes: 1 addition & 1 deletion lib/runners/clojure.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var shovel = require('../shovel'),
path = require('path');
path = require('path');

module.exports.run = function run(opts, cb) {
var uberJar = path.resolve(__dirname, '../../jvm-runner/target/jvm-runner-0.1.3-standalone.jar');
Expand Down
10 changes: 5 additions & 5 deletions lib/runners/coffeescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ module.exports.run = function run(opts, cb) {
},
testIntegration: function(runCode) {
switch (opts.testFramework) {
case 'cw':
case 'cw-2':
return prepareCw2(opts, runCode);
case 'cw':
case 'cw-2':
return prepareCw2(opts, runCode);

default:
throw 'Test framework is not supported';
default:
throw 'Test framework is not supported';
}
}
});
Expand Down
30 changes: 15 additions & 15 deletions lib/runners/cpp.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
var shovel = require('../shovel'),
util = require('../util'),
path = require('path'),
temp = require('temp'),
exec = require('child_process').exec,
fs = require('fs'),
cppDir = path.resolve(__dirname, '..', '..', 'frameworks', 'cpp'),
main = fs.readFileSync(path.resolve(cppDir, 'main.cpp'));
util = require('../util'),
path = require('path'),
temp = require('temp'),
exec = require('child_process').exec,
fs = require('fs'),
cppDir = path.resolve(__dirname, '..', '..', 'frameworks', 'cpp'),
main = fs.readFileSync(path.resolve(cppDir, 'main.cpp'));

function compile(args, cb) {
args.unshift('clang++-3.6', '-stdlib=libc++ -std=c++1y');
Expand All @@ -26,7 +26,7 @@ module.exports.run = function run(opts, cb) {
shovel.start(opts, cb, {
solutionOnly: function(runCode, fail) {
var executable = path.join(dir, 'solution'),
solutionFile = util.codeWriteSync('cpp', opts.solution, dir, 'solution.cpp');
solutionFile = util.codeWriteSync('cpp', opts.solution, dir, 'solution.cpp');
args = [solutionFile, '-o', executable];
compile(args, function(error, stdout, stderr) {
if (error) return fail(error, stdout, stderr);
Expand All @@ -36,13 +36,13 @@ module.exports.run = function run(opts, cb) {
},
testIntegration: function(runCode, fail) {
var executable = path.join(dir, 'solution'),
solutionFile = util.codeWriteSync('cpp', [
'#include <igloo/igloo_alt.h>',
'using namespace igloo;',
opts.solution,
opts.fixture,
main
].join('\n'), dir, 'solution.cpp');
solutionFile = util.codeWriteSync('cpp', [
'#include <igloo/igloo_alt.h>',
'using namespace igloo;',
opts.solution,
opts.fixture,
main
].join('\n'), dir, 'solution.cpp');
args = ['-isystem', cppDir, solutionFile, '-o', executable];
compile(args, function(error, stdout, stderr) {
if (error) return fail(error, stdout, stderr);
Expand Down
6 changes: 3 additions & 3 deletions lib/runners/crystal.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var shovel = require('../shovel'),
util = require('../util'),
Convert = require('ansi-to-html'),
convert = new Convert();
util = require('../util'),
Convert = require('ansi-to-html'),
convert = new Convert();

module.exports.run = function run(opts, cb) {
shovel.start(opts, cb, {
Expand Down
58 changes: 29 additions & 29 deletions lib/runners/csharp.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
var shovel = require('../shovel'),
util = require('../util'),
path = require('path'),
nunitAssemblies = ['nunit.core.dll', 'nunit.framework.dll', 'nunit.core.interfaces.dll', 'nunit.util', 'Newtonsoft.Json.dll'].join(','),
nunitPath = '/runner/frameworks/csharp/nunit/bin';
util = require('../util'),
path = require('path'),
nunitAssemblies = ['nunit.core.dll', 'nunit.framework.dll', 'nunit.core.interfaces.dll', 'nunit.util', 'Newtonsoft.Json.dll'].join(','),
nunitPath = '/runner/frameworks/csharp/nunit/bin';

module.exports.run = function run(opts, cb) {
shovel.start(opts, cb, {
solutionOnly: function(runCode, fail) {
var codeFile = util.codeWriteSync('csharp', opts.solution, opts.dir, 'code.cs'),
exe = path.join(opts.dir, 'solution.exe'),
args = ['mcs', '-out:' + exe, codeFile];
exe = path.join(opts.dir, 'solution.exe'),
args = ['mcs', '-out:' + exe, codeFile];

if (opts.setup) {
args.push(util.codeWriteSync('csharp', opts.setup, opts.dir, 'setup.cs'));
Expand All @@ -24,29 +24,29 @@ module.exports.run = function run(opts, cb) {
// copydir('/runner/frameworks/nunit', opts.dir);

var dll = path.join(opts.dir, 'test.dll'),
args = [
'mcs',
'-out:' + dll,
`-lib:${opts.dir},/runner/frameworks/csharp/mono-4.5,${nunitPath}`,
'-langversion:Default',
'-sdk:4.5',
'-warn:2',
'-target:library',
'-r:' + nunitAssemblies,
'-r:System.Numerics.dll',
'-r:System.Drawing.dll',
'-r:System.Data.dll',
'-r:System.Data.SQLite.dll',
'-r:System.Data.SQLite.Linq.dll',
'-r:System.IO.dll',
'-r:System.Linq.dll',
'-r:System.Linq.Dynamic.dll',
'-r:System.Linq.Expressions.dll',
'-r:System.Messaging.dll',
'-r:System.Threading.Tasks.dll',
'-r:System.Xml.dll',
'-r:Mono.Linq.Expressions.dll',
];
args = [
'mcs',
'-out:' + dll,
`-lib:${opts.dir},/runner/frameworks/csharp/mono-4.5,${nunitPath}`,
'-langversion:Default',
'-sdk:4.5',
'-warn:2',
'-target:library',
'-r:' + nunitAssemblies,
'-r:System.Numerics.dll',
'-r:System.Drawing.dll',
'-r:System.Data.dll',
'-r:System.Data.SQLite.dll',
'-r:System.Data.SQLite.Linq.dll',
'-r:System.IO.dll',
'-r:System.Linq.dll',
'-r:System.Linq.Dynamic.dll',
'-r:System.Linq.Expressions.dll',
'-r:System.Messaging.dll',
'-r:System.Threading.Tasks.dll',
'-r:System.Xml.dll',
'-r:Mono.Linq.Expressions.dll',
];

if (opts.services.includes("mongodb")) {
args.push('-r:MongoDB.Bson.dll');
Expand Down
14 changes: 7 additions & 7 deletions lib/runners/elixir.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var shovel = require('../shovel'),
util = require('../util'),
temp = require('temp');
util = require('../util'),
temp = require('temp');

module.exports.run = function run(opts, cb) {
shovel.start(opts, cb, {
Expand All @@ -12,12 +12,12 @@ module.exports.run = function run(opts, cb) {
},
testIntegration: function(runCode) {
switch (opts.testFramework) {
case 'ex_unit':
case 'exunit':
return prepareExUnit(opts, runCode);
case 'ex_unit':
case 'exunit':
return prepareExUnit(opts, runCode);

default:
throw 'Test framework is not supported';
default:
throw 'Test framework is not supported';
}
},
});
Expand Down
Loading

0 comments on commit 570a05b

Please sign in to comment.