check

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package check provides an AST-based linter for .ui.go files.

The linter enforces a restricted subset of Go that is safe for client-side hydration. It forbids goroutines, channels, I/O, networking, reflection, and other patterns that are not suitable for the declarative UI layer.

Allowed imports are limited to a safe subset of the standard library (fmt, strings, strconv, html/template, html, math, time, errors) and any package under github.com/DonaldMurillo/gofastr/.

check-csp:ignore-file The linter itself references <script> in regex patterns and error messages; the directive exempts this file from its own checks.

check-csp:ignore-file The linter itself references `style="…"` in regex patterns and error messages; the directive exempts this file from its own checks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	Violations []Violation
}

Result holds all violations found in a file or package.

func LintFile

func LintFile(filename string) (*Result, error)

LintFile lints a single .ui.go file.

func LintNoInlineScripts

func LintNoInlineScripts(dir string) (*Result, error)

LintNoInlineScripts scans every .go file in dir (non-recursive) for string literals or render.Tag("script", ...) calls that emit an inline <script> block. Returns one Violation per offending site.

A file can opt out by including the directive `//check-csp:ignore-file` somewhere in its source (typically near the top). Use only when the file inherently references <script> in non-emitting contexts — the linter itself, regex patterns, or CLI scaffolding.

func LintNoInlineScriptsRecursive

func LintNoInlineScriptsRecursive(root string) (*Result, error)

LintNoInlineScriptsRecursive walks dir and every subdirectory, running LintNoInlineScripts on each. Skips vendor/, node_modules/, hidden dirs, and testdata/.

func LintNoInlineStyles

func LintNoInlineStyles(dir string) (*Result, error)

LintNoInlineStyles scans every .go file in dir (non-recursive) for inline style attributes in HTML, and for "style" keys passed as attrs to render.Tag / html.Attrs literals. Returns one violation per offending source location.

func LintNoInlineStylesRecursive

func LintNoInlineStylesRecursive(root string) (*Result, error)

LintNoInlineStylesRecursive walks dir and every subdirectory. Skips vendor/, node_modules/, hidden dirs, and testdata/ — matching the script linter's recursion contract.

func LintNoPatternBaseCSS

func LintNoPatternBaseCSS(root string) (*Result, error)

LintNoPatternBaseCSS walks core-ui/patterns/* (or any subdir of the given root that lives under "patterns") and reports any package that exports a top-level `func BaseCSS`. Use it from a test in any package to enforce the rule on every `go test ./...`.

func LintNoVarJS

func LintNoVarJS(dir string) (*Result, error)

LintNoVarJS scans .js files at dir (non-recursive) and reports any `var` declaration found in executable code (not in comments / string literals).

func LintNoVarJSRecursive

func LintNoVarJSRecursive(root string) (*Result, error)

LintNoVarJSRecursive walks dir + every subdirectory, running LintNoVarJS on each. Skips vendor/, node_modules/, hidden dirs, and testdata/.

func LintPackage

func LintPackage(dir string) (*Result, error)

LintPackage lints all .go files in a directory.

func (*Result) Error

func (r *Result) Error() string

Error returns a formatted string of all violations.

func (*Result) HasErrors

func (r *Result) HasErrors() bool

HasErrors returns true if any violations were found.

type Violation

type Violation struct {
	File    string
	Line    int
	Message string
}

Violation represents a linter error.

Jump to

Keyboard shortcuts

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