Rule

Trait Rule 

Source
pub trait Rule:
    DynClone
    + Send
    + Sync {
Show 14 methods // Required methods fn name(&self) -> &'static str; fn description(&self) -> &'static str; fn check(&self, ctx: &LintContext<'_>) -> LintResult; fn fix(&self, ctx: &LintContext<'_>) -> Result<String, LintError>; fn as_any(&self) -> &dyn Any; // Provided methods fn should_skip(&self, _ctx: &LintContext<'_>) -> bool { ... } fn category(&self) -> RuleCategory { ... } fn default_config_section(&self) -> Option<(String, Value)> { ... } fn config_aliases(&self) -> Option<HashMap<String, String>> { ... } fn fix_capability(&self) -> FixCapability { ... } fn cross_file_scope(&self) -> CrossFileScope { ... } fn contribute_to_index( &self, _ctx: &LintContext<'_>, _file_index: &mut FileIndex, ) { ... } fn cross_file_check( &self, _file_path: &Path, _file_index: &FileIndex, _workspace_index: &WorkspaceIndex, ) -> LintResult { ... } fn from_config(_config: &Config) -> Box<dyn Rule> where Self: Sized { ... }
}
Expand description

Remove marker /// TRAIT_MARKER_V1

Required Methods§

Source

fn name(&self) -> &'static str

Source

fn description(&self) -> &'static str

Source

fn check(&self, ctx: &LintContext<'_>) -> LintResult

Source

fn fix(&self, ctx: &LintContext<'_>) -> Result<String, LintError>

Source

fn as_any(&self) -> &dyn Any

Provided Methods§

Source

fn should_skip(&self, _ctx: &LintContext<'_>) -> bool

Check if this rule should quickly skip processing based on content

Source

fn category(&self) -> RuleCategory

Get the category of this rule for selective processing

Source

fn default_config_section(&self) -> Option<(String, Value)>

Returns the rule name and default config table if the rule has config. If a rule implements this, it MUST be defined on the impl Rule for ... block, not just the inherent impl.

Source

fn config_aliases(&self) -> Option<HashMap<String, String>>

Returns config key aliases for this rule This allows rules to accept alternative config key names for backwards compatibility

Source

fn fix_capability(&self) -> FixCapability

Declares the fix capability of this rule

Source

fn cross_file_scope(&self) -> CrossFileScope

Declares cross-file analysis requirements for this rule

Returns CrossFileScope::None by default, meaning the rule only needs single-file context. Rules that need workspace-wide data should override this to return CrossFileScope::Workspace.

Source

fn contribute_to_index( &self, _ctx: &LintContext<'_>, _file_index: &mut FileIndex, )

Contribute data to the workspace index during linting

Called during the single-file linting phase for rules that return CrossFileScope::Workspace. Rules should extract headings, links, and other data needed for cross-file validation.

This is called as a side effect of linting, so LintContext is already created - no duplicate parsing required.

Source

fn cross_file_check( &self, _file_path: &Path, _file_index: &FileIndex, _workspace_index: &WorkspaceIndex, ) -> LintResult

Perform cross-file validation after all files have been linted

Called once per file after the entire workspace has been indexed. Rules receive the file_index (from contribute_to_index) and the full workspace_index for cross-file lookups.

Note: This receives the FileIndex instead of LintContext to avoid re-parsing each file. The FileIndex was already populated during contribute_to_index.

Rules can use workspace_index methods for cross-file validation:

  • get_file(path) - to look up headings in target files (for MD051)
  • files() - to iterate all indexed files

Returns additional warnings for cross-file issues. These are appended to the single-file warnings.

Source

fn from_config(_config: &Config) -> Box<dyn Rule>
where Self: Sized,

Factory: create a rule from config (if present), or use defaults.

Implementors§

Source§

impl Rule for MD004UnorderedListStyle

Source§

impl Rule for MD013LineLength

Source§

impl Rule for MD030ListMarkerSpace

Source§

impl Rule for MD001HeadingIncrement

Source§

impl Rule for MD003HeadingStyle

Source§

impl Rule for MD005ListIndent

Source§

impl Rule for MD007ULIndent

Source§

impl Rule for MD009TrailingSpaces

Source§

impl Rule for MD010NoHardTabs

Source§

impl Rule for MD012NoMultipleBlanks

Source§

impl Rule for MD014CommandsShowOutput

Source§

impl Rule for MD018NoMissingSpaceAtx

Source§

impl Rule for MD019NoMultipleSpaceAtx

Source§

impl Rule for MD020NoMissingSpaceClosedAtx

Source§

impl Rule for MD021NoMultipleSpaceClosedAtx

Source§

impl Rule for MD022BlanksAroundHeadings

Source§

impl Rule for MD023HeadingStartLeft

Source§

impl Rule for MD024NoDuplicateHeading

Source§

impl Rule for MD025SingleTitle

Source§

impl Rule for MD026NoTrailingPunctuation

Source§

impl Rule for MD027MultipleSpacesBlockquote

Source§

impl Rule for MD028NoBlanksBlockquote

Source§

impl Rule for MD029OrderedListPrefix

Source§

impl Rule for MD031BlanksAroundFences

Source§

impl Rule for MD032BlanksAroundLists

Source§

impl Rule for MD033NoInlineHtml

Source§

impl Rule for MD034NoBareUrls

Source§

impl Rule for MD035HRStyle

Source§

impl Rule for MD036NoEmphasisAsHeading

Source§

impl Rule for MD037NoSpaceInEmphasis

Source§

impl Rule for MD038NoSpaceInCode

Source§

impl Rule for MD040FencedCodeLanguage

Source§

impl Rule for MD041FirstLineHeading

Source§

impl Rule for MD043RequiredHeadings

Source§

impl Rule for MD044ProperNames

Source§

impl Rule for MD045NoAltText

Source§

impl Rule for MD046CodeBlockStyle

Source§

impl Rule for MD047SingleTrailingNewline

Source§

impl Rule for MD048CodeFenceStyle

Source§

impl Rule for MD049EmphasisStyle

Source§

impl Rule for MD050StrongStyle

Source§

impl Rule for MD051LinkFragments

Source§

impl Rule for MD052ReferenceLinkImages

Source§

impl Rule for MD053LinkImageReferenceDefinitions

Source§

impl Rule for MD054LinkImageStyle

Source§

impl Rule for MD055TablePipeStyle

Source§

impl Rule for MD056TableColumnCount

Source§

impl Rule for MD058BlanksAroundTables

Source§

impl Rule for MD059LinkText

Source§

impl Rule for MD060TableFormat

Source§

impl Rule for MD061ForbiddenTerms

Source§

impl Rule for MD062LinkDestinationWhitespace

Source§

impl Rule for MD063HeadingCapitalization

Source§

impl Rule for MD064NoMultipleConsecutiveSpaces

Source§

impl Rule for MD065BlanksAroundHorizontalRules

Source§

impl Rule for MD066FootnoteValidation

Source§

impl Rule for MD067FootnoteDefinitionOrder

Source§

impl Rule for MD068EmptyFootnoteDefinition