//#region src/dirs.d.ts /** A component directory declaration on a Nuxt layer. */ type NuxtComponentDirDeclaration = string | { path?: string; prefix?: string; [key: string]: unknown; }; /** The subset of a Nuxt layer's config that lint directories are derived from. */ interface NuxtLintLayer { srcDir: string; imports?: { dirs?: Array; }; components?: boolean | NuxtComponentDirDeclaration[] | { dirs?: NuxtComponentDirDeclaration[]; }; } /** The `nuxt.options.dir` overrides that lint directories honour. */ interface NuxtLintDirNames { pages?: string; layouts?: string; plugins?: string; middleware?: string; modules?: string; } /** The Nuxt project state lint directories are derived from. */ interface NuxtLintProjectState { /** Directory the emitted globs are relative to. */ rootDir: string; /** `nuxt.options.dir`. Missing entries fall back to their Nuxt defaults. */ dir?: NuxtLintDirNames; /** `nuxt.options._layers`, in Nuxt's own order. */ layers: NuxtLintLayer[]; } /** Every directory list the generated lint config globs over. */ interface NuxtLintDirs { pages: string[]; composables: string[]; components: string[]; componentsPrefixed: string[]; layouts: string[]; plugins: string[]; middleware: string[]; modules: string[]; servers: string[]; root: string[]; src: string[]; } /** * The key order of {@link NuxtLintDirs}. * * Upstream serialises `dirs` with `Object.entries`, so this order is observable * in the generated config file and the oracle asserts it. */ declare const NUXT_LINT_DIR_KEYS: readonly ["pages", "composables", "components", "componentsPrefixed", "layouts", "plugins", "middleware", "modules", "servers", "root", "src"]; /** * Derive every lint directory from the Nuxt project state. * * `servers` and `root` are intentionally left empty: upstream's `getDirs` never * populates them, and because an empty array is truthy the `||=` defaults in * `resolveNuxtLintDirs` do not fire for a module-generated config either. The * oracle pins that, so a future upstream change surfaces as a failure rather * than as a silently different set of linted files. */ declare function collectNuxtLintDirs(state: NuxtLintProjectState): NuxtLintDirs; /** * Apply the directory defaults used when a config is written by hand rather * than generated from a Nuxt instance. * * Upstream uses `||=`, so a directory list that is present but empty keeps its * empty value. This port reproduces that, because generated configs rely on it. */ declare function resolveNuxtLintDirs(dirs: Partial | undefined): NuxtLintDirs; //#endregion //#region src/features.d.ts /** * Feature-flag resolution for the shareable Nuxt lint config. * * This is a behavioural port of `resolveOptions().features` in * `@nuxt/eslint-config` (see `test/nuxt-eslint-compat/`). The defaults are * load-bearing: they decide which config blocks the generator emits, so they * are pinned against the real package by the differential oracle rather than * restated from documentation. */ /** Options for the Nuxt-specific rule block. */ interface NuxtLintNuxtOptions { /** * Enforce a recommended key order in `nuxt.config`. * * @default true when `stylistic` is enabled */ sortConfigKeys?: boolean; } /** Options for the tooling (module/library author) rule blocks. */ interface NuxtLintToolingOptions { /** @default true */ regexp?: boolean; /** @default true */ unicorn?: boolean; /** @default true */ jsdoc?: boolean; } /** Options for the import rule block. */ interface NuxtLintImportOptions { /** @default "eslint-plugin-import-x" */ package?: "eslint-plugin-import-lite" | "eslint-plugin-import-x"; } /** Options for the TypeScript rule block. */ interface NuxtLintTypeScriptOptions { /** @default true */ strict?: boolean; /** Enables type-aware rules when set. */ tsconfigPath?: string; } /** * The `features` surface of the generated lint config. * * Mirrors `NuxtESLintFeaturesOptions` from `@nuxt/eslint-config`. */ interface NuxtLintFeatures { /** * Set up the baseline JavaScript, TypeScript and Vue rule blocks. * * @default true */ standalone?: boolean; /** * Enable rules aimed at Nuxt module and library authors. * * @default false */ tooling?: boolean | NuxtLintToolingOptions; /** * Enable the import rule block. * * @default true */ import?: boolean | NuxtLintImportOptions; /** * Enable stylistic (formatting) rules. * * @default false */ stylistic?: boolean | Record; /** * Enable formatter delegation for non-script file types. * * @default false */ formatters?: boolean | Record; /** Options for the Nuxt-specific rule block. */ nuxt?: NuxtLintNuxtOptions; /** * Enable TypeScript support. * * Defaults to whether `typescript` is resolvable from the project. */ typescript?: boolean | NuxtLintTypeScriptOptions; } /** Every feature flag with its default applied. */ interface ResolvedNuxtLintFeatures { standalone: boolean; stylistic: boolean | Record; typescript: boolean | NuxtLintTypeScriptOptions; tooling: boolean | NuxtLintToolingOptions; formatters: boolean | Record; nuxt: NuxtLintNuxtOptions; import: boolean | NuxtLintImportOptions; } /** * Whether TypeScript is present in the project. * * `@nuxt/eslint-config` calls `local-pkg`'s `isPackageExists("typescript")` * here. The probe is injected so the resolver stays a pure function: the * generator passes the real detection, tests pass a fixed answer. */ type TypeScriptProbe = () => boolean; /** * Apply `@nuxt/eslint-config`'s feature defaults. * * Note that only *missing* keys take a default: an explicitly passed * `undefined` value is spread over the defaults by the upstream implementation * and therefore wins, which this port reproduces by spreading the same way. */ declare function resolveNuxtLintFeatures(features: NuxtLintFeatures | undefined, hasTypeScript: TypeScriptProbe): ResolvedNuxtLintFeatures; /** * Whether `nuxt/nuxt-config-keys-order` is enabled. * * Upstream reads `features.nuxt.sortConfigKeys` and falls back to * `!!features.stylistic`, so enabling stylistic rules also turns on config-key * sorting unless the project opts out explicitly. */ declare function shouldSortNuxtConfigKeys(features: ResolvedNuxtLintFeatures): boolean; //#endregion //#region src/plan.d.ts /** Extensions every Nuxt-aware glob covers. */ declare const NUXT_LINT_GLOB_EXTS = "{js,ts,jsx,tsx,vue}"; /** Globs matching a `nuxt.config` file in either supported location. */ declare const NUXT_CONFIG_GLOBS: readonly ["**/.config/nuxt.?([cm])[jt]s?(x)", "**/nuxt.config.?([cm])[jt]s?(x)"]; /** Directories the generated config never lints. */ declare const NUXT_LINT_IGNORES: readonly ["**/dist", "**/node_modules", "**/.nuxt", "**/.output", "**/.vercel", "**/.netlify", "**/public"]; /** A severity as it appears in the plan. */ type NuxtLintSeverity = "off" | "warn" | "error"; /** One item of the generated config: a named block of rules over a glob set. */ interface NuxtLintConfigItem { /** Stable identity, matching `@nuxt/eslint`'s config item names. */ name: string; /** Files the block applies to. Absent means "every linted file". */ files?: string[]; /** Paths excluded from linting entirely. */ ignores?: string[]; /** Rule severities keyed by eslint-compatible rule id. */ rules?: Record; /** Globals the block declares, so undefined-variable rules stay quiet. */ globals?: Record; } /** Runtime globals Nuxt injects into every linted file. */ declare const NUXT_RUNTIME_GLOBALS: Record; /** * Build the Nuxt-specific part of the generated lint config, in emission order. * * The order is observable — later items override earlier ones — so it is part * of the contract the oracle pins, not an implementation detail. */ declare function buildNuxtLintPlan(features: ResolvedNuxtLintFeatures, dirs: NuxtLintDirs): NuxtLintConfigItem[]; //#endregion export { NUXT_CONFIG_GLOBS, NUXT_LINT_DIR_KEYS, NUXT_LINT_GLOB_EXTS, NUXT_LINT_IGNORES, NUXT_RUNTIME_GLOBALS, type NuxtComponentDirDeclaration, type NuxtLintConfigItem, type NuxtLintDirNames, type NuxtLintDirs, type NuxtLintFeatures, type NuxtLintImportOptions, type NuxtLintLayer, type NuxtLintNuxtOptions, type NuxtLintProjectState, type NuxtLintSeverity, type NuxtLintToolingOptions, type NuxtLintTypeScriptOptions, type ResolvedNuxtLintFeatures, type TypeScriptProbe, buildNuxtLintPlan, collectNuxtLintDirs, resolveNuxtLintDirs, resolveNuxtLintFeatures, shouldSortNuxtConfigKeys };