provide-deprecation-message
Same as provide_deprecation_message in Dart lints
- Group
- Style
- Path
lint/style/provide-deprecation-message- Default
- On (recommended)
- Origin
- Dart lints
- Rule
- 426 of 512
Flags @deprecated and @Deprecated() annotations that carry no message.
A deprecation is only useful if it tells callers what to do instead — which
replacement to adopt, or since when the API is going away. The bare
@deprecated constant can never carry that guidance, and @Deprecated()
with no argument (or an empty/whitespace-only string) is just as unhelpful,
so both should be replaced with @Deprecated("message"). A @Deprecated
whose positional argument is any non-empty expression is accepted. The rule
also inspects field-level annotations, which the generic syntax-tree walk would
otherwise skip.
Invalid
class Api {
@deprecated
void oldMethod() {}
@Deprecated('')
void emptyMessage() {}
@Deprecated(' ')
void whitespaceMessage() {}
@deprecated
int oldField = 0;
}
@deprecated
void oldTopLevel() {}
class MultiField {
// The annotation belongs to the declaration, so one diagnostic covers both.
@deprecated
int a = 0, b = 1;
}class Api { @deprecated @Deprecated('') @Deprecated(' ') @deprecated @deprecated // The annotation belongs to the declaration, so one diagnostic covers both. @deprecatedValid
class Api {
@Deprecated('Use newMethod instead.')
void oldMethod() {}
@Deprecated('Removed in version 2.0.')
int oldField = 0;
@override
String toString() => 'Api';
}
@Deprecated('No longer supported; use Service.')
void oldTopLevel() {}
@Deprecated('Use the replacement class.')
class OldClass {}Configure provide-deprecation-message
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"style": {
"provide-deprecation-message": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/style/provide-deprecation-message: <reason>More style rules
- public-member-api-docs
public_member_api_docsDocuments public declarations and members in package libraries.
- record-fields-ordering
Flags named record type fields that violate the configured order.
- require-trailing-commas
require_trailing_commasFlags a multi-line call, declaration, assert, or collection literal that is missing a trailing comma.
- sized-box-shrink-expand
sized_box_shrink_expandrecommendedflutterPrefers
SizedBox.shrink()/SizedBox.expand()over aSizedBoxsized to zero or infinity. - slash-for-doc-comments
slash_for_doc_commentsrecommendedFlags
/** ... - sort-child-properties-last
sort_child_properties_lastrecommendedflutterSort Widget-valued child properties last, except before closure arguments.
- sort-constructors-first
sort_constructors_firstFlags a constructor declared after a non-constructor member.
- sort-unnamed-constructors-first
sort_unnamed_constructors_firstFlags an unnamed constructor declared after a named constructor.