29
29
*/
30
30
'use strict' ;
31
31
32
+ const astUtil = require ( '../util/ast' ) ;
33
+
32
34
// ------------------------------------------------------------------------------
33
35
// Rule Definition
34
36
// ------------------------------------------------------------------------------
@@ -136,20 +138,6 @@ module.exports = {
136
138
return indent ? indent [ 0 ] . length : 0 ;
137
139
}
138
140
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
-
153
141
/**
154
142
* Check indent for nodes list
155
143
* @param {ASTNode[] } nodes list of node objects
@@ -161,7 +149,7 @@ module.exports = {
161
149
const nodeIndent = getNodeIndent ( node , false , excludeCommas ) ;
162
150
if (
163
151
node . type !== 'ArrayExpression' && node . type !== 'ObjectExpression' &&
164
- nodeIndent !== indent && isNodeFirstInLine ( node )
152
+ nodeIndent !== indent && astUtil . isNodeFirstInLine ( context , node )
165
153
) {
166
154
report ( node , indent , nodeIndent ) ;
167
155
}
0 commit comments