import type { CSpellSettingsWithSourceTrace, CSpellUserSettings, ImportFileRef, PnPSettings as PnPSettingsStrict } from '@cspell/cspell-types'; import { CSpellIO } from 'cspell-io'; import { URI } from 'vscode-uri'; import { CSpellSettingsInternal } from '../../../Models/CSpellSettingsInternalDef'; import { OptionalOrUndefined } from '../../../util/types'; import { LoaderResult } from '../pnpLoader'; import { normalizeCacheSettings } from './normalizeRawSettings'; export type CSpellSettingsWST = CSpellSettingsWithSourceTrace; export type CSpellSettingsI = CSpellSettingsInternal; type PnPSettings = OptionalOrUndefined; export declare const sectionCSpell = "cSpell"; export declare const defaultFileName = "cspell.json"; export declare const defaultConfigFilenames: readonly string[]; export declare class ConfigLoader { readonly cspellIO: CSpellIO; /** * Use `createConfigLoader` * @param cspellIO - CSpellIO interface for reading files. */ protected constructor(cspellIO: CSpellIO); protected cachedFiles: Map; protected cspellConfigExplorer: { readonly search: (searchFrom?: string | undefined) => Promise; readonly load: (filepath: string) => Promise; readonly clearLoadCache: () => void; readonly clearSearchCache: () => void; readonly clearCaches: () => void; }; protected cspellConfigExplorerSync: { readonly search: (searchFrom?: string | undefined) => import("cosmiconfig/dist/types").CosmiconfigResult; readonly load: (filepath: string) => import("cosmiconfig/dist/types").CosmiconfigResult; readonly clearLoadCache: () => void; readonly clearSearchCache: () => void; readonly clearCaches: () => void; }; protected globalSettings: CSpellSettingsI | undefined; /** * Read / import a cspell configuration file. * @param filename - the path to the file. * Supported types: json, yaml, js, and cjs. ES Modules are not supported. * - absolute path `/absolute/path/to/file` * - relative path `./path/to/file` (relative to the current working directory) * - package `@cspell/dict-typescript/cspell-ext.json` */ readSettings(filename: string): CSpellSettingsI; readSettings(filename: string, defaultValues: CSpellSettingsWST): CSpellSettingsI; /** * Read / import a cspell configuration file. * @param filename - the path to the file. * Supported types: json, yaml, js, and cjs. ES Modules are not supported. * - absolute path `/absolute/path/to/file` * - relative path `./path/to/file` (relative to `relativeTo`) * - package `@cspell/dict-typescript/cspell-ext.json` searches for node_modules relative to `relativeTo` * @param relativeTo - absolute path to start searching for relative files or node_modules. */ readSettings(filename: string, relativeTo?: string): CSpellSettingsI; readSettings(filename: string, relativeTo: string, defaultValues: CSpellSettingsWST): CSpellSettingsI; readSettings(filename: string, relativeToOrDefault?: CSpellSettingsWST | string): CSpellSettingsI; getGlobalSettings(): CSpellSettingsI; clearCachedSettingsFiles(): void; /** * Read a config file and inject the fileRef. * @param fileRef - filename plus context, injected into the resulting config. */ protected readConfig(fileRef: ImportFileRef): CSpellSettingsWST; protected importSettings(fileRef: ImportFileRef, defaultValues: CSpellSettingsWST | undefined, pnpSettings: PnPSettings): CSpellSettingsI; /** * normalizeSettings handles correcting all relative paths, anchoring globs, and importing other config files. * @param rawSettings - raw configuration settings * @param pathToSettingsFile - path to the source file of the configuration settings. */ protected normalizeSettings(rawSettings: CSpellSettingsWST, pathToSettingsFile: string, pnpSettings: PnPSettings): CSpellSettingsI; } declare class ConfigLoaderInternal extends ConfigLoader { constructor(cspellIO: CSpellIO); get _cachedFiles(): Map; get _cspellConfigExplorer(): { readonly search: (searchFrom?: string | undefined) => Promise; readonly load: (filepath: string) => Promise; readonly clearLoadCache: () => void; readonly clearSearchCache: () => void; readonly clearCaches: () => void; }; get _cspellConfigExplorerSync(): { readonly search: (searchFrom?: string | undefined) => import("cosmiconfig/dist/types").CosmiconfigResult; readonly load: (filepath: string) => import("cosmiconfig/dist/types").CosmiconfigResult; readonly clearLoadCache: () => void; readonly clearSearchCache: () => void; readonly clearCaches: () => void; }; readonly _readConfig: (fileRef: ImportFileRef) => CSpellSettingsWithSourceTrace; readonly _normalizeSettings: (rawSettings: CSpellSettingsWithSourceTrace, pathToSettingsFile: string, pnpSettings: OptionalOrUndefined) => CSpellSettingsInternal; } export declare function searchForConfig(searchFrom: string | undefined, pnpSettings?: PnPSettings): Promise; export declare function searchForConfigSync(searchFrom: string | undefined, pnpSettings?: PnPSettings): CSpellSettingsI | undefined; /** * Load a CSpell configuration files. * @param file - path or package reference to load. * @param pnpSettings - PnP settings * @returns normalized CSpellSettings */ export declare function loadConfig(file: string, pnpSettings?: PnPSettings): Promise; /** * Load a CSpell configuration files. * @param filename - path or package reference to load. * @param pnpSettings - PnP settings * @returns normalized CSpellSettings */ export declare function loadConfigSync(filename: string, pnpSettings?: PnPSettings): CSpellSettingsI; export declare function loadPnP(pnpSettings: PnPSettings, searchFrom: URI): Promise; export declare function loadPnPSync(pnpSettings: PnPSettings, searchFrom: URI): LoaderResult; export declare function readRawSettings(filename: string, relativeTo?: string): CSpellSettingsWST; /** * * @param filenames - settings files to read * @returns combined configuration * @deprecated true */ export declare function readSettingsFiles(filenames: string[]): CSpellSettingsI; export declare function getGlobalSettings(): CSpellSettingsI; export declare function getCachedFileSize(): number; export declare function clearCachedSettingsFiles(): void; declare function validateRawConfigVersion(config: CSpellUserSettings | { version: unknown; }, fileRef: ImportFileRef): void; declare function validateRawConfigExports(config: CSpellUserSettings, fileRef: ImportFileRef): void; export declare function createConfigLoader(cspellIO?: CSpellIO): ConfigLoader; declare function getDefaultConfigLoaderInternal(): ConfigLoaderInternal; export declare function getDefaultConfigLoader(): ConfigLoader; export declare const __testing__: { getDefaultConfigLoaderInternal: typeof getDefaultConfigLoaderInternal; normalizeCacheSettings: typeof normalizeCacheSettings; validateRawConfigExports: typeof validateRawConfigExports; validateRawConfigVersion: typeof validateRawConfigVersion; }; export {}; //# sourceMappingURL=configLoader.d.ts.map