Skip to content

Commit 71a4b0a

Browse files
committed
feat(scripts): add script to eslint --fix clients source code
1 parent 7e634cf commit 71a4b0a

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// @ts-check
2+
const { spawnProcess } = require("../utils/spawn-process");
3+
const path = require("path");
4+
5+
const eslintFixCode = async (dir) => {
6+
await spawnProcess(path.join(__dirname, "..", "..", "node_modules", ".bin", "eslint"), [
7+
"--fix",
8+
"--quiet",
9+
"--rule",
10+
`{'prefer-const': 'off'}`,
11+
`${dir}/*/typescript-codegen/**/*.ts`,
12+
]);
13+
};
14+
15+
module.exports = {
16+
eslintFixCode,
17+
};

scripts/generate-clients/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const {
1010
TEMP_CODE_GEN_INPUT_DIR,
1111
} = require("./code-gen-dir");
1212
const { prettifyCode } = require("./code-prettify");
13+
const { eslintFixCode } = require("./code-eslint-fix");
1314

1415
const SDK_CLIENTS_DIR = path.normalize(path.join(__dirname, "..", "..", "clients"));
1516
const PROTOCOL_TESTS_CLIENTS_DIR = path.normalize(path.join(__dirname, "..", "..", "protocol_tests"));
@@ -58,8 +59,12 @@ const {
5859
await generateClients(models || globs);
5960
if (!noProtocolTest) await generateProtocolTests();
6061

62+
await eslintFixCode(CODE_GEN_SDK_OUTPUT_DIR);
6163
await prettifyCode(CODE_GEN_SDK_OUTPUT_DIR);
62-
if (!noProtocolTest) await prettifyCode(CODE_GEN_PROTOCOL_TESTS_OUTPUT_DIR);
64+
if (!noProtocolTest) {
65+
await eslintFixCode(CODE_GEN_PROTOCOL_TESTS_OUTPUT_DIR);
66+
await prettifyCode(CODE_GEN_PROTOCOL_TESTS_OUTPUT_DIR);
67+
}
6368

6469
await copyToClients(CODE_GEN_SDK_OUTPUT_DIR, clientsDir);
6570
if (!noProtocolTest) await copyToClients(CODE_GEN_PROTOCOL_TESTS_OUTPUT_DIR, PROTOCOL_TESTS_CLIENTS_DIR);

0 commit comments

Comments
 (0)