@@ -20,8 +20,8 @@ module.exports = {
2020 } ,
2121
2222 create : function ( context ) {
23- var spaced = context . options [ 0 ] === 'always'
24- var either = context . options [ 0 ] === 'either'
23+ const spaced = context . options [ 0 ] === 'always'
24+ const either = context . options [ 0 ] === 'either'
2525
2626 /**
2727 * Determines whether an option is set, relative to the spacing option.
@@ -34,7 +34,7 @@ module.exports = {
3434 return context . options [ 1 ] != null ? context . options [ 1 ] [ option ] === ! spaced : false
3535 }
3636
37- var options = {
37+ const options = {
3838 spaced,
3939 either,
4040 arraysInObjectsException : isOptionSet ( 'arraysInObjects' ) ,
@@ -118,8 +118,8 @@ module.exports = {
118118 * @returns {boolean }
119119 */
120120 function isEvenlySpacedAndNotTooLong ( node , start , end ) {
121- var expectedSpace = start [ 1 ] . range [ 0 ] - start [ 0 ] . range [ 1 ]
122- var endSpace = end [ 1 ] . range [ 0 ] - end [ 0 ] . range [ 1 ]
121+ const expectedSpace = start [ 1 ] . range [ 0 ] - start [ 0 ] . range [ 1 ]
122+ const endSpace = end [ 1 ] . range [ 0 ] - end [ 0 ] . range [ 1 ]
123123 return endSpace === expectedSpace && endSpace <= 1
124124 }
125125
@@ -133,7 +133,7 @@ module.exports = {
133133 * @returns {void }
134134 */
135135 function validateBraceSpacing ( node , first , second , penultimate , last ) {
136- var closingCurlyBraceMustBeSpaced =
136+ const closingCurlyBraceMustBeSpaced =
137137 ( options . arraysInObjectsException && penultimate . value === ']' ) ||
138138 ( options . objectsInObjectsException && penultimate . value === '}' )
139139 ? ! options . spaced
@@ -186,13 +186,13 @@ module.exports = {
186186 return
187187 }
188188
189- var firstSpecifier = node . properties [ 0 ]
190- var lastSpecifier = node . properties [ node . properties . length - 1 ]
189+ const firstSpecifier = node . properties [ 0 ]
190+ const lastSpecifier = node . properties [ node . properties . length - 1 ]
191191
192- var first = context . getTokenBefore ( firstSpecifier )
193- var second = context . getFirstToken ( firstSpecifier )
194- var penultimate = context . getLastToken ( lastSpecifier )
195- var last = context . getTokenAfter ( lastSpecifier )
192+ const first = context . getTokenBefore ( firstSpecifier )
193+ const second = context . getFirstToken ( firstSpecifier )
194+ let penultimate = context . getLastToken ( lastSpecifier )
195+ let last = context . getTokenAfter ( lastSpecifier )
196196
197197 // support trailing commas
198198 if ( last . value === ',' ) {
@@ -205,15 +205,15 @@ module.exports = {
205205
206206 // import {y} from 'x'
207207 ImportDeclaration : function ( node ) {
208- var firstSpecifier = node . specifiers [ 0 ]
209- var lastSpecifier = node . specifiers [ node . specifiers . length - 1 ]
208+ const firstSpecifier = node . specifiers [ 0 ]
209+ const lastSpecifier = node . specifiers [ node . specifiers . length - 1 ]
210210
211211 // don't do anything for namespace or default imports
212212 if ( firstSpecifier && lastSpecifier && firstSpecifier . type === 'ImportSpecifier' && lastSpecifier . type === 'ImportSpecifier' ) {
213- var first = context . getTokenBefore ( firstSpecifier )
214- var second = context . getFirstToken ( firstSpecifier )
215- var penultimate = context . getLastToken ( lastSpecifier )
216- var last = context . getTokenAfter ( lastSpecifier )
213+ const first = context . getTokenBefore ( firstSpecifier )
214+ const second = context . getFirstToken ( firstSpecifier )
215+ const penultimate = context . getLastToken ( lastSpecifier )
216+ const last = context . getTokenAfter ( lastSpecifier )
217217
218218 validateBraceSpacing ( node , first , second , penultimate , last )
219219 }
@@ -225,12 +225,12 @@ module.exports = {
225225 return
226226 }
227227
228- var firstSpecifier = node . specifiers [ 0 ]
229- var lastSpecifier = node . specifiers [ node . specifiers . length - 1 ]
230- var first = context . getTokenBefore ( firstSpecifier )
231- var second = context . getFirstToken ( firstSpecifier )
232- var penultimate = context . getLastToken ( lastSpecifier )
233- var last = context . getTokenAfter ( lastSpecifier )
228+ const firstSpecifier = node . specifiers [ 0 ]
229+ const lastSpecifier = node . specifiers [ node . specifiers . length - 1 ]
230+ const first = context . getTokenBefore ( firstSpecifier )
231+ const second = context . getFirstToken ( firstSpecifier )
232+ const penultimate = context . getLastToken ( lastSpecifier )
233+ const last = context . getTokenAfter ( lastSpecifier )
234234
235235 validateBraceSpacing ( node , first , second , penultimate , last )
236236 } ,
@@ -241,10 +241,10 @@ module.exports = {
241241 return
242242 }
243243
244- var first = context . getFirstToken ( node )
245- var second = context . getFirstToken ( node , 1 )
246- var penultimate = context . getLastToken ( node , 1 )
247- var last = context . getLastToken ( node )
244+ const first = context . getFirstToken ( node )
245+ const second = context . getFirstToken ( node , 1 )
246+ const penultimate = context . getLastToken ( node , 1 )
247+ const last = context . getLastToken ( node )
248248
249249 validateBraceSpacing ( node , first , second , penultimate , last )
250250 }
0 commit comments