Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 1 addition & 3 deletions packages/eslint-config/scripts/typegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ import {
yaml,
} from "../src";

async function combine(
...configs: MaybePromise<MaybeArray<TypedFlatConfigItem>>[]
): Promise<any[]> {
async function combine(...configs: MaybePromise[]): Promise {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Retain specific input and return types for better type safety and specificity.

Changing the input and return types to more generic types reduces type safety and specificity. It is recommended to retain the specific input and return types to ensure the expected input and output structure and prevent potential type-related errors in the consuming code.

Apply this diff to retain the specific input and return types:

-async function combine(...configs: MaybePromise[]): Promise {
+async function combine(...configs: MaybePromise<MaybeArray<TypedFlatConfigItem>>[]): Promise<any[]> {
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
async function combine(...configs: MaybePromise[]): Promise {
async function combine(...configs: MaybePromise<MaybeArray<TypedFlatConfigItem>>[]): Promise<any[]> {

const resolved = await Promise.all(configs);

return resolved.flat();
Expand Down
6 changes: 2 additions & 4 deletions packages/eslint-config/src/configs/formatting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { GLOB_PACKAGEJSON, GLOB_TESTS, GLOB_TSCONFIG } from "../globs";
import type { MaybeArray, Options, TypedFlatConfigItem } from "../types";
import { interopDefault } from "../utils";

export async function formatting(
options?: Options,
): Promise<TypedFlatConfigItem[]> {
export async function formatting(options?: Options): Promise {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maintain type specificity in the function return type.

Changing the return type from Promise<TypedFlatConfigItem[]> to Promise reduces type specificity and may lead to less predictable behavior in type-checking scenarios. Consider maintaining the original return type for better type safety.

Apply this diff to maintain type specificity:

-export async function formatting(options?: Options): Promise {
+export async function formatting(options?: Options): Promise<TypedFlatConfigItem[]> {
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export async function formatting(options?: Options): Promise {
export async function formatting(options?: Options): Promise<TypedFlatConfigItem[]> {

const pluginStylistic = await interopDefault(
import("@stylistic/eslint-plugin"),
);
Expand Down Expand Up @@ -181,7 +179,7 @@ export async function formatting(
"jest-formatting/padding-around-all": "error",
},
},
] satisfies (MaybeArray<TypedFlatConfigItem> | boolean)[]
] satisfies (MaybeArray | boolean)[]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maintain type specificity in type assertion.

Changing the type assertion from (MaybeArray<TypedFlatConfigItem> | boolean)[] to (MaybeArray | boolean)[] reduces type specificity and may lead to less predictable behavior in type-checking scenarios. Consider maintaining the original type assertion for better type safety.

Apply this diff to maintain type specificity:

-] satisfies (MaybeArray | boolean)[]
+] satisfies (MaybeArray<TypedFlatConfigItem> | boolean)[]
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
] satisfies (MaybeArray | boolean)[]
] satisfies (MaybeArray<TypedFlatConfigItem> | boolean)[]

)
.flat()
.filter(Boolean) as any;
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config/src/configs/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { GLOB_HTML } from "../globs";
import type { TypedFlatConfigItem } from "../types";
import { interopDefault, renameRules } from "../utils";

export async function html(): Promise<TypedFlatConfigItem[]> {
export async function html(): Promise {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Retain specific return type for better type safety and specificity.

Changing the return type from Promise<TypedFlatConfigItem[]> to Promise reduces type safety and specificity. It is recommended to retain the specific return type to ensure the expected output structure and prevent potential type-related errors in the consuming code.

Apply this diff to retain the specific return type:

-export async function html(): Promise {
+export async function html(): Promise<TypedFlatConfigItem[]> {
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export async function html(): Promise {
export async function html(): Promise<TypedFlatConfigItem[]> {

const parserHtml = await interopDefault(import("@html-eslint/parser"));
const pluginHtml = await interopDefault(import("@html-eslint/eslint-plugin"));
const pluginHtmlJsSupport = await interopDefault(
Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-config/src/configs/javascript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import {
import type { OptionsOverrides, TypedFlatConfigItem } from "../types";
import { interopDefault } from "../utils";

export async function javascript({ overrides }: OptionsOverrides = {}): Promise<
TypedFlatConfigItem[]
> {
export async function javascript({
overrides,
}: OptionsOverrides = {}): Promise {
const regexpRecommended = pluginRegexp.configs["flat/recommended"];

return [
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config/src/configs/jsonc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { GLOB_ESLINTRC, GLOB_JSON, GLOB_JSON5, GLOB_JSONC } from "../globs";
import type { TypedFlatConfigItem } from "../types";
import { interopDefault } from "../utils";

export async function jsonc(): Promise<TypedFlatConfigItem[]> {
export async function jsonc(): Promise {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert to the more specific return type for better type safety.

The original return type Promise<TypedFlatConfigItem[]> provided more information about the structure of the returned data, which is beneficial for consumers of the function. Consider reverting to the original return type for better type safety and specificity.

Apply this diff to revert the return type:

-export async function jsonc(): Promise {
+export async function jsonc(): Promise<TypedFlatConfigItem[]> {
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export async function jsonc(): Promise {
export async function jsonc(): Promise<TypedFlatConfigItem[]> {

const parserJsonc = await interopDefault(import("jsonc-eslint-parser"));
const pluginJsonc = await interopDefault(import("eslint-plugin-jsonc"));

Expand Down
4 changes: 1 addition & 3 deletions packages/eslint-config/src/configs/mdx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import { interopDefault } from "../utils";
export async function mdx({
componentExts = [],
overrides,
}: OptionsComponentExts & OptionsOverrides = {}): Promise<
TypedFlatConfigItem[]
> {
}: OptionsComponentExts & OptionsOverrides = {}): Promise {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Retain specific return type for better type safety and specificity.

Changing the return type from Promise<TypedFlatConfigItem[]> to Promise reduces type safety and specificity. It is recommended to retain the specific return type to ensure the expected output structure and prevent potential type-related errors in the consuming code.

Apply this diff to retain the specific return type:

}: OptionsComponentExts & OptionsOverrides = {}): Promise {
}: OptionsComponentExts & OptionsOverrides = {}): Promise<TypedFlatConfigItem[]> {
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
}: OptionsComponentExts & OptionsOverrides = {}): Promise {
}: OptionsComponentExts & OptionsOverrides = {}): Promise<TypedFlatConfigItem[]> {

const pluginMdx = await interopDefault(import("eslint-plugin-mdx"));

return [
Expand Down
4 changes: 1 addition & 3 deletions packages/eslint-config/src/configs/solid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import { interopDefault } from "../utils";
export async function solid({
overrides,
typescript,
}: OptionsHasTypeScript & OptionsOverrides = {}): Promise<
TypedFlatConfigItem[]
> {
}: OptionsHasTypeScript & OptionsOverrides = {}): Promise {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert the return type change.

The function still returns an array of configuration objects, so the original return type Promise<TypedFlatConfigItem[]> should be retained to maintain type safety and clarity.

Apply this diff to revert the return type change:

-export async function solid({ overrides, typescript }: OptionsHasTypeScript & OptionsOverrides = {}): Promise {
+export async function solid({ overrides, typescript }: OptionsHasTypeScript & OptionsOverrides = {}): Promise<TypedFlatConfigItem[]> {
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
}: OptionsHasTypeScript & OptionsOverrides = {}): Promise {
export async function solid({ overrides, typescript }: OptionsHasTypeScript & OptionsOverrides = {}): Promise<TypedFlatConfigItem[]> {

const pluginSolid = await interopDefault(import("eslint-plugin-solid"));

return [
Expand Down
4 changes: 1 addition & 3 deletions packages/eslint-config/src/configs/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { GLOB_TESTS } from "../globs";
import type { OptionsOverrides, TypedFlatConfigItem } from "../types";
import { interopDefault } from "../utils";

export async function test({ overrides }: OptionsOverrides = {}): Promise<
TypedFlatConfigItem[]
> {
export async function test({ overrides }: OptionsOverrides = {}): Promise {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert the return type change to maintain type safety and clarity.

The return type of the function test has been changed from Promise<TypedFlatConfigItem[]> to Promise. This reduces type safety and clarity regarding the expected return value. Revert the change to maintain type safety and clarity.

-export async function test({ overrides }: OptionsOverrides = {}): Promise {
+export async function test({ overrides }: OptionsOverrides = {}): Promise<TypedFlatConfigItem[]> {
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export async function test({ overrides }: OptionsOverrides = {}): Promise {
export async function test({ overrides }: OptionsOverrides = {}): Promise<TypedFlatConfigItem[]> {

const pluginNoOnlyTests = await interopDefault(
// @ts-expect-error No declaration
import("eslint-plugin-no-only-tests"),
Expand Down
4 changes: 1 addition & 3 deletions packages/eslint-config/src/configs/toml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { GLOB_TOML } from "../globs";
import type { OptionsOverrides, TypedFlatConfigItem } from "../types";
import { interopDefault } from "../utils";

export async function toml({ overrides }: OptionsOverrides = {}): Promise<
TypedFlatConfigItem[]
> {
export async function toml({ overrides }: OptionsOverrides = {}): Promise {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert the return type change.

The function still returns an array of configuration objects, so the original return type Promise<TypedFlatConfigItem[]> should be retained to maintain type safety and clarity.

Apply this diff to revert the return type change:

-export async function toml({ overrides }: OptionsOverrides = {}): Promise {
+export async function toml({ overrides }: OptionsOverrides = {}): Promise<TypedFlatConfigItem[]> {
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export async function toml({ overrides }: OptionsOverrides = {}): Promise {
export async function toml({ overrides }: OptionsOverrides = {}): Promise<TypedFlatConfigItem[]> {

const parserToml = await interopDefault(import("toml-eslint-parser"));
const pluginToml = await interopDefault(import("eslint-plugin-toml"));

Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config/src/configs/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export async function typescript({
overrides,
}: OptionsTypeScriptParserOptions &
OptionsComponentExts &
OptionsOverrides = {}): Promise<TypedFlatConfigItem[]> {
OptionsOverrides = {}): Promise {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maintain type specificity in the function return type.

Changing the return type from Promise<TypedFlatConfigItem[]> to Promise reduces type specificity and may lead to less predictable behavior in type-checking scenarios. Consider maintaining the original return type for better type safety.

Apply this diff to maintain type specificity:

	OptionsOverrides = {}): Promise {
+	OptionsOverrides = {}): Promise<TypedFlatConfigItem[]> {

Committable suggestion was skipped due to low confidence.

const typeAwareRules: Rules = {
"no-throw-literal": "off",
"ts/no-throw-literal": "error",
Expand Down
4 changes: 1 addition & 3 deletions packages/eslint-config/src/configs/vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import { interopDefault } from "../utils";
export async function vue({
overrides,
typescript,
}: OptionsHasTypeScript & OptionsOverrides = {}): Promise<
TypedFlatConfigItem[]
> {
}: OptionsHasTypeScript & OptionsOverrides = {}): Promise {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maintain type specificity in the function return type.

Changing the return type from Promise<TypedFlatConfigItem[]> to Promise reduces type specificity and may lead to less predictable behavior in type-checking scenarios. Consider maintaining the original return type for better type safety.

Apply this diff to maintain type specificity:

}: OptionsHasTypeScript & OptionsOverrides = {}): Promise {
+}: OptionsHasTypeScript & OptionsOverrides = {}): Promise<TypedFlatConfigItem[]> {

Committable suggestion was skipped due to low confidence.

const parserVue = await interopDefault(import("vue-eslint-parser"));
// @ts-expect-error No declaration
const pluginVue = await interopDefault(import("eslint-plugin-vue"));
Expand Down
4 changes: 1 addition & 3 deletions packages/eslint-config/src/configs/yaml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { GLOB_YAML } from "../globs";
import type { OptionsOverrides, TypedFlatConfigItem } from "../types";
import { interopDefault, renameRules } from "../utils";

export async function yaml({ overrides }: OptionsOverrides = {}): Promise<
TypedFlatConfigItem[]
> {
export async function yaml({ overrides }: OptionsOverrides = {}): Promise {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert the return type change.

The function still returns an array of configuration objects, so the original return type Promise<TypedFlatConfigItem[]> should be retained to maintain type safety and clarity.

Apply this diff to revert the return type change:

-export async function yaml({ overrides }: OptionsOverrides = {}): Promise {
+export async function yaml({ overrides }: OptionsOverrides = {}): Promise<TypedFlatConfigItem[]> {
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export async function yaml({ overrides }: OptionsOverrides = {}): Promise {
export async function yaml({ overrides }: OptionsOverrides = {}): Promise<TypedFlatConfigItem[]> {

const parserYaml = await interopDefault(import("yaml-eslint-parser"));
const pluginYaml = await interopDefault(import("eslint-plugin-yml"));

Expand Down
8 changes: 4 additions & 4 deletions packages/eslint-config/src/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const defaultPluginRenaming = {
*/
export function so1ve(
options: Options & TypedFlatConfigItem = {},
...userConfigs: MaybeArray<TypedFlatConfigItem>[]
...userConfigs: MaybeArray[]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert the parameter and variable type changes to maintain type safety and specificity.

The parameter type for userConfigs has been changed from MaybeArray<TypedFlatConfigItem>[] to MaybeArray[], and the configs variable declaration has been changed from MaybePromise<TypedFlatConfigItem[]>[] to MaybePromise[]. These changes broaden the accepted input type but reduce type safety and specificity. Revert the changes to maintain type safety and specificity.

...userConfigs: MaybeArray[]
...userConfigs: MaybeArray<TypedFlatConfigItem>[]

const configs: MaybePromise[]
const configs: MaybePromise<TypedFlatConfigItem[]>[]

Also applies to: 73-73

) {
const {
vue: enableVue = VuePackages.some((i) => isPackageExists(i)),
Expand All @@ -70,7 +70,7 @@ export function so1ve(
componentExts = [],
} = options;

const configs: MaybePromise<TypedFlatConfigItem[]>[] = [];
const configs: MaybePromise[] = [];

if (enableGitignore) {
if (typeof enableGitignore === "boolean") {
Expand Down Expand Up @@ -202,12 +202,12 @@ export function so1ve(
return composer;
}

export type ResolvedOptions<T> = T extends boolean ? never : NonNullable<T>;
export type ResolvedOptions<T> = T extends boolean ? never : NonNullable;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert the type change to maintain type specificity.

The type ResolvedOptions<T> has been changed to ResolvedOptions. This removes the generic type parameter, reducing type specificity and potentially impacting type resolution in contexts where ResolvedOptions is utilized. Revert the change to maintain type specificity.

-export type ResolvedOptions<T> = T extends boolean ? never : NonNullable;
+export type ResolvedOptions<T> = T extends boolean ? never : NonNullable<T>;

): ResolvedOptions =>
): ResolvedOptions<Options[K]> =>

Also applies to: 210-210


export const resolveSubOptions = <K extends keyof Options>(
options: Options & TypedFlatConfigItem,
key: K,
): ResolvedOptions<Options[K]> =>
): ResolvedOptions =>
typeof options[key] === "boolean" ? ({} as any) : options[key] || {};

export function getOverrides<K extends keyof Options>(
Expand Down
11 changes: 4 additions & 7 deletions packages/eslint-config/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@ import type { FlatGitignoreOptions } from "eslint-config-flat-gitignore";

import type { RuleOptions } from "./typegen";

export type MaybePromise<T> = T | Promise<T>;
export type MaybePromise<T> = T | Promise;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert the type change to maintain type safety and specificity.

The type MaybePromise has been changed from T | Promise<T> to T | Promise. This simplifies the promise type handling but removes the generic parameter, reducing type safety and specificity. Revert the change to maintain type safety and specificity.

-export type MaybePromise<T> = T | Promise;
+export type MaybePromise<T> = T | Promise<T>;
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export type MaybePromise<T> = T | Promise;
export type MaybePromise<T> = T | Promise<T>;

export type MaybeArray<T> = T | T[];

export type Rules = RuleOptions;

export type TypedFlatConfigItem = Omit<
Linter.FlatConfig<Linter.RulesRecord & Rules>,
"plugins"
> & {
export type TypedFlatConfigItem = Omit & {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert the type change to maintain strict type checking.

The type TypedFlatConfigItem has been changed from Omit<Linter.FlatConfig<Linter.RulesRecord & Rules>, "plugins"> to Omit. This removes the specific type context, potentially leading to less strict type checking. Revert the change to maintain strict type checking.

-export type TypedFlatConfigItem = Omit & {
+export type TypedFlatConfigItem = Omit<Linter.FlatConfig<Linter.RulesRecord & Rules>, "plugins"> & {

Committable suggestion was skipped due to low confidence.

// Relax plugins type limitation, as most of the plugins did not have correct type info yet.
/**
* An object containing a name-value mapping of plugin names to plugin
Expand All @@ -21,7 +18,7 @@ export type TypedFlatConfigItem = Omit<
*
* @see [Using plugins in your configuration](https://eslint.org/docs/latest/user-guide/configuring/configuration-files-new#using-plugins-in-your-configuration)
*/
plugins?: Record<string, any>;
plugins?: Record;
};

export interface OptionsComponentExts {
Expand All @@ -35,7 +32,7 @@ export interface OptionsTypeScriptParserOptions {
/**
* Additional parser options for TypeScript.
*/
parserOptions?: Partial<ParserOptions>;
parserOptions?: Partial;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert the type change to maintain type specificity.

The parserOptions property has been changed from Partial<ParserOptions> to Partial. This removes the specific type reference, leading to broader and less predictable types being accepted for parser options. Revert the change to maintain type specificity.

-parserOptions?: Partial;
+parserOptions?: Partial<ParserOptions>;
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
parserOptions?: Partial;
parserOptions?: Partial<ParserOptions>;

}

export interface OptionsHasTypeScript {
Expand Down
9 changes: 2 additions & 7 deletions packages/eslint-config/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ import type { MaybePromise } from "./types";
* ];
* ```
*/
export const renameRules = (
rules: Record<string, any>,
map: Record<string, string>,
) =>
export const renameRules = (rules: Record, map: Record) =>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert to the more specific parameter types for better type safety.

The original parameter types Record<string, any> and Record<string, string> provided more information about the expected structure of the input data, which is beneficial for consumers of the function. Consider reverting to the original parameter types for better type safety and specificity.

Apply this diff to revert the parameter types:

-export const renameRules = (rules: Record, map: Record) =>
+export const renameRules = (rules: Record<string, any>, map: Record<string, string>) =>
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export const renameRules = (rules: Record, map: Record) =>
export const renameRules = (rules: Record<string, any>, map: Record<string, string>) =>

Object.fromEntries(
Object.entries(rules).map(([key, value]) => {
for (const [from, to] of Object.entries(map)) {
Expand All @@ -36,9 +33,7 @@ export const renameRules = (
}),
);

export async function interopDefault<T>(
m: MaybePromise<T>,
): Promise<T extends { default: infer U } ? U : T> {
export async function interopDefault<T>(m: MaybePromise): Promise {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert to the more specific return type for better type safety.

The original return type Promise<T extends { default: infer U } ? U : T> provided more information about the structure of the returned data, which is beneficial for consumers of the function. Consider reverting to the original return type for better type safety and specificity.

Apply this diff to revert the return type:

-export async function interopDefault<T>(m: MaybePromise): Promise {
+export async function interopDefault<T>(m: MaybePromise<T>): Promise<T extends { default: infer U } ? U : T> {
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export async function interopDefault<T>(m: MaybePromise): Promise {
export async function interopDefault<T>(m: MaybePromise<T>): Promise<T extends { default: infer U } ? U : T> {

const resolved = await m;

return (resolved as any).default || resolved;
Expand Down
2 changes: 1 addition & 1 deletion packages/prettier-config/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ export default {
jsdocPreferCodeFences: true,
jsdocCommentLineStrategy: "multiline",
tsdoc: true,
} satisfies Config & Record<string, unknown>;
} satisfies Config & Record;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert to the more specific type assertion for better type safety.

The original type assertion Record<string, unknown> provided more information about the expected structure of the object, which is beneficial for consumers of the object. Consider reverting to the original type assertion for better type safety and specificity.

Apply this diff to revert the type assertion:

-} satisfies Config & Record;
+} satisfies Config & Record<string, unknown>;
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
} satisfies Config & Record;
} satisfies Config & Record<string, unknown>;

Loading