mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-27 12:05:10 +00:00
Add ESLinte to Auction Example
The auction example had no ESLint configuration. This change adds a .eslintrc.js file that matches the rest of the projects. This change also fixes all the linting issue in the auction example. Signed-off-by: Brett Logan <lindluni@github.com>
This commit is contained in:
parent
37513c3c2b
commit
6726e77932
12 changed files with 541 additions and 500 deletions
5
auction/application-javascript/.eslintignore
Normal file
5
auction/application-javascript/.eslintignore
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
coverage
|
||||
36
auction/application-javascript/.eslintrc.js
Normal file
36
auction/application-javascript/.eslintrc.js
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
env: {
|
||||
node: true,
|
||||
mocha: true
|
||||
},
|
||||
parserOptions: {
|
||||
ecmaVersion: 8,
|
||||
sourceType: 'script'
|
||||
},
|
||||
extends: 'eslint:recommended',
|
||||
rules: {
|
||||
indent: ['error', 'tab'],
|
||||
'linebreak-style': ['error', 'unix'],
|
||||
quotes: ['error', 'single'],
|
||||
semi: ['error', 'always'],
|
||||
'no-unused-vars': ['error', { args: 'none' }],
|
||||
'no-console': 'off',
|
||||
curly: 'error',
|
||||
eqeqeq: 'error',
|
||||
'no-throw-literal': 'error',
|
||||
strict: 'error',
|
||||
'no-var': 'error',
|
||||
'dot-notation': 'error',
|
||||
'no-trailing-spaces': 'error',
|
||||
'no-use-before-define': 'error',
|
||||
'no-useless-call': 'error',
|
||||
'no-with': 'error',
|
||||
'operator-linebreak': 'error',
|
||||
yoda: 'error',
|
||||
'quote-props': ['error', 'as-needed']
|
||||
}
|
||||
};
|
||||
|
|
@ -62,9 +62,9 @@ async function bid(ccp,wallet,user,orgMSP,auctionID,price) {
|
|||
async function main() {
|
||||
try {
|
||||
|
||||
if (process.argv[2] == undefined || process.argv[3] == undefined
|
||||
|| process.argv[4] == undefined || process.argv[5] == undefined) {
|
||||
console.log("Usage: node bid.js org userID auctionID price");
|
||||
if (process.argv[2] == undefined || process.argv[3] == undefined ||
|
||||
process.argv[4] == undefined || process.argv[5] == undefined) {
|
||||
console.log('Usage: node bid.js org userID auctionID price');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
|
|
@ -89,8 +89,8 @@ async function main() {
|
|||
const wallet = await buildWallet(Wallets, walletPath);
|
||||
await bid(ccp,wallet,user,orgMSP,auctionID,price);
|
||||
} else {
|
||||
console.log("Usage: node bid.js org userID auctionID price");
|
||||
console.log("Org must be Org1 or Org2");
|
||||
console.log('Usage: node bid.js org userID auctionID price');
|
||||
console.log('Org must be Org1 or Org2');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`******** FAILED to run the application: ${error}`);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ async function closeAuction(ccp,wallet,user,auctionID) {
|
|||
|
||||
// Query the auction to get the list of endorsing orgs.
|
||||
let auctionString = await contract.evaluateTransaction('QueryAuction',auctionID);
|
||||
var auctionJSON = JSON.parse(auctionString);
|
||||
let auctionJSON = JSON.parse(auctionString);
|
||||
|
||||
let statefulTxn = contract.createTransaction('CloseAuction');
|
||||
|
||||
|
|
@ -55,9 +55,9 @@ async function closeAuction(ccp,wallet,user,auctionID) {
|
|||
async function main() {
|
||||
try {
|
||||
|
||||
if (process.argv[2] == undefined || process.argv[3] == undefined
|
||||
|| process.argv[4] == undefined) {
|
||||
console.log("Usage: node closeAuction.js org userID auctionID");
|
||||
if (process.argv[2] == undefined || process.argv[3] == undefined ||
|
||||
process.argv[4] == undefined) {
|
||||
console.log('Usage: node closeAuction.js org userID auctionID');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
|
|
@ -81,8 +81,8 @@ async function main() {
|
|||
const wallet = await buildWallet(Wallets, walletPath);
|
||||
await closeAuction(ccp,wallet,user,auctionID);
|
||||
} else {
|
||||
console.log("Usage: node closeAuction.js org userID auctionID ");
|
||||
console.log("Org must be Org1 or Org2");
|
||||
console.log('Usage: node closeAuction.js org userID auctionID ');
|
||||
console.log('Org must be Org1 or Org2');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`******** FAILED to run the application: ${error}`);
|
||||
|
|
|
|||
|
|
@ -44,9 +44,9 @@ async function createAuction(ccp,wallet,user,auctionID,item) {
|
|||
async function main() {
|
||||
try {
|
||||
|
||||
if (process.argv[2] == undefined || process.argv[3] == undefined
|
||||
|| process.argv[4] == undefined || process.argv[5] == undefined) {
|
||||
console.log("Usage: node createAuction.js org userID auctionID item");
|
||||
if (process.argv[2] == undefined || process.argv[3] == undefined ||
|
||||
process.argv[4] == undefined || process.argv[5] == undefined) {
|
||||
console.log('Usage: node createAuction.js org userID auctionID item');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
|
|
@ -71,8 +71,8 @@ async function main() {
|
|||
const wallet = await buildWallet(Wallets, walletPath);
|
||||
await createAuction(ccp,wallet,user,auctionID,item);
|
||||
} else {
|
||||
console.log("Usage: node createAuction.js org userID auctionID item");
|
||||
console.log("Org must be Org1 or Org2");
|
||||
console.log('Usage: node createAuction.js org userID auctionID item');
|
||||
console.log('Org must be Org1 or Org2');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`******** FAILED to run the application: ${error}`);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ async function endAuction(ccp,wallet,user,auctionID) {
|
|||
|
||||
// Query the auction to get the list of endorsing orgs.
|
||||
let auctionString = await contract.evaluateTransaction('QueryAuction',auctionID);
|
||||
var auctionJSON = JSON.parse(auctionString);
|
||||
let auctionJSON = JSON.parse(auctionString);
|
||||
|
||||
let statefulTxn = contract.createTransaction('EndAuction');
|
||||
|
||||
|
|
@ -55,9 +55,9 @@ async function endAuction(ccp,wallet,user,auctionID) {
|
|||
async function main() {
|
||||
try {
|
||||
|
||||
if (process.argv[2] == undefined || process.argv[3] == undefined
|
||||
|| process.argv[4] == undefined) {
|
||||
console.log("Usage: node endAuction.js org userID auctionID");
|
||||
if (process.argv[2] == undefined || process.argv[3] == undefined ||
|
||||
process.argv[4] == undefined) {
|
||||
console.log('Usage: node endAuction.js org userID auctionID');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
|
|
@ -81,8 +81,8 @@ async function main() {
|
|||
const wallet = await buildWallet(Wallets, walletPath);
|
||||
await endAuction(ccp,wallet,user,auctionID);
|
||||
} else {
|
||||
console.log("Usage: node endAuction.js org userID auctionID");
|
||||
console.log("Org must be Org1 or Org2");
|
||||
console.log('Usage: node endAuction.js org userID auctionID');
|
||||
console.log('Org must be Org1 or Org2');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`******** FAILED to run the application: ${error}`);
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ async function connectToOrg2CA() {
|
|||
async function main() {
|
||||
|
||||
if (process.argv[2] == undefined) {
|
||||
console.log("Usage: node enrollAdmin.js Org");
|
||||
console.log('Usage: node enrollAdmin.js Org');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
|
|
@ -55,8 +55,8 @@ async function main() {
|
|||
else if (org == 'Org2' || org == 'org2') {
|
||||
await connectToOrg2CA();
|
||||
} else {
|
||||
console.log("Usage: node registerUser.js org userID");
|
||||
console.log("Org must be Org1 or Org2");
|
||||
console.log('Usage: node registerUser.js org userID');
|
||||
console.log('Org must be Org1 or Org2');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error in enrolling admin: ${error}`);
|
||||
|
|
|
|||
|
|
@ -38,9 +38,9 @@ async function queryAuction(ccp,wallet,user,auctionID) {
|
|||
async function main() {
|
||||
try {
|
||||
|
||||
if (process.argv[2] == undefined || process.argv[3] == undefined
|
||||
|| process.argv[4] == undefined) {
|
||||
console.log("Usage: node queryAuction.js org userID auctionID");
|
||||
if (process.argv[2] == undefined || process.argv[3] == undefined ||
|
||||
process.argv[4] == undefined) {
|
||||
console.log('Usage: node queryAuction.js org userID auctionID');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
|
|
@ -64,8 +64,8 @@ async function main() {
|
|||
const wallet = await buildWallet(Wallets, walletPath);
|
||||
await queryAuction(ccp,wallet,user,auctionID);
|
||||
} else {
|
||||
console.log("Usage: node queryAuction.js org userID auctionID");
|
||||
console.log("Org must be Org1 or Org2");
|
||||
console.log('Usage: node queryAuction.js org userID auctionID');
|
||||
console.log('Org must be Org1 or Org2');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`******** FAILED to run the application: ${error}`);
|
||||
|
|
|
|||
|
|
@ -38,9 +38,9 @@ async function queryBid(ccp,wallet,user,auctionID,bidID) {
|
|||
async function main() {
|
||||
try {
|
||||
|
||||
if (process.argv[2] == undefined || process.argv[3] == undefined
|
||||
|| process.argv[4] == undefined || process.argv[5] == undefined) {
|
||||
console.log("Usage: node bid.js org userID auctionID bidID");
|
||||
if (process.argv[2] == undefined || process.argv[3] == undefined ||
|
||||
process.argv[4] == undefined || process.argv[5] == undefined) {
|
||||
console.log('Usage: node bid.js org userID auctionID bidID');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
|
|
@ -65,8 +65,8 @@ async function main() {
|
|||
const wallet = await buildWallet(Wallets, walletPath);
|
||||
await queryBid(ccp,wallet,user,auctionID,bidID);
|
||||
} else {
|
||||
console.log("Usage: node bid.js org userID auctionID bidID");
|
||||
console.log("Org must be Org1 or Org2");
|
||||
console.log('Usage: node bid.js org userID auctionID bidID');
|
||||
console.log('Org must be Org1 or Org2');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`******** FAILED to run the application: ${error}`);
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ async function connectToOrg2CA(UserID) {
|
|||
async function main() {
|
||||
|
||||
if (process.argv[2] == undefined && process.argv[3] == undefined) {
|
||||
console.log("Usage: node registerEnrollUser.js org userID");
|
||||
console.log('Usage: node registerEnrollUser.js org userID');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
|
|
@ -56,8 +56,8 @@ async function main() {
|
|||
else if (org == 'Org2' || org == 'org2') {
|
||||
await connectToOrg2CA(userId);
|
||||
} else {
|
||||
console.log("Usage: node registerEnrollUser.js org userID");
|
||||
console.log("Org must be Org1 or Org2");
|
||||
console.log('Usage: node registerEnrollUser.js org userID');
|
||||
console.log('Org must be Org1 or Org2');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error in enrolling admin: ${error}`);
|
||||
|
|
|
|||
|
|
@ -27,12 +27,12 @@ async function addBid(ccp,wallet,user,auctionID,bidID) {
|
|||
|
||||
console.log('\n--> Evaluate Transaction: read your bid');
|
||||
let bidString = await contract.evaluateTransaction('QueryBid',auctionID,bidID);
|
||||
var bidJSON = JSON.parse(bidString);
|
||||
let bidJSON = JSON.parse(bidString);
|
||||
|
||||
//console.log('\n--> Evaluate Transaction: query the auction you want to join');
|
||||
let auctionString = await contract.evaluateTransaction('QueryAuction',auctionID);
|
||||
// console.log('*** Result: Bid: ' + prettyJSONString(auctionString.toString()));
|
||||
var auctionJSON = JSON.parse(auctionString);
|
||||
let auctionJSON = JSON.parse(auctionString);
|
||||
|
||||
let bidData = { objectType: 'bid', price: parseInt(bidJSON.price), org: bidJSON.org, bidder: bidJSON.bidder};
|
||||
console.log('*** Result: Bid: ' + JSON.stringify(bidData,null,2));
|
||||
|
|
@ -65,9 +65,9 @@ async function addBid(ccp,wallet,user,auctionID,bidID) {
|
|||
async function main() {
|
||||
try {
|
||||
|
||||
if (process.argv[2] == undefined || process.argv[3] == undefined
|
||||
|| process.argv[4] == undefined || process.argv[5] == undefined) {
|
||||
console.log("Usage: node revealBid.js org userID auctionID bidID");
|
||||
if (process.argv[2] == undefined || process.argv[3] == undefined ||
|
||||
process.argv[4] == undefined || process.argv[5] == undefined) {
|
||||
console.log('Usage: node revealBid.js org userID auctionID bidID');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
|
|
@ -93,8 +93,8 @@ async function main() {
|
|||
await addBid(ccp,wallet,user,auctionID,bidID);
|
||||
}
|
||||
else {
|
||||
console.log("Usage: node revealBid.js org userID auctionID bidID");
|
||||
console.log("Org must be Org1 or Org2");
|
||||
console.log('Usage: node revealBid.js org userID auctionID bidID');
|
||||
console.log('Org must be Org1 or Org2');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`******** FAILED to run the application: ${error}`);
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ async function submitBid(ccp,wallet,user,auctionID,bidID) {
|
|||
|
||||
console.log('\n--> Evaluate Transaction: query the auction you want to join');
|
||||
let auctionString = await contract.evaluateTransaction('QueryAuction',auctionID);
|
||||
var auctionJSON = JSON.parse(auctionString);
|
||||
let auctionJSON = JSON.parse(auctionString);
|
||||
|
||||
let statefulTxn = contract.createTransaction('SubmitBid');
|
||||
|
||||
|
|
@ -64,13 +64,13 @@ async function submitBid(ccp,wallet,user,auctionID,bidID) {
|
|||
async function main() {
|
||||
try {
|
||||
|
||||
if (process.argv[2] == undefined || process.argv[3] == undefined
|
||||
|| process.argv[4] == undefined || process.argv[5] == undefined) {
|
||||
console.log("Usage: node submitBid.js org userID auctionID bidID");
|
||||
if (process.argv[2] == undefined || process.argv[3] == undefined ||
|
||||
process.argv[4] == undefined || process.argv[5] == undefined) {
|
||||
console.log('Usage: node submitBid.js org userID auctionID bidID');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const org = process.argv[2]
|
||||
const org = process.argv[2];
|
||||
const user = process.argv[3];
|
||||
const auctionID = process.argv[4];
|
||||
const bidID = process.argv[5];
|
||||
|
|
@ -92,8 +92,8 @@ async function main() {
|
|||
await submitBid(ccp,wallet,user,auctionID,bidID);
|
||||
}
|
||||
else {
|
||||
console.log("Usage: node submitBid.js org userID auctionID bidID");
|
||||
console.log("Org must be Org1 or Org2");
|
||||
console.log('Usage: node submitBid.js org userID auctionID bidID');
|
||||
console.log('Org must be Org1 or Org2');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`******** FAILED to run the application: ${error}`);
|
||||
|
|
|
|||
Loading…
Reference in a new issue