Help us shape the future of Go! Take the 2026 Go Developer Survey

lint

package
v3.26.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 48 Imported by: 0

Documentation

Overview

Native code linting: parse source with tree-sitter, extract the regions a language's queries capture (comments by default, or a `tree-sitter` View's scopes), and lint each. The grammars are CGo, so this file and the internal/lint/code package it imports are native-only; the wasm build falls back to the regex-based lintCodeOld (see code_js.go).

Package lint implements Vale's syntax-aware linting functionality.

The package is split into core linting logic (this file), source code (code.go), and markup (markup.go).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConverterOptions added in v3.26.0

func ConverterOptions(cfg *core.Config, format string) (map[string]any, error)

ConverterOptions returns what a host must give the converter for format so that its HTML is what Vale would have produced: Asciidoctor's attributes, Docutils' flags, or xsltproc's parameters. The values are those Vale passes itself, plus, for AsciiDoc, the configuration's own `[asciidoctor]` section.

Types

type DocumentErrors added in v3.25.0

type DocumentErrors []error

DocumentErrors are the documents a run couldn't lint, each with its own error. Every other document was linted.

func (DocumentErrors) Error added in v3.25.0

func (e DocumentErrors) Error() string

type ExtendedHTMLWriter

type ExtendedHTMLWriter struct {
	*org.HTMLWriter
}

func (*ExtendedHTMLWriter) WriteComment

func (w *ExtendedHTMLWriter) WriteComment(n org.Comment)

func (*ExtendedHTMLWriter) WriteFootnoteDefinition added in v3.23.0

func (w *ExtendedHTMLWriter) WriteFootnoteDefinition(f org.FootnoteDefinition)

WriteFootnoteDefinition writes a footnote's body where the source has it. go-org collects the definitions and writes them at the end of the document, and an alert in one was then reported wherever the text next happened to match.

func (w *ExtendedHTMLWriter) WriteFootnoteLink(l org.FootnoteLink)

WriteFootnoteLink writes an inline footnote's text and nothing for a reference: the number go-org writes is not in the source.

func (*ExtendedHTMLWriter) WriteKeyword added in v3.23.0

func (w *ExtendedHTMLWriter) WriteKeyword(k org.Keyword)

WriteKeyword writes a prose keyword where it is: the title as a heading, the author or description as a paragraph. go-org writes the title at the top of the document instead, which is not where the source has it, so that is switched off in lintOrg.

type Linter

type Linter struct {
	Manager *check.Manager

	// BlockHook, when set, receives every block before its rules run.
	BlockHook func(nlp.Block)

	// RuleHook, when set, receives each rule's name and what its Run cost.
	// A hooked run takes the serial path, which is the one that can time a rule.
	RuleHook func(name string, took time.Duration)
	// contains filtered or unexported fields
}

A Linter lints a File.

func NewLinter

func NewLinter(cfg *core.Config) (*Linter, error)

NewLinter initializes a Linter.

func (*Linter) Lint

func (l *Linter) Lint(input []string, pat string) ([]*core.File, error)

Lint src according to its format.

func (*Linter) LintBuilt added in v3.26.0

func (l *Linter) LintBuilt(content, virtualName, html string) ([]*core.File, error)

LintBuilt lints content as the document named virtualName, from the HTML that a converter the host ran produced for it. It is how a host without the converter Vale would run, such as a browser with Asciidoctor.js, lints a format Vale reads through one.

func (*Linter) LintString

func (l *Linter) LintString(src string) ([]*core.File, error)

LintString src according to its format.

func (*Linter) LintStringAs added in v3.26.0

func (l *Linter) LintStringAs(content, virtualName string) ([]*core.File, error)

LintStringAs lints content as the document named virtualName, whose extension says how it is read. It is how a host with no filesystem, such as a browser, lints.

func (*Linter) Transform

func (l *Linter) Transform(f *core.File) (string, error)

Transform applies the configured transformations to text and returns the result.

This is used by the `vale` command to apply transformations to text before linting it.

Transformations include block and token ignores, as well as some built-in replacements.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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