Skip to content

Commit bf0ba0a

Browse files
authored
Prettier - ESLint (#531)
* eslint and prettier * working on eslint * working on eslint * fixed travis * rolled back md changes * Added unit tests * improved NamespaceHttp
1 parent b7e6858 commit bf0ba0a

File tree

322 files changed

+9976
-8470
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

322 files changed

+9976
-8470
lines changed

.eslintrc.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module.exports = {
2+
parser: "@typescript-eslint/parser", // Specifies the ESLint parser
3+
extends: [
4+
"plugin:@typescript-eslint/recommended", // Uses the recommended rules from the @typescript-eslint/eslint-plugin
5+
"prettier/@typescript-eslint", // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
6+
"plugin:prettier/recommended" // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
7+
],
8+
parserOptions: {
9+
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
10+
sourceType: "module" // Allows for the use of imports
11+
},
12+
rules: {
13+
"@typescript-eslint/no-non-null-assertion": "off",
14+
"@typescript-eslint/interface-name-prefix": "off",
15+
"@typescript-eslint/camelcase": "off",
16+
// TODO fix all the warnings
17+
"@typescript-eslint/explicit-function-return-type": "warn",
18+
"@typescript-eslint/no-unused-vars": "warn",
19+
"@typescript-eslint/no-inferrable-types": "warn",
20+
"@typescript-eslint/no-use-before-define": "warn"
21+
}
22+
};

.github/issue_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
2. Steps to reproduce the problem.
44

5-
3. Specifications like the version of the project, operating system, or hardware.
5+
3. Specifications like the version of the project, operating system, or hardware.

.prettierrc.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright 2020 NEM
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
module.exports = {
18+
semi: true,
19+
trailingComma: "all",
20+
singleQuote: true,
21+
printWidth: 140,
22+
tabWidth: 4
23+
};

.travis.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,39 @@
11
language: node_js
22
node_js:
3-
- "8"
4-
- "9"
5-
- "10"
3+
- '8'
4+
- '9'
5+
- '10'
6+
- '12'
67
cache:
78
directories:
8-
- "node_modules"
9+
- 'node_modules'
10+
- .eslintcache
911
before_script:
1012
- npm run build
13+
- if [ "$TRAVIS_NODE_VERSION" = "10" ] || [ "$TRAVIS_NODE_VERSION" = "12" ]; then npm run lint; fi
1114
script:
1215
- npm run test:cov
1316
- npm install --global typedoc typescript
1417
- CURRENT_VERSION=$(npm run version --silent)
1518
- typedoc --out "ts-docs/$CURRENT_VERSION" src
1619
- touch ./ts-docs/.nojekyll
17-
- if [ "$TRAVIS_NODE_VERSION" = "8" ]; then npm run coveralls-report; fi
20+
- if [ "$TRAVIS_NODE_VERSION" = "10" ]; then npm run coveralls-report; fi
1821
deploy:
1922
- provider: script
2023
skip_cleanup: true
2124
script: /bin/sh travis/github-pages.sh
2225
on:
2326
branch: master
24-
node_js: "9"
27+
node_js: '12'
2528
- provider: script
2629
skip_cleanup: true
2730
script: /bin/sh travis/uploadArchives.sh
2831
on:
2932
branch: master
30-
node_js: "8"
33+
node_js: '10'
3134
- provider: script
3235
skip_cleanup: true
3336
script: /bin/sh travis/release.sh
3437
on:
3538
branch: $RELEASE_BRANCH
36-
node_js: "8"
39+
node_js: '10'

e2e/infrastructure/AccountHttp.spec.ts

Lines changed: 54 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ describe('AccountHttp', () => {
120120
});
121121

122122
describe('Setup test AddressAlias', () => {
123-
124123
it('Announce addressAliasTransaction', () => {
125124
const addressAliasTransaction = AddressAliasTransaction.create(
126125
Deadline.create(),
@@ -136,29 +135,29 @@ describe('AccountHttp', () => {
136135
});
137136

138137
describe('Setup test multisig account', () => {
139-
140138
it('Announce MultisigAccountModificationTransaction', () => {
141139
const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create(
142140
Deadline.create(),
143141
2,
144142
1,
145-
[
146-
cosignAccount1.publicAccount,
147-
cosignAccount2.publicAccount,
148-
cosignAccount3.publicAccount,
149-
],
143+
[cosignAccount1.publicAccount, cosignAccount2.publicAccount, cosignAccount3.publicAccount],
150144
[],
151145
networkType,
152146
helper.maxFee,
153147
);
154148

155-
const aggregateTransaction = AggregateTransaction.createComplete(Deadline.create(),
149+
const aggregateTransaction = AggregateTransaction.createComplete(
150+
Deadline.create(),
156151
[modifyMultisigAccountTransaction.toAggregate(multisigAccount.publicAccount)],
157152
networkType,
158153
[],
159-
helper.maxFee);
160-
const signedTransaction = aggregateTransaction
161-
.signTransactionWithCosignatories(multisigAccount, [cosignAccount1, cosignAccount2, cosignAccount3], generationHash);
154+
helper.maxFee,
155+
);
156+
const signedTransaction = aggregateTransaction.signTransactionWithCosignatories(
157+
multisigAccount,
158+
[cosignAccount1, cosignAccount2, cosignAccount3],
159+
generationHash,
160+
);
162161

163162
return helper.announce(signedTransaction);
164163
});
@@ -186,8 +185,9 @@ describe('AccountHttp', () => {
186185

187186
describe('getMultisigAccountGraphInfo', () => {
188187
it('should call getMultisigAccountGraphInfo successfully', async () => {
189-
const multisigAccountGraphInfo =
190-
await multisigRepository.getMultisigAccountGraphInfo(multisigAccount.publicAccount.address).toPromise();
188+
const multisigAccountGraphInfo = await multisigRepository
189+
.getMultisigAccountGraphInfo(multisigAccount.publicAccount.address)
190+
.toPromise();
191191
expect(multisigAccountGraphInfo.multisigAccounts.get(0)![0].account.publicKey).to.be.equal(multisigAccount.publicKey);
192192
});
193193
});
@@ -213,26 +213,37 @@ describe('AccountHttp', () => {
213213

214214
describe('transactions', () => {
215215
it('should not return accounts when account does not exist', () => {
216-
return accountRepository.getAccountInfo(Account.generateNewAccount(networkType).address).toPromise().then(() => {
217-
return Promise.reject('should fail!');
218-
}, (err) => {
219-
const error = JSON.parse(err.message);
220-
expect(error.statusCode).to.be.eq(404);
221-
expect(error.errorDetails.statusMessage).to.be.eq('Not Found');
222-
return Promise.resolve();
223-
});
216+
return accountRepository
217+
.getAccountInfo(Account.generateNewAccount(networkType).address)
218+
.toPromise()
219+
.then(
220+
() => {
221+
return Promise.reject('should fail!');
222+
},
223+
(err) => {
224+
const error = JSON.parse(err.message);
225+
expect(error.statusCode).to.be.eq(404);
226+
expect(error.errorDetails.statusMessage).to.be.eq('Not Found');
227+
return Promise.resolve();
228+
},
229+
);
224230
});
225231
});
226232

227233
describe('transactions', () => {
228234
it('should call transactions successfully by type', async () => {
229-
const transactions = await accountRepository.getAccountTransactions(
230-
publicAccount.address, new QueryParams(), new TransactionFilter({
231-
types: [TransactionType.TRANSFER, TransactionType.AGGREGATE_COMPLETE],
232-
})).toPromise();
235+
const transactions = await accountRepository
236+
.getAccountTransactions(
237+
publicAccount.address,
238+
new QueryParams(),
239+
new TransactionFilter({
240+
types: [TransactionType.TRANSFER, TransactionType.AGGREGATE_COMPLETE],
241+
}),
242+
)
243+
.toPromise();
233244
expect(transactions.length).to.be.greaterThan(0);
234245
transactions.forEach((t) => {
235-
expect((t.type === TransactionType.TRANSFER || t.type === TransactionType.AGGREGATE_COMPLETE)).to.be.eq(true);
246+
expect(t.type === TransactionType.TRANSFER || t.type === TransactionType.AGGREGATE_COMPLETE).to.be.eq(true);
236247
});
237248
});
238249
});
@@ -285,8 +296,7 @@ describe('AccountHttp', () => {
285296
-1,
286297
0,
287298
[],
288-
[cosignAccount1.publicAccount,
289-
],
299+
[cosignAccount1.publicAccount],
290300
networkType,
291301
helper.maxFee,
292302
);
@@ -295,9 +305,7 @@ describe('AccountHttp', () => {
295305
0,
296306
0,
297307
[],
298-
[
299-
cosignAccount2.publicAccount,
300-
],
308+
[cosignAccount2.publicAccount],
301309
networkType,
302310
helper.maxFee,
303311
);
@@ -307,21 +315,27 @@ describe('AccountHttp', () => {
307315
-1,
308316
-1,
309317
[],
310-
[
311-
cosignAccount3.publicAccount,
312-
],
318+
[cosignAccount3.publicAccount],
313319
networkType,
314320
helper.maxFee,
315321
);
316322

317-
const aggregateTransaction = AggregateTransaction.createComplete(Deadline.create(),
318-
[removeCosigner1.toAggregate(multisigAccount.publicAccount),
323+
const aggregateTransaction = AggregateTransaction.createComplete(
324+
Deadline.create(),
325+
[
326+
removeCosigner1.toAggregate(multisigAccount.publicAccount),
319327
removeCosigner2.toAggregate(multisigAccount.publicAccount),
320-
removeCosigner3.toAggregate(multisigAccount.publicAccount)],
328+
removeCosigner3.toAggregate(multisigAccount.publicAccount),
329+
],
321330
networkType,
322-
[], helper.maxFee);
323-
const signedTransaction = aggregateTransaction
324-
.signTransactionWithCosignatories(cosignAccount1, [cosignAccount2, cosignAccount3], generationHash);
331+
[],
332+
helper.maxFee,
333+
);
334+
const signedTransaction = aggregateTransaction.signTransactionWithCosignatories(
335+
cosignAccount1,
336+
[cosignAccount2, cosignAccount3],
337+
generationHash,
338+
);
325339
return helper.announce(signedTransaction);
326340
});
327341
});

e2e/infrastructure/BlockHttp.spec.ts

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ describe('BlockHttp', () => {
6666
*/
6767

6868
describe('Setup Test Data', () => {
69-
7069
it('Announce TransferTransaction', () => {
7170
const transferTransaction = TransferTransaction.create(
7271
Deadline.create(),
@@ -110,8 +109,9 @@ describe('BlockHttp', () => {
110109
});
111110

112111
it('should return block transactions data given height with paginated transactionId', async () => {
113-
const transactions = await blockRepository.getBlockTransactions(UInt64.fromUint(1),
114-
new QueryParams({ pageSize: 10, id: nextId})).toPromise();
112+
const transactions = await blockRepository
113+
.getBlockTransactions(UInt64.fromUint(1), new QueryParams({ pageSize: 10, id: nextId }))
114+
.toPromise();
115115
expect(transactions[0].transactionInfo!.id).to.be.equal(firstId);
116116
expect(transactions.length).to.be.greaterThan(0);
117117
});
@@ -125,24 +125,32 @@ describe('BlockHttp', () => {
125125
});
126126
describe('getMerkleReceipts', () => {
127127
it('should return Merkle Receipts', async () => {
128-
const merkleReceipts = await receiptRepository.getBlockReceipts(chainHeight).pipe(
129-
mergeMap((_) => {
130-
return receiptRepository.getMerkleReceipts(chainHeight, _.transactionStatements[0].generateHash());
131-
})).toPromise();
128+
const merkleReceipts = await receiptRepository
129+
.getBlockReceipts(chainHeight)
130+
.pipe(
131+
mergeMap((_) => {
132+
return receiptRepository.getMerkleReceipts(chainHeight, _.transactionStatements[0].generateHash());
133+
}),
134+
)
135+
.toPromise();
132136
expect(merkleReceipts.merklePath).not.to.be.null;
133137
});
134138
});
135139
describe('getMerkleTransaction', () => {
136140
it('should return Merkle Transaction', async () => {
137-
const merkleTransactionss = await blockRepository.getBlockTransactions(chainHeight).pipe(
138-
mergeMap((_) => {
139-
const hash = (_[0].transactionInfo as TransactionInfo).hash;
140-
if (hash) {
141-
return blockRepository.getMerkleTransaction(chainHeight, hash);
142-
}
143-
// If reaching this line, something is not right
144-
throw new Error('Tansacation hash is undefined');
145-
})).toPromise();
141+
const merkleTransactionss = await blockRepository
142+
.getBlockTransactions(chainHeight)
143+
.pipe(
144+
mergeMap((_) => {
145+
const hash = (_[0].transactionInfo as TransactionInfo).hash;
146+
if (hash) {
147+
return blockRepository.getMerkleTransaction(chainHeight, hash);
148+
}
149+
// If reaching this line, something is not right
150+
throw new Error('Tansacation hash is undefined');
151+
}),
152+
)
153+
.toPromise();
146154
expect(merkleTransactionss.merklePath).not.to.be.null;
147155
});
148156
});

0 commit comments

Comments
 (0)