avoid-non-ascii-symbols
Warns when a string literal contains non ascii characters.
Ascii characters in string literals might indicate that the string was not localized.
⚙️ Config
Set ignored-invocations
(default is [print
, debugPrint
]) to ignore strings in specific invocations (example).
analysis_options.yaml
dart_code_metrics:
rules:
- avoid-non-ascii-symbols:
ignored-invocations:
- print
- debugPrint
Example
❌ Bad:
final chinese = 'hello 汉字'; // LINT: Avoid using non ascii symbols in string literals.
final russian = 'hello привет'; // LINT: Avoid using non ascii symbols in string literals.
final withSomeNonAsciiSymbols = '#!$_&- éè ;∞¥₤€'; // LINT: Avoid using non ascii symbols in string literals.
final misspelling = 'inform@tiv€'; // LINT: Avoid using non ascii symbols in string literals.
✅ Good:
final english = 'hello';
final someGenericSymbols ='!@#$%^';
Example with "ignored-invocations"
Config
analysis_options.yaml
dart_code_metrics:
rules:
- avoid-non-ascii-symbols:
ignored-invocations:
- print
✅ Good:
print('hello 汉字'); // Correct, 'print' is ignored