Skip to content

Commit

Permalink
Fix test by using the same isNodeFirstInLine function found in jsx-cl…
Browse files Browse the repository at this point in the history
…osing-tag-location rule
  • Loading branch information
jseminck committed Nov 16, 2017
1 parent 8f3dc55 commit 6d50fb6
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/rules/jsx-indent.js
Expand Up @@ -159,12 +159,19 @@ module.exports = {
*/
function isNodeFirstInLine(node) {
let token = node;
let lines;
do {
token = sourceCode.getTokenBefore(token);
} while (token.type === 'JSXText' && /^\s*$/.test(token.value));
lines = token.type === 'JSXText'
? token.value.split('\n')
: null;
} while (
token.type === 'JSXText' &&
/^\s*$/.test(lines[lines.length - 1])
);

const startLine = node.loc.start.line;
const endLine = token ? token.loc.end.line : -1;

return startLine !== endLine;
}

Expand Down

0 comments on commit 6d50fb6

Please sign in to comment.