Skip to content

feat(scripts): add script to eslint --fix clients source code #2838

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions scripts/generate-clients/code-eslint-fix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// @ts-check
const { spawnProcess } = require("../utils/spawn-process");
const path = require("path");

const eslintFixCode = async (dir) => {
await spawnProcess(path.join(__dirname, "..", "..", "node_modules", ".bin", "eslint"), [
"--fix",
"--quiet",
"--rule",
`{'prefer-const': 'off'}`,
`${dir}/*/typescript-codegen/**/*.ts`,
]);
};

module.exports = {
eslintFixCode,
};
7 changes: 6 additions & 1 deletion scripts/generate-clients/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const {
TEMP_CODE_GEN_INPUT_DIR,
} = require("./code-gen-dir");
const { prettifyCode } = require("./code-prettify");
const { eslintFixCode } = require("./code-eslint-fix");

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

await eslintFixCode(CODE_GEN_SDK_OUTPUT_DIR);
await prettifyCode(CODE_GEN_SDK_OUTPUT_DIR);
if (!noProtocolTest) await prettifyCode(CODE_GEN_PROTOCOL_TESTS_OUTPUT_DIR);
if (!noProtocolTest) {
await eslintFixCode(CODE_GEN_PROTOCOL_TESTS_OUTPUT_DIR);
await prettifyCode(CODE_GEN_PROTOCOL_TESTS_OUTPUT_DIR);
}

await copyToClients(CODE_GEN_SDK_OUTPUT_DIR, clientsDir);
if (!noProtocolTest) await copyToClients(CODE_GEN_PROTOCOL_TESTS_OUTPUT_DIR, PROTOCOL_TESTS_CLIENTS_DIR);
Expand Down