Skip to content

Commit 25462b2

Browse files
authored
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
1 parent de0aab9 commit 25462b2

2 files changed

Lines changed: 481 additions & 45 deletions

File tree

lib/rules/block-spacing.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,18 @@ module.exports = {
102102

103103
// Check.
104104
if (!isValid(openBrace, firstToken)) {
105+
let loc = openBrace.loc;
106+
107+
if (messageId === "extra") {
108+
loc = {
109+
start: openBrace.loc.end,
110+
end: firstToken.loc.start
111+
};
112+
}
113+
105114
context.report({
106115
node,
107-
loc: openBrace.loc.start,
116+
loc,
108117
messageId,
109118
data: {
110119
location: "after",
@@ -120,9 +129,17 @@ module.exports = {
120129
});
121130
}
122131
if (!isValid(lastToken, closeBrace)) {
132+
let loc = closeBrace.loc;
133+
134+
if (messageId === "extra") {
135+
loc = {
136+
start: lastToken.loc.end,
137+
end: closeBrace.loc.start
138+
};
139+
}
123140
context.report({
124141
node,
125-
loc: closeBrace.loc.start,
142+
loc,
126143
messageId,
127144
data: {
128145
location: "before",

0 commit comments

Comments
 (0)