Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DX-1248: Redis Eslint Update #1278

Merged
merged 3 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bun.lockb
Binary file not shown.
81 changes: 81 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import unicorn from "eslint-plugin-unicorn";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});

export default [{
ignores: ["**/*.config.*", "**/examples", "**/dist"],
}, ...compat.extends(
"eslint:recommended",
"plugin:unicorn/recommended",
"plugin:@typescript-eslint/recommended",
), {
plugins: {
"@typescript-eslint": typescriptEslint,
unicorn,
},

languageOptions: {
globals: {},
ecmaVersion: 5,
sourceType: "script",

parserOptions: {
project: "./tsconfig.json",
},
},

rules: {
"no-console": ["error", {
allow: ["warn", "error"],
}],

"@typescript-eslint/no-magic-numbers": "off",
"@typescript-eslint/unbound-method": "off",
"@typescript-eslint/prefer-as-const": "error",
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/restrict-template-expressions": "off",
"@typescript-eslint/consistent-type-definitions": ["error", "type"],

"@typescript-eslint/no-unused-vars": ["error", {
varsIgnorePattern: "^_",
argsIgnorePattern: "^_",
}],

"@typescript-eslint/prefer-ts-expect-error": "off",

"@typescript-eslint/no-misused-promises": ["error", {
checksVoidReturn: false,
}],

"unicorn/prevent-abbreviations": "off",

"no-implicit-coercion": ["error", {
boolean: true,
}],

"no-extra-boolean-cast": ["error", {
enforceForLogicalOperands: true,
}],

"no-unneeded-ternary": ["error", {
defaultAssignment: true,
}],

"unicorn/no-array-reduce": ["off"],
"unicorn/no-nested-ternary": "off",
"unicorn/no-null": "off",
"unicorn/filename-case": "off",
},
}];
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@
"test": "bun test pkg",
"fmt": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"",
"prepare": "husky install",
"lint": "eslint . --ext .ts,.tsx,.js,.jsx",
"lint": "eslint \"**/*.{js,ts,tsx}\" --quiet --fix",
"format": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"",
"format:check": "prettier --check \"**/*.{ts,tsx,js,jsx,json,md}\"",
"lint:fix": "eslint . --ext .ts,.tsx,.js,.jsx --fix",
"lint:fix": "eslint . -c .ts,.tsx,.js,.jsx --fix",
"commit": "cz",
"lint:format": "bun run lint:fix && bun run format"
},
Expand Down Expand Up @@ -79,10 +79,10 @@
"@commitlint/cli": "^19.3.0",
"@commitlint/config-conventional": "^19.2.2",
"@types/crypto-js": "^4.1.3",
"@typescript-eslint/eslint-plugin": "7.17.0",
"@typescript-eslint/parser": "7.17.0",
"@typescript-eslint/eslint-plugin": "8.4.0",
"@typescript-eslint/parser": "8.4.0",
"bun-types": "1.0.33",
"eslint": "8.56",
"eslint": "9.10.0",
"eslint-plugin-unicorn": "55.0.0",
"husky": "^9.1.1",
"prettier": "^3.3.3",
Expand Down
10 changes: 5 additions & 5 deletions pkg/auto-pipeline.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/ban-types */
import type { Command } from "./commands/command";
import type { Pipeline } from "./pipeline";
import type { Redis } from "./redis";
Expand All @@ -12,7 +11,6 @@ export function createAutoPipelineProxy(_redis: Redis, json?: boolean): Redis {
autoPipelineExecutor: AutoPipelineExecutor;
};

// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!redis.autoPipelineExecutor) {
redis.autoPipelineExecutor = new AutoPipelineExecutor(redis);
}
Expand Down Expand Up @@ -45,9 +43,11 @@ export function createAutoPipelineProxy(_redis: Redis, json?: boolean): Redis {
// pass the function as a callback
return redis.autoPipelineExecutor.withAutoPipeline((pipeline) => {
if (json) {
(pipeline.json[command as keyof Pipeline["json"]] as Function)(...args);
(pipeline.json[command as keyof Pipeline["json"]] as (...args: any) => unknown)(
...args
);
} else {
(pipeline[command as keyof Pipeline] as Function)(...args);
(pipeline[command as keyof Pipeline] as (...args: any) => unknown)(...args);
}
});
};
Expand Down Expand Up @@ -92,7 +92,7 @@ class AutoPipelineExecutor {
this.pipelinePromises.set(pipeline, pipelinePromise);
this.activePipeline = null;
}
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion

return this.pipelinePromises.get(pipeline)!;
});

Expand Down
4 changes: 2 additions & 2 deletions pkg/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export type UpstashRequest = {
};
export type UpstashResponse<TResult> = { result?: TResult; error?: string };

export interface Requester {
export type Requester = {
CahidArda marked this conversation as resolved.
Show resolved Hide resolved
/**
* When this flag is enabled, any subsequent commands issued by this client are guaranteed to observe the effects of all earlier writes submitted by the same client.
*/
Expand All @@ -31,7 +31,7 @@ export interface Requester {
*/
upstashSyncToken?: string;
request: <TResult = unknown>(req: UpstashRequest) => Promise<UpstashResponse<TResult>>;
}
};

type ResultError = {
result?: string | number | null | (string | number | null)[];
Expand Down
Loading