Skip to content

Commit

Permalink
Run Eslint on each folder, and fail on warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
shachlanAmazon committed Oct 1, 2023
1 parent a6968ca commit eecccd0
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 7 deletions.
20 changes: 18 additions & 2 deletions .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 . --max-warnings=0
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

0 comments on commit eecccd0

Please sign in to comment.