@@ -14,25 +14,31 @@ const RE_DANGLINGDOT_OR_ZERO_FRACTIONS = /^([+-]?\d*)(?:(\.0*)|(\.\d*[1-9])0+)(e
1414const create = context => {
1515 return {
1616 Literal : node => {
17- if ( typeof node . value === 'number' ) {
18- const match = RE_DANGLINGDOT_OR_ZERO_FRACTIONS . exec ( node . raw ) ;
19- if ( match !== null ) {
20- const [ , integerPart , dotAndZeroes , dotAndDigits , scientificNotationSuffix ] = match ;
21- const isDanglingDot = dotAndZeroes === '.' ;
22- context . report ( {
23- node,
24- message : isDanglingDot ? MESSAGE_DANGLING_DOT : MESSAGE_ZERO_FRACTION ,
25- fix : fixer => {
26- let wantedString = ( dotAndZeroes === undefined ) ? integerPart + dotAndDigits : integerPart ;
27- if ( scientificNotationSuffix !== undefined ) {
28- wantedString += scientificNotationSuffix ;
29- }
30-
31- return fixer . replaceText ( node , wantedString ) ;
32- }
33- } ) ;
34- }
17+ if ( typeof node . value !== 'number' ) {
18+ return ;
19+ }
20+
21+ const match = RE_DANGLINGDOT_OR_ZERO_FRACTIONS . exec ( node . raw ) ;
22+ if ( match === null ) {
23+ return ;
3524 }
25+
26+ const [ , integerPart , dotAndZeroes , dotAndDigits , scientificNotationSuffix ] = match ;
27+ const isDanglingDot = dotAndZeroes === '.' ;
28+
29+ context . report ( {
30+ node,
31+ message : isDanglingDot ? MESSAGE_DANGLING_DOT : MESSAGE_ZERO_FRACTION ,
32+ fix : fixer => {
33+ let wantedString = dotAndZeroes === undefined ? integerPart + dotAndDigits : integerPart ;
34+
35+ if ( scientificNotationSuffix !== undefined ) {
36+ wantedString += scientificNotationSuffix ;
37+ }
38+
39+ return fixer . replaceText ( node , wantedString ) ;
40+ }
41+ } ) ;
3642 }
3743 } ;
3844} ;
0 commit comments