Skip to content

Commit

Permalink
Merge pull request #4525 from eslint/issue4516
Browse files Browse the repository at this point in the history
Fix: Incorrect location in no-fallthrough (fixes #4516)
  • Loading branch information
nzakas committed Nov 23, 2015
2 parents 0e73089 + f4af63b commit 3f1a8a4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
3 changes: 1 addition & 2 deletions lib/rules/no-fallthrough.js
Expand Up @@ -48,8 +48,7 @@ module.exports = function(context) {

// check for comment
if (!comment || !FALLTHROUGH_COMMENT.test(comment.value)) {

context.report(switchData.lastCase,
context.report(node,
"Expected a \"break\" statement before \"{{code}}\".",
{ code: node.test ? "case" : "default" });
}
Expand Down
12 changes: 8 additions & 4 deletions tests/lib/rules/no-fallthrough.js
Expand Up @@ -48,20 +48,24 @@ ruleTester.run("no-fallthrough", rule, {
],
invalid: [
{
code: "switch(foo) { case 0: a(); case 1: b() }",
code: "switch(foo) { case 0: a();\ncase 1: b() }",
errors: [
{
message: "Expected a \"break\" statement before \"case\".",
type: "SwitchCase"
type: "SwitchCase",
line: 2,
column: 1
}
]
},
{
code: "switch(foo) { case 0: a(); default: b() }",
code: "switch(foo) { case 0: a();\ndefault: b() }",
errors: [
{
message: "Expected a \"break\" statement before \"default\".",
type: "SwitchCase"
type: "SwitchCase",
line: 2,
column: 1
}
]
}
Expand Down

0 comments on commit 3f1a8a4

Please sign in to comment.