@@ -347,6 +347,40 @@ module.exports = {
347347 ) ;
348348 }
349349
350+ /**
351+ * Starting from the given node (a property.key node here) looks forward
352+ * until it finds the colon punctuator and returns it.
353+ * @param {ASTNode } node The node to start looking from.
354+ * @returns {ASTNode } The colon punctuator.
355+ */
356+ function getNextColon ( node ) {
357+ return sourceCode . getTokenAfter ( node , astUtils . isColonToken ) ;
358+ }
359+
360+ /**
361+ * Starting from the given node (a property.key node here) looks forward
362+ * until it finds the last token before a colon punctuator and returns it.
363+ * @param {ASTNode } node The node to start looking from.
364+ * @returns {ASTNode } The last token before a colon punctuator.
365+ */
366+ function getLastTokenBeforeColon ( node ) {
367+ const colonToken = getNextColon ( node ) ;
368+
369+ return sourceCode . getTokenBefore ( colonToken ) ;
370+ }
371+
372+ /**
373+ * Starting from the given node (a property.key node here) looks forward
374+ * until it finds the first token after a colon punctuator and returns it.
375+ * @param {ASTNode } node The node to start looking from.
376+ * @returns {ASTNode } The first token after a colon punctuator.
377+ */
378+ function getFirstTokenAfterColon ( node ) {
379+ const colonToken = getNextColon ( node ) ;
380+
381+ return sourceCode . getTokenAfter ( colonToken ) ;
382+ }
383+
350384 /**
351385 * Checks whether a property is a member of the property group it follows.
352386 * @param {ASTNode } lastMember The last Property known to be in the group.
@@ -355,7 +389,7 @@ module.exports = {
355389 */
356390 function continuesPropertyGroup ( lastMember , candidate ) {
357391 const groupEndLine = lastMember . loc . start . line ,
358- candidateValueStartLine = ( isKeyValueProperty ( candidate ) ? candidate . value : candidate ) . loc . start . line ;
392+ candidateValueStartLine = ( isKeyValueProperty ( candidate ) ? getFirstTokenAfterColon ( candidate . key ) : candidate ) . loc . start . line ;
359393
360394 if ( candidateValueStartLine - groupEndLine <= 1 ) {
361395 return true ;
@@ -384,28 +418,6 @@ module.exports = {
384418 return false ;
385419 }
386420
387- /**
388- * Starting from the given a node (a property.key node here) looks forward
389- * until it finds the last token before a colon punctuator and returns it.
390- * @param {ASTNode } node The node to start looking from.
391- * @returns {ASTNode } The last token before a colon punctuator.
392- */
393- function getLastTokenBeforeColon ( node ) {
394- const colonToken = sourceCode . getTokenAfter ( node , astUtils . isColonToken ) ;
395-
396- return sourceCode . getTokenBefore ( colonToken ) ;
397- }
398-
399- /**
400- * Starting from the given a node (a property.key node here) looks forward
401- * until it finds the colon punctuator and returns it.
402- * @param {ASTNode } node The node to start looking from.
403- * @returns {ASTNode } The colon punctuator.
404- */
405- function getNextColon ( node ) {
406- return sourceCode . getTokenAfter ( node , astUtils . isColonToken ) ;
407- }
408-
409421 /**
410422 * Gets an object literal property's key as the identifier name or string value.
411423 * @param {ASTNode } property Property node whose key to retrieve.
0 commit comments