/**
* Available configuration names for the ESLint flat config system.
* These correspond to the different rule sets that can be enabled or disabled.
*/
export type ConfigNames = "base" | "typescript" | "vue" | "import" | "stylistic";
/**
* Represents a preset configuration that combines Antfu ESLint settings with custom rules.
*
* @property antfu - The Antfu ESLint configuration options (excluding files property)
* @property custom - Array of custom ESLint configuration items to apply
*/
export type Preset = {
antfu: OptionsConfig & Omit<TypedFlatConfigItem, "files">;
custom: TypedFlatConfigItem[];
};
/**
* Options for configuring the ESLint factory function.
*
* @property preset - Optional preset to use for the configuration ("nuxt-app", "nuxt-module", "ts-lib")
* @property antfu - Optional Antfu ESLint configuration overrides
*/
export type FactoryOptions = {
preset?: "nuxt-app" | "nuxt-module" | "ts-lib";
antfu?: OptionsConfig & Omit<TypedFlatConfigItem, "files">;
};
/**
* Factory function to create ESLint configurations with optional presets and custom configurations.
*
* This function provides a flexible way to generate ESLint configurations by combining:
* - Antfu ESLint config base
* - Optional preset configurations (nuxt-app, nuxt-module, ts-lib)
* - Custom user configurations
*
* @param options - Configuration options for the factory
* @param options.preset - Optional preset to use ("nuxt-app", "nuxt-module", "ts-lib")
* @param options.antfu - Optional Antfu ESLint configuration overrides
* @param userConfigs - Additional user-defined ESLint configurations to merge
* @returns A FlatConfigComposer instance with the combined ESLint configuration
*/
export function eslintFactory(
options: FactoryOptions = {},
...userConfigs: Awaitable<TypedFlatConfigItem | TypedFlatConfigItem[] | FlatConfigComposer<any, any> | Linter.Config[]>[]
): FlatConfigComposer<TypedFlatConfigItem, ConfigNames>;
import { eslintFactory } from "@nobears-front-end/eslint";
export default eslintFactory();
import { eslintFactory } from "@nobears-front-end/eslint";
export default eslintFactory({
preset: "nuxt-app"
});
import { eslintFactory } from "@nobears-front-end/eslint";
export default eslintFactory({
preset: "nuxt-module",
antfu: {
ignores: ["*.yaml", "workflows/ci.yml", ".gitlab-ci.yml", ".release-it.ts"],
},
});
import { eslintFactory } from "@nobears-front-end/eslint";
export default eslintFactory(
{ preset: "ts-lib" },
{
files: ["**/*.test.ts"],
rules: { "no-console": "off" }
}
);