2929 */
3030'use strict' ;
3131
32+ const astUtil = require ( '../util/ast' ) ;
33+
3234// ------------------------------------------------------------------------------
3335// Rule Definition
3436// ------------------------------------------------------------------------------
@@ -136,20 +138,6 @@ module.exports = {
136138 return indent ? indent [ 0 ] . length : 0 ;
137139 }
138140
139- /**
140- * Checks node is the first in its own start line. By default it looks by start line.
141- * @param {ASTNode } node The node to check
142- * @param {Boolean } [byEndLocation] Lookup based on start position or end
143- * @return {Boolean } true if its the first in the its start line
144- */
145- function isNodeFirstInLine ( node , byEndLocation ) {
146- const firstToken = byEndLocation === true ? sourceCode . getLastToken ( node , 1 ) : sourceCode . getTokenBefore ( node ) ;
147- const startLine = byEndLocation === true ? node . loc . end . line : node . loc . start . line ;
148- const endLine = firstToken ? firstToken . loc . end . line : - 1 ;
149-
150- return startLine !== endLine ;
151- }
152-
153141 /**
154142 * Check indent for nodes list
155143 * @param {ASTNode[] } nodes list of node objects
@@ -161,7 +149,7 @@ module.exports = {
161149 const nodeIndent = getNodeIndent ( node , false , excludeCommas ) ;
162150 if (
163151 node . type !== 'ArrayExpression' && node . type !== 'ObjectExpression' &&
164- nodeIndent !== indent && isNodeFirstInLine ( node )
152+ nodeIndent !== indent && astUtil . isNodeFirstInLine ( context , node )
165153 ) {
166154 report ( node , indent , nodeIndent ) ;
167155 }
0 commit comments