import type stylelint from 'stylelint'; import type LSP from 'vscode-languageserver-protocol'; import type { RuleCustomization } from '../types.js'; export type Stylelint = typeof stylelint; export type ConfigurationError = Error & { code: 78; }; export type RuleMetadataSnapshot = Record; /** * A Stylelint warning. */ export type Warning = stylelint.Warning & { /** URL for the rule documentation. Available in Stylelint 16.7+. */ url?: string; }; export type RuleMetadataSource = { get(ruleName: string): stylelint.RuleMeta | undefined; }; /** * Minimal subset of a Stylelint lint result required by the language server. */ export type LintResult = { source?: string; warnings: Warning[]; invalidOptionWarnings: stylelint.LintResult['invalidOptionWarnings']; ignored?: boolean; }; /** * Minimal subset of a Stylelint linter result required by the language server. */ export type LinterResult = { results: LintResult[]; report?: string; code?: string; output?: string; ruleMetadata?: stylelint.LinterResult['ruleMetadata']; }; /** * Diagnostics for a lint run. */ export type LintDiagnostics = { /** * The diagnostics, each corresponding to a warning or error emitted by * Stylelint. */ diagnostics: LSP.Diagnostic[]; /** * Formatted report returned by Stylelint, if any. */ report?: string; /** * Autofixed code returned by Stylelint when linting source text with `fix` * enabled. */ code?: string; /** * Raw output from Stylelint, if any. Deprecated in Stylelint 16 in favour of * `report` and `code`. */ output?: string; /** * Gets the original warning from the given diagnostic. */ getWarning?: (diagnostic: LSP.Diagnostic) => Warning | null; }; /** * Diagnostics for a multi-file lint run, keyed by file URI. */ export type MultiFileLintDiagnostics = Map; /** * Disable report rule names. */ export declare enum DisableReportRuleNames { Needless = "--report-needless-disables", InvalidScope = "--report-invalid-scope-disables", Descriptionless = "--report-descriptionless-disables", Illegal = "reportDisables" } /** * Stylelint runner options. */ export type RunnerOptions = { config?: stylelint.Config | null; configBasedir?: string; configFile?: string; customSyntax?: string; ignoreDisables?: boolean; ignorePath?: string; packageManager?: PackageManager; reportDescriptionlessDisables?: boolean; reportInvalidScopeDisables?: boolean; reportNeedlessDisables?: boolean; snippet?: string[]; stylelintPath?: string; validate?: string[]; rules?: { customizations?: RuleCustomization[]; }; lintFilesGlob?: string; }; /** * Error thrown when a rule's option is invalid. */ export declare class InvalidOptionError extends Error { reasons: string[]; constructor(warnings: { text: string; }[]); } /** * Creates a rule metadata source from a Stylelint instance. */ export declare function createRuleMetadataSourceFromStylelint(stylelintInstance?: Stylelint): RuleMetadataSource | undefined; /** * Creates a rule metadata source from a snapshot. */ export declare function createRuleMetadataSourceFromSnapshot(snapshot?: RuleMetadataSnapshot): RuleMetadataSource | undefined; /** * Package manager identifiers. */ export type PackageManager = 'npm' | 'yarn' | 'pnpm'; /** * Options for resolving the Stylelint package. */ export type ResolverOptions = { packageManager?: PackageManager; stylelintPath?: string; }; /** * Stylelint package resolution result. */ export type StylelintResolutionResult = { /** Absolute path to the resolved Stylelint entry file or package directory. */ entryPath: string; /** Absolute path to the Stylelint package root (falls back to entryPath when unknown). */ resolvedPath: string; /** Package version if known. */ version?: string; }; /** * A tracer function that can be used to log messages. */ export type TracerFn = (message: string, verbose?: string) => void;