Files
oxc-project__oxc/apps/oxlint/src-js/package/config.ts
Boshen 3ff2e0e6fa docs(linter): clarify config extends types (#24936)
The generated config reference only described the JSON schema's `string[]` form. Clarify that `oxlint.config.ts` accepts imported `OxlintConfig[]`, add an example and public JSDoc, and regenerate the derived artifacts.

Closes #20238.

Validated with the website generator suite, targeted TypeScript checks, and the relevant Oxlint tests. The full `just ready` run reached an unrelated parallel suppression-fixture cleanup race; the failing test passes in isolation.

AI-assisted.
2026-07-27 01:51:16 +00:00

53 lines
1.1 KiB
TypeScript

/*
* `defineConfig` helper and config types.
*
* Types are generated from npm/oxlint/configuration_schema.json.
*/
import type {
AllowWarnDeny,
DummyRule,
DummyRuleMap,
ExternalPluginEntry,
Oxlintrc as FullOxlintrc,
OxlintEnv,
OxlintGlobals,
OxlintOverride,
RuleCategories,
} from "./config.generated.ts";
type Oxlintrc = Omit<FullOxlintrc, "$schema" | "extends">;
export type {
AllowWarnDeny,
DummyRule,
DummyRuleMap,
RuleCategories,
OxlintGlobals,
OxlintEnv,
ExternalPluginEntry,
};
export type ExternalPluginsConfig = Exclude<Oxlintrc["jsPlugins"], undefined | null>;
export interface OxlintConfig extends Oxlintrc {
/**
* Configuration objects to extend.
*
* Import configurations and pass them directly instead of using file paths.
*/
extends?: OxlintConfig[];
}
export type { OxlintOverride };
/**
* Define an Oxlint configuration with type inference.
*
* @param config - Oxlint configuration
* @returns Config unchanged
*/
export function defineConfig<T extends OxlintConfig>(config: T & OxlintConfig): T {
return config;
}