Skip to content

Commit 1bacedd

Browse files
author
Dimitri POSTOLOV
authored
fix: adjust report location for no-anonymous-operations rule (#720)
1 parent 98b6bcb commit 1bacedd

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

.changeset/orange-poets-shout.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-eslint/eslint-plugin': patch
3+
---
4+
5+
fix: adjust report location for `no-anonymous-operations` rule

packages/plugin/src/rules/no-anonymous-operations.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,18 @@ const rule: GraphQLESLintRule = {
3838
create(context) {
3939
return {
4040
OperationDefinition(node) {
41-
if (node && (!node.name || node.name.value === '')) {
41+
const isAnonymous = (node.name?.value || '').length === 0;
42+
if (isAnonymous) {
43+
const { start } = node.loc;
4244
context.report({
4345
loc: {
4446
start: {
45-
column: node.loc.start.column - 1,
46-
line: node.loc.start.line,
47+
column: start.column - 1,
48+
line: start.line,
4749
},
4850
end: {
49-
column: node.loc.start.column + node.operation.length,
50-
line: node.loc.start.line,
51+
column: start.column - 1 + node.operation.length,
52+
line: start.line,
5153
},
5254
},
5355
data: {

0 commit comments

Comments
 (0)