fix lint errors and configure eslintrc to automatically work /w tooling

This commit is contained in:
Fred K. Schott
2017-11-12 12:40:44 -08:00
parent 27aa0247e7
commit 567036f382
10 changed files with 21 additions and 23 deletions

2
.gitignore vendored
View File

@@ -60,4 +60,4 @@ out/
# Ignore perf test cache
scripts/cache
eslintrc
.eslintrc

View File

@@ -72,7 +72,7 @@
"prepublish": "npm run clean && npm run compile",
"test": "babel-node ./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha",
"coveralls": "cat ./coverage/lcov.info | coveralls",
"lint": "if ! [ -f eslintrc ]; then curl -o eslintrc 'https://raw.githubusercontent.com/ripple/javascript-style-guide/es6/eslintrc'; echo 'parser: babel-eslint' >> eslintrc; fi; eslint -c eslintrc src/",
"lint": "if ! [ -f .eslintrc ]; then curl -o .eslintrc 'https://raw.githubusercontent.com/ripple/javascript-style-guide/es6/eslintrc'; echo 'parser: babel-eslint' >> .eslintrc; fi; eslint -c .eslintrc src/",
"perf": "./scripts/perf_test.sh",
"start": "babel-node scripts/http.js",
"sauce": "babel-node scripts/sauce-runner.js"

View File

@@ -17,9 +17,9 @@ lint() {
echo "eslint $(node_modules/.bin/eslint --version)"
yarn list babel-eslint
REPO_URL="https://raw.githubusercontent.com/ripple/javascript-style-guide"
curl "$REPO_URL/es6/eslintrc" > ./eslintrc
echo "parser: babel-eslint" >> ./eslintrc
node_modules/.bin/eslint -c ./eslintrc $(git --no-pager diff --name-only -M100% --diff-filter=AM --relative $(git merge-base FETCH_HEAD origin/HEAD) FETCH_HEAD | grep "\.js$")
curl "$REPO_URL/es6/eslintrc" > .eslintrc
echo "parser: babel-eslint" >> .eslintrc
node_modules/.bin/eslint -c .eslintrc $(git --no-pager diff --name-only -M100% --diff-filter=AM --relative $(git merge-base FETCH_HEAD origin/HEAD) FETCH_HEAD | grep "\.js$")
}
unittest() {

View File

@@ -1,6 +1,5 @@
/* @flow */
'use strict' // eslint-disable-line strict
const _ = require('lodash')
const assert = require('assert')
const utils = require('./utils')
const parseAmount = require('./amount')

View File

@@ -36,12 +36,14 @@ function parseFields(data: Object): Object {
settings.signers.threshold = data.signer_lists[0].SignerQuorum
}
if (data.signer_lists[0].SignerEntries) {
settings.signers.weights = _.map(data.signer_lists[0].SignerEntries, entry => {
return {
address: entry.SignerEntry.Account,
weight: entry.SignerEntry.SignerWeight
}
})
settings.signers.weights = _.map(
data.signer_lists[0].SignerEntries,
entry => {
return {
address: entry.SignerEntry.Account,
weight: entry.SignerEntry.SignerWeight
}
})
}
}
return settings

View File

@@ -1,6 +1,5 @@
/* @flow */
'use strict' // eslint-disable-line strict
const _ = require('lodash')
const utils = require('./utils')
type PaymentChannelResponse = {

View File

@@ -1,9 +1,8 @@
/* @flow */
'use strict' // eslint-disable-line strict
const _ = require('lodash')
const utils = require('./utils')
const parsePaymentChannel = require('./parse/payment-channel')
const {validate, removeUndefined} = utils.common
const {validate} = utils.common
const NotFoundError = utils.common.errors.NotFoundError
type PaymentChannel = {
@@ -34,15 +33,14 @@ type LedgerEntryResponse = {
function formatResponse(response: LedgerEntryResponse) {
if (response.node !== undefined &&
response.node.LedgerEntryType === 'PayChannel')
{
response.node.LedgerEntryType === 'PayChannel') {
return parsePaymentChannel(response.node)
} else {
throw new NotFoundError('Payment channel ledger entry not found')
}
}
function getPaymentChannel(id: string): Promise<PaymentChannelResponse> {
function getPaymentChannel(id: string): Promise<PaymentChannel> {
validate.getPaymentChannel({id})
const request = {
@@ -52,7 +50,7 @@ function getPaymentChannel(id: string): Promise<PaymentChannelResponse> {
ledger_index: 'validated'
}
return this.connection.request(request).then(_.partial(formatResponse))
return this.connection.request(request).then(formatResponse)
}
module.exports = getPaymentChannel

View File

@@ -12,7 +12,7 @@ function signPaymentChannelClaim(channel: string, amount: string,
const signingData = binary.encodeForSigningClaim({
channel: channel,
amount: xrpToDrops(amount),
amount: xrpToDrops(amount)
})
return keypairs.sign(signingData, privateKey)
}

View File

@@ -12,7 +12,7 @@ function verifyPaymentChannelClaim(channel: string, amount: string,
const signingData = binary.encodeForSigningClaim({
channel: channel,
amount: xrpToDrops(amount),
amount: xrpToDrops(amount)
})
return keypairs.verify(signingData, signature, publicKey)
}

View File

@@ -5,7 +5,7 @@ const utils = require('./utils')
const {validate, iso8601ToRippleTime, xrpToDrops} = utils.common
const ValidationError = utils.common.errors.ValidationError
import type {Instructions, Prepare} from './types.js'
import type {Adjustment, MaxAdjustment, Memo} from '../common/types.js'
import type {Memo} from '../common/types.js'
type EscrowCreation = {
amount: string,
@@ -25,7 +25,7 @@ function createEscrowCreationTransaction(account: string,
TransactionType: 'EscrowCreate',
Account: account,
Destination: payment.destination,
Amount: xrpToDrops(payment.amount),
Amount: xrpToDrops(payment.amount)
}
if (payment.condition !== undefined) {