unnecessary-library-directive
Same as unnecessary_library_directive in Dart lints
- Group
- Style
- Path
lint/style/unnecessary-library-directive- Default
- On (recommended)
- Origin
- Dart lints
- Rule
- 459 of 512
Flags a library directive that has neither a doc comment nor annotations.
A library directive is only needed to anchor library-level documentation or annotations (and, historically, a name). Without either it is noise:
library; // flagged
/// Utilities for parsing.
library; // fine: documented
@TestOn('browser')
library; // fine: annotated
Libraries that declare part files are skipped, since parts may still refer
to the library by name.
Invalid
// A bare library directive with no doc comment or annotation.
library;
void main() {}// A bare library directive with no doc comment or annotation.library;Valid
/// Utilities for parsing.
library;
void main() {}Configure unnecessary-library-directive
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"style": {
"unnecessary-library-directive": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/style/unnecessary-library-directive: <reason>More style rules
- unnecessary-library-name
unnecessary_library_namerecommendedFlags a
librarydirective that carries an explicit name. - unnecessary-new
unnecessary_newrecommendedFlags an explicit
newkeyword in an instance-creation expression. - unnecessary-null-aware-operator-on-extension-on-nullable
unnecessary_null_aware_operator_on_extension_on_nullableFlags a null-aware access whose member comes from an extension on a nullable type.
- unnecessary-null-checks
unnecessary_null_checksFlags a null assertion
!on a value that flows into a nullable context. - unnecessary-nullable-for-final-variable-declarations
unnecessary_nullable_for_final_variable_declarationsrecommendedFlags a
finalorconstvariable given a nullable type but initialized to a provably non-null value. - unnecessary-parenthesis
unnecessary_parenthesisrecommendedFlags parentheses that can be removed without changing the meaning or hurting readability.
- unnecessary-raw-strings
unnecessary_raw_stringsrecommendedFlags raw string literals that contain no backslash or
$. - unnecessary-string-escapes
unnecessary_string_escapesrecommendedFlags backslashes that do not affect a string's value.