dart-lang / i18n

A general mono-repo for Dart i18n and l10n packages.
BSD 3-Clause "New" or "Revised" License
63 stars 38 forks source link

some generated files have unused imports #292

Open devoncarew opened 8 years ago

devoncarew commented 8 years ago

This causes issues with build systems that check code for no warnings or info level messages. In this file (https://github.com/flutter/flutter/blob/master/examples/stocks/lib/i18n/stock_messages_es.dart#L9), the import 'package:intl/intl.dart'; line is unused.

alan-knight commented 8 years ago

That seems excessively fussy of the build system. They don't have a way to not check generated code?

We could probably make that work, but it's not trivial. It would have to generate the code, look to see if it used any constructs that require the Intl library, and only include the import if it did. Or, I suppose it could be "fixed" more easily by adding some constant thing that used Intl and was never called. But that doesn't really seem desirable.

devoncarew commented 8 years ago

Perhaps there's an easy way to know when generating a file if it'll use package:intl/intl.dart? Or, an easy way to know if it won't use the package. Then you wouldn't have to do the work of doing a full analysis post-generation. I agree that that wouldn't be great.

devoncarew commented 8 years ago

I do think it's a good goal though to generate analysis clean code. Also, perhaps code with few or no dartfmt formatting diffs.

devoncarew commented 8 years ago

Some formatting changes here: https://github.com/dart-lang/intl/pull/95

alan-knight commented 8 years ago

It wouldn't need to be a full analysis, it would just need something like a flag for whether constructs requiring that import were used when generating any particular message, and deferring writing anything until after all the messages had been generated.

mosuem commented 2 years ago

See also dart-lang/i18n#186 .