linter
linter copied to clipboard
consider `list_comprehensions` lint
Follow-up from https://github.com/flutter/devtools/pull/1837#discussion_r411544355, where @jacobr suggested:
nit: consider using List comprehensions for this case instead of map followed by toList(). this might be a reasonable general lint to encourage users to take advantage of list comprehensions if we think the list comprehension way is easier to read.
ExceptionMode.modes.map((mode) {
return DropdownMenuItem<ExceptionMode>(
value: mode,
child: Text(mode.name),
);
}).toList();
vs
[ for (mode in ExceptionMode.modes)
DropdownMenuItem<ExceptionMode>(
value: mode,
child: Text(mode.name),
)
]
Fyi @munificent for whether the style guide should also have an opinion on this case. For example: "do use list comprehension for loops instead of map when it will avoid a call to toList".
Yes please, @munificent: any guidance would be hugely appreciated!
We deliberately don't have guidance on this yet because we're still waiting to get enough user experience to figure out what the best practice is. Right now, I don't think we know so it's best to give users the freedom to explore.
thanks @munificent!
/fyi @inmatrix @jayoung-lee @bwilkerson this makes for another potential research area when we do corpus analysis...