themecheck

package
v1.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package themecheck detects styles that are frozen to the default theme.

internal/styles exposes the palette as package-level *variables* that ApplyTheme reassigns at runtime. Anything that reads one of those variables while building a value in a package-level `var` block — or in an `init()` — is evaluated once, at program init, before any theme has been applied. It therefore keeps the default theme's colours forever, and the bug is invisible to anyone running the default theme.

This package walks the module's source and reports every such site, so a test can fail when the pattern reappears.

Index

Constants

View Source
const StylesPkgPath = "github.com/marcus/sidecar/internal/styles"

StylesPkgPath is the import path of the package whose exported variables are reassigned when the theme changes.

Variables

This section is empty.

Functions

func HasDotImport

func HasDotImport(root string) (string, bool)

HasDotImport reports whether any file under root dot-imports the styles package, which would hide theme references from the scanner.

func MutableSymbols

func MutableSymbols(root string) (map[string]bool, error)

MutableSymbols is Scan's first step, exposed so tests can assert the set is non-trivial and contains the palette variables it is meant to cover.

Types

type Finding

type Finding struct {
	File   string // path relative to the scanned root
	Line   int
	Name   string // the package-level identifier being initialised
	Symbol string // the styles.* symbol it froze
}

Finding is one package-level value that captures a theme colour at init.

func Scan

func Scan(root string) ([]Finding, error)

Scan walks root, finds the theme-mutable symbols exported by the styles package, and reports every package-level value elsewhere in the module that is initialised from one of them.

If root contains no styles package (as in the analyzer's own fixtures), the caller-supplied mutable set is used instead; see ScanWith.

func ScanWith

func ScanWith(root string, mutable map[string]bool, skipDir string) ([]Finding, error)

ScanWith is Scan with an explicit set of theme-mutable symbol names, and an optional directory to skip (the styles package itself, which legitimately owns and rebuilds those variables).

func (Finding) String

func (f Finding) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL