Skip to content

Commit

Permalink
TSDoc linter added & update the doc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Adan committed Sep 3, 2023
1 parent cb525c9 commit 2869447
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 28 deletions.
5 changes: 4 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
module.exports = {
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
plugins: ["@typescript-eslint", 'eslint-plugin-tsdoc'],
root: true,
env: {
browser: true,
node: true,
jest: true,
},
rules: {
'tsdoc/syntax': 'warn'
}
};
2 changes: 1 addition & 1 deletion .github/workflows/lint-ts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ jobs:
- uses: actions/checkout@v3
- name: lint ts
run: |
npm install @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint typescript
npm install @typescript-eslint/parser @typescript-eslint/eslint-plugin -plugin-tsdoc eslint eslint typescript
npm i
npx eslint .
3 changes: 2 additions & 1 deletion node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"build-protobuf": "npm run compile-protobuf-files && npm run fix-protobuf-file",
"compile-protobuf-files": "cd src && pbjs -t static-module -o ProtobufMessage.js ../../babushka-core/src/protobuf/*.proto && pbts -o ProtobufMessage.d.ts ProtobufMessage.js",
"fix-protobuf-file": "replace 'this\\.encode\\(message, writer\\)\\.ldelim' 'this.encode(message, writer && writer.len ? writer.fork() : writer).ldelim' src/ProtobufMessage.js",
"test": "jest --verbose --runInBand"
"test": "jest --verbose --runInBand",
"lint": "eslint -f unix \"src/**/*.{ts,tsx}\""
},
"devDependencies": {
"@babel/preset-env": "^7.20.2",
Expand Down
43 changes: 32 additions & 11 deletions node/src/RedisClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,14 +258,27 @@ export class RedisClient {
this.writeBufferedRequestsToSocket();
}

/// Get the value associated with the given key, or null if no such value exists.
/// See https://redis.io/commands/get/ for details.

/** Get the value associated with the given key, or null if no such value exists.
* See https://redis.io/commands/get/ for details.
*
* @param key - The key to retrieve from the database.
* @returns If the key exists, returns the value of the key as a string. Otherwise, return null.
*/
public get(key: string): Promise<string | null> {
return this.createWritePromise(createGet(key));
}

/// Set the given key with the given value. Return value is dependent on the passed options.
/// See https://redis.io/commands/set/ for details.
/** Set the given key with the given value. Return value is dependent on the passed options.
* See https://redis.io/commands/set/ for details.
*
* @param key - The key to store.
* @param value - The value to store with the given key.
* @param options - The set options.
* @returns - If the value is successfully set, return OK.
* If value isn't set because of only_if_exists or only_if_does_not_exist conditions, return null.
* If return_old_value is set, return the old value as a string.
*/
public set(
key: string,
value: string,
Expand All @@ -274,24 +287,32 @@ export class RedisClient {
return this.createWritePromise(createSet(key, value, options));
}

/// Returns information and statistics about the server according to the given arguments.
/// When no parameter is provided, the default option is assumed.
/// See https://redis.io/commands/info/ for details.
/** Get information and statistics about the Redis server.
* See https://redis.io/commands/info/ for details.
*
* @param options - A list of InfoSection values specifying which sections of information to retrieve.
* When no parameter is provided, the default option is assumed.
* @returns a string containing the information for the sections requested.
*/
public info(options?: InfoOptions[]): Promise<string> {
return this.createWritePromise(createInfo(options));
}

/// Removes the specified keys. A key is ignored if it does not exist.
/// Returns the number of keys that were removed.
/// See https://redis.io/commands/del/ for details.
/** Get information and statistics about the Redis server.
* See https://redis.io/commands/info/ for details.
*
* @param options - A list of InfoSection values specifying which sections of information to retrieve.
* When no parameter is provided, the default option is assumed.
* @returns a string containing the information for the sections requested.
*/
public del(keys: string[]): Promise<number> {
return this.createWritePromise(createDel(keys));
}

/** Change the currently selected Redis database.
* See https://redis.io/commands/select/ for details.
*
* @param index : The index of the database to select.
* @param index - The index of the database to select.
* @returns A simple OK response.
*/
public select(index: number): Promise<"OK"> {
Expand Down
14 changes: 11 additions & 3 deletions node/src/RedisClusterClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,24 @@ export class RedisClusterClient extends RedisClient {
return super.createWritePromise(command, toProtobufRoute(route));
}

/// Returns information and statistics about the server according to the given arguments.
/// See https://redis.io/commands/info/ for details.

/** Get information and statistics about the Redis server.
* See https://redis.io/commands/info/ for details.
*
* @param options - A list of InfoSection values specifying which sections of information to retrieve.
* When no parameter is provided, the default option is assumed.
* @param route - The command will be routed automatically, unless `route` is provided, in which
* case the client will initially try to route the command to the nodes defined by `route`.
* @returns a string containing the information for the sections requested.
*/
public info(options?: InfoOptions[], route?: Routes): Promise<string> {
return this.createWritePromise(createInfo(options), toProtobufRoute(route));
}

/** Resets the statistics reported by Redis using the INFO and LATENCY HISTOGRAM commands.
* See https://redis.io/commands/config-resetstat/ for details.
*
* @param route The command will be routed automatically, unless `route` is provided, in which
* @param route - The command will be routed automatically, unless `route` is provided, in which
* case the client will initially try to route the command to the nodes defined by `route`.
*
* @returns always "OK"
Expand Down
42 changes: 31 additions & 11 deletions node/src/Transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,47 @@ import { redis_request } from "./ProtobufMessage";
export class BaseTransaction {
readonly commands: redis_request.Command[] = [];

/// Get the value associated with the given key, or null if no such value exists.
/// See https://redis.io/commands/get/ for details.
/** Get the value associated with the given key, or null if no such value exists.
* See https://redis.io/commands/get/ for details.
*
* @param key - The key to retrieve from the database.
* @returns If the key exists, returns the value of the key as a string. Otherwise, return null.
*/
public get(key: string) {
this.commands.push(createGet(key));
}

/// Set the given key with the given value. Return value is dependent on the passed options.
/// See https://redis.io/commands/set/ for details.
/** Set the given key with the given value. Return value is dependent on the passed options.
* See https://redis.io/commands/set/ for details.
*
* @param key - The key to store.
* @param value - The value to store with the given key.
* @param options - The set options.
* @returns If the value is successfully set, return OK.
* If value isn't set because of only_if_exists or only_if_does_not_exist conditions, return null.
* If return_old_value is set, return the old value as a string.
*/
public set(key: string, value: string, options?: SetOptions) {
this.commands.push(createSet(key, value, options));
}

/// Returns information and statistics about the server according to the given arguments.
/// See https://redis.io/commands/info/ for details.
/** Get information and statistics about the Redis server.
* See https://redis.io/commands/info/ for details.
*
* @param options - A list of InfoSection values specifying which sections of information to retrieve.
* When no parameter is provided, the default option is assumed.
* @returns a string containing the information for the sections requested.
*/
public info(options?: InfoOptions[]) {
this.commands.push(createInfo(options));
}

/// Removes the specified keys. A key is ignored if it does not exist.
/// Returns the number of keys that were removed.
/// See https://redis.io/commands/del/ for details.
/** Remove the specified keys. A key is ignored if it does not exist.
* See https://redis.io/commands/del/ for details.
*
* @param keys - A list of keys to be deleted from the database.
* @returns the number of keys that were removed.
*/
public del(keys: string[]) {
this.commands.push(createDel(keys));
}
Expand Down Expand Up @@ -70,8 +90,8 @@ export class Transaction extends BaseTransaction{
/** Change the currently selected Redis database.
* See https://redis.io/commands/select/ for details.
*
* @param index : The index of the database to select.
* @CommandResponse : A simple OK response.
* @param index - The index of the database to select.
* Returns A simple OK response.
*/
public select(index: number) {
this.commands.push(createSelect(index));
Expand Down

0 comments on commit 2869447

Please sign in to comment.