Skip to content

Commit 6d50fb6

Browse files
committed
Fix test by using the same isNodeFirstInLine function found in jsx-closing-tag-location rule
1 parent 8f3dc55 commit 6d50fb6

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/rules/jsx-indent.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,19 @@ module.exports = {
159159
*/
160160
function isNodeFirstInLine(node) {
161161
let token = node;
162+
let lines;
162163
do {
163164
token = sourceCode.getTokenBefore(token);
164-
} while (token.type === 'JSXText' && /^\s*$/.test(token.value));
165+
lines = token.type === 'JSXText'
166+
? token.value.split('\n')
167+
: null;
168+
} while (
169+
token.type === 'JSXText' &&
170+
/^\s*$/.test(lines[lines.length - 1])
171+
);
172+
165173
const startLine = node.loc.start.line;
166174
const endLine = token ? token.loc.end.line : -1;
167-
168175
return startLine !== endLine;
169176
}
170177

0 commit comments

Comments
 (0)