Skip to content

Commit

Permalink
Fabo/quotes rule (#1362)
Browse files Browse the repository at this point in the history
* linted

* changelog

* some more changes

* update jest

* fix tests

* Revert "update jest"

This reverts commit 873736c.
  • Loading branch information
faboweb authored and fedekunze committed Sep 27, 2018
1 parent bafdd04 commit 6497228
Show file tree
Hide file tree
Showing 214 changed files with 5,173 additions and 4,644 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports = {
// allow debugger during development
"no-debugger": process.env.NODE_ENV === "production" ? 2 : 0,
"no-undef": "error",
"no-unused-vars": "error"
"no-unused-vars": "error",
quotes: ["error", "backtick"]
}
}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
* Added new validator profile page @faboweb
* cleaning up new validator profile page and balance header @jbibla
* Changed a bunch of JavaScript files to strict mode. @NodeGuy @faboweb
* prefer backquotes in code @ƒaboweb
* Refactord submitDelegation. @NodeGuy

### Fixed
Expand Down
44 changes: 22 additions & 22 deletions app/src/main/addressbook.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"use strict"

const fs = require("fs-extra")
const { join } = require("path")
const axios = require("axios")
const fs = require(`fs-extra`)
const { join } = require(`path`)
const axios = require(`axios`)

const LOGGING = JSON.parse(process.env.LOGGING || "true") !== false
const LOGGING = JSON.parse(process.env.LOGGING || `true`) !== false
const FIXED_NODE = process.env.COSMOS_NODE

module.exports = class Addressbook {
Expand All @@ -23,7 +23,7 @@ module.exports = class Addressbook {
return
}

this.addressbookPath = join(configPath, "addressbook.json")
this.addressbookPath = join(configPath, `addressbook.json`)
this.loadFromDisc()

// add persistent peers to already stored peers
Expand All @@ -41,11 +41,11 @@ module.exports = class Addressbook {
)

if (!peerIsKnown) {
LOGGING && console.log("Adding new peer:", peerHost)
LOGGING && console.log(`Adding new peer:`, peerHost)
this.peers.push({
host: peerHost,
// assume that new peers are available
state: "available"
state: `available`
})
}
}
Expand All @@ -58,21 +58,21 @@ module.exports = class Addressbook {
this.peers = []
return
}
let content = fs.readFileSync(this.addressbookPath, "utf8")
let content = fs.readFileSync(this.addressbookPath, `utf8`)
let peers = JSON.parse(content)
this.peers = peers.map(host => ({
host,
state: "available"
state: `available`
}))
}

persistToDisc() {
let peers = this.peers
// only remember available nodes
.filter(p => p.state === "available")
.filter(p => p.state === `available`)
.map(p => p.host)
fs.ensureFileSync(this.addressbookPath)
fs.writeFileSync(this.addressbookPath, JSON.stringify(peers), "utf8")
fs.writeFileSync(this.addressbookPath, JSON.stringify(peers), `utf8`)
}

// returns an available node or throws if it can't find any
Expand All @@ -94,18 +94,18 @@ module.exports = class Addressbook {
)
.then(() => true, () => false)
if (!alive)
throw Error("The fixed node you tried to connect to is not reachable.")
throw Error(`The fixed node you tried to connect to is not reachable.`)
} else {
let availableNodes = this.peers.filter(node => node.state === "available")
let availableNodes = this.peers.filter(node => node.state === `available`)
if (availableNodes.length === 0) {
throw Error("No nodes available to connect to")
throw Error(`No nodes available to connect to`)
}
// pick a random node
curNode =
availableNodes[Math.floor(Math.random() * availableNodes.length)]

try {
let peerIP = curNode.host.split(":")[0]
let peerIP = curNode.host.split(`:`)[0]
await this.discoverPeers(peerIP)
} catch (exception) {
console.log(
Expand All @@ -122,26 +122,26 @@ module.exports = class Addressbook {
this.persistToDisc()
}

this.onConnectionMessage("Picked node: " + curNode.host)
return (
curNode.host.split(":")[0] + ":" + this.config.default_tendermint_port // export the picked node with the correct tendermint port
)
this.onConnectionMessage(`Picked node: ` + curNode.host)
return `${curNode.host.split(`:`)[0]}:${
this.config.default_tendermint_port
}` // export the picked node with the correct tendermint port
}

flagNodeOffline(host) {
let peer = this.peers.find(p => p.host === host)
if (peer) peer.state = "down"
if (peer) peer.state = `down`
}

flagNodeIncompatible(host) {
let peer = this.peers.find(p => p.host === host)
if (peer) peer.state = "incompatible"
if (peer) peer.state = `incompatible`
}

resetNodes() {
this.peers = this.peers.map(peer =>
Object.assign({}, peer, {
state: "available"
state: `available`
})
)
}
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/index.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@
/* eslint-disable no-console */

// Set babel `env` and install `babel-register`
process.env.BABEL_ENV = "main"
process.env.BABEL_ENV = `main`

require("babel-register")({ ignore: /node_modules/ })
require(`babel-register`)({ ignore: /node_modules/ })

// Install `vue-devtools`
require("electron").app.on("ready", () => {
let installExtension = require("electron-devtools-installer")
require(`electron`).app.on(`ready`, () => {
let installExtension = require(`electron-devtools-installer`)
installExtension
.default(installExtension.VUEJS_DEVTOOLS)
.then(() => {})
.catch(err => {
console.log("Unable to install `vue-devtools`: \n", err)
console.log(`Unable to install \`vue-devtools\`: \n`, err)
})
})

// Require `main` process to boot app
require("./index")
require(`./index`)
Loading

0 comments on commit 6497228

Please sign in to comment.