Open jacob314 opened 5 years ago
Looks great. Thanks for the examples too. 👍
The only one I'd like to get more crisp on is this bit:
foo.bar.baz() is a complex expression and we cannot be confident we will extract out the value reference for it that the person writing the template expected.
Can you clarify what constitutes an expression that's too complex for the kernel transformer?
These Flutter constructors provide a hook for a kernel transformer to extract out object references in package:flutter. See: https://github.com/flutter/flutter/issues/27673
A lint warning should trigger if the constructor is called with a value other than a string literal as in that case there is no way to robustly extract out the object ids and we will not attempt to be clever and handle any cases where the value passed to the constructor is more than a string literal. The goal is to keep the kernel transformer simple only handling the very basic cases that are needed rather than providing an unfocused and complex templating scheme.
Examples ``dart // Good: ErrorDescription('$someMessage'); ErrorDescription('Maybe you have fallen prey to floating point rounding errors.') ErrorDescription('The $labelA is $valueA, but the $labelB is $valueB.') // Triggering lint errors: ErrorDescription(someMessage) ErrorDescription('Maybe you have fallen prey to' + ' floating point rounding errors.') // foo.bar.baz() is a complex expression and we cannot be confident we will extract out the value reference for it that the person writing the template expected. ErrorDescription('The $labelA is $valueA, but the $labelB is ${foo.bar.baz()}.')