-
Notifications
You must be signed in to change notification settings - Fork 32
Rules
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
- arguments-ordering
Enforces named argument order in function and constructor invocations to be the same as corresponding named parameter declaration order.
default: style ⚙️🛠
- avoid-banned-imports
Configure some imports that you want to ban.
default: warning ⚙️
- avoid-cascade-after-if-null
Warns when a cascade expression is used after if null (??) binary expression without parentheses.
default: warning
- avoid-collection-methods-with-unrelated-types
Avoid using collection methods with unrelated types, such as accessing a map of integers using a string key.
default: warning
- avoid-double-slash-imports
Warns when an import/export directive contains a double slash.
default: warning 🛠
- avoid-duplicate-exports
Warns when a file has multiple exports declarations with the same URI.
default: warning 🛠
- avoid-dynamic
Warns when dynamic type is used as variable type in declaration, return type of a function, etc.
default: warning
- avoid-global-state
Warns about usage mutable global variables.
default: warning
- avoid-ignoring-return-values
Warns when a return value of a method or function invocation or a class instance property access is not used.
default: warning
- avoid-late-keyword
Warns when a field or variable is declared with a late keyword.
default: warning ⚙️🛠
- avoid-missing-enum-constant-in-map
Warns when a enum constant is missing in a map declaration.
default: warning
- avoid-nested-conditional-expressions
Warns about nested conditional expressions.
default: style
- avoid-non-ascii-symbols
Warns when a string literal contains non ascii characters.
default: warning
- avoid-non-null-assertion
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.
default: warning
- avoid-passing-async-when-sync-expected
Warns when an asynchronous function is used as an argument where a synchronous function is expected.
default: warning
- avoid-redundant-async
Checks for redundant async in a method or function body.
default: warning 🛠
- avoid-throw-in-catch-block
Warns when call throw in a catch block.
default: warning
- avoid-top-level-members-in-tests
Warns when a public top-level member (except the entrypoint) is declared inside a test file.
default: warning 🛠
- avoid-unnecessary-conditionals
Checks for unnessesary conditional expressions.
default: warning 🛠
- avoid-unnecessary-type-assertions
Warns about unnecessary usage of is and whereType operators.
default: warning
- avoid-unnecessary-type-casts
Warns about unnecessary usage of as operators.
default: warning
- avoid-unrelated-type-assertions
Warns about unrelated usages of is operators.
default: warning
- avoid-unused-parameters
Checks for unused parameters inside a function or method body.
default: warning 🛠
- ban-name
Configure some names that you want to ban.
default: warning ⚙️
- binary-expression-operand-order
Warns when a literal value is on the left hand side in a binary expressions.
default: style 🛠
- double-literal-format
Checks that double literals should begin with 0. instead of just ., and should not end with a trailing 0.
default: style 🛠
- format-comment
Prefer format comments like sentences.
default: style ⚙️🛠
- list-all-equatable-fields
Warns when a field is not added to props getter of a class that extends Equtable or EquatableMixin.
default: warning 🛠
- member-ordering
Enforces ordering for a class members.
default: style ⚙️🛠
- missing-test-assertion
Warns that there is no assertion in the test.
default: warning ⚙️
- newline-before-return
Enforces blank line between statements and return in a block.
default: style ⚙️🛠
- no-boolean-literal-compare
Warns on comparison to a boolean literal, as in x == true.
default: style 🛠
- no-empty-block
Disallows empty blocks except catch clause block.
default: style
- no-equal-arguments
Warns when equal arguments are passed to a function or method invocation.
default: warning ⚙️
- no-equal-then-else
Warns when if statement has equal then and else statements or conditional expression has equal then and else expressions.
default: warning 🛠
- no-magic-number
Warns against using number literals outside of named constants or variables.
default: warning ⚙️
- no-object-declaration
Warns when a class member is declared with Object type.
default: style
- prefer-async-await
Recommends to use async/await syntax to handle a Future result instead of .then() invocation.
default: style
- prefer-commenting-analyzer-ignores
Warns when // ignore: comments are left without any additional description why this ignore is applied.
default: warning
- prefer-conditional-expressions
Recommends to use a conditional expression instead of assigning to the same thing or return statement in each branch of an if statement.
default: style ⚙️🛠
- prefer-correct-identifier-length
Warns when an identifier name length is very short or long.
default: style ⚙️
- prefer-correct-test-file-name
Warns if the file within /test contains a main, but the file name doesn't end with _test.dart.
default: warning
- prefer-correct-type-name
Type name should only contain alphanumeric characters, start with an uppercase character and span between min-length and max-length characters in length.
default: style ⚙️
- prefer-enums-by-name
Since Dart 2.15 it's possible to use byName method on enum values prop instead of searching the value with firstWhere.
default: style
- prefer-first
Use first to gets the first element.
default: style 🛠
- prefer-immediate-return
Warns when a method or a function returns a variable declared right before the return statement.
default: style 🛠
- prefer-iterable-of
Warns when List.from() factory is used instead of List.of().
default: warning 🛠
- prefer-last
Use last to gets the last element.
default: style 🛠
- prefer-match-file-name
Warns when a file name does not match the class name.
default: warning 🛠
- prefer-moving-to-variable
Warns when a property access or a method invocation start with duplicated chains of other invocations / accesses inside a single function or method block.
default: warning ⚙️
- prefer-static-class
Suggests to use static class member instead of global constants, variables and functions.
default: style ⚙️
- prefer-trailing-comma
Checks for a trailing comma for arguments, parameters, enum values and collections.
default: style ⚙️🛠
- tag-name
Warns when a tag name does not match the class name.
default: warning ⚙️🛠
- always-remove-listener
Warns when an event listener is added but never removed.
default: warning
- avoid-border-all
Avoid using Border.all constructor.
default: performance 🛠
- avoid-returning-widgets
Warns when a method or function returns a Widget or subclass of a Widget.
default: warning ⚙️
- avoid-shrink-wrap-in-lists
Warns when a ListView widget with shrinkWrap parameter is wrapped in a Column, Row or another ListView widget.
default: performance
- avoid-unnecessary-setstate
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.
default: warning
- use-setstate-synchronously
Warns when setState is called past an await point.
default: warning ⚙️
- avoid-expanded-as-spacer
Avoid using Expanded widget as Spacer.
default: warning 🛠
- avoid-wrapping-in-padding
Warns when a widget is wrapped in a Padding widget but has a padding settings by itself.
default: warning
- check-for-equals-in-render-object-setters
Warns when a RenderObject setter doesn't have an equality check for the new value.
default: warning
- consistent-update-render-object
Warns when an updateRenderObject method is absent or doesn't update all fields set in createRenderObject.
default: warning
- prefer-const-border-radius
Warns when a non-const border radius is used.
default: performance 🛠
- prefer-correct-edge-insets-constructor
Prefer correct EdgeInsets constructor.
default: style 🛠
- prefer-extracting-callbacks
Warns about inline callbacks in a widget tree and suggest to extract them to a widget method.
default: style ⚙️
- prefer-single-widget-per-file
Warns when a file contains more than a single widget.
default: style ⚙️
- prefer-using-list-view
Warns when a Column widget with only children parameter is wrapped in a SingleChildScrollView widget.
default: performance
- prefer-define-hero-tag
When heroTag is not set, the default value is used. Having two or more widgets with the same heroTag will result in an error. default: warning
Lints for the Flame package.
- avoid-creating-vector-in-update
Warns when a Vector2 is created inside a Component's update method.
default: warning
- avoid-initializing-in-on-mount
Warns when a late final variable is being initialized in the Component's onMount method.
default: warning
- avoid-redundant-async-on-load
Warns when a Component's onLoad method can be made sync.
default: warning 🛠
- correct-game-instantiating
Warns when a game is instantiated in a stateless widget build method.
default: warning 🛠
Lints for the Intl package.
- prefer-intl-name
Recommends to use ClassName_ClassMemberName pattern for Intl methods name argument.
default: style
- prefer-provide-intl-description
Warns when a Intl method invoked without a description.
default: warning
- provide-correct-intl-args
Warns when the Intl.message() invocation has incorrect args.
default: warning