lints
lints copied to clipboard
Consider adding `invalid_runtime_check_with_js_interop_types` to the `recommended` rule set
Describe the rule you'd like to see added and to what rule set
invalid_runtime_check_with_js_interop_types
is a new rule added to address runtime type inconsistencies for JS interop types available through dart:js_interop
. It will trigger when users use an is
or as
expression involving a JS interop type that may result in either confusing or inconsistent results.
https://dart.dev/tools/linter-rules/invalid_runtime_check_with_js_interop_types (will be in Dart 3.5+)
We may want to add this to the recommended
rule set.
Additional context
This is predominantly intended to address the inconsistencies between dart2wasm and the JS compilers. When switching between compilers, most of the cases this lint rule catches either are likely to end in an error in the case of as
expressions or a different boolean (which is worse!) in the case of is
expressions.
This rule also only affects expressions where a JS interop type is used, so it should not affect other code. We could also consider adding it to the core
set based on the guidelines, but I can imagine cases where it won't result in an error or inconsistency e.g. JSString s = ...; s is Future;
. It's undesirable, but not necessarily worrisome.