Skip to content

Commit 983648d

Browse files
authored
Merge pull request #372 from rsksmart/add-linter-and-prettier-support
Installed prettier and linter
2 parents c28238c + 33b141b commit 983648d

84 files changed

Lines changed: 10244 additions & 6362 deletions

File tree

Some content is hidden

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

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ tcpsigner.log
1818
logs/
1919
federate-node.jar
2020
zlogs/
21+
.eslintcache

.prettierignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Dependency Directories
2+
node_modules/
3+
4+
# Build Outputs
5+
dist/
6+
build/
7+
coverage/
8+
9+
# Auto-generated artifacts
10+
package-lock.json
11+
pnpm-lock.yaml
12+
13+
# OS / Editor junk
14+
.DS_Store
15+
.idea/
16+
.vscode/
17+
18+
# File types to ignore
19+
*.json
20+
*.xml
21+
*.md
22+
*.yml
23+
*.yaml

.prettierrc.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"semi": true,
3+
"trailingComma": "es5",
4+
"singleQuote": true,
5+
"printWidth": 100,
6+
"tabWidth": 4,
7+
"useTabs": false,
8+
"arrowParens": "always",
9+
"endOfLine": "lf",
10+
"bracketSpacing": true
11+
}

cleanEnv.js

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -7,50 +7,50 @@ require('dotenv').config();
77
const killServicesCommand = "kill $(ps -A | grep -e java -e bitcoind | awk '{print $1}')";
88

99
async function clearLogFiles(directory) {
10-
try {
11-
const files = await fs.promises.readdir(directory, { withFileTypes: true });
12-
13-
for (const file of files) {
14-
const filePath = path.join(directory, file.name);
15-
16-
if (file.isDirectory()) {
17-
await clearLogFiles(filePath);
18-
} else if (path.extname(file.name) === ".log") {
19-
await fs.promises.truncate(filePath, 0);
20-
console.log(`Cleared content of file: ${filePath}`);
21-
}
10+
try {
11+
const files = await fs.promises.readdir(directory, { withFileTypes: true });
12+
13+
for (const file of files) {
14+
const filePath = path.join(directory, file.name);
15+
16+
if (file.isDirectory()) {
17+
await clearLogFiles(filePath);
18+
} else if (path.extname(file.name) === '.log') {
19+
await fs.promises.truncate(filePath, 0);
20+
console.log(`Cleared content of file: ${filePath}`);
21+
}
22+
}
23+
} catch (err) {
24+
console.error(`Error processing directory ${directory}: ${err.message}`);
2225
}
23-
} catch (err) {
24-
console.error(`Error processing directory ${directory}: ${err.message}`);
25-
}
2626
}
2727

2828
function clearBitcoinDataDirectory() {
29-
return new Promise((resolve, reject) => {
30-
const directory = process.env.BITCOIN_DATA_DIR;
31-
32-
if (!directory) {
33-
return reject(new Error("BITCOIN_DATA_DIR is not set."));
34-
}
35-
36-
fs.readdir(directory, (err, files) => {
37-
if (err) {
38-
return reject(new Error(`Error reading directory ${directory}: ${err.message}`));
39-
}
40-
41-
const deletePromises = files.map(file => {
42-
const filePath = path.join(directory, file);
43-
return fs.promises.rm(filePath, { recursive: true, force: true });
44-
});
45-
46-
Promise.all(deletePromises)
47-
.then(() => {
48-
console.log(`Successfully cleared contents of: ${directory}`);
49-
resolve();
50-
})
51-
.catch(reject);
29+
return new Promise((resolve, reject) => {
30+
const directory = process.env.BITCOIN_DATA_DIR;
31+
32+
if (!directory) {
33+
return reject(new Error('BITCOIN_DATA_DIR is not set.'));
34+
}
35+
36+
fs.readdir(directory, (err, files) => {
37+
if (err) {
38+
return reject(new Error(`Error reading directory ${directory}: ${err.message}`));
39+
}
40+
41+
const deletePromises = files.map((file) => {
42+
const filePath = path.join(directory, file);
43+
return fs.promises.rm(filePath, { recursive: true, force: true });
44+
});
45+
46+
Promise.all(deletePromises)
47+
.then(() => {
48+
console.log(`Successfully cleared contents of: ${directory}`);
49+
resolve();
50+
})
51+
.catch(reject);
52+
});
5253
});
53-
});
5454
}
5555
const cleanEnvironment = async () => {
5656
console.info('Cleaning environment...');

config/regtest-all-keyfiles.js

Lines changed: 271 additions & 114 deletions
Large diffs are not rendered by default.

config/regtest-key-files-and-hsms.js

Lines changed: 185 additions & 99 deletions
Large diffs are not rendered by default.

eslint.config.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
const js = require('@eslint/js');
2+
const globals = require('globals');
3+
4+
const JS_FILES = ['**/*.js']; // only .js files (not .mjs/.cjs)
5+
6+
module.exports = [
7+
{ ignores: ['node_modules/**', 'dist/**', 'coverage/**'] },
8+
9+
{
10+
files: ['**/*.{js,cjs,mjs}'],
11+
...js.configs.recommended,
12+
},
13+
14+
// Your environment + language options
15+
{
16+
files: JS_FILES,
17+
languageOptions: {
18+
ecmaVersion: 2021,
19+
globals: {
20+
...globals.node,
21+
...globals.es2021,
22+
...globals.mocha,
23+
},
24+
},
25+
rules: {
26+
'no-console': 'warn',
27+
},
28+
},
29+
30+
{
31+
files: ['**/*.cjs'],
32+
languageOptions: {
33+
ecmaVersion: 2021,
34+
sourceType: 'commonjs',
35+
globals: {
36+
...globals.node,
37+
...globals.es2021,
38+
},
39+
},
40+
},
41+
42+
{
43+
files: ['**/*.mjs'],
44+
languageOptions: {
45+
ecmaVersion: 2021,
46+
sourceType: 'module',
47+
globals: {
48+
...globals.node,
49+
...globals.es2021,
50+
},
51+
},
52+
},
53+
];

lib/2wp-utils-legacy.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,20 @@ const rsk = require('peglib').rsk;
33
const rskUtilsLegacy = require('./rsk-utils-legacy');
44

55
const sendTxToBridgeWithoutMining = (rskClient) => async (senderAddress, valueInWeis) => {
6-
76
return new Promise((resolve, reject) => {
87
const sendResult = rskClient.eth.sendTransaction({
98
from: senderAddress,
109
to: rsk.getBridgeAddress(),
1110
value: valueInWeis,
12-
gasPrice: 2
11+
gasPrice: 2,
1312
});
1413

1514
sendResult.catch((err) => reject(err));
1615
sendResult.once('transactionHash', (txHash) => {
1716
resolve(txHash);
1817
});
19-
})
20-
}
18+
});
19+
};
2120

2221
const createPegoutRequest = async (rskClient, pegClient, amountInRBTC, requestSize = 1) => {
2322
const AMOUNT_IN_WEIS = rsk.btcToWeis(amountInRBTC);
@@ -34,11 +33,10 @@ const createPegoutRequest = async (rskClient, pegClient, amountInRBTC, requestSi
3433
for (let i = 0; i < requestSize; i++) {
3534
await sendTxToBridgeFunction(addresses.rsk, AMOUNT_IN_WEIS);
3635
}
37-
await rskClient.evm.mine()
38-
}
36+
await rskClient.evm.mine();
37+
};
3938

4039
module.exports = {
41-
with: (btcClient, rskClient) => ({
42-
}),
40+
with: (btcClient, rskClient) => ({}),
4341
createPegoutRequest,
4442
};

0 commit comments

Comments
 (0)