From abaa40b269150432ed10783a83953cd50275e39a Mon Sep 17 00:00:00 2001 From: getlarge Date: Tue, 9 Mar 2021 14:20:00 +0100 Subject: [PATCH] fix: run lint Signed-off-by: getlarge --- plugins/add-vendors-plugin.js | 4 +++- src/baseRequest.js | 11 +++++---- src/connection.js | 6 ++--- src/format_text.js | 1 - src/request.js | 12 +++++----- src/sanitize.js | 7 +++--- src/stringify_as_query_param.js | 1 - src/transaction.js | 2 +- src/transport.js | 2 -- test/constants.js | 13 +++++----- webpack.development.js | 42 ++++++++++++++++----------------- webpack.parts.js | 2 +- 12 files changed, 51 insertions(+), 52 deletions(-) diff --git a/plugins/add-vendors-plugin.js b/plugins/add-vendors-plugin.js index 8ed1071..d76bc27 100644 --- a/plugins/add-vendors-plugin.js +++ b/plugins/add-vendors-plugin.js @@ -2,6 +2,8 @@ // SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) // Code is Apache-2.0 and docs are CC-BY-4.0 +/* eslint-disable strict, no-console, object-shorthand, import/no-extraneous-dependencies */ + const { ConcatSource } = require('webpack-sources') module.exports = class AddVendorsPlugin { @@ -28,7 +30,7 @@ module.exports = class AddVendorsPlugin { compilation.assets[this.base] = main compilation.assets[`${this.base}.map`] = mainMap } - + callback() } ) diff --git a/src/baseRequest.js b/src/baseRequest.js index 20d11ab..8f52478 100644 --- a/src/baseRequest.js +++ b/src/baseRequest.js @@ -11,7 +11,7 @@ import stringifyAsQueryParam from './stringify_as_query_param' const fetch = fetchPonyfill(Promise) -export function ResponseError(message, status, requestURI) { +export function ResponseError(message, status, requestURI) { this.name = 'ResponseError' this.message = message this.status = status @@ -19,7 +19,7 @@ export function ResponseError(message, status, requestURI) { this.stack = (new Error()).stack } -ResponseError.prototype = new Error; +ResponseError.prototype = new Error() /** * @private @@ -50,12 +50,15 @@ function handleResponse(res) { // If status is not a 2xx (based on Response.ok), assume it's an error // See https://developer.mozilla.org/en-US/docs/Web/API/GlobalFetch/fetch if (!(res && res.ok)) { - throw new ResponseError('HTTP Error: Requested page not reachable', `${res.status} ${res.statusText}`, res.url) + throw new ResponseError( + 'HTTP Error: Requested page not reachable', + `${res.status} ${res.statusText}`, + res.url + ) } return res } - /** * @private * imported from https://github.com/bigchaindb/js-utility-belt/ diff --git a/src/connection.js b/src/connection.js index f2b3a76..94ac3cc 100644 --- a/src/connection.js +++ b/src/connection.js @@ -22,7 +22,7 @@ export default class Connection { // This driver implements the BEP-14 https://github.com/bigchaindb/BEPs/tree/master/14 constructor(nodes, headers = {}, timeout = DEFAULT_TIMEOUT) { // Copy object - this.headers = Object.assign({}, headers) + this.headers = { ...headers } // Validate headers Object.keys(headers).forEach(header => { @@ -49,7 +49,7 @@ export default class Connection { if (typeof node === 'string') { return { 'endpoint': node, 'headers': headers } } else { - const allHeaders = Object.assign({}, headers, node.headers) + const allHeaders = { ...headers, ...node.headers } return { 'endpoint': node.endpoint, 'headers': allHeaders } } } @@ -155,7 +155,6 @@ export default class Connection { }) } - /** * @param transaction */ @@ -166,7 +165,6 @@ export default class Connection { }) } - /** * @param transaction */ diff --git a/src/format_text.js b/src/format_text.js index c8077ff..032fb49 100644 --- a/src/format_text.js +++ b/src/format_text.js @@ -4,7 +4,6 @@ import { sprintf } from 'sprintf-js' - // Regexes taken from or inspired by sprintf-js const Regex = { TEMPLATE_LITERAL: /\${([^)]+?)}/g, diff --git a/src/request.js b/src/request.js index 967a41f..8ccaa40 100644 --- a/src/request.js +++ b/src/request.js @@ -19,7 +19,6 @@ const ERROR_FROM_SERVER = 'HTTP Error: Requested page not reachable' * default settings, and response handling. */ - export default class Request { constructor(node) { this.node = node @@ -33,14 +32,15 @@ export default class Request { return Promise.reject(new Error('Request was not given a url.')) } // Load default fetch configuration and remove any falsy query parameters - const requestConfig = Object.assign({}, this.node.headers, DEFAULT_REQUEST_CONFIG, config, { + const requestConfig = { + ...this.node.headers, + ...DEFAULT_REQUEST_CONFIG, + ...config, query: config.query && sanitize(config.query) - }) + } const apiUrl = this.node.endpoint + urlPath if (requestConfig.jsonBody) { - requestConfig.headers = Object.assign({}, requestConfig.headers, { - 'Content-Type': 'application/json' - }) + requestConfig.headers = { ...requestConfig.headers, 'Content-Type': 'application/json' } } // If connectionError occurs, a timestamp equal to now + diff --git a/src/sanitize.js b/src/sanitize.js index 2d7029d..7215e6f 100644 --- a/src/sanitize.js +++ b/src/sanitize.js @@ -2,9 +2,8 @@ // SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) // Code is Apache-2.0 and docs are CC-BY-4.0 -import 'core-js/features/array/includes'; -import 'core-js/features/object/entries'; - +import 'core-js/features/array/includes' +import 'core-js/features/object/entries' /** * @private @@ -32,7 +31,7 @@ function filterFromObject(obj, filter, { isInclusion = true } = {}) { */ function applyFilterOnObject(obj, filterFn) { if (filterFn == null) { - return Object.assign({}, obj) + return { ...obj } } const filteredObj = {} diff --git a/src/stringify_as_query_param.js b/src/stringify_as_query_param.js index d6afd09..6c94439 100644 --- a/src/stringify_as_query_param.js +++ b/src/stringify_as_query_param.js @@ -6,7 +6,6 @@ import 'core-js/features/object/entries' import decamelize from 'decamelize' import queryString from 'query-string' - /** * @private * imported from https://github.com/bigchaindb/js-utility-belt/ diff --git a/src/transaction.js b/src/transaction.js index d9564ea..c38f371 100644 --- a/src/transaction.js +++ b/src/transaction.js @@ -166,7 +166,7 @@ export default class Transaction { subconditions.forEach((subcondition) => { // TODO: add support for Condition thresholdCondition.addSubfulfillment(subcondition) - //? Should be thresholdCondition.addSubcondition(subcondition) + // ? Should be thresholdCondition.addSubcondition(subcondition) }) if (json) { diff --git a/src/transport.js b/src/transport.js index 3c411b3..224aa39 100644 --- a/src/transport.js +++ b/src/transport.js @@ -4,7 +4,6 @@ import Request from './request' - /** * * @private @@ -13,7 +12,6 @@ import Request from './request' * customizable in the future). */ - export default class Transport { constructor(nodes, timeout) { this.connectionPool = [] diff --git a/test/constants.js b/test/constants.js index a85c63b..7c7a4c5 100644 --- a/test/constants.js +++ b/test/constants.js @@ -2,8 +2,8 @@ // SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) // Code is Apache-2.0 and docs are CC-BY-4.0 -import base58 from 'bs58' import { createHash } from 'crypto' +import base58 from 'bs58' import { Ed25519Sha256 } from 'crypto-conditions' import { Transaction, Ed25519Keypair } from '../src' // TODO: Find out if ava has something like conftest, if so put this there. @@ -34,13 +34,14 @@ export const bobCondition = Transaction.makeEd25519Condition(bob.publicKey) export const bobOutput = Transaction.makeOutput(bobCondition) export function delegatedSignTransaction(...keyPairs) { - return function sign(serializedTransaction, input, index) { + return function sign(serializedTransaction, input) { const transactionUniqueFulfillment = input.fulfills ? serializedTransaction - .concat(input.fulfills.transaction_id) - .concat(input.fulfills.output_index) : serializedTransaction + .concat(input.fulfills.transaction_id) + .concat(input.fulfills.output_index) : serializedTransaction const transactionHash = createHash('sha3-256').update(transactionUniqueFulfillment).digest() - const filteredKeyPairs = keyPairs.filter(({ publicKey }) => - input.owners_before.includes(publicKey)) + const filteredKeyPairs = keyPairs.filter( + ({ publicKey }) => input.owners_before.includes(publicKey) + ) const ed25519Fulfillment = new Ed25519Sha256() filteredKeyPairs.forEach(keyPair => { diff --git a/webpack.development.js b/webpack.development.js index e60bb0b..e4249a6 100644 --- a/webpack.development.js +++ b/webpack.development.js @@ -2,33 +2,33 @@ // SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) // Code is Apache-2.0 and docs are CC-BY-4.0 -/* eslint-disable strict, no-console, object-shorthand */ +/* eslint-disable strict, no-console, object-shorthand, import/no-extraneous-dependencies */ 'use strict' const TerserPlugin = require('terser-webpack-plugin') module.exports = { - devtool: 'inline-source-map', - optimization: { - minimizer: [ - new TerserPlugin({ - test: /vendor/, - sourceMap: false - }), - new TerserPlugin({ - test: /^((?!(vendor)).)*.js$/, - sourceMap: false - }) - ], - splitChunks: { - cacheGroups: { - commons: { - test: /[\\/]node_modules[\\/]/, - name: 'vendors', - chunks: 'all' + devtool: 'inline-source-map', + optimization: { + minimizer: [ + new TerserPlugin({ + test: /vendor/, + sourceMap: false + }), + new TerserPlugin({ + test: /^((?!(vendor)).)*.js$/, + sourceMap: false + }) + ], + splitChunks: { + cacheGroups: { + commons: { + test: /[\\/]node_modules[\\/]/, + name: 'vendors', + chunks: 'all' + } + } } - } } - } } diff --git a/webpack.parts.js b/webpack.parts.js index bbc8436..eb292d8 100644 --- a/webpack.parts.js +++ b/webpack.parts.js @@ -2,7 +2,7 @@ // SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) // Code is Apache-2.0 and docs are CC-BY-4.0 -/* eslint-disable strict, no-console, object-shorthand */ +/* eslint-disable strict, no-console, object-shorthand, import/no-extraneous-dependencies */ 'use strict'