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 ¶
- func ConverterOptions(cfg *core.Config, format string) (map[string]any, error)
- type DocumentErrors
- type ExtendedHTMLWriter
- type Linter
- func (l *Linter) Lint(input []string, pat string) ([]*core.File, error)
- func (l *Linter) LintBuilt(content, virtualName, html string) ([]*core.File, error)
- func (l *Linter) LintString(src string) ([]*core.File, error)
- func (l *Linter) LintStringAs(content, virtualName string) ([]*core.File, error)
- func (l *Linter) Transform(f *core.File) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConverterOptions ¶ added in v3.26.0
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 (*ExtendedHTMLWriter) WriteFootnoteLink ¶ added in v3.23.0
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 (*Linter) LintBuilt ¶ added in v3.26.0
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 ¶
LintString src according to its format.
func (*Linter) LintStringAs ¶ added in v3.26.0
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.