Skip to content

Commit

Permalink
resolve linting issues in test/helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Aug 22, 2019
1 parent 7ee8ca3 commit 94d1768
Show file tree
Hide file tree
Showing 17 changed files with 56 additions and 44 deletions.
41 changes: 22 additions & 19 deletions test/helpers/PluginEnvironment.js
Expand Up @@ -22,27 +22,30 @@ module.exports = function PluginEnvironment() {
// In the meanwhile, `hooks` is a `Proxy` which creates fake hooks
// on demand. Instead of creating a dummy object with a few `Hook`
// method, a custom `Hook` class could be used.
hooks: new Proxy({}, {
get(target, hookName) {
let hook = hooks.get(hookName);
if (hook === undefined) {
const eventName = getEventName(hookName);
hook = {
tap(_, handler) {
addEvent(eventName, handler);
},
tapAsync(_, handler) {
addEvent(eventName, handler);
},
tapPromise(_, handler) {
addEvent(eventName, handler);
}
};
hooks.set(hookName, hook);
hooks: new Proxy(
{},
{
get(target, hookName) {
let hook = hooks.get(hookName);
if (hook === undefined) {
const eventName = getEventName(hookName);
hook = {
tap(_, handler) {
addEvent(eventName, handler);
},
tapAsync(_, handler) {
addEvent(eventName, handler);
},
tapPromise(_, handler) {
addEvent(eventName, handler);
}
};
hooks.set(hookName, hook);
}
return hook;
}
return hook;
}
})
)
};
};

Expand Down
2 changes: 1 addition & 1 deletion test/helpers/TemplatePluginEnvironment.js
@@ -1,4 +1,4 @@
var PluginEnvironment = require('./PluginEnvironment');
var PluginEnvironment = require("./PluginEnvironment");

module.exports = function TemplatePluginEnvironment() {
var events = [];
Expand Down
6 changes: 3 additions & 3 deletions test/helpers/applyPluginWithOptions.js
@@ -1,11 +1,11 @@
var PluginEnvironment = require('./PluginEnvironment');
var PluginEnvironment = require("./PluginEnvironment");

module.exports = function applyPluginWithOptions(Plugin) {
var plugin = new (Function.prototype.bind.apply(Plugin, arguments));
var plugin = new (Function.prototype.bind.apply(Plugin, arguments))();
var pluginEnvironment = new PluginEnvironment();
plugin.apply(pluginEnvironment.getEnvironmentStub());

var env = (this === global) ? {} : this;
var env = this === global ? {} : this;
env.plugin = plugin;
env.pluginEnvironment = pluginEnvironment;

Expand Down
2 changes: 1 addition & 1 deletion test/helpers/createLazyTestEnv.js
Expand Up @@ -72,7 +72,7 @@ module.exports = (env, globalTimeout = 2000, nameSuffix = "") => {
fn = createOnceFn(fn);
numberOfTests++;
let spec;
if(fn) {
if (fn) {
spec = env.fit(title, fn, timeout);
} else {
spec = env.fit(title, () => {});
Expand Down
5 changes: 4 additions & 1 deletion test/helpers/remove.js
@@ -1,3 +1,6 @@
const fs = require("fs");
const path = require("path");

module.exports.remove = function remove(src) {
if (!fs.existsSync(src)) return;
const files = fs.readdirSync(src);
Expand All @@ -10,4 +13,4 @@ module.exports.remove = function remove(src) {
fs.unlinkSync(srcFile);
}
});
}
};
9 changes: 5 additions & 4 deletions test/helpers/supportDefaultAssignment.js
@@ -1,9 +1,10 @@
module.exports = function supportDefaultAssignment() {
try {
var E = eval("class E { toString() { return 'default' } }")
var f1 = eval("(function f1({a, b = E}) {return new b().toString();})")
return f1({a: "test"}) === "default" ;
} catch(e) {
// eslint-disable-next-line no-unused-vars
var E = eval("class E { toString() { return 'default' } }");
var f1 = eval("(function f1({a, b = E}) {return new b().toString();})");
return f1({ a: "test" }) === "default";
} catch (e) {
return false;
}
};
6 changes: 4 additions & 2 deletions test/helpers/supportsArrowFunctionExpression.js
@@ -1,8 +1,10 @@
module.exports = function supportArrowFunctionExpression() {
try {
eval("var foo = function(fn) {return fn.toString()}; foo(() => {return 'a'})");
eval(
"var foo = function(fn) {return fn.toString()}; foo(() => {return 'a'})"
);
return true;
} catch(e) {
} catch (e) {
return false;
}
};
6 changes: 4 additions & 2 deletions test/helpers/supportsBlockScoping.js
@@ -1,8 +1,10 @@
module.exports = function supportsBlockScoping() {
try {
var f = eval("(function f() { const x = 1; if (true) { const x = 2; } return x; })");
var f = eval(
"(function f() { const x = 1; if (true) { const x = 2; } return x; })"
);
return f() === 1;
} catch(e) {
} catch (e) {
return false;
}
};
2 changes: 1 addition & 1 deletion test/helpers/supportsDefaultArgs.js
Expand Up @@ -2,7 +2,7 @@ module.exports = function supportsDefaultArgs() {
try {
var f = eval("(function f(a = 123) { return a; })");
return f() === 123;
} catch(e) {
} catch (e) {
return false;
}
};
2 changes: 1 addition & 1 deletion test/helpers/supportsES6.js
Expand Up @@ -2,7 +2,7 @@ module.exports = function supportsES6() {
try {
eval("class A {}");
return true;
} catch(e) {
} catch (e) {
return false;
}
};
4 changes: 2 additions & 2 deletions test/helpers/supportsForOf.js
@@ -1,8 +1,8 @@
module.exports = function supportDefaultAssignment() {
try {
var f = eval("(function f() { for(var x of ['ok', 'fail']) return x; })");
return f() === "ok" ;
} catch(e) {
return f() === "ok";
} catch (e) {
return false;
}
};
2 changes: 1 addition & 1 deletion test/helpers/supportsIteratorDestructuring.js
Expand Up @@ -2,7 +2,7 @@ module.exports = function supportsIteratorDestructuring() {
try {
var f = eval("(function f([, x, ...y]) { return x; })");
return f([1, 2]) === 2;
} catch(e) {
} catch (e) {
return false;
}
};
2 changes: 1 addition & 1 deletion test/helpers/supportsObjectDestructuring.js
Expand Up @@ -2,7 +2,7 @@ module.exports = function supportsObjectDestructuring() {
try {
var f = eval("(function f({x, y}) { return x + y; })");
return f({ x: 1, y: 2 }) === 3;
} catch(e) {
} catch (e) {
return false;
}
};
2 changes: 1 addition & 1 deletion test/helpers/supportsOptionalCatchBinding.js
Expand Up @@ -2,7 +2,7 @@ module.exports = function supportsOptionalCatchBinding() {
try {
eval("try {} catch {}");
return true;
} catch(e) {
} catch (e) {
return false;
}
};
5 changes: 3 additions & 2 deletions test/helpers/supportsSpread.js
@@ -1,9 +1,10 @@
module.exports = function supportsSpread() {
try {
var x = { a: true }, y; // eslint-disable-line no-unused-vars
var x = { a: true },
y; // eslint-disable-line no-unused-vars
eval("y = { ...x }");
return y !== x && y.a;
} catch(e) {
} catch (e) {
return false;
}
};
2 changes: 1 addition & 1 deletion test/helpers/supportsTemplateStrings.js
Expand Up @@ -2,7 +2,7 @@ module.exports = function supportsTemplateStrings() {
try {
var f = eval("(function f() { return String.raw`a\\b`; })");
return f() === "a\\b";
} catch(e) {
} catch (e) {
return false;
}
};
2 changes: 1 addition & 1 deletion test/helpers/supportsWebAssembly.js
@@ -1,7 +1,7 @@
module.exports = function supportsWebAssembly() {
try {
return typeof WebAssembly !== "undefined";
} catch(e) {
} catch (e) {
return false;
}
};

0 comments on commit 94d1768

Please sign in to comment.