Documentation
¶
Overview ¶
Package etscore provides core types for Effect TypeScript integration. This is a leaf package with no dependencies, designed to be imported by both typescript-go/internal/core and effectapi without circular imports.
Index ¶
- Constants
- Variables
- func DiagnosticsEnabled(config *EffectPluginOptions) bool
- func EnterCommandLineMode() func()
- func IsCommandLineMode() bool
- type EffectPluginDiagnosticsOptions
- type EffectPluginOptions
- func (e *EffectPluginOptions) GetBarrelImportPackages() []string
- func (e *EffectPluginOptions) GetCompletionsEnabled() bool
- func (e *EffectPluginOptions) GetDebugEnabled() bool
- func (e *EffectPluginOptions) GetImportAliases() map[string]string
- func (e *EffectPluginOptions) GetIncludeSuggestionsInTsc() bool
- func (e *EffectPluginOptions) GetLayerGraphFollowDepth() int
- func (e *EffectPluginOptions) GetMermaidBaseURL() string
- func (e *EffectPluginOptions) GetNamespaceImportPackages() []string
- func (e *EffectPluginOptions) GetQuickinfoEnabled() bool
- func (e *EffectPluginOptions) GetRefactorsEnabled() bool
- func (e *EffectPluginOptions) GetTopLevelNamedReexports() TopLevelNamedReexportsMode
- type KeyPattern
- type Override
- type OverrideOptions
- type ResolvedEffectPluginOptions
- func (e *ResolvedEffectPluginOptions) EffectFnIncludes(variant string) bool
- func (e *ResolvedEffectPluginOptions) GetAllowedDuplicatedPackages() []string
- func (e *ResolvedEffectPluginOptions) GetEffectFn() []string
- func (e *ResolvedEffectPluginOptions) GetKeyPatterns() []KeyPattern
- func (e *ResolvedEffectPluginOptions) GetPipeableMinArgCount() int
- type Severity
- type TopLevelNamedReexportsMode
Constants ¶
const ( EffectFnSpan = "span" EffectFnUntraced = "untraced" EffectFnNoSpan = "no-span" EffectFnInferredSpan = "inferred-span" EffectFnSuggestedSpan = "suggested-span" )
EffectFn variant constants.
const EffectPluginName = "@effect/language-service"
EffectPluginName is the name of the Effect language service plugin. This is used to identify the plugin in the tsconfig.json plugins array.
const EffectVersion = "0.14.5"
Variables ¶
var DefaultEffectFn = []string{EffectFnSpan}
DefaultEffectFn is the default effectFn configuration.
var DefaultKeyPatterns = []KeyPattern{ {Target: "service", Pattern: "default", SkipLeadingPath: []string{"src/"}}, {Target: "custom", Pattern: "default", SkipLeadingPath: []string{"src/"}}, }
DefaultKeyPatterns is the default key patterns configuration.
Functions ¶
func DiagnosticsEnabled ¶
func DiagnosticsEnabled(config *EffectPluginOptions) bool
DiagnosticsEnabled reports whether Effect diagnostics are enabled for the parsed config in the current program.
func EnterCommandLineMode ¶
func EnterCommandLineMode() func()
EnterCommandLineMode sets the CLI mode flag to true and returns a restore function that reverts it to its previous value. Intended for use with defer:
restore := etscore.EnterCommandLineMode() defer restore()
func IsCommandLineMode ¶
func IsCommandLineMode() bool
IsCommandLineMode reports whether the process is currently running in CLI (tsc) mode, as opposed to LSP or other flows.
Types ¶
type EffectPluginDiagnosticsOptions ¶
type EffectPluginDiagnosticsOptions = ResolvedEffectPluginOptions
EffectPluginDiagnosticsOptions is a compatibility alias for the resolved per-file diagnostic options.
type EffectPluginOptions ¶
type EffectPluginOptions struct {
// Refactors enables Effect refactor actions in the language service.
Refactors bool `json:"refactors,omitzero" schema_description:"Controls Effect refactors." schema_default:"true"`
// Diagnostics enables Effect diagnostics in the checker.
Diagnostics bool `json:"diagnostics,omitzero" schema_description:"Controls Effect diagnostics." schema_default:"true"`
// IncludeSuggestionsInTsc controls whether suggestion-level Effect diagnostics appear
// in tsc CLI output. Default: true (suggestions are included).
IncludeSuggestionsInTsc bool `` /* 163-byte string literal not displayed */
// Quickinfo enables Effect hover enrichment in the language service.
Quickinfo bool `json:"quickinfo,omitzero" schema_description:"Controls Effect quickinfo." schema_default:"true"`
// Completions enables Effect completions in the language service.
Completions bool `json:"completions,omitzero" schema_description:"Controls Effect completions." schema_default:"true"`
// Debug enables extra debugging-oriented language service output.
Debug bool `` /* 127-byte string literal not displayed */
// Goto enables Effect goto/definition helpers in the language service.
Goto bool `json:"goto,omitzero" schema_description:"Controls Effect goto references support." schema_default:"true"`
// Renames enables Effect rename helpers in the language service.
Renames bool `json:"renames,omitzero" schema_description:"Controls Effect rename helpers." schema_default:"true"`
// IgnoreEffectSuggestionsInTscExitCode controls whether Effect suggestion/message-category
// diagnostics affect the tsc exit code. Default: true (suggestions do NOT affect exit code).
IgnoreEffectSuggestionsInTscExitCode bool `` /* 162-byte string literal not displayed */
// IgnoreEffectWarningsInTscExitCode controls whether Effect warning-category diagnostics
// affect the tsc exit code. Default: false (warnings DO affect exit code).
IgnoreEffectWarningsInTscExitCode bool `` /* 157-byte string literal not displayed */
// IgnoreEffectErrorsInTscExitCode controls whether Effect error-category diagnostics
// affect the tsc exit code. Default: false (errors DO affect exit code).
IgnoreEffectErrorsInTscExitCode bool `` /* 153-byte string literal not displayed */
// SkipDisabledOptimization bypasses the optimization that skips off-severity rules entirely.
// When true, disabled rules are still processed so per-line or per-section directive overrides
// can enable them.
SkipDisabledOptimization bool `` /* 170-byte string literal not displayed */
// MermaidProvider selects the Mermaid rendering service for hover links.
// Accepted values: "" or "mermaid.live" (default), "mermaid.com", or a custom URL.
MermaidProvider string `` /* 187-byte string literal not displayed */
// NoExternal suppresses external links (Mermaid URLs) in hover output. Default: false.
NoExternal bool `` /* 132-byte string literal not displayed */
// LayerGraphFollowDepth controls how many levels deep the graph extraction
// follows symbol references when building the layer graph. Default: 0.
LayerGraphFollowDepth int `` /* 171-byte string literal not displayed */
// Inlays enables inlay hint middleware. When true, suppresses redundant
// return-type inlay hints on Effect.gen, Effect.fn, and Effect.fnUntraced
// generator functions. Default: false.
Inlays bool `` /* 163-byte string literal not displayed */
// NamespaceImportPackages configures package names that should prefer namespace imports.
// Package matching is case-insensitive.
NamespaceImportPackages []string `` /* 159-byte string literal not displayed */
// BarrelImportPackages configures package names that should prefer barrel named imports.
// Package matching is case-insensitive.
BarrelImportPackages []string `` /* 159-byte string literal not displayed */
// ImportAliases configures package-level import aliases keyed by package name.
// Package matching for keys is case-insensitive.
ImportAliases map[string]string `` /* 165-byte string literal not displayed */
// TopLevelNamedReexports controls whether named reexports are followed at package top-level.
// Accepted values are "ignore" (default) and "follow".
TopLevelNamedReexports TopLevelNamedReexportsMode `` /* 193-byte string literal not displayed */
// KeyPatterns configures key pattern formulas for the deterministicKeys rule.
// If nil, GetKeyPatterns() returns the defaults.
KeyPatterns []KeyPattern `json:"keyPatterns,omitzero" schema_description:"Configures key pattern formulas for the deterministicKeys rule."`
// ExtendedKeyDetection enables matching constructors with @effect-identifier annotations.
ExtendedKeyDetection bool `` /* 147-byte string literal not displayed */
// PipeableMinArgCount is the minimum number of contiguous pipeable transformations
// required to trigger the missedPipeableOpportunity diagnostic. Default: 2.
PipeableMinArgCount int `` /* 186-byte string literal not displayed */
// AllowedDuplicatedPackages is a list of package names that are allowed to
// have multiple versions without triggering the duplicatePackage diagnostic.
AllowedDuplicatedPackages []string `` /* 194-byte string literal not displayed */
// EffectFn controls which effectFnOpportunity quickfix variants are offered.
// Valid values: "span", "untraced", "no-span", "inferred-span", "suggested-span".
// Default (when empty/nil): ["span"].
EffectFn []string `` /* 286-byte string literal not displayed */
// DiagnosticSeverity maps rule names to severity levels.
// If nil, diagnostics are explicitly disabled.
// If empty map {}, diagnostics are enabled with defaults.
DiagnosticSeverity map[string]Severity `` /* 140-byte string literal not displayed */
// Overrides applies ordered per-file diagnostic option overrides.
Overrides []Override `json:"overrides,omitzero" schema_description:"Ordered per-file diagnostic option overrides."`
}
EffectPluginOptions defines the configuration schema for `@effect/language-service` as parsed from tsconfig plugin JSON. This type is stored in CompilerOptions.Effect after parsing tsconfig.json.
func ParseFromPlugins ¶
func ParseFromPlugins(value any) *EffectPluginOptions
ParseFromPlugins parses the @effect/language-service plugin config from the plugins array. The plugins parameter is the value of compilerOptions.plugins from tsconfig.json. Returns nil if the plugin is not configured or if diagnosticSeverity is explicitly set to null.
func (*EffectPluginOptions) GetBarrelImportPackages ¶
func (e *EffectPluginOptions) GetBarrelImportPackages() []string
GetBarrelImportPackages returns normalized package names configured for barrel imports. Defaults to an empty list when unset.
func (*EffectPluginOptions) GetCompletionsEnabled ¶
func (e *EffectPluginOptions) GetCompletionsEnabled() bool
func (*EffectPluginOptions) GetDebugEnabled ¶
func (e *EffectPluginOptions) GetDebugEnabled() bool
func (*EffectPluginOptions) GetImportAliases ¶
func (e *EffectPluginOptions) GetImportAliases() map[string]string
GetImportAliases returns normalized import aliases keyed by lower-cased package names. Defaults to an empty map when unset.
func (*EffectPluginOptions) GetIncludeSuggestionsInTsc ¶
func (e *EffectPluginOptions) GetIncludeSuggestionsInTsc() bool
GetIncludeSuggestionsInTsc returns whether suggestion diagnostics should appear in tsc output. Returns true (include suggestions) when the receiver is nil.
func (*EffectPluginOptions) GetLayerGraphFollowDepth ¶
func (e *EffectPluginOptions) GetLayerGraphFollowDepth() int
GetLayerGraphFollowDepth returns the configured layer graph follow depth, or 0 if not set.
func (*EffectPluginOptions) GetMermaidBaseURL ¶
func (e *EffectPluginOptions) GetMermaidBaseURL() string
GetMermaidBaseURL resolves the MermaidProvider value to a full base URL.
- "" or "mermaid.live" → "https://mermaid.live/edit#"
- "mermaid.com" → "https://www.mermaidchart.com/play#"
- Any other string → "<value>/edit#"
func (*EffectPluginOptions) GetNamespaceImportPackages ¶
func (e *EffectPluginOptions) GetNamespaceImportPackages() []string
GetNamespaceImportPackages returns normalized package names configured for namespace imports. Defaults to an empty list when unset.
func (*EffectPluginOptions) GetQuickinfoEnabled ¶
func (e *EffectPluginOptions) GetQuickinfoEnabled() bool
func (*EffectPluginOptions) GetRefactorsEnabled ¶
func (e *EffectPluginOptions) GetRefactorsEnabled() bool
func (*EffectPluginOptions) GetTopLevelNamedReexports ¶
func (e *EffectPluginOptions) GetTopLevelNamedReexports() TopLevelNamedReexportsMode
GetTopLevelNamedReexports returns the normalized top-level named reexports mode. Defaults to "ignore" when unset or invalid.
type KeyPattern ¶
type KeyPattern struct {
// Target is the category this pattern applies to: "service", "error", or "custom".
Target string `` /* 153-byte string literal not displayed */
// Pattern is the formula to compute the key: "default", "package-identifier", or "default-hashed".
Pattern string `` /* 167-byte string literal not displayed */
// SkipLeadingPath is a list of path prefixes to strip from the sub-directory segment.
SkipLeadingPath []string `` /* 153-byte string literal not displayed */
}
KeyPattern defines a key pattern configuration for the deterministicKeys rule.
type Override ¶
type Override struct {
Include []string `json:"include,omitzero" schema_description:"Files included by this override." schema_items_type:"string"`
Exclude []string `json:"exclude,omitzero" schema_description:"Files excluded from this override." schema_items_type:"string"`
Options OverrideOptions `json:"options,omitzero" schema_description:"Diagnostic option overrides applied when this override matches."`
}
Override is a path-scoped partial override for diagnostic configuration.
type OverrideOptions ¶
type OverrideOptions struct {
DiagnosticSeverity map[string]Severity `json:"diagnosticSeverity,omitzero" schema_description:"Severity overrides applied when this override matches."`
PipeableMinArgCount *int `` /* 167-byte string literal not displayed */
KeyPatterns *[]KeyPattern `json:"keyPatterns,omitzero" schema_description:"Scoped key pattern configuration for deterministicKeys."`
ExtendedKeyDetection *bool `json:"extendedKeyDetection,omitzero" schema_description:"Scoped override for extended deterministic key detection."`
AllowedDuplicatedPackages *[]string `` /* 129-byte string literal not displayed */
EffectFn *[]string `` /* 240-byte string literal not displayed */
}
OverrideOptions is the subset of plugin options that can vary per file.
type ResolvedEffectPluginOptions ¶
type ResolvedEffectPluginOptions struct {
NamespaceImportPackages []string
BarrelImportPackages []string
ImportAliases map[string]string
TopLevelNamedReexports TopLevelNamedReexportsMode
KeyPatterns []KeyPattern
ExtendedKeyDetection bool
PipeableMinArgCount int
AllowedDuplicatedPackages []string
EffectFn []string
}
ResolvedEffectPluginOptions contains Effect plugin options that may vary per source file after applying matching overrides.
func (*ResolvedEffectPluginOptions) EffectFnIncludes ¶
func (e *ResolvedEffectPluginOptions) EffectFnIncludes(variant string) bool
EffectFnIncludes checks if a variant is in the configured (or default) effectFn list.
func (*ResolvedEffectPluginOptions) GetAllowedDuplicatedPackages ¶
func (e *ResolvedEffectPluginOptions) GetAllowedDuplicatedPackages() []string
GetAllowedDuplicatedPackages returns the list of package names allowed to have multiple versions, or nil if none are configured.
func (*ResolvedEffectPluginOptions) GetEffectFn ¶
func (e *ResolvedEffectPluginOptions) GetEffectFn() []string
GetEffectFn returns the configured effectFn variants, or the default ["span"] when unset/empty.
func (*ResolvedEffectPluginOptions) GetKeyPatterns ¶
func (e *ResolvedEffectPluginOptions) GetKeyPatterns() []KeyPattern
GetKeyPatterns returns the configured key patterns or the defaults if none are configured.
func (*ResolvedEffectPluginOptions) GetPipeableMinArgCount ¶
func (e *ResolvedEffectPluginOptions) GetPipeableMinArgCount() int
GetPipeableMinArgCount returns the configured minimum pipeable arg count, or 2 if not set.
type Severity ¶
type Severity int
Severity represents the configured severity level for a diagnostic rule.
func ParseSeverity ¶
ParseSeverity parses a severity string into a Severity constant. Valid values: "off", "warning", "warn", "error", "suggestion", "message", "skip-file"
func (Severity) MarshalJSON ¶
MarshalJSON implements json.Marshaler for Severity. Serializes as the string representation (e.g., "error", "warning").
func (*Severity) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler for Severity. Parses from string representation (e.g., "error", "warning").
type TopLevelNamedReexportsMode ¶
type TopLevelNamedReexportsMode string
TopLevelNamedReexportsMode configures top-level named reexport resolution behavior.
const ( TopLevelNamedReexportsIgnore TopLevelNamedReexportsMode = "ignore" TopLevelNamedReexportsFollow TopLevelNamedReexportsMode = "follow" )