import RuleEntry from '@site/src/components/RuleEntry';
:::tip
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
<RuleEntry name="avoid-banned-imports" type="common" severity="style" version="4.16.0" hasConfig
Configure some imports that you want to ban.
<RuleEntry name="avoid-collection-methods-with-unrelated-types" type="common" severity="warning" version="4.14.0"
Avoid using collection methods with unrelated types, such as accessing a map of integers using a string key.
<RuleEntry name="avoid-duplicate-exports" type="common" severity="warning" version="4.17.0"
Warns when a file has multiple exports
declarations with the same
URI.
<RuleEntry name="avoid-dynamic" type="common" severity="warning" version="4.11.0"
Warns when dynamic
type is used as variable type in declaration,
return type of a function, etc.
<RuleEntry name="avoid-global-state" type="common" severity="warning" version="4.10.0"
Warns about usage mutable global variables.
<RuleEntry name="avoid-ignoring-return-values" type="common" severity="warning" version="4.2.0"
Warns when a return value of a method or function invocation or a class instance property access is not used.
<RuleEntry name="avoid-late-keyword" type="common" severity="warning" version="3.2.0"
Warns when a field or variable is declared with a late
keyword.
<RuleEntry name="avoid-missing-enum-constant-in-map" type="common" severity="warning" version="4.7.0"
Warns when a enum constant is missing in a map declaration.
<RuleEntry name="avoid-nested-conditional-expressions" type="common" severity="style" version="4.5.0"
Warns about nested conditional expressions.
<RuleEntry name="avoid-non-ascii-symbols" type="common" severity="warning" version="4.15.0"
Warns when a string literal contains non ascii characters.
<RuleEntry name="avoid-non-null-assertion" type="common" severity="warning" version="3.2.0"
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.
<RuleEntry name="avoid-passing-async-when-sync-expected" type="common" severity="warning" version="4.18.0"
Warns when an asynchronous function is used as an argument where a synchronous function is expected.
<RuleEntry name="avoid-throw-in-catch-block" type="common" severity="warning" version="4.7.0"
Warns when call throw
in a catch block.
<RuleEntry name="avoid-top-level-members-in-tests" type="common" severity="warning" version="4.17.0"
Warns when a public top-level member (except the entrypoint) is declared inside a test file.
<RuleEntry name="avoid-unnecessary-type-assertions" type="common" severity="warning" version="4.7.0"
Warns about unnecessary usage of is
and whereType
{' '}
operators.
<RuleEntry name="avoid-unnecessary-type-casts" type="common" severity="warning" version="4.7.0"
Warns about unnecessary usage of as
operators.
<RuleEntry name="avoid-unrelated-type-assertions" type="common" severity="warning" version="4.9.0"
Warns about unrelated usages of is
operators.
<RuleEntry name="avoid-unused-parameters" type="common" severity="warning" version="2.4.0"
Checks for unused parameters inside a function or method body.
<RuleEntry name="ban-name" type="common" severity="style" version="4.12.0" hasConfig
Configure some names that you want to ban.
<RuleEntry name="binary-expression-operand-order" type="common" severity="style" version="1.7.0" hasFix
Warns when a literal value is on the left hand side in a binary expressions.
<RuleEntry name="double-literal-format" type="common" severity="style" version="1.5.0" hasFix
Checks that double literals should begin with 0.
instead of just{' '}
.
, and should not end with a trailing 0
.
<RuleEntry name="format-comment" type="common" severity="style" version="4.11.0" hasConfig hasFix
Prefer format comments like sentences.
<RuleEntry name="member-ordering" type="common" severity="style" version="1.8.0" hasConfig isDeprecated
Enforces ordering for a class members.
<RuleEntry name="member-ordering-extended" type="common" severity="style" version="3.0.0" hasConfig
Enforces ordering for a class members.
<RuleEntry name="newline-before-return" type="common" severity="style" version="1.5.1" hasConfig
Enforces blank line between statements and return in a block.
<RuleEntry name="no-boolean-literal-compare" type="common" severity="style" version="1.5.0" hasFix
Warns on comparison to a boolean literal, as in x == true
.
<RuleEntry name="no-equal-arguments" type="common" severity="warning" version="2.1.0" hasConfig
Warns when equal arguments are passed to a function or method invocation.
<RuleEntry name="no-equal-then-else" type="common" severity="warning" version="1.10.0"
Warns when if statement has equal then and else statements or conditional expression has equal then and else expressions.
<RuleEntry name="no-magic-number" type="common" severity="warning" version="1.6.0" hasConfig
Warns against using number literals outside of named constants or variables.
<RuleEntry name="no-object-declaration" type="common" severity="style" version="1.8.0"
Warns when a class member is declared with Object
type.
<RuleEntry name="prefer-async-await" type="common" severity="style" version="4.11.0"
Recommends to use async/await
syntax to handle a{' '}
Future
result instead of .then()
invocation.
<RuleEntry name="prefer-commenting-analyzer-ignores" type="common" severity="warning" version="4.14.0"
Warns when // ignore:
comments are left without any additional
description why this ignore is applied.
<RuleEntry name="prefer-conditional-expressions" type="common" severity="style" version="1.8.0" hasFix
Recommends to use a conditional expression instead of assigning to the same thing or return statement in each branch of an if statement.
<RuleEntry name="prefer-correct-identifier-length" type="common" severity="style" version="4.5.0" hasConfig
Warns when an identifier name length is very short or long.
<RuleEntry name="prefer-correct-test-file-name" type="common" severity="warning" version="4.19.0"
Warns if the file within /test
contains a main
, but
the file name doesn't end with _test.dart
.
<RuleEntry name="prefer-correct-type-name" type="common" severity="style" version="4.5.0" hasConfig
Type name should only contain alphanumeric characters, start with an uppercase character and span between min-length and max-length characters in length.
<RuleEntry name="prefer-enums-by-name" severity="style" version="4.17.0" type="common"
Since Dart 2.15 it's possible to use byName
method on enum{' '}
values
prop instead of searching the value with{' '}
firstWhere
.
<RuleEntry name="prefer-first" type="common" severity="style" version="4.5.0" hasFix
Use first
to gets the first element.
<RuleEntry name="prefer-immediate-return" type="common" severity="style" version="4.13.0" hasFix
Warns when a method or a function returns a variable declared right before the return statement.
<RuleEntry name="prefer-iterable-of" type="common" severity="warning" version="4.19.0" hasFix
Warns when List.from()
factory is used instead of{' '}
List.of()
.
<RuleEntry name="prefer-last" type="common" severity="style" version="4.5.0" hasFix
Use last
to gets the last element.
<RuleEntry name="prefer-match-file-name" type="common" severity="warning" version="4.2.0"
Warns when a file name does not match the class name.
<RuleEntry name="prefer-moving-to-variable" type="common" severity="warning" version="4.14.0" hasConfig
Warns when a property access or a method invocation start with duplicated chains of other invocations / accesses inside a single function or method block.
<RuleEntry name="prefer-trailing-comma" type="common" severity="warning" version="2.2.0" hasConfig hasFix
Checks for a trailing comma for arguments, parameters, enum values and collections.
<RuleEntry name="tag-name" type="common" severity="warning" version="4.12.0" hasConfig hasFix
Warns when a tag name does not match the class name.
<RuleEntry name="always-remove-listener" type="flutter" severity="warning" version="4.0.0"
Warns when an event listener is added but never removed.
<RuleEntry name="avoid-border-all" type="flutter" severity="performance" version="4.11.0" hasFix
Avoid using Border.all constructor.
<RuleEntry name="avoid-returning-widgets" type="flutter" severity="warning" version="3.1.0" hasConfig
Warns when a method or function returns a Widget or subclass of a Widget.
<RuleEntry name="avoid-shrink-wrap-in-lists" type="flutter" severity="performance" version="4.17.0"
Warns when a ListView
widget with shrinkWrap
{' '}
parameter is wrapped in a Column
, Row
or another{' '}
ListView
widget.
<RuleEntry name="avoid-unnecessary-setstate" type="flutter" severity="warning" version="4.0.0"
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.
<RuleEntry name="avoid-use-expanded-as-spacer" type="flutter" severity="warning" version="4.17.0" hasFix
Avoid using Expanded widget as Spacer.
<RuleEntry name="avoid-wrapping-in-padding" type="flutter" severity="warning" version="4.0.0"
Warns when a widget is wrapped in a Padding widget but has a padding settings by itself.
<RuleEntry name="prefer-const-border-radius" type="flutter" severity="performance" version="4.4.0" hasFix
Warns when a non-const border radius is used.
<RuleEntry name="prefer-correct-edge-insets-constructor" type="flutter" severity="style" version="4.17.0" hasFix
Prefer correct EdgeInsets
constructor.
<RuleEntry name="prefer-extracting-callbacks" type="flutter" severity="style" version="4.0.0" hasConfig
Warns about inline callbacks in a widget tree and suggest to extract them to a widget method.
<RuleEntry name="prefer-single-widget-per-file" type="flutter" severity="style" version="4.2.0" hasConfig
Warns when a file contains more than a single widget.
<RuleEntry name="prefer-intl-name" type="intl" severity="style" version="1.7.0" hasFix
Recommends to use ClassName_ClassMemberName
pattern for Intl
methods name argument.
<RuleEntry name="provide-correct-intl-args" type="intl" severity="warning" version="1.9.0"
Warns when the Intl.message()
invocation has incorrect args.
<RuleEntry name="avoid-preserve-whitespace-false" type="angular" severity="warning" version="1.5.1"
Warns when a @Component
annotation has explicit false value for{' '}
preserveWhitespace
.
<RuleEntry name="component-annotation-arguments-ordering" type="angular" severity="style" version="1.9.0" hasConfig
Enforces Angular @Component
annotation arguments ordering.
<RuleEntry name="prefer-on-push-cd-strategy" type="angular" severity="warning" version="1.8.0"
Prefer setting changeDetection: ChangeDetectionStrategy.OnPush
in
Angular @Component
annotations.