unnecessary-raw-strings
Same as unnecessary_raw_strings in Dart lints
- Group
- Style
- Path
lint/style/unnecessary-raw-strings- Default
- On (recommended)
- Origin
- Dart lints
- Rule
- 471 of 512
Flags raw string literals that contain no backslash or $.
A raw string only differs from a regular one when its text holds \ or $;
otherwise the r prefix is noise:
var s1 = r'a b c'; // flagged
var s2 = 'a b c'; // preferred
var s3 = r'a \ b'; // fine: the backslash stays literal
Each part of an adjacent-string concatenation is checked on its own.
Invalid
void use(Object o) {}
void main() {
use(r'plain');
use(r"double plain");
use(r'''multi''');
use(r'');
use('ok' r'plain part');
}void main() { use(r'plain'); use(r'plain'); use(r"double plain"); use(r"double plain"); use(r'''multi'''); use(r'''multi'''); use(r''); use(r''); use('ok' r'plain part');Valid
void use(Object o) {}
void main() {
use(r'a \ b');
use(r'cost $5');
use(r'\d+');
use(r'''multi \n''');
use('plain');
use(r'$' 'plain');
}Configure unnecessary-raw-strings
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"style": {
"unnecessary-raw-strings": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/style/unnecessary-raw-strings: <reason>More style rules
- unnecessary-string-escapes
unnecessary_string_escapesrecommendedFlags backslashes that do not affect a string's value.
- unnecessary-string-interpolations
unnecessary_string_interpolationsrecommendedFlags a string literal whose entire content is a single interpolation of a provably non-nullable
String. - unnecessary-this
unnecessary_thisrecommendedFlags a redundant
this.qualifier on member access. - unreachable-from-main
unreachable_from_mainReport public declarations that no entry point of an executable library reaches.
- use-colored-box
use_colored_boxrecommendedflutterPrefers
ColoredBoxover aContainerthat only paints a color behind its child. - use-decorated-box
use_decorated_boxrecommendedflutterPrefers
DecoratedBoxover aContainerthat only decorates its child. - use-design-system-item
use-design-system-itemflutterFlags construction of a widget or type that should be replaced by its design-system equivalent.
- use-enums
use_enumsFlags classes that emulate an enum and could be declared as one.