@oxlint/migrate
Version:
Generates a `.oxlintrc.json` from a existing eslint flat config
51 lines (50 loc) • 1.82 kB
text/typescript
import { Linter } from "eslint";
//#region src/types.d.ts
type OxlintConfigPlugins = string[];
type OxlintConfigJsPlugins = string[];
type OxlintConfigCategories = Partial<Record<Category, unknown>>;
type OxlintConfigEnv = Record<string, boolean>;
type OxlintConfigIgnorePatterns = string[];
type OxlintConfigOverride = {
files: string[];
env?: OxlintConfigEnv;
globals?: Linter.Globals;
plugins?: OxlintConfigPlugins;
jsPlugins?: OxlintConfigJsPlugins;
categories?: OxlintConfigCategories;
rules?: Partial<Linter.RulesRecord>;
};
type OxlintConfig = {
$schema?: string;
env?: OxlintConfigEnv;
globals?: Linter.Globals;
plugins?: OxlintConfigPlugins;
jsPlugins?: OxlintConfigJsPlugins;
categories?: OxlintConfigCategories;
rules?: Partial<Linter.RulesRecord>;
overrides?: OxlintConfigOverride[];
ignorePatterns?: OxlintConfigIgnorePatterns;
};
type RuleSkippedCategory = 'nursery' | 'type-aware' | 'unsupported';
type SkippedCategoryGroup = Record<RuleSkippedCategory, string[]>;
type Reporter = {
report(message: string): void;
remove(message: string): void;
getReports(): string[];
markSkipped(rule: string, category: RuleSkippedCategory): void;
removeSkipped(rule: string, category: RuleSkippedCategory): void;
getSkippedRulesByCategory(): SkippedCategoryGroup;
};
type Options = {
reporter?: Reporter;
merge?: boolean;
withNursery?: boolean;
typeAware?: boolean;
jsPlugins?: boolean;
};
type Category = 'style' | 'correctness' | 'nursery' | 'suspicious' | 'pedantic' | 'perf' | 'restriction';
//#endregion
//#region src/index.d.ts
declare const main: (configs: Linter.Config | Linter.Config[] | Promise<Linter.Config> | Promise<Linter.Config[]>, oxlintConfig?: OxlintConfig, options?: Options) => Promise<OxlintConfig>;
//#endregion
export { main as default };