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 object-curly-spacing #12563

Merged
merged 1 commit into from Nov 15, 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/object-curly-spacing.js
Expand Up @@ -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]]);
}
});
Expand All @@ -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]]);
}
});
Expand All @@ -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
Expand All @@ -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
Expand Down