Ignore `unnecessary_string_interpolations` in messages_XX.dart files
bambinoua opened this issue · 4 comments
I have this code in translation file
static String m1(isNew, table, message) => "${Intl.select(isNew, {
'true':
'Could not insert record into \'${table}\' table. ${message}',
'false':
'Could not update record into \'${table}\' table. ${message}',
})}";
And my analysis_options.yaml
contains this unnecessary_string_interpolations: true
. So I have a warnig about unnecessary string interpolation. Is it possible to ignore this in messages files or remove redundant string interpolation from Intl.select
Hi @bambinoua,
Thanks for reporting this!
The analysis_options.yaml
file offers the option to exclude certain files and directories from analysis with the exclude
section. Unfortunately, this does not work at the moment (issue).
I think this is more linter than a generated code issue. If you agree, I suggest leaving this open so we can monitor the need for this. In case of high demand, maybe we could add one more ignore rule within generated files.
Yes. My suggestion is just add the additional rule to generated files:
// Ignore issues from commonly used lints in this file.
// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new
// ignore_for_file:prefer_single_quotes,comment_references, directives_ordering
// ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases
// ignore_for_file:unused_import, file_names, avoid_escaping_inner_quotes
// ignore_for_file:unnecessary_string_interpolations <--- something like this
Hi @bambinoua,
I've noticed that the previously mentioned issue with the exclude
section within the analysis_options.yaml
file works fine now with the latest Flutter version (Flutter 2.2.3
) and the latest IDE extensions for Flutter and Dart.
Does updating analyzer config work for you?
The analysis_options.ymal
file:
include: package:pedantic/analysis_options.yaml
analyzer:
exclude:
- lib/generated/intl/*.dart
linter:
rules:
- unnecessary_string_interpolations
I'm closing this issue as the latest version of the Flutter Intl extension (1.17.0
) generates code that should not complain for the unnecessary_string_interpolations
lint rule.
In case you still see warnings after update to the latest version, please feel free to open a new issue.