Skip to content

Commit

Permalink
fix: adjust report location for no-anonymous-operations rule (#720)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimitri POSTOLOV committed Oct 27, 2021
1 parent 98b6bcb commit 1bacedd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/orange-poets-shout.md
@@ -0,0 +1,5 @@
---
'@graphql-eslint/eslint-plugin': patch
---

fix: adjust report location for `no-anonymous-operations` rule
12 changes: 7 additions & 5 deletions packages/plugin/src/rules/no-anonymous-operations.ts
Expand Up @@ -38,16 +38,18 @@ const rule: GraphQLESLintRule = {
create(context) {
return {
OperationDefinition(node) {
if (node && (!node.name || node.name.value === '')) {
const isAnonymous = (node.name?.value || '').length === 0;
if (isAnonymous) {
const { start } = node.loc;
context.report({
loc: {
start: {
column: node.loc.start.column - 1,
line: node.loc.start.line,
column: start.column - 1,
line: start.line,
},
end: {
column: node.loc.start.column + node.operation.length,
line: node.loc.start.line,
column: start.column - 1 + node.operation.length,
line: start.line,
},
},
data: {
Expand Down

0 comments on commit 1bacedd

Please sign in to comment.