module

Ignorelint

Supported output formats for lint results.

Each value corresponds to a concrete Formatter subclass:

  • Human → HumanFormatter — colored terminal output
  • Json → JsonFormatter — machine-readable JSON
  • Checkstyle → CheckstyleFormatter — XML for CI integrations
  • Sarif → SarifFormatter — SARIF 2.1.0 for GitHub Advanced Security

Crystal enums are value types (like structs). Each member gets an integer index starting at 0. You can pattern-match on them with case using the when .human? shorthand (the ? is a macro-generated predicate method).

Constants

CODE_TAG_MAP = {Code::TrailingWhitespace => "IG-001", Code::UnescapedHash => "IG-002", Code::DoubleNegation => "IG-003", Code::EmptyPattern => "IG-004", Code::ConsecutiveStar => "IG-005", Code::MalformedBrackets => "IG-006", Code::SpaceInPattern => "IG-007", Code::DuplicateRule => "IG-008", Code::InvalidDoublestar => "IG-009", Code::RootedShallow => "IG-010", Code::NegatedRooted => "IG-011", Code::RedundantPair => "IG-012", Code::NegationUnsupported => "IG-013", Code::PathTraversal => "IG-014", Code::SlashNoEffect => "IG-015", Code::DoublestarUnsupported => "IG-016", Code::UnrootedNonRecursive => "IG-017", Code::RedundantBuiltinExclude => "IG-018", Code::BuiltinIncludeProtected => "IG-019", Code::PathNotFound => "IG-020", Code::DeadGlobRule => "IG-021", Code::DoubleSlash => "IG-022", Code::UnsortedRule => "IG-023", Code::LeadingWhitespace => "IG-024", Code::CaseMismatch => "IG-025"}

Machine-readable diagnostic codes for every known lint rule.

Each code maps to a human-readable "IG-NNN" tag via #tag. The tag appears in all output formats (human, JSON, Checkstyle, SARIF) so users can suppress or search for specific rules.

The naming convention is CamelCase for the Crystal enum member and snake_case for the :symbol used in Issue.new(...).

CODE_TITLE_MAP = {Code::TrailingWhitespace => "Trailing whitespace", Code::UnescapedHash => "Unescaped hash", Code::DoubleNegation => "Double negation", Code::EmptyPattern => "Empty pattern", Code::ConsecutiveStar => "Consecutive asterisks", Code::MalformedBrackets => "Malformed brackets", Code::SpaceInPattern => "Space in pattern", Code::DuplicateRule => "Duplicate rule", Code::InvalidDoublestar => "Invalid doublestar", Code::RootedShallow => "Rooted shallow pattern", Code::NegatedRooted => "Negated rooted pattern", Code::RedundantPair => "Redundant pair", Code::NegationUnsupported => "Negation unsupported", Code::PathTraversal => "Path traversal", Code::SlashNoEffect => "Slash has no effect", Code::DoublestarUnsupported => "Doublestar unsupported", Code::UnrootedNonRecursive => "Unrooted non-recursive pattern", Code::RedundantBuiltinExclude => "Redundant built-in exclude", Code::BuiltinIncludeProtected => "Built-in include protected", Code::PathNotFound => "Path not found", Code::DeadGlobRule => "Dead glob rule", Code::DoubleSlash => "Double slash", Code::UnsortedRule => "Unsorted rule", Code::LeadingWhitespace => "Leading whitespace", Code::CaseMismatch => "Case mismatch"}

Human-readable rule titles, e.g. for SARIF shortDescription.

FIXABLE_CODES = Set {Code::TrailingWhitespace, Code::UnescapedHash, Code::DoubleNegation, Code::DuplicateRule, Code::DoubleSlash, Code::UnsortedRule, Code::LeadingWhitespace, Code::SlashNoEffect, Code::RedundantBuiltinExclude}

The set of Code values that can be automatically fixed.

This is a module-level constant (created once at program startup) because it never changes. Set gives O(1) lookups via includes?.

KNOWN_FILES = {".gitignore" => FileType::Gitignore, ".dockerignore" => FileType::Dockerignore, ".npmignore" => FileType::Npmignore, ".claudeignore" => FileType::Claudeignore, ".eslintignore" => FileType::Eslintignore, ".prettierignore" => FileType::Prettierignore, ".stylelintignore" => FileType::Stylelintignore, ".yarnignore" => FileType::Yarnignore, ".tfignore" => FileType::Tfignore, ".containerignore" => FileType::Containerignore, ".helmignore" => FileType::Helmignore, ".gcloudignore" => FileType::Gcloudignore, ".ebignore" => FileType::Ebignore, ".slugignore" => FileType::Slugignore, ".vercelignore" => FileType::Vercelignore, ".cfignore" => FileType::Cfignore, ".openapi-generator-ignore" => FileType::OpenapiGeneratorIgnore, ".cursorignore" => FileType::Cursorignore, ".aiderignore" => FileType::Aiderignore, ".aiexclude" => FileType::Aiexclude, ".codeiumignore" => FileType::Codeiumignore, ".ignore" => FileType::Ignore, ".rgignore" => FileType::Rgignore, ".fdignore" => FileType::Fdignore, ".eleventyignore" => FileType::Eleventyignore} of String => FileType

Master registry of all recognized *ignore filenames → their FileType.

Used by:

  • CLI.find_ignore_files to auto-discover files in the current directory
  • Ignorelint.file_type_from_path to determine which format linter to use

The type annotation of String => FileType tells Crystal this is a Hash(String, FileType), ensuring type safety at compile time.

VALID_TAGS = CODE_TAG_MAP.values.to_set

Every known diagnostic tag in upper case, for override validation.

VERSION = {{ (env("M6E_VERSION")) || "dev" }}

Class methods

file_type_from_path(path : String) : FileType

Resolve a file path to its FileType by looking up the basename.

Returns FileType::Unknown for unrecognized filenames.

known_file?(name : String) : Bool

Check whether a filename (e.g. ".gitignore") is a recognized *ignore file.

Nested types