Skip to content

Commit e42a027

Browse files
committed
Fixed linting errors and warnings.
1 parent 75d62e5 commit e42a027

File tree

6 files changed

+41
-33
lines changed

6 files changed

+41
-33
lines changed

example/.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ ios/*
44
android/*
55
!.eslintrc.js
66
metro.config.js
7+
postinstall.js
78
__mocks__/**
89
coverage
910

example/App.tsx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import './shim';
2-
import React, { useEffect, useState } from 'react';
2+
import React, { ReactElement, useEffect, useState } from 'react';
33
import {
44
SafeAreaView,
55
ScrollView,
@@ -17,7 +17,7 @@ import lm from '@synonymdev/react-native-ldk';
1717
import { peers } from './utils/constants';
1818
import { dummyRandomSeed, setSeed } from './utils/helpers';
1919

20-
const App = () => {
20+
const App = (): ReactElement => {
2121
const [message, setMessage] = useState('...');
2222

2323
useEffect(() => {
@@ -32,7 +32,7 @@ const App = () => {
3232
}
3333
// Subscribe to new blocks and sync LDK accordingly.
3434
await subscribeToHeader({
35-
onReceive: async () => {
35+
onReceive: async (): Promise<void> => {
3636
const syncRes = await syncLdk();
3737
if (syncRes.isErr()) {
3838
setMessage(syncRes.error.message);
@@ -62,7 +62,7 @@ const App = () => {
6262
<View style={styles.container}>
6363
<Button
6464
title={'Create New Random Seed'}
65-
onPress={async () => {
65+
onPress={async (): Promise<void> => {
6666
const seed = dummyRandomSeed();
6767
await setSeed('ldkseed', seed);
6868
await setItem('LDKData', '');
@@ -72,7 +72,7 @@ const App = () => {
7272

7373
<Button
7474
title={'Sync LDK'}
75-
onPress={async () => {
75+
onPress={async (): Promise<void> => {
7676
const syncRes = await syncLdk();
7777
if (syncRes.isErr()) {
7878
setMessage(syncRes.error.message);
@@ -84,7 +84,7 @@ const App = () => {
8484

8585
<Button
8686
title={'Add Peers'}
87-
onPress={async () => {
87+
onPress={async (): Promise<void> => {
8888
try {
8989
const peersRes = await Promise.all(
9090
Object.keys(peers).map(async (peer) => {
@@ -108,7 +108,7 @@ const App = () => {
108108

109109
<Button
110110
title={'List peers'}
111-
onPress={async () => {
111+
onPress={async (): Promise<void> => {
112112
try {
113113
const listPeers = await ldk.listPeers();
114114
if (listPeers.isErr()) {
@@ -124,7 +124,7 @@ const App = () => {
124124

125125
<Button
126126
title={'List channels'}
127-
onPress={async () => {
127+
onPress={async (): Promise<void> => {
128128
try {
129129
const listChannels = await ldk.listChannels();
130130
if (listChannels.isErr()) {
@@ -164,22 +164,22 @@ const App = () => {
164164

165165
<Button
166166
title={'List watch transactions'}
167-
onPress={async () => {
167+
onPress={async (): Promise<void> => {
168168
console.log(lm.watchTxs);
169169
setMessage(`Watch TXs: ${JSON.stringify(lm.watchTxs)}`);
170170
}}
171171
/>
172172

173173
<Button
174174
title={'List watch outputs'}
175-
onPress={async () => {
175+
onPress={async (): Promise<void> => {
176176
setMessage(`Watch Outputs: ${JSON.stringify(lm.watchOutputs)}`);
177177
}}
178178
/>
179179

180180
<Button
181181
title={'Create invoice'}
182-
onPress={async () => {
182+
onPress={async (): Promise<void> => {
183183
try {
184184
const createPaymentRequest = await ldk.createPaymentRequest({
185185
amountSats: 1000000,
@@ -203,7 +203,7 @@ const App = () => {
203203

204204
<Button
205205
title={'Pay invoice'}
206-
onPress={async () => {
206+
onPress={async (): Promise<void> => {
207207
const paymentRequest = await Clipboard.getString();
208208
const decode = await ldk.decode({ paymentRequest });
209209
if (decode.isErr()) {
@@ -224,7 +224,7 @@ const App = () => {
224224
},
225225
{
226226
text: 'Pay',
227-
onPress: async () => {
227+
onPress: async (): Promise<void> => {
228228
const pay = await ldk.pay({ paymentRequest });
229229
if (pay.isErr()) {
230230
return setMessage(pay.error.message);
@@ -240,7 +240,7 @@ const App = () => {
240240

241241
<Button
242242
title={'Get info'}
243-
onPress={async () => {
243+
onPress={async (): Promise<void> => {
244244
const nodeIdRes = await ldk.nodeId();
245245
if (nodeIdRes.isErr()) {
246246
return setMessage(nodeIdRes.error.message);
@@ -255,7 +255,7 @@ const App = () => {
255255

256256
<Button
257257
title={'Show version'}
258-
onPress={async () => {
258+
onPress={async (): Promise<void> => {
259259
const ldkVersion = await ldk.version();
260260
if (ldkVersion.isErr()) {
261261
return setMessage(ldkVersion.error.message);

example/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"ios": "react-native run-ios",
88
"start": "react-native start",
99
"test": "jest",
10-
"lint": "eslint .",
10+
"lint:check": "eslint . --ext .js,.jsx,.ts,.tsx",
11+
"lint:fix": "eslint . --ext .js,.jsx,.ts,.tsx --fix",
1112
"clean": "rm -rf node_modules ios/Pods ios/Podfile.lock ios/build && yarn install && cd ios && pod deintegrate && pod install && cd ../",
1213
"postinstall": "node postinstall.js"
1314
},

example/postinstall.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
var exec = require('child_process').exec;
22
var os = require('os');
33

4-
const baseCommand = `rn-nodeify --install buffer,stream,assert,events,crypto,vm,process --hack`;
4+
const baseCommand =
5+
'rn-nodeify --install buffer,stream,assert,events,crypto,vm,process --hack';
56

67
function postInstallMac() {
78
exec(`${baseCommand} && cd ios && pod install && cd ..`);

example/shim.js

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,35 @@
1-
if (typeof __dirname === 'undefined') global.__dirname = '/'
2-
if (typeof __filename === 'undefined') global.__filename = ''
1+
if (typeof __dirname === 'undefined') {
2+
global.__dirname = '/';
3+
}
4+
if (typeof __filename === 'undefined') {
5+
global.__filename = '';
6+
}
37
if (typeof process === 'undefined') {
4-
global.process = require('process')
8+
global.process = require('process');
59
} else {
6-
const bProcess = require('process')
7-
for (var p in bProcess) {
8-
if (!(p in process)) {
9-
process[p] = bProcess[p]
10-
}
11-
}
10+
const bProcess = require('process');
11+
for (var p in bProcess) {
12+
if (!(p in process)) {
13+
process[p] = bProcess[p];
14+
}
15+
}
1216
}
1317

1418
global.net = require('./electrum/net');
1519
global.tls = require('./electrum/tls');
1620

17-
process.browser = false
18-
if (typeof Buffer === 'undefined') global.Buffer = require('buffer').Buffer
21+
process.browser = false;
22+
if (typeof Buffer === 'undefined') {
23+
global.Buffer = require('buffer').Buffer;
24+
}
1925

2026
// global.location = global.location || { port: 80 }
21-
const isDev = typeof __DEV__ === 'boolean' && __DEV__
22-
process.env['NODE_ENV'] = isDev ? 'development' : 'production'
27+
const isDev = typeof __DEV__ === 'boolean' && __DEV__;
28+
process.env.NODE_ENV = isDev ? 'development' : 'production';
2329
if (typeof localStorage !== 'undefined') {
24-
localStorage.debug = isDev ? '*' : ''
30+
localStorage.debug = isDev ? '*' : '';
2531
}
2632

2733
// If using the crypto shim, uncomment the following line to ensure
2834
// crypto is loaded first, so it can populate global.crypto
29-
require('crypto')
35+
require('crypto');

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
"scripts": {
2222
"build": "rm -rf dist && mkdir dist/ && tsc -p ./src",
2323
"watch": "yarn run build -- -w",
24-
"lint": "yarn lint",
2524
"lint:check": "eslint . --ext .js,.jsx,.ts,.tsx",
2625
"lint:fix": "eslint . --fix --ext .js,.jsx,.ts,.tsx",
2726
"prepublish": "yarn lint:fix && yarn run build && npm --no-git-tag-version version patch",

0 commit comments

Comments
 (0)