@@ -39,33 +39,25 @@ function getTopConcatBinaryExpression(node) {
39
39
}
40
40
41
41
/**
42
- * Determines whether a given node is a octal escape sequence
42
+ * Checks whether or not a node contains a string literal with an octal or non-octal decimal escape sequence
43
43
* @param {ASTNode } node A node to check
44
- * @returns {boolean } `true` if the node is an octal escape sequence
44
+ * @returns {boolean } `true` if at least one string literal within the node contains
45
+ * an octal or non-octal decimal escape sequence
45
46
*/
46
- function isOctalEscapeSequence ( node ) {
47
-
48
- // No need to check TemplateLiterals – would throw error with octal escape
49
- const isStringLiteral = node . type === "Literal" && typeof node . value === "string" ;
50
-
51
- if ( ! isStringLiteral ) {
52
- return false ;
47
+ function hasOctalOrNonOctalDecimalEscapeSequence ( node ) {
48
+ if ( isConcatenation ( node ) ) {
49
+ return (
50
+ hasOctalOrNonOctalDecimalEscapeSequence ( node . left ) ||
51
+ hasOctalOrNonOctalDecimalEscapeSequence ( node . right )
52
+ ) ;
53
53
}
54
54
55
- return astUtils . hasOctalEscapeSequence ( node . raw ) ;
56
- }
57
-
58
- /**
59
- * Checks whether or not a node contains a octal escape sequence
60
- * @param {ASTNode } node A node to check
61
- * @returns {boolean } `true` if the node contains an octal escape sequence
62
- */
63
- function hasOctalEscapeSequence ( node ) {
64
- if ( isConcatenation ( node ) ) {
65
- return hasOctalEscapeSequence ( node . left ) || hasOctalEscapeSequence ( node . right ) ;
55
+ // No need to check TemplateLiterals – would throw parsing error
56
+ if ( node . type === "Literal" && typeof node . value === "string" ) {
57
+ return astUtils . hasOctalOrNonOctalDecimalEscapeSequence ( node . raw ) ;
66
58
}
67
59
68
- return isOctalEscapeSequence ( node ) ;
60
+ return false ;
69
61
}
70
62
71
63
/**
@@ -237,7 +229,7 @@ module.exports = {
237
229
function fixNonStringBinaryExpression ( fixer , node ) {
238
230
const topBinaryExpr = getTopConcatBinaryExpression ( node . parent ) ;
239
231
240
- if ( hasOctalEscapeSequence ( topBinaryExpr ) ) {
232
+ if ( hasOctalOrNonOctalDecimalEscapeSequence ( topBinaryExpr ) ) {
241
233
return null ;
242
234
}
243
235
0 commit comments