Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
boopathi committed Nov 20, 2016
1 parent 4d262f4 commit caaba85
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
6 changes: 3 additions & 3 deletions packages/babel-preset-babili/src/index.js
Expand Up @@ -36,7 +36,7 @@ function preset(_opts = {}) {
let usedPlugins = new Set;

const optionsMap = PLUGINS
.map(plugin => option(plugin[0], plugin[1], plugin[2]))
.map((plugin) => option(plugin[0], plugin[1], plugin[2]))
.reduce((acc, cur) => {
Object.defineProperty(acc, cur.name, {
get() {
Expand Down Expand Up @@ -91,8 +91,8 @@ function preset(_opts = {}) {
// verify all plugins are used
if (usedPlugins.size !== PLUGINS.length) {
const unusedPlugins = PLUGINS
.filter(plugin => !usedPlugins.has(plugin[0]))
.map(plugin => plugin[0]);
.filter((plugin) => !usedPlugins.has(plugin[0]))
.map((plugin) => plugin[0]);
throw new Error("Some imported plugins unused\n" + unusedPlugins);
}

Expand Down
40 changes: 20 additions & 20 deletions packages/babel-preset-babili/src/options-manager.js
Expand Up @@ -55,12 +55,12 @@ function generateResult(resolvedOpts) {
const option = options[i];

switch (option.type) {
case "option":
case "option":
if (option.resolvedValue) {
result.push(option.resolvedValue);
}
break;
case "group":
case "group":
result.push(...generateResult(option));
break;
}
Expand All @@ -86,22 +86,22 @@ function resolveOptions(optionTree, inputOpts = {}) {
for (let i = 0; i < options.length; i++) {
const option = options[i];
switch (option.type) {
case "option":
case "option":
resolveTypeOption(option, inputOpts);
break;

case "group":
case "group":
resolveTypeGroup(option, inputOpts);
break;

case "proxy":
case "proxy":
if (!hop(inputOpts, option.name)) {
break;
}
proxiesToResolve.push(option);
break;

default:
default:
throw new TypeError("Option type not supported - " + option.type);
}
}
Expand All @@ -112,15 +112,15 @@ function resolveOptions(optionTree, inputOpts = {}) {
for (let j = 0; j < proxy.to.length; j++) {
const option = proxy.to[j];
switch (option.type) {
case "option":
case "option":
resolveTypeProxyToOption(proxy, option, inputOpts);
break;

case "group":
case "proxy":
case "group":
case "proxy":
throw new Error(`proxy option cannot proxy to group/proxy. ${proxy.name} proxied to ${option.name}`);

default:
default:
throw new Error("Unsupported option type ${option.name}");
}
}
Expand Down Expand Up @@ -171,14 +171,14 @@ function resolveTypeGroup(option, inputOpts) {
if (!hop(inputOpts, option.name)) {
const newInputOpts = option
.children
.filter(opt => opt.type !== "proxy")
.filter((opt) => opt.type !== "proxy")
.reduce((acc, cur) => {
let value;
switch (option.defaultValue) {
case "all": value = true; break;
case "some": value = cur.defaultValue; break;
case "none": value = false; break;
default: throw new Error(`Unsupported defaultValue - ${option.defaultValue} for option ${option.name}`);
case "all": value = true; break;
case "some": value = cur.defaultValue; break;
case "none": value = false; break;
default: throw new Error(`Unsupported defaultValue - ${option.defaultValue} for option ${option.name}`);
}
return Object.assign({}, acc, {
[cur.name]: value,
Expand All @@ -201,7 +201,7 @@ function resolveTypeGroup(option, inputOpts) {
// { unsafe: <true | false> }
const newInputOpts = option
.children
.filter(opt => opt.type !== "proxy")
.filter((opt) => opt.type !== "proxy")
.reduce((acc, cur) => Object.assign({}, acc, {
// if the input is truthy, enable all, else disable all
[cur.name]: !!inputOpts[option.name]
Expand Down Expand Up @@ -281,7 +281,7 @@ function group(name, children, defaultValue = "some") {
return {
type: "group",
name,
children: children.filter(x => !!x),
children: children.filter((x) => !!x),
defaultValue,
};
}
Expand All @@ -290,14 +290,14 @@ function hop(o, key) {
return Object.hasOwnProperty.call(o, key);
}

function assertArray(arr, name, prop) {
if (!Array.isArray(children)) {
function assertArray(name, prop, arr) {
if (!Array.isArray(arr)) {
throw new Error(`Expected ${prop} to be an array in option ${name}`);
}
}

function assertName(name) {
if (!!name) {
if (!name) {
throw new Error("Invalid option name " + name);
}
}

0 comments on commit caaba85

Please sign in to comment.