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 ¶
- type Result
- func LintFile(filename string) (*Result, error)
- func LintNoInlineScripts(dir string) (*Result, error)
- func LintNoInlineScriptsRecursive(root string) (*Result, error)
- func LintNoInlineStyles(dir string) (*Result, error)
- func LintNoInlineStylesRecursive(root string) (*Result, error)
- func LintNoPatternBaseCSS(root string) (*Result, error)
- func LintNoVarJS(dir string) (*Result, error)
- func LintNoVarJSRecursive(root string) (*Result, error)
- func LintPackage(dir string) (*Result, error)
- type Violation
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 LintNoInlineScripts ¶
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 ¶
LintNoInlineScriptsRecursive walks dir and every subdirectory, running LintNoInlineScripts on each. Skips vendor/, node_modules/, hidden dirs, and testdata/.
func LintNoInlineStyles ¶
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 ¶
LintNoInlineStylesRecursive walks dir and every subdirectory. Skips vendor/, node_modules/, hidden dirs, and testdata/ — matching the script linter's recursion contract.
func LintNoPatternBaseCSS ¶
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 ¶
LintNoVarJS scans .js files at dir (non-recursive) and reports any `var` declaration found in executable code (not in comments / string literals).
func LintNoVarJSRecursive ¶
LintNoVarJSRecursive walks dir + every subdirectory, running LintNoVarJS on each. Skips vendor/, node_modules/, hidden dirs, and testdata/.
func LintPackage ¶
LintPackage lints all .go files in a directory.