Skip to content

Commit 7199863

Browse files
DX-1248: Redis Eslint Update (#1278)
* bump eslint * lint * revert
1 parent 7a572b4 commit 7199863

File tree

5 files changed

+112
-54
lines changed

5 files changed

+112
-54
lines changed

.eslintrc.json

Lines changed: 0 additions & 44 deletions
This file was deleted.

bun.lockb

9.74 KB
Binary file not shown.

eslint.config.mjs

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
import typescriptEslint from "@typescript-eslint/eslint-plugin";
2+
import unicorn from "eslint-plugin-unicorn";
3+
import path from "node:path";
4+
import { fileURLToPath } from "node:url";
5+
import js from "@eslint/js";
6+
import { FlatCompat } from "@eslint/eslintrc";
7+
8+
const __filename = fileURLToPath(import.meta.url);
9+
const __dirname = path.dirname(__filename);
10+
const compat = new FlatCompat({
11+
baseDirectory: __dirname,
12+
recommendedConfig: js.configs.recommended,
13+
allConfig: js.configs.all,
14+
});
15+
16+
export default [
17+
{
18+
ignores: ["**/*.config.*", "**/examples", "**/dist"],
19+
},
20+
...compat.extends(
21+
"eslint:recommended",
22+
"plugin:unicorn/recommended",
23+
"plugin:@typescript-eslint/recommended"
24+
),
25+
{
26+
plugins: {
27+
"@typescript-eslint": typescriptEslint,
28+
unicorn,
29+
},
30+
31+
languageOptions: {
32+
globals: {},
33+
ecmaVersion: 5,
34+
sourceType: "script",
35+
36+
parserOptions: {
37+
project: "./tsconfig.json",
38+
},
39+
},
40+
41+
rules: {
42+
"no-console": [
43+
"error",
44+
{
45+
allow: ["warn", "error"],
46+
},
47+
],
48+
49+
"@typescript-eslint/no-magic-numbers": "off",
50+
"@typescript-eslint/unbound-method": "off",
51+
"@typescript-eslint/prefer-as-const": "error",
52+
"@typescript-eslint/consistent-type-imports": "error",
53+
"@typescript-eslint/no-explicit-any": "off",
54+
"@typescript-eslint/restrict-template-expressions": "off",
55+
56+
"@typescript-eslint/no-unused-vars": [
57+
"error",
58+
{
59+
varsIgnorePattern: "^_",
60+
argsIgnorePattern: "^_",
61+
},
62+
],
63+
64+
"@typescript-eslint/prefer-ts-expect-error": "off",
65+
66+
"@typescript-eslint/no-misused-promises": [
67+
"error",
68+
{
69+
checksVoidReturn: false,
70+
},
71+
],
72+
73+
"unicorn/prevent-abbreviations": "off",
74+
75+
"no-implicit-coercion": [
76+
"error",
77+
{
78+
boolean: true,
79+
},
80+
],
81+
82+
"no-extra-boolean-cast": [
83+
"error",
84+
{
85+
enforceForLogicalOperands: true,
86+
},
87+
],
88+
89+
"no-unneeded-ternary": [
90+
"error",
91+
{
92+
defaultAssignment: true,
93+
},
94+
],
95+
96+
"unicorn/no-array-reduce": ["off"],
97+
"unicorn/no-nested-ternary": "off",
98+
"unicorn/no-null": "off",
99+
"unicorn/filename-case": "off",
100+
},
101+
},
102+
];

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@
4848
"test": "bun test pkg",
4949
"fmt": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"",
5050
"prepare": "husky install",
51-
"lint": "eslint . --ext .ts,.tsx,.js,.jsx",
51+
"lint": "eslint \"**/*.{js,ts,tsx}\" --quiet --fix",
5252
"format": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"",
5353
"format:check": "prettier --check \"**/*.{ts,tsx,js,jsx,json,md}\"",
54-
"lint:fix": "eslint . --ext .ts,.tsx,.js,.jsx --fix",
54+
"lint:fix": "eslint . -c .ts,.tsx,.js,.jsx --fix",
5555
"commit": "cz",
5656
"lint:format": "bun run lint:fix && bun run format"
5757
},
@@ -79,10 +79,10 @@
7979
"@commitlint/cli": "^19.3.0",
8080
"@commitlint/config-conventional": "^19.2.2",
8181
"@types/crypto-js": "^4.1.3",
82-
"@typescript-eslint/eslint-plugin": "7.17.0",
83-
"@typescript-eslint/parser": "7.17.0",
82+
"@typescript-eslint/eslint-plugin": "8.4.0",
83+
"@typescript-eslint/parser": "8.4.0",
8484
"bun-types": "1.0.33",
85-
"eslint": "8.56",
85+
"eslint": "9.10.0",
8686
"eslint-plugin-unicorn": "55.0.0",
8787
"husky": "^9.1.1",
8888
"prettier": "^3.3.3",

pkg/auto-pipeline.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable @typescript-eslint/ban-types */
21
import type { Command } from "./commands/command";
32
import type { Pipeline } from "./pipeline";
43
import type { Redis } from "./redis";
@@ -12,7 +11,6 @@ export function createAutoPipelineProxy(_redis: Redis, json?: boolean): Redis {
1211
autoPipelineExecutor: AutoPipelineExecutor;
1312
};
1413

15-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1614
if (!redis.autoPipelineExecutor) {
1715
redis.autoPipelineExecutor = new AutoPipelineExecutor(redis);
1816
}
@@ -45,9 +43,11 @@ export function createAutoPipelineProxy(_redis: Redis, json?: boolean): Redis {
4543
// pass the function as a callback
4644
return redis.autoPipelineExecutor.withAutoPipeline((pipeline) => {
4745
if (json) {
48-
(pipeline.json[command as keyof Pipeline["json"]] as Function)(...args);
46+
(pipeline.json[command as keyof Pipeline["json"]] as (...args: any) => unknown)(
47+
...args
48+
);
4949
} else {
50-
(pipeline[command as keyof Pipeline] as Function)(...args);
50+
(pipeline[command as keyof Pipeline] as (...args: any) => unknown)(...args);
5151
}
5252
});
5353
};
@@ -92,7 +92,7 @@ class AutoPipelineExecutor {
9292
this.pipelinePromises.set(pipeline, pipelinePromise);
9393
this.activePipeline = null;
9494
}
95-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
95+
9696
return this.pipelinePromises.get(pipeline)!;
9797
});
9898

0 commit comments

Comments
 (0)