Skip to content

Commit

Permalink
fix(no-focused-test): Only report focused test keyword, not test
Browse files Browse the repository at this point in the history
Change endLine and endColumn so only the focused test keyword is
reported as problematic instead of the whole test call. The previous
behavior made working on a focused much harder with editors selecting
all code from line to endLine.

Fixes issue tlvince#230.
  • Loading branch information
DamienCassou committed Apr 12, 2020
1 parent f7be38e commit 7fd1095
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/helpers/prohibit.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ module.exports = function (prohibiteds, context) {
name: result[1]
},
message: 'Unexpected {{name}}.',
node
node,
loc: {
start: node.loc.start,
end: {
line: node.loc.start.line,
column: node.loc.start.column + node.callee.name.length
}
}
})
}
}
Expand Down
14 changes: 14 additions & 0 deletions test/rules/no-focused-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ eslintTester.run('no-focused-tests', rule, {
type: 'CallExpression'
}
]
},
{
code: 'fit("My focused spec", function() {\n\n});',
errors: [
{
message: 'Unexpected fit.',
type: 'CallExpression',
line: 1,
column: 1,
// only report the word 'fit', not the whole test:
endLine: 1,
endColumn: 4
}
]
}
]
})

0 comments on commit 7fd1095

Please sign in to comment.