Skip to content

Commit 46f03f7

Browse files
author
Dimitri POSTOLOV
authored
fix error report for description-style rule (#741)
1 parent 578b890 commit 46f03f7

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

.changeset/rich-cougars-sort.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 error report for `description-style` rule

packages/plugin/src/rules/description-style.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { GraphQLESLintRule } from '../types';
2+
import { getLocation } from '../utils';
23

34
type DescriptionStyleRuleConfig = [
45
{
@@ -58,7 +59,7 @@ const rule: GraphQLESLintRule<DescriptionStyleRuleConfig> = {
5859
'[description.type="StringValue"]': node => {
5960
if (node.description.block !== (style === 'block')) {
6061
context.report({
61-
node: node.description,
62+
loc: getLocation(node.description.loc),
6263
message: `Unexpected ${wrongDescriptionType} description`,
6364
});
6465
}

packages/plugin/tests/__snapshots__/description-style.spec.ts.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ exports[` 1`] = `
44
1 |
55
2 | enum EnumUserLanguagesSkill {
66
> 3 | """
7-
| ^ Unexpected block description
7+
| ^ Unexpected block description
88
4 | basic
99
5 | """
1010
6 | basic
@@ -28,7 +28,7 @@ exports[` 2`] = `
2828
5 | """
2929
6 | basic
3030
> 7 | """
31-
| ^ Unexpected block description
31+
| ^ Unexpected block description
3232
8 | fluent
3333
9 | """
3434
10 | fluent
@@ -52,7 +52,7 @@ exports[` 3`] = `
5252
9 | """
5353
10 | fluent
5454
> 11 | """
55-
| ^ Unexpected block description
55+
| ^ Unexpected block description
5656
12 | native
5757
13 | """
5858
14 | native
@@ -63,7 +63,7 @@ exports[` 3`] = `
6363
exports[` 4`] = `
6464
1 |
6565
> 2 | " Test "
66-
| ^ Unexpected inline description
66+
| ^ Unexpected inline description
6767
3 | type CreateOneUserPayload {
6868
4 | "Created document ID"
6969
5 | recordId: MongoID
@@ -79,7 +79,7 @@ exports[` 5`] = `
7979
2 | " Test "
8080
3 | type CreateOneUserPayload {
8181
> 4 | "Created document ID"
82-
| ^ Unexpected inline description
82+
| ^ Unexpected inline description
8383
5 | recordId: MongoID
8484
6 |
8585
7 | "Created document"
@@ -96,7 +96,7 @@ exports[` 6`] = `
9696
5 | recordId: MongoID
9797
6 |
9898
> 7 | "Created document"
99-
| ^ Unexpected inline description
99+
| ^ Unexpected inline description
100100
8 | record: User
101101
9 | }
102102
10 |

0 commit comments

Comments
 (0)