Skip to content
Permalink
Browse files

Fix: improve report location for object-curly-spacing (#12563)

  • Loading branch information
mdjermanovic authored and kaicataldo committed Nov 15, 2019
1 parent 1110045 commit 40c8c3264c7c383d98c9faf9c4cb4f8b75aee40f
Showing with 338 additions and 81 deletions.
  1. +8 −8 lib/rules/object-curly-spacing.js
  2. +330 −73 tests/lib/rules/object-curly-spacing.js
@@ -74,16 +74,16 @@ module.exports = {
* @returns {void}
*/
function reportNoBeginningSpace(node, token) {
const nextToken = context.getSourceCode().getTokenAfter(token, { includeComments: true });

context.report({
node,
loc: token.loc.start,
loc: { start: token.loc.end, end: nextToken.loc.start },
message: "There should be no space after '{{token}}'.",
data: {
token: token.value
},
fix(fixer) {
const nextToken = context.getSourceCode().getTokenAfter(token, { includeComments: true });

return fixer.removeRange([token.range[1], nextToken.range[0]]);
}
});
@@ -96,16 +96,16 @@ module.exports = {
* @returns {void}
*/
function reportNoEndingSpace(node, token) {
const previousToken = context.getSourceCode().getTokenBefore(token, { includeComments: true });

context.report({
node,
loc: token.loc.start,
loc: { start: previousToken.loc.end, end: token.loc.start },
message: "There should be no space before '{{token}}'.",
data: {
token: token.value
},
fix(fixer) {
const previousToken = context.getSourceCode().getTokenBefore(token, { includeComments: true });

return fixer.removeRange([previousToken.range[1], token.range[0]]);
}
});
@@ -120,7 +120,7 @@ module.exports = {
function reportRequiredBeginningSpace(node, token) {
context.report({
node,
loc: token.loc.start,
loc: token.loc,
message: "A space is required after '{{token}}'.",
data: {
token: token.value
@@ -140,7 +140,7 @@ module.exports = {
function reportRequiredEndingSpace(node, token) {
context.report({
node,
loc: token.loc.start,
loc: token.loc,
message: "A space is required before '{{token}}'.",
data: {
token: token.value

0 comments on commit 40c8c32

Please sign in to comment.
You can’t perform that action at this time.