chore(lint): enable unnecessary type parameter rule

This commit is contained in:
Peter Steinberger
2026-04-18 18:28:20 +01:00
parent 630f2bcabe
commit df525b90f2
94 changed files with 186 additions and 152 deletions

View File

@@ -9,8 +9,8 @@ function resolveMockOverrides<TModule extends object>(
return typeof factory === "function" ? factory(actual) : factory;
}
function resolveDefaultBase<TModule extends object>(actual: TModule): Record<string, unknown> {
const defaultExport = (actual as TModule & { default?: unknown }).default;
function resolveDefaultBase(actual: object): Record<string, unknown> {
const defaultExport = (actual as { default?: unknown }).default;
if (defaultExport && typeof defaultExport === "object") {
return defaultExport as Record<string, unknown>;
}

View File

@@ -22,6 +22,7 @@ type PackageManifestContractParams = {
minHostVersionBaseline?: string;
};
// oxlint-disable-next-line typescript/no-unnecessary-type-parameters -- Test helper lets assertions ascribe package manifest shape.
function readJson<T>(relativePath: string): T {
const absolutePath = path.resolve(process.cwd(), relativePath);
return JSON.parse(fs.readFileSync(absolutePath, "utf8")) as T;
@@ -34,8 +35,8 @@ export function describePackageManifestContract(params: PackageManifestContractP
if (params.pluginLocalRuntimeDeps?.length) {
for (const dependencyName of params.pluginLocalRuntimeDeps) {
it(`keeps ${dependencyName} plugin-local`, () => {
const rootManifest = readJson<PackageManifest>("package.json");
const pluginManifest = readJson<PackageManifest>(packagePath);
const rootManifest = readJson("package.json") as PackageManifest;
const pluginManifest = readJson(packagePath) as PackageManifest;
const pluginSpec =
pluginManifest.dependencies?.[dependencyName] ??
pluginManifest.optionalDependencies?.[dependencyName];

View File

@@ -16,6 +16,7 @@ export function createRuntimeEnv(options?: { throwOnExit?: boolean }): OutputRun
};
}
// oxlint-disable-next-line typescript/no-unnecessary-type-parameters -- Test helper lets plugin suites ascribe runtime extension shape.
export function createTypedRuntimeEnv<TRuntime>(options?: { throwOnExit?: boolean }): TRuntime {
return createRuntimeEnv(options) as TRuntime;
}
@@ -24,6 +25,7 @@ export function createNonExitingRuntimeEnv(): OutputRuntimeEnv {
return createRuntimeEnv({ throwOnExit: false });
}
// oxlint-disable-next-line typescript/no-unnecessary-type-parameters -- Test helper lets plugin suites ascribe runtime extension shape.
export function createNonExitingTypedRuntimeEnv<TRuntime>(): TRuntime {
return createTypedRuntimeEnv<TRuntime>({ throwOnExit: false });
}

View File

@@ -151,6 +151,7 @@ export function createSetupWizardAdapter(params: SetupWizardAdapterParams) {
return buildChannelSetupWizardAdapterFromSetupWizard(params);
}
// oxlint-disable-next-line typescript/no-unnecessary-type-parameters -- Test helper preserves plugin-specific setup wizard surface type.
export function createPluginSetupWizardAdapter<TPlugin extends SetupWizardTestPlugin>(
plugin: TPlugin,
) {
@@ -161,12 +162,14 @@ export function createPluginSetupWizardAdapter<TPlugin extends SetupWizardTestPl
});
}
// oxlint-disable-next-line typescript/no-unnecessary-type-parameters -- Test helper preserves plugin-specific setup wizard surface type.
export function createPluginSetupWizardConfigure<TPlugin extends SetupWizardTestPlugin>(
plugin: TPlugin,
) {
return createPluginSetupWizardAdapter(plugin).configure;
}
// oxlint-disable-next-line typescript/no-unnecessary-type-parameters -- Test helper preserves plugin-specific setup wizard surface type.
export function createPluginSetupWizardStatus<TPlugin extends SetupWizardTestPlugin>(
plugin: TPlugin,
) {

View File

@@ -1,3 +1,4 @@
// oxlint-disable-next-line typescript/no-unnecessary-type-parameters -- Test helper preserves plugin-specific hook API type.
export function registerHookHandlersForTest<TApi>(params: {
config: Record<string, unknown>;
register: (api: TApi) => void;

View File

@@ -10,8 +10,8 @@ type OxlintTsconfig = {
exclude?: string[];
};
function readJson<T>(path: string): T {
return JSON.parse(fs.readFileSync(path, "utf8")) as T;
function readJson(path: string): unknown {
return JSON.parse(fs.readFileSync(path, "utf8")) as unknown;
}
describe("oxlint config", () => {