Skip to content

Commit

Permalink
Merge pull request #57 from heatherlp/linting
Browse files Browse the repository at this point in the history
Create eslint task
  • Loading branch information
harrisob authored Dec 4, 2019
2 parents 0c2f520 + 67365b5 commit 804e680
Show file tree
Hide file tree
Showing 31 changed files with 294 additions and 339 deletions.
12 changes: 7 additions & 5 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#
# Copyright 2018 IBM All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
./test
coverage
node_modules

**/coverage/**
**/node_modules/**
docs/**
fabric-network/lib/**
fabric-protos/**
fabric-client/test/data/**
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
}
],
"no-console": ["warn"],
"no-mixed-spaces-and-tabs": ["error"],
"no-mixed-spaces-and-tabs": ["error"],
"no-shadow": ["error"],
"no-throw-literal": ["error"],
"no-trailing-spaces": ["error"],
Expand Down
2 changes: 1 addition & 1 deletion fabric-ca-client/lib/FabricCAClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const FabricCAClient = class {
}

this._caName = connect_opts.caname,
this._httpClient = (connect_opts.protocol === 'http') ? http : https;
this._httpClient = (connect_opts.protocol === 'http') ? http : https;
this._hostname = connect_opts.hostname;
if (connect_opts.port) {
this._port = connect_opts.port;
Expand Down
2 changes: 1 addition & 1 deletion fabric-client/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ coverage
node_modules
config
.nyc_output

test/data/**
6 changes: 3 additions & 3 deletions fabric-client/lib/Policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const EndorsementPolicy = class {
const signedBys = [];
let index = 0;
for (const name in msps) {
if (msps.hasOwnProperty(name)) {
if (Object.prototype.hasOwnProperty.call(msps, name)) {
const onePrn = new fabprotos.common.MSPPrincipal();
onePrn.setPrincipalClassification(fabprotos.common.MSPPrincipal.Classification.ROLE);

Expand Down Expand Up @@ -172,7 +172,7 @@ function buildPrincipal(identity) {
function getIdentityType(obj) {
const invalidTypes = [];
for (const key in obj) {
if (obj.hasOwnProperty(key)) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
if (key === IDENTITY_TYPE.Role || key === IDENTITY_TYPE.OrganizationUnit || key === IDENTITY_TYPE.Identity) {
return key;
} else {
Expand All @@ -192,7 +192,7 @@ function getIdentityType(obj) {
function getPolicyType(spec) {
const invalidTypes = [];
for (const key in spec) {
if (spec.hasOwnProperty(key)) {
if (Object.prototype.hasOwnProperty.call(spec, key)) {
// each policy spec has exactly one property of one of these two forms: 'n-of' or 'signed-by'
if (key === 'signed-by' || key.match(/^\d+-of$/)) {
return key;
Expand Down
6 changes: 3 additions & 3 deletions fabric-client/lib/impl/DiscoveryEndorsementHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,7 @@ class DiscoveryEndorsementHandler extends EndorsementHandler {
if (results.success) {
results.endorsements = await this._execute_endorsements(endorsers);
for (const endorsement of results.endorsements) {
if (endorsement instanceof Error) {
results.success = false;
} else if (typeof endorsement.success === 'boolean' && endorsement.success === false) {
if (endorsement instanceof Error || (typeof endorsement.success === 'boolean' && endorsement.success === false)) {
results.success = false;
}
}
Expand Down Expand Up @@ -267,6 +265,7 @@ class DiscoveryEndorsementHandler extends EndorsementHandler {
logger.debug('%s - start', method);
let error = null;
const self = this;
// eslint-disable-next-line no-async-promise-executor
return new Promise(async (resolve) => {
for (const peer_info of group.peers) {
const previous_endorsement = endorsement_plan.endorsements[peer_info.name];
Expand All @@ -287,6 +286,7 @@ class DiscoveryEndorsementHandler extends EndorsementHandler {
try {
const endorsement = await peer.sendProposal(proposal, timeout);
// save this endorsement results in case we try this peer again
// eslint-disable-next-line require-atomic-updates
endorsement_plan.endorsements[peer_info.name] = {endorsement, success: true};
logger.debug('%s - endorsement completed to %s - %s', method, peer_info.name, endorsement.response.status);
resolve(endorsement);
Expand Down
4 changes: 2 additions & 2 deletions fabric-client/test/Chaincode.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const lifecycle_protos = require('fabric-protos').lifecycle;

function propertiesToBeEqual(obj, properties, value) {
properties.forEach((prop) => {
if (obj.hasOwnProperty(prop)) {
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
should.equal(obj[prop], value);
} else {
should.fail();
Expand All @@ -45,7 +45,7 @@ function propertiesToBeNull(obj, properties) {

function propertiesToBeInstanceOf(obj, properties, clazz) {
properties.forEach((prop) => {
if (obj.hasOwnProperty(prop)) {
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
obj[prop].should.be.instanceof(clazz);
} else {
should.fail();
Expand Down
3 changes: 3 additions & 0 deletions fabric-client/types/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
"index.d.ts",
"base.d.ts"
],
"exclude": [
"test/data/**"
],
"formatCodeOptions": {
"indentSize": 4,
"tabSize": 4
Expand Down
1 change: 1 addition & 0 deletions fabric-common/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ coverage
node_modules
config
.nyc_output
test/data/**
2 changes: 2 additions & 0 deletions fabric-common/lib/DiscoveryHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ class DiscoveryHandler extends ServiceHandler {
const method = '_build_endorse_group_member >> ' + group_name + ':' + endorser_process_index;
logger.debug('%s - start', method);

// eslint-disable-next-line no-async-promise-executor
return new Promise(async (resolve) => {
let endorsement = null;
for (const peer_info of group.peers) {
Expand All @@ -332,6 +333,7 @@ class DiscoveryHandler extends ServiceHandler {
logger.error('%s - error on endorsement to %s error %s', method, peer_info.name, error);
}
// save this endorsement results in case we try this peer again
// eslint-disable-next-line require-atomic-updates
endorsement_plan.endorsements[peer_info.name] = endorsement;
} else {
logger.debug('%s - peer %s not assigned to this channel', method, peer_info.name);
Expand Down
2 changes: 1 addition & 1 deletion fabric-common/lib/Eventer.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class Eventer extends ServiceEndpoint {
logger.debug(`${method} - end`);
}

/**
/**
* Check the connection status
*/
async checkConnection() {
Expand Down
10 changes: 3 additions & 7 deletions fabric-common/lib/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,13 +450,9 @@ const CryptoKeyStore = function (KVSImplClass, opts) {
if (this._store === null) {
this.logger.debug(util.format('This class requires a CryptoKeyStore to save keys, using the store: %j', this._storeConfig));

try {
this._store = await CKS(this._storeConfig.superClass, this._storeConfig.opts);
await this._store.initialize();
return this._store;
} catch (err) {
throw err;
}
this._store = await CKS(this._storeConfig.superClass, this._storeConfig.opts);
await this._store.initialize();
return this._store;
} else {
this.logger.debug('_getKeyStore returning store');
return this._store;
Expand Down
Loading

0 comments on commit 804e680

Please sign in to comment.