Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update: block-spacing changed loc for extra (refs #12334) (#13314)
* Update: changed loc for extra (refs #12334)

* Chore: linting fixes

* Update: loc reporting for missing case

* Chore: un-comment valid case

* Chore: consistent ordering of datas in errors object
  • Loading branch information
anikethsaha committed May 22, 2020
1 parent de0aab9 commit 25462b2
Show file tree
Hide file tree
Showing 2 changed files with 481 additions and 45 deletions.
21 changes: 19 additions & 2 deletions lib/rules/block-spacing.js
Expand Up @@ -102,9 +102,18 @@ module.exports = {

// Check.
if (!isValid(openBrace, firstToken)) {
let loc = openBrace.loc;

if (messageId === "extra") {
loc = {
start: openBrace.loc.end,
end: firstToken.loc.start
};
}

context.report({
node,
loc: openBrace.loc.start,
loc,
messageId,
data: {
location: "after",
Expand All @@ -120,9 +129,17 @@ module.exports = {
});
}
if (!isValid(lastToken, closeBrace)) {
let loc = closeBrace.loc;

if (messageId === "extra") {
loc = {
start: lastToken.loc.end,
end: closeBrace.loc.start
};
}
context.report({
node,
loc: closeBrace.loc.start,
loc,
messageId,
data: {
location: "before",
Expand Down

0 comments on commit 25462b2

Please sign in to comment.