i18n
i18n copied to clipboard
Enhance generated code to comply to lint
When including lint analysis_options (include: package:lint/analysis_options.yaml), the generated code for messages_*.dart no longer works.
Please change one of the following:
- Add: // ignore_for_file:invalid_assignment, map_value_type_not_assignable
- Don't regenerate // ignore_... statements, so that the rules can be adapted by the user without beeing overwritten by the next code generation.
- Enhance the generated code:
static _notInlinedMessages(_) => <String, Function>{
"enterEmailAddress": MessageLookupByLibrary.simpleMessage(
"Please enter you email address"),
"preferencesGlobal":
MessageLookupByLibrary.simpleMessage("Global Settings"),
"preferencesTitle": MessageLookupByLibrary.simpleMessage("Settings")
};
becomes
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
"enterEmailAddress": MessageLookupByLibrary.simpleMessage(
"Please enter you email address") as Function,
"preferencesGlobal":
MessageLookupByLibrary.simpleMessage("Global Settings") as Function,
"preferencesTitle": MessageLookupByLibrary.simpleMessage("Settings") as Function
};
I have 2 additional requests:
- Make variables final if not reassigned in messages_all.dart (Lint rule: prefer_final_locals)
- Change final Mmessages = new MessageLookup(); to final MessageLookup messages = MessageLookup(); in messages_xx.dart (Lint rule: type_annotate_public_apis)
Not all lints can be accounted for as some are mutually exclusive. Using effective_dart, I only have 3 lints that are giving suggestions, which I believe should be accounted for somehow:
- public_member_api_docs: Either document everything in the generated code, or add it to the list of ignored linters
- avoid_catches_without_on_clauses: In messages_all.dart, ~~preferably add 'on Exeption' to the try/catch clause.~~ it looks like the implimentation is correct in this case to prevent anything breaking, so probably add it to the list of ignored linters
- type_annotate_public_apis: In messages_xx.dart, probably best to add this to the list of ignored linters
Edit: In any case, this issue should probably be on intl_translation, not intl. I've created a pull request over there for ignoring the three lints I've mentioned.