Skip to main content

Module directive

Module directive 

Source
Expand description

The # arity… directive grammar, shared by the formatter and the linter.

A directive is an ordinary # comment that tells one or both tools to stand down. One grammar spans them:

# arity[-format|-lint] <verb> [<rule>][: <reason>]      verb: skip | off | on | skip-file

which fills a three-by-three table of scope against tool:

# arity-format skip: why        # arity-lint skip <rule>: why       # arity skip: why
# arity-format off … on         # arity-lint off <rule> … on        # arity off … on
# arity-format skip-file: why   # arity-lint skip-file <rule>: why  # arity skip-file: why

Only a lint directive names a rule: # arity-format has no lint half, and # arity covers every rule by construction.

§Deprecated spellings

# arity-ignore <rule>: why and # arity-ignore-file <rule>: why are what the linter shipped with. They still parse, as Verb::Skip and Verb::SkipFile tagged Spelling::Deprecated, so a rule can find and rewrite them; nothing else should treat them differently.

This module is the single source of truth for that table. It parses comment text — no tree, no grammar — which is what lets the R walk, the DESCRIPTION walk, and the formatter share it without sharing a node type.

§Offsets

Every range is relative to the start of the comment text passed in. A caller holding a token adds the token’s own start to make it absolute.

Structs§

Directive
A recognized directive.
Malformed
A comment that announced itself as a directive but does not parse as one.
RuleRef
A rule ID as written, with the range it occupies.

Enums§

MalformedKind
Parsed
The result of reading one comment.
RuleScope
Which lint rules a directive covers.
Spelling
Whether a directive is written the canonical way or in one of the spellings the linter shipped with.
Tool
Which tool a directive addresses.
Verb
What a directive does, and over what span.

Functions§

parse
Read one # comment as a directive.