avoid-escaping-inner-quotes
Same as avoid_escaping_inner_quotes in Dart lints
- Group
- Style
- Path
lint/style/avoid-escaping-inner-quotes- Default
- Off, opt in
- Origin
- Dart lints
- Rule
- 63 of 512
Flags a string literal that escapes its own quote character when switching the outer quotes would remove every escape.
A single-quoted literal whose value contains ' but no " (or the mirror
case for double quotes) can swap its delimiters and drop the backslashes:
var s = 'It\'s here'; // flagged
var s = "It's here"; // preferred
var s = 'It\'s "here"'; // fine: both quote kinds appear
Only literal text counts; interpolated expressions are ignored. Raw and multiline (triple-quoted) literals are never flagged. Each part of an adjacent-string concatenation is checked on its own.
Invalid
void use(Object o) {}
void main() {
var name = 'Ann';
use('It\'s here');
use("Say \"hi\"");
use('Don\'t panic, $name');
use("${name} said \"no\"");
use('It\x27s escaped');
use('a\'b' 'plain');
} var name = 'Ann'; use('It\'s here'); use('It\'s here'); use("Say \"hi\""); use("Say \"hi\""); use('Don\'t panic, $name'); use('Don\'t panic, $name'); use("${name} said \"no\""); use("${name} said \"no\""); use('It\x27s escaped'); use('It\x27s escaped'); use('a\'b' 'plain');Valid
void use(Object o) {}
void main() {
var name = 'Ann';
use("It's here");
use('Say "hi"');
use('It\'s "both" kinds');
use("Mixed 'single' and \"double\"");
use(r"raw ' quote");
use('''It\'s multiline''');
use('plain $name');
use("${name.contains("'")}");
}Configure avoid-escaping-inner-quotes
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"style": {
"avoid-escaping-inner-quotes": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/style/avoid-escaping-inner-quotes: <reason>More style rules
- avoid-field-initializers-in-const-classes
avoid_field_initializers_in_const_classesFlags field initializers in classes with a
constconstructor. - avoid-final-parameters
avoid_final_parametersFlags parameters declared
final. - avoid-implementing-value-types
avoid_implementing_value_typesFlags
implementsof a class that overrides==. - avoid-init-to-null
avoid_init_to_nullrecommendedFlags explicit
= nullinitializers on declarations that already default to null. - avoid-js-rounded-ints
avoid_js_rounded_intsrecommendedAvoid integer literals that JavaScript would round.
- avoid-late-keyword
avoid-late-keywordFlags use of the
latekeyword on variables and fields. - avoid-multiple-declarations-per-line
avoid_multiple_declarations_per_linerecommendedFlags a variable declaration that declares more than one variable.
- avoid-non-null-assertion
avoid-non-null-assertionFlags the null-assertion operator
!except on a resolvedMapindex.