Rules
General rules configuration is described here.
Rules are grouped by category to help you understand their purpose. Each rule has emojis denoting:
- βοΈ - this rule is configurable
- π - some problems reported by this rule can be fixed by editor suggestions
- β οΈ - this rule is deprecated and will be removed in the next major release
Commonβ
Enforces named argument order in function and constructor invocations to be the same as corresponding named parameter declaration order.
Warns when a cascade expression is used after if null (??) binary expression without parentheses.
Avoid using collection methods with unrelated types, such as accessing a map of integers using a string key.
Warns when an import/export directive contains a double slash.
Warns when a file has multiple exports
declarations with the same URI.
Warns when dynamic
type is used as variable type in declaration, return type of a function, etc.
Warns when a return value of a method or function invocation or a class instance property access is not used.
Warns when a field or variable is declared with a late
keyword.
Warns when a enum constant is missing in a map declaration.
Warns when a string literal contains non ascii characters.
Warns when non null assertion operator !
(or βbangβ operator) is used for a property access or method invocation. The operator check works at runtime and it may fail and throw a runtime exception.
Warns when an asynchronous function is used as an argument where a synchronous function is expected.
Checks for redundant async
in a method or function body.
Warns when a public top-level member (except the entrypoint) is declared inside a test file.
Warns about unnecessary usage of is
and whereType
operators.
Checks for unused parameters inside a function or method body.
Warns when a literal value is on the left hand side in a binary expressions.
Checks that double literals should begin with 0.
instead of just .
, and should not end with a trailing 0
.
Warns when a field is not added to props
getter of a class that extends Equatable
or EquatableMixin
.
Enforces blank line between statements and return in a block.
Warns on comparison to a boolean literal, as in x == true
.
Warns when equal arguments are passed to a function or method invocation.
Warns when if statement has equal then and else statements or conditional expression has equal then and else expressions.
Warns against using number literals outside of named constants or variables.
Recommends to use async/await
syntax to handle a Future
result instead of .then()
invocation.
Warns when // ignore:
comments are left without any additional description why this ignore is applied.
Recommends to use a conditional expression instead of assigning to the same thing or return statement in each branch of an if statement.
Warns when an identifier name length is very short or long.
Warns if the file within /test
contains a main
, but the file name doesn't end with _test.dart
.
Type name should only contain alphanumeric characters, start with an uppercase character and span between min-length and max-length characters in length.
Since Dart 2.15 it's possible to use byName
method on enum values
prop instead of searching the value with firstWhere
.
Warns when a method or a function returns a variable declared right before the return statement.
Warns when List.from()
factory is used instead of List.of()
.
Warns when a property access or a method invocation start with duplicated chains of other invocations / accesses inside a single function or method block.
Suggests to use static class member instead of global constants, variables and functions.
Checks for a trailing comma for arguments, parameters, enum values and collections.
Flutter specificβ
Warns when an event listener is added but never removed.
Warns when a method or function returns a Widget or subclass of a Widget.
Warns when a ListView
widget with shrinkWrap
parameter is wrapped in a Column
, Row
or another ListView
widget.
Warns when setState
is called inside initState
, didUpdateWidget
or build
methods and when it is called from a sync
method that is called inside those methods.
Warns when a widget is wrapped in a Padding widget but has a padding settings by itself.
Warns when a RenderObject
setter doesn't have an equality check for the new value.
Warns when an updateRenderObject
method is absent or doesn't update all fields set in createRenderObject
.
Warns about inline callbacks in a widget tree and suggest to extract them to a widget method.
Warns when a file contains more than a single widget.
Warns when a Column
widget with only children
parameter is wrapped in a SingleChildScrollView
widget.
Flameβ
Lints for the Flame package.
Warns when a Vector2
is created inside a Component's update
method.
Warns when a late final
variable is being initialized in the Component's onMount
method.
Warns when a Component's onLoad
method can be made sync.
Warns when a game is instantiated in a stateless widget build method.
Intl specificβ
Recommends to use ClassName_ClassMemberName
pattern for Intl methods name argument.
Warns when a Intl
method invoked without a description.
Warns when the Intl.message()
invocation has incorrect args.
Angular specificβ
Warns when a @Component
annotation has explicit false value for preserveWhitespace
.
Enforces Angular @Component
annotation arguments ordering.
Prefer setting changeDetection: ChangeDetectionStrategy.OnPush
in Angular @Component
annotations.