Skip to content

Commit

Permalink
adding linter eslint and making sure our code is aligned with the rules
Browse files Browse the repository at this point in the history
set.
  • Loading branch information
itamararjuan committed Apr 28, 2019
1 parent e367049 commit c2e4532
Show file tree
Hide file tree
Showing 16 changed files with 2,396 additions and 88 deletions.
1 change: 1 addition & 0 deletions .eslintignore
@@ -0,0 +1 @@
node_modules/
18 changes: 18 additions & 0 deletions .eslintrc.json
@@ -0,0 +1,18 @@
{
"env": {
"commonjs": true,
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018
},
"rules": {
"no-console": 0
}
}
1 change: 0 additions & 1 deletion lib/cli/handlers/create.js
@@ -1,4 +1,3 @@
const path = require('path');
const _ = require('lodash');

const { createBoyarConfig } = require('./../boyar/create-config');
Expand Down
2 changes: 0 additions & 2 deletions lib/cli/handlers/destroy.js
@@ -1,5 +1,3 @@
const path = require('path');

const { logRed, logGreen, getComposeFileOrFlagsHandler } = require('./../methods');
const { Nebula } = require('./../../../lib/services/nebula');
const { resolvePath } = require("../../utils/resolve-path");
Expand Down
1 change: 1 addition & 0 deletions lib/cli/handlers/network-status.js
Expand Up @@ -2,6 +2,7 @@ const _ = require('lodash');

const { getNodes } = require('../boyar/create-config');
const { getEndpoint, getStatus } = require('../../metrics');
const { logRed, logGreen } = require('../methods');

async function status({ configPath, vchain }) {
if (!configPath || !vchain) {
Expand Down
2 changes: 2 additions & 0 deletions lib/cli/methods.js
Expand Up @@ -5,6 +5,8 @@ const readFile = fs.readFileSync;
const { isEmpty } = require("lodash");

function getComposeFileOrFlagsHandler(handler) {
let argsAsFile;

return (argv) => {
let _argv = {};

Expand Down
32 changes: 16 additions & 16 deletions lib/services/terraform.js
Expand Up @@ -53,18 +53,18 @@ class Terraform {
const { name } = cloud;

// SSH key specific variables
rows.push({path_to_ssh_pubkey: keys.ssh.path});
rows.push({ path_to_ssh_pubkey: keys.ssh.path });

if (!isEmpty(keys.ssh.cidr)) {
rows.push({incoming_ssh_cidr_blocks: keys.ssh.cidr});
rows.push({ incoming_ssh_cidr_blocks: keys.ssh.cidr });
}

rows.push(
{name: cloud.name},
{aws_profile: keys.aws.profile},
{region: cloud.region},
{instance_type: cloud.instanceType},
{instance_count: isInteger(cloud.nodeCount) ? cloud.nodeCount : 2}
{ name: cloud.name },
{ aws_profile: keys.aws.profile },
{ region: cloud.region },
{ instance_type: cloud.instanceType },
{ instance_count: isInteger(cloud.nodeCount) ? cloud.nodeCount : 2 }
);

const boyarKey = 'boyar/config.json';
Expand All @@ -73,18 +73,18 @@ class Terraform {
const boyarConfigUrl = !isEmpty(cloud.bootstrapUrl) ? cloud.bootstrapUrl : `https://${s3Endpoint}.amazonaws.com/${boyarBucket}/${boyarKey}`;

rows.push(
{boyar_config_source: `<<EOF\n${JSON.stringify(keys.orbs.boyarConfig)}\nEOF`, multiline: true},
{s3_bucket_name: boyarBucket},
{s3_boyar_key: boyarKey},
{s3_boyar_config_url: boyarConfigUrl}
{ boyar_config_source: `<<EOF\n${JSON.stringify(keys.orbs.boyarConfig)}\nEOF`, multiline: true },
{ s3_bucket_name: boyarBucket },
{ s3_boyar_key: boyarKey },
{ s3_boyar_config_url: boyarConfigUrl }
);

if (!isEmpty(keys.orbs.ethereumEndpoint)) {
rows.push({ethereum_endpoint: keys.orbs.ethereumEndpoint});
rows.push({ ethereum_endpoint: keys.orbs.ethereumEndpoint });
}

if (!isEmpty(keys.orbs.ethereumTopologyContractAddress)) {
rows.push({ethereum_topology_contract_address: keys.orbs.ethereumTopologyContractAddress});
rows.push({ ethereum_topology_contract_address: keys.orbs.ethereumTopologyContractAddress });
}

return map(rows, (row) => {
Expand Down Expand Up @@ -328,7 +328,7 @@ class Terraform {
if (_item.indexOf(' = ') === -1) {
return null;
}

/*eslint no-control-regex: 0*/
const item = _item.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');

const outputParts = item.split(' = ');
Expand Down Expand Up @@ -395,7 +395,7 @@ class Terraform {
});
});
}
};
}

function log(text, name, op, stdType = 'out') {
if (!outputs[name]) {
Expand All @@ -416,7 +416,7 @@ function log(text, name, op, stdType = 'out') {
};
element.ops[op][stdType].push(text);
}
};
}

function base64JSON(source) {
return Buffer.from(JSON.stringify(source)).toString("base64");
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/exec.js
@@ -1,7 +1,7 @@
const { exec: _exec } = require('child-process-promise');
const { isError } = require('lodash');

const verboseDefaultValue = 'NEBULA_VERBOSE' in process.env && process.env[NEBULA_VERBOSE] === '1' | false;
const verboseDefaultValue = 'NEBULA_VERBOSE' in process.env && process.env['NEBULA_VERBOSE'] === '1' | false;

async function exec(cmd, opts = {}, verbose = verboseDefaultValue) {
if (verbose) {
Expand Down

0 comments on commit c2e4532

Please sign in to comment.