Skip to content

Commit

Permalink
added prettier check to ci and added prettier format script
Browse files Browse the repository at this point in the history
  • Loading branch information
avifenesh committed Feb 20, 2024
1 parent d27205a commit 6eeafbe
Show file tree
Hide file tree
Showing 9 changed files with 216 additions and 204 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/lint-ts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:

- name: lint ts
run: |
npm install @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-tsdoc eslint typescript eslint-plugin-import@latest eslint-config-prettier
npm install @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-tsdoc eslint typescript eslint-plugin-import@latest eslint-config-prettier prettier
npm i
npx eslint .
npm run prettier:check:ci
4 changes: 3 additions & 1 deletion benchmarks/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"description": "",
"main": "node_benchmark.ts",
"scripts": {
"prettier:check:ci": "./node_modules/.bin/prettier --check .",
"prettier:format": "./node_modules/.bin/prettier --write .",
"bench": "node node_benchmark.js"
},
"author": "",
Expand All @@ -20,7 +22,7 @@
},
"devDependencies": {
"@types/node": "^18.7.9",
"prettier": "^2.7.1",
"prettier": "^2.8.8",
"typescript": "^4.8.4"
}
}
186 changes: 93 additions & 93 deletions benchmarks/node/tsconfig.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions benchmarks/utilities/fill_db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ async function fill_database(
host: string,
isCluster: boolean,
tls: boolean,
port: number
port: number,
) {
const client = await createRedisClient(host, isCluster, tls, port);
const data = generateValue(data_size);
Expand All @@ -27,7 +27,7 @@ async function fill_database(
const key = (i * CONCURRENT_SETS + index).toString();
await client.set(key, data);
}
}
},
);

await Promise.all(sets);
Expand All @@ -37,14 +37,14 @@ async function fill_database(
Promise.resolve()
.then(async () => {
console.log(
`Filling ${receivedOptions.host} with data size ${receivedOptions.dataSize}`
`Filling ${receivedOptions.host} with data size ${receivedOptions.dataSize}`,
);
await fill_database(
receivedOptions.dataSize,
receivedOptions.host,
receivedOptions.clusterModeEnabled,
receivedOptions.tls,
receivedOptions.port
receivedOptions.port,
);
})
.then(() => {
Expand Down
10 changes: 5 additions & 5 deletions benchmarks/utilities/flush_db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@ async function flush_database(
host: string,
isCluster: boolean,
tls: boolean,
port: number
port: number,
) {
if (isCluster) {
const client = (await createRedisClient(
host,
isCluster,
tls,
port
port,
)) as RedisClusterType;
await Promise.all(
client.masters.map((master) => {
return flush_database(master.host, false, tls, master.port);
})
}),
);
await client.quit();
} else {
const client = (await createRedisClient(
host,
isCluster,
tls,
port
port,
)) as RedisClientType;
await client.connect();
await client.flushAll();
Expand All @@ -44,7 +44,7 @@ Promise.resolve()
receivedOptions.host,
receivedOptions.clusterModeEnabled,
receivedOptions.tls,
receivedOptions.port
receivedOptions.port,
);
})
.then(() => {
Expand Down
9 changes: 6 additions & 3 deletions benchmarks/utilities/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"fill": "node fill_db.js",
"flush": "node flush_db.js"
"flush": "node flush_db.js",
"prettier:check:ci": "./node_modules/.bin/prettier --check .",
"prettier:format": "./node_modules/.bin/prettier --write ."
},
"author": "",
"license": "ISC",
"dependencies": {
"command-line-args": "^5.2.1",
"prettier": "^3.2.5",
"redis": "^4.6.8"
},
"devDependencies": {
"@types/command-line-args": "^5.2.1",
"typescript": "^4.8.4",
"@types/node": "^20.6.3"
"@types/node": "^20.6.3",
"typescript": "^4.8.4"
}
}
186 changes: 93 additions & 93 deletions benchmarks/utilities/tsconfig.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion benchmarks/utilities/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function createRedisClient(
host: string,
isCluster: boolean,
tls: boolean,
port: number
port: number,
): RedisClusterType | RedisClientType {
return isCluster
? createCluster({
Expand Down
12 changes: 9 additions & 3 deletions node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
"test": "jest --verbose --runInBand --testPathIgnorePatterns='RedisModules'",
"lint": "eslint -f unix \"src/**/*.{ts,tsx}\"",
"prepack": "npmignore --auto",
"test-modules": "jest --verbose --runInBand 'tests/RedisModules.test.ts'"
"test-modules": "jest --verbose --runInBand 'tests/RedisModules.test.ts'",
"prettier:check:ci": "./node_modules/.bin/prettier --check ./src ./tests --ignore-unknown '!**/*.{js,d.ts}'",
"prettier:format": "./node_modules/.bin/prettier --write ./src ./tests --ignore-unknown '!**/*.{js,d.ts}'"
},
"devDependencies": {
"@babel/preset-env": "^7.20.2",
Expand Down Expand Up @@ -70,8 +72,12 @@
"//": [
"The fields below have been commented out and are only necessary for publishing the package."
],
"///cpu": ["${node_arch}"],
"///os": ["${node_os}"],
"///cpu": [
"${node_arch}"
],
"///os": [
"${node_os}"
],
"///name": "${scope}${pkg_name}",
"///version": "${package_version}"
}

0 comments on commit 6eeafbe

Please sign in to comment.