Skip to content

Commit

Permalink
Merge pull request valkey-io#490 from shachlanAmazon/ts-import-lint
Browse files Browse the repository at this point in the history
add import sort and warnings as errors to TS lint.
  • Loading branch information
shachlanAmazon authored Oct 2, 2023
2 parents 170867a + eecccd0 commit 5e4c183
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 12 deletions.
14 changes: 10 additions & 4 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
module.exports = {
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/errors",
"plugin:import/warnings",
],
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint", 'eslint-plugin-tsdoc'],
plugins: ["@typescript-eslint", "eslint-plugin-tsdoc", "import"],
root: true,
env: {
browser: true,
node: true,
jest: true,
},
rules: {
'tsdoc/syntax': 'error'
}
"tsdoc/syntax": "error",
"import/no-unresolved": "off",
},
};
18 changes: 17 additions & 1 deletion .github/workflows/lint-ts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,24 @@ jobs:
timeout-minutes: 10
steps:
- uses: actions/checkout@v4

- uses: ./.github/workflows/lint-ts
with:
package-folder: ./node
name: lint node

- uses: ./.github/workflows/lint-ts
with:
package-folder: ./benchmarks/node
name: lint benchmark

- uses: ./.github/workflows/lint-ts
with:
package-folder: ./benchmarks/utilities
name: lint benchmark utilities

- name: lint ts
run: |
npm install @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-tsdoc eslint typescript
npm install @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-tsdoc eslint typescript eslint-plugin-import@latest eslint-config-prettier
npm i
npx eslint .
23 changes: 23 additions & 0 deletions .github/workflows/lint-ts/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Lint TypeScript

inputs:
package-folder:
description: "folder that contains the target Cargo.toml file"
required: true
type: string

runs:
using: "composite"

steps:
- uses: actions/checkout@v4

- run: cp .eslintrc.cjs ${{ inputs.package-folder }}
shell: bash

- run: |
npm install @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-tsdoc eslint typescript eslint-plugin-import@latest eslint-config-prettier
npm i
npx eslint . --max-warnings=0
working-directory: ${{ inputs.package-folder }}
shell: bash
12 changes: 7 additions & 5 deletions node/tests/RedisClientInternals.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function sendResponse(
const new_response = response.Response.create();
new_response.callbackIdx = callbackIndex;
if (responseType == ResponseType.Value) {
const pointer = createLeakedValue(message!);
const pointer = createLeakedValue(message ?? "fake value");
const pointer_number = Number(pointer.toString());
new_response.respPointer = pointer_number;
} else if (responseType == ResponseType.ClosingError) {
Expand Down Expand Up @@ -86,9 +86,7 @@ function getConnectionAndSocket(
path.join(os.tmpdir(), `socket_listener`)
);
const socketName = path.join(temporaryFolder, "read");
let connectionPromise:
| Promise<RedisClient | RedisClusterClient>
| undefined = undefined;
let connectionPromise: Promise<RedisClient | RedisClusterClient>; // eslint-disable-line prefer-const
const server = net
.createServer(async (socket) => {
socket.once("data", (data) => {
Expand All @@ -105,7 +103,11 @@ function getConnectionAndSocket(
sendResponse(socket, ResponseType.Null, 0);
});

const connection = await connectionPromise!;
if (!connectionPromise) {
throw new Error("connectionPromise wasn't set");
}

const connection = await connectionPromise;
resolve({
connection,
socket,
Expand Down
4 changes: 2 additions & 2 deletions node/tests/RedisClusterClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import {
it,
} from "@jest/globals";
import { exec } from "child_process";
import { ClusterTransaction } from "../";
import {
ClusterTransaction,
ConnectionOptions,
InfoOptions,
RedisClusterClient,
} from "../build-ts";
} from "../";
import { convertMultiNodeResponseToDict } from "../src/RedisClusterClient";
import { runBaseTests } from "./SharedTests";
import { flushallOnPort, transactionTest } from "./TestUtilities";
Expand Down

0 comments on commit 5e4c183

Please sign in to comment.