File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed
Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change 11'use strict' ;
2- const escapeWithLowercase = / \\ ( x [ a - f 0 - 9 ] { 2 } | u [ a - f 0 - 9 ] { 4 } | u \{ ( [ 0 - 9 a - f ] { 1 , } ) \} | c [ a - z ] ) / ;
2+ const escapeWithLowercase = / \\ ( x [ a - f \d ] { 2 } | u [ a - f \d ] { 4 } | u \{ ( [ a - f \d ] { 1 , } ) \} | c [ a - z ] ) / ;
33const hasLowercaseCharacter = / [ a - z ] + / ;
44const message = 'Use uppercase characters for the value of the escape sequence.' ;
55
@@ -17,8 +17,13 @@ const fix = value => {
1717const create = context => {
1818 return {
1919 Literal ( node ) {
20- let matches ;
21- if ( typeof node . value === 'string' && ( matches = node . raw . match ( escapeWithLowercase ) ) && matches [ 0 ] . slice ( 2 ) . match ( hasLowercaseCharacter ) ) {
20+ if ( typeof node . value !== 'string' ) {
21+ return ;
22+ }
23+
24+ const matches = node . raw . match ( escapeWithLowercase ) ;
25+
26+ if ( matches && matches [ 0 ] . slice ( 2 ) . match ( hasLowercaseCharacter ) ) {
2227 context . report ( {
2328 node,
2429 message,
@@ -27,8 +32,13 @@ const create = context => {
2732 }
2833 } ,
2934 TemplateElement ( node ) {
30- let matches ;
31- if ( typeof node . value . raw === 'string' && ( matches = node . value . raw . match ( escapeWithLowercase ) ) && matches [ 0 ] . slice ( 2 ) . match ( hasLowercaseCharacter ) ) {
35+ if ( typeof node . value . raw !== 'string' ) {
36+ return ;
37+ }
38+
39+ const matches = node . value . raw . match ( escapeWithLowercase ) ;
40+
41+ if ( matches && matches [ 0 ] . slice ( 2 ) . match ( hasLowercaseCharacter ) ) {
3242 context . report ( {
3343 node,
3444 message,
You can’t perform that action at this time.
0 commit comments