avoid-js-rounded-ints
Same as avoid_js_rounded_ints in Dart lints
- Group
- Style
- Path
lint/style/avoid-js-rounded-ints- Default
- On (recommended)
- Origin
- Dart lints
- Rule
- 80 of 512
Avoid integer literals that JavaScript would round.
Dart compiled to JavaScript stores every int as a 64-bit float, so an
integer literal that a double cannot represent exactly silently changes
value on the web:
int value = 9007199254740995; // BAD: becomes 9007199254740996 in JavaScript
BigInt value = BigInt.parse('9007199254740995'); // GOOD
Invalid
int a = 9007199254740993;
int b = 9007199254740995;
int c = -9007199254740993;
int d = 0x20000000000001;
int e = 1234567890123456789;
void use() {
print(9007199254740997);
final values = [1, 18014398509481983];
print(values);
}int a = 9007199254740993;int a = 9007199254740993;int b = 9007199254740995;int b = 9007199254740995;int c = -9007199254740993;int c = -9007199254740993;int d = 0x20000000000001;int d = 0x20000000000001;int e = 1234567890123456789;void use() { print(9007199254740997); print(9007199254740997); final values = [1, 18014398509481983];Valid
int a = 9007199254740991;
int b = 9007199254740992;
int c = -9007199254740991;
int d = 0x20000000000000;
int e = 18014398509481984;
int f = 1 << 60;
int g = 42;
double h = 9007199254740993.0;
BigInt i = BigInt.parse('9007199254740993');Configure avoid-js-rounded-ints
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"style": {
"avoid-js-rounded-ints": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/style/avoid-js-rounded-ints: <reason>More style rules
- avoid-late-keyword
avoid-late-keywordFlags use of the
latekeyword on variables and fields. - avoid-multiple-declarations-per-line
avoid_multiple_declarations_per_linerecommendedFlags a variable declaration that declares more than one variable.
- avoid-non-null-assertion
avoid-non-null-assertionFlags the null-assertion operator
!except on a resolvedMapindex. - avoid-null-checks-in-equality-operators
avoid_null_checks_in_equality_operatorsrecommendedFlags null checks of the parameter inside a custom
operator ==. - avoid-positional-boolean-parameters
avoid_positional_boolean_parametersFlags a positional
boolparameter in a public signature. - avoid-positional-fields-in-records
avoid_positional_fields_in_recordsFlags positional fields in record types.
- avoid-private-typedef-functions
avoid_private_typedef_functionsFlags a private function typedef that is used at most once.
- avoid-public-notifier-propertiesriverpod
Keeps notifier state behind Riverpod's observable state property.