Skip to main content

Custom Rules

Define project-specific regex rules in .revet.toml — no Rust code needed. Prefix: CUSTOM-

Basic rule

[[rules]]
id = "no-console-log"
pattern = 'console\.log'
message = "console.log should not be used in production code"
severity = "warning"
paths = ["*.ts", "*.js", "*.tsx"]
suggestion = "Use the logger utility instead"

With auto-fix

Add fix_find and fix_replace to enable revet review --fix support:

[[rules]]
id = "no-console-log"
pattern = 'console\.log'
message = "console.log should not be used in production"
severity = "warning"
paths = ["*.ts", "*.js"]
suggestion = "Use the logger utility instead"
fix_find = 'console\.log\(' # regex matched on the line
fix_replace = 'logger.info(' # replacement string

All fields

FieldRequiredDescription
idyesUnique rule identifier (appended to CUSTOM-)
patternyesRegex matched against each line
messageyesFinding message shown to the user
severityyeserror, warning, or info
pathsnoGlob patterns to restrict which files are scanned
suggestionnoShown below the finding as a hint
reject_if_containsnoSkip the line if it contains this substring (for suppression comments)
fix_findnoRegex to find on the matched line for --fix
fix_replacenoReplacement string for --fix

Multiple rules

[[rules]]
id = "no-fixme"
pattern = 'FIXME'
message = "FIXME left in code"
severity = "info"

[[rules]]
id = "no-todo-prod"
pattern = 'TODO'
message = "TODO left in code"
severity = "info"
paths = ["src/**/*.ts"]
reject_if_contains = "// tracked:"