File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed
packages/plugin/src/rules Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @graphql-eslint/eslint-plugin ' : patch
3
+ ---
4
+
5
+ fix: adjust report location for ` no-operation-name-suffix ` rule
Original file line number Diff line number Diff line change @@ -42,12 +42,23 @@ const rule: GraphQLESLintRule = {
42
42
'OperationDefinition, FragmentDefinition' (
43
43
node : GraphQLESTreeNode < OperationDefinitionNode | FragmentDefinitionNode >
44
44
) {
45
- if ( node && node . name && node . name . value !== '' ) {
46
- const invalidSuffix = ( node . type === 'OperationDefinition' ? node . operation : 'fragment' ) . toLowerCase ( ) ;
45
+ const name = node . name ?. value || '' ;
46
+ if ( name . length > 0 ) {
47
+ const invalidSuffix = 'operation' in node ? node . operation : 'fragment' ;
47
48
48
- if ( node . name . value . toLowerCase ( ) . endsWith ( invalidSuffix ) ) {
49
+ if ( name . toLowerCase ( ) . endsWith ( invalidSuffix ) ) {
50
+ const { start, end } = node . name . loc ;
49
51
context . report ( {
50
- node : node . name ,
52
+ loc : {
53
+ start : {
54
+ column : start . column - 1 + name . length - invalidSuffix . length ,
55
+ line : start . line ,
56
+ } ,
57
+ end : {
58
+ column : end . column - 1 + name . length ,
59
+ line : end . line ,
60
+ } ,
61
+ } ,
51
62
data : {
52
63
invalidSuffix,
53
64
} ,
You can’t perform that action at this time.
0 commit comments