diagnostics.ts

Diagnostic types for CSS class extraction and generation.

Provides a unified diagnostic system across all phases:

  • Extraction: Parsing source files to find class names
  • Generation: Producing CSS output from class definitions
view source

Declarations
#

12 declarations

BaseDiagnostic
#

diagnostics.ts view source

BaseDiagnostic import type {BaseDiagnostic} from '@fuzdev/fuz_css/diagnostics.js';

Base diagnostic with common fields.

level

type "error" | "warning"

message

type string

suggestion

type string | null

create_diagnostic_dispatcher
#

diagnostics.ts view source

internal

The dispatch the generators share - not stable API.

(options: DiagnosticDispatchOptions, sink: DiagnosticSink): (diagnostics: Diagnostic[]) => void import {create_diagnostic_dispatcher} from '@fuzdev/fuz_css/diagnostics.js';

Creates the diagnostic dispatch a generator runs after each render: a diagnostic level set to 'throw' fails the render with a CssGenerationError, and the rest are logged to sink - except that a message the previous dispatch already logged isn't logged again.

A render reports every file's diagnostics, so a dev server or watch mode re-rendering on each edit would otherwise repeat every warning in the project on every change. A diagnostic that goes away and comes back is logged again.

options

the on_error/on_warning settings

sink

where logged diagnostics go

returns

(diagnostics: Diagnostic[]) => void

the dispatch, to call with each render's diagnostics

throws

  • CssGenerationError - from the returned dispatch, for a level set to `'throw'`

create_generation_diagnostic
#

CssGenerationError
#

diagnostics.ts view source

import {CssGenerationError} from '@fuzdev/fuz_css/diagnostics.js';

Error thrown when CSS generation encounters errors or warnings (depending on on_error and on_warning settings). Contains the full diagnostics array for programmatic access.

inheritance

extends: Error

diagnostics

type Diagnostic[]

constructor

type new (diagnostics: Diagnostic[]): CssGenerationError

diagnostics

type Diagnostic[]

Diagnostic
#

DiagnosticDispatchOptions
#

diagnostics.ts view source

internal

The dispatch the generators share - not stable API.

DiagnosticDispatchOptions import type {DiagnosticDispatchOptions} from '@fuzdev/fuz_css/diagnostics.js';

How generation diagnostics are handled - see CssDiagnosticsOptions.

on_error

type "log" | "throw"

on_warning

type "log" | "throw" | "ignore"

DiagnosticSink
#

diagnostics.ts view source

internal

The dispatch the generators share - not stable API.

DiagnosticSink import type {DiagnosticSink} from '@fuzdev/fuz_css/diagnostics.js';

Where a dispatcher writes the diagnostics it logs.

warn

type (message: string): void

message

type string
returns void

error

type (message: string): void

message

type string
returns void

ExtractionDiagnostic
#

format_diagnostic
#

diagnostics.ts view source

(d: Diagnostic): string import {format_diagnostic} from '@fuzdev/fuz_css/diagnostics.js';

Formats a diagnostic for display.

d

returns

string

GenerationDiagnostic
#

diagnostics.ts view source

GenerationDiagnostic import type {GenerationDiagnostic} from '@fuzdev/fuz_css/diagnostics.js';

Diagnostic from the generation phase.

phase

type "generation"

level

type "error" | "warning"

message

type string

suggestion

type string | null

identifier

The class name, element name, or variable name this diagnostic refers to

type string

locations

Source locations where this class was used, or null if from additional_classes

type SourceLocation[] | null

InterpreterDiagnostic
#

diagnostics.ts view source

InterpreterDiagnostic import type {InterpreterDiagnostic} from '@fuzdev/fuz_css/diagnostics.js';

Diagnostic from CSS class interpretation. Used internally by interpreters; converted to GenerationDiagnostic with locations.

level

type "error" | "warning"

message

type string

identifier

The class name, element name, or variable name this diagnostic refers to

type string

suggestion

type string | null

SourceLocation
#

diagnostics.ts view source

SourceLocation import type {SourceLocation} from '@fuzdev/fuz_css/diagnostics.js';

Source location for IDE/LSP integration.

file

type string

line

1-based line number

type number

column

1-based column number

type number

Imported by
#