@fenge/eslint-config
Version:
A super strict eslint config for linting js/ts/package.json.
50 lines • 2.42 kB
TypeScript
import type { Linter } from "eslint";
import { type BaseOptions } from "./config/base.ts";
import { html } from "./config/html.ts";
import { javascript } from "./config/javascript.ts";
import { packagejson } from "./config/packagejson.ts";
import { typescript } from "./config/typescript.ts";
type NoDuplicate<A extends unknown[]> = {
[I in keyof A]: true extends {
[J in keyof A]: J extends I ? false : A[J] extends A[I] ? true : false;
}[number] ? never : A[I];
};
type OriginJsRuleKey = keyof ReturnType<typeof javascript>[0]["rules"];
type OriginTsRuleKey = keyof ReturnType<typeof typescript>[0]["rules"];
type OriginPkgRuleKey = keyof ReturnType<typeof packagejson>[0]["rules"];
type OriginHtmlRuleKey = keyof ReturnType<typeof html>[0]["rules"];
type GetPlugins<T extends string> = T extends `${infer Left}/${string}` ? Left : never;
type JsRuleKey = OriginJsRuleKey | `${GetPlugins<OriginJsRuleKey>}/*`;
type TsRuleKey = OriginTsRuleKey | `${GetPlugins<OriginTsRuleKey>}/*`;
type PkgRuleKey = OriginPkgRuleKey | `${GetPlugins<OriginPkgRuleKey>}/*`;
type HtmlRuleKey = OriginHtmlRuleKey | `${GetPlugins<OriginHtmlRuleKey>}/*`;
type RuleValue = "error" | "warn" | "off" | ["error" | "warn", ...unknown[]];
interface Options<P extends string[], O extends string[]> {
pick?: NoDuplicate<P>;
omit?: NoDuplicate<O>;
}
interface ConfigItem {
name?: string;
files?: string[];
plugins?: Record<string, object>;
rules: Partial<Record<PkgRuleKey | JsRuleKey | TsRuleKey, RuleValue>> | Record<string, RuleValue>;
}
export type LinterConfig = Linter.Config;
export type BuilderOptions = BaseOptions;
export declare class Builder {
private readonly configs;
private readonly options;
private readonly enabled;
constructor(options?: BuilderOptions);
toConfig(): LinterConfig[];
private setup;
enableTypeScript<P extends TsRuleKey[], O extends TsRuleKey[]>(options?: Options<P, O>): this;
enableJavaScript<P extends JsRuleKey[], O extends JsRuleKey[]>(options?: Options<P, O>): this;
enablePackageJson<P extends PkgRuleKey[], O extends PkgRuleKey[]>(options?: Options<P, O>): this;
enableHtml<P extends HtmlRuleKey[], O extends HtmlRuleKey[]>(options?: Options<P, O>): this;
enableAll(): this;
append(config: ConfigItem): this;
}
declare const _default: LinterConfig[];
export default _default;
//# sourceMappingURL=eslint.config.d.ts.map