Open
Description
dartdoc_macro_reference
Description
"Only use macros with pre-defined templates"
Details
Currently, there is no safeguard for dartdoc macros.
When writing:
/// {@macro whatever}
var x;
there is nothing that checks whatever
matches with a valid {@template whatever}
defined previously.
So if a typo is made when using the macro, or if somehow during refactoring a template is renamed/removed, this would break the documentation.
A lint cold be added to verify that the macro string correctly has a template
Kind
info, like most of the other lints
Good Examples
/// {@template whatever}
/// {@endtemplate}
var a;
/// {@macro whatever} // "whatever" correctly exists as a template
var b;
Bad Examples
/// {@template whatever}
/// {@endtemplate}
var a;
/// {@macro not_found}
^^^^^^^ // There's no template with the key "not_found"
var b;