diff --git a/changelog/fix_false_positive_for_style_string_literals.md b/changelog/fix_false_positive_for_style_string_literals.md new file mode 100644 index 00000000000..b79452f1d61 --- /dev/null +++ b/changelog/fix_false_positive_for_style_string_literals.md @@ -0,0 +1 @@ +* [#10166](https://github.com/rubocop/rubocop/pull/10166): Fix a false positive for `Style/StringLiterals` when using some meta characters (e.g. `'\s'`, `'\z'`) with `EnforcedStyle: double_quotes`. ([@koic][]) diff --git a/lib/rubocop/cop/mixin/string_literals_help.rb b/lib/rubocop/cop/mixin/string_literals_help.rb index b9d7677dec7..fba7dceaad0 100644 --- a/lib/rubocop/cop/mixin/string_literals_help.rb +++ b/lib/rubocop/cop/mixin/string_literals_help.rb @@ -17,7 +17,7 @@ def wrong_quotes?(src_or_node) # 1. It contains a double quote # 2. It contains text that would become an escape sequence with double quotes # 3. It contains text that would become an interpolation with double quotes - !/" | (?