Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: improve report location for array-bracket-spacing #12653

Merged
merged 1 commit into from Dec 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions lib/rules/array-bracket-spacing.js
Expand Up @@ -84,16 +84,16 @@ module.exports = {
* @returns {void}
*/
function reportNoBeginningSpace(node, token) {
const nextToken = sourceCode.getTokenAfter(token);

context.report({
node,
loc: token.loc.start,
loc: { start: token.loc.end, end: nextToken.loc.start },
messageId: "unexpectedSpaceAfter",
data: {
tokenValue: token.value
},
fix(fixer) {
const nextToken = sourceCode.getTokenAfter(token);

return fixer.removeRange([token.range[1], nextToken.range[0]]);
}
});
Expand All @@ -106,16 +106,16 @@ module.exports = {
* @returns {void}
*/
function reportNoEndingSpace(node, token) {
const previousToken = sourceCode.getTokenBefore(token);

context.report({
node,
loc: token.loc.start,
loc: { start: previousToken.loc.end, end: token.loc.start },
messageId: "unexpectedSpaceBefore",
data: {
tokenValue: token.value
},
fix(fixer) {
const previousToken = sourceCode.getTokenBefore(token);

return fixer.removeRange([previousToken.range[1], token.range[0]]);
}
});
Expand All @@ -130,7 +130,7 @@ module.exports = {
function reportRequiredBeginningSpace(node, token) {
context.report({
node,
loc: token.loc.start,
loc: token.loc,
messageId: "missingSpaceAfter",
data: {
tokenValue: token.value
Expand All @@ -150,7 +150,7 @@ module.exports = {
function reportRequiredEndingSpace(node, token) {
context.report({
node,
loc: token.loc.start,
loc: token.loc,
messageId: "missingSpaceBefore",
data: {
tokenValue: token.value
Expand Down