mirror of
https://github.com/Xahau/xahau.js.git
synced 2026-06-04 17:26:46 +00:00
fix lint errors and configure eslintrc to automatically work /w tooling
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -60,4 +60,4 @@ out/
|
||||
# Ignore perf test cache
|
||||
scripts/cache
|
||||
|
||||
eslintrc
|
||||
.eslintrc
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* @flow */
|
||||
'use strict' // eslint-disable-line strict
|
||||
const _ = require('lodash')
|
||||
const utils = require('./utils')
|
||||
|
||||
type PaymentChannelResponse = {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user