From 46f03f7cf5fc9aaec4b829a7f87b366e7d27ac3d Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Sun, 31 Oct 2021 16:45:34 +0100 Subject: [PATCH] fix error report for `description-style` rule (#741) --- .changeset/rich-cougars-sort.md | 5 +++++ packages/plugin/src/rules/description-style.ts | 3 ++- .../__snapshots__/description-style.spec.ts.snap | 12 ++++++------ 3 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 .changeset/rich-cougars-sort.md diff --git a/.changeset/rich-cougars-sort.md b/.changeset/rich-cougars-sort.md new file mode 100644 index 00000000000..95dc5e044b4 --- /dev/null +++ b/.changeset/rich-cougars-sort.md @@ -0,0 +1,5 @@ +--- +'@graphql-eslint/eslint-plugin': patch +--- + +fix error report for `description-style` rule diff --git a/packages/plugin/src/rules/description-style.ts b/packages/plugin/src/rules/description-style.ts index 803740ca9e0..43f1bccc4c3 100644 --- a/packages/plugin/src/rules/description-style.ts +++ b/packages/plugin/src/rules/description-style.ts @@ -1,4 +1,5 @@ import { GraphQLESLintRule } from '../types'; +import { getLocation } from '../utils'; type DescriptionStyleRuleConfig = [ { @@ -58,7 +59,7 @@ const rule: GraphQLESLintRule = { '[description.type="StringValue"]': node => { if (node.description.block !== (style === 'block')) { context.report({ - node: node.description, + loc: getLocation(node.description.loc), message: `Unexpected ${wrongDescriptionType} description`, }); } diff --git a/packages/plugin/tests/__snapshots__/description-style.spec.ts.snap b/packages/plugin/tests/__snapshots__/description-style.spec.ts.snap index 572dc78a441..5b818a16238 100644 --- a/packages/plugin/tests/__snapshots__/description-style.spec.ts.snap +++ b/packages/plugin/tests/__snapshots__/description-style.spec.ts.snap @@ -4,7 +4,7 @@ exports[` 1`] = ` 1 | 2 | enum EnumUserLanguagesSkill { > 3 | """ - | ^ Unexpected block description + | ^ Unexpected block description 4 | basic 5 | """ 6 | basic @@ -28,7 +28,7 @@ exports[` 2`] = ` 5 | """ 6 | basic > 7 | """ - | ^ Unexpected block description + | ^ Unexpected block description 8 | fluent 9 | """ 10 | fluent @@ -52,7 +52,7 @@ exports[` 3`] = ` 9 | """ 10 | fluent > 11 | """ - | ^ Unexpected block description + | ^ Unexpected block description 12 | native 13 | """ 14 | native @@ -63,7 +63,7 @@ exports[` 3`] = ` exports[` 4`] = ` 1 | > 2 | " Test " - | ^ Unexpected inline description + | ^ Unexpected inline description 3 | type CreateOneUserPayload { 4 | "Created document ID" 5 | recordId: MongoID @@ -79,7 +79,7 @@ exports[` 5`] = ` 2 | " Test " 3 | type CreateOneUserPayload { > 4 | "Created document ID" - | ^ Unexpected inline description + | ^ Unexpected inline description 5 | recordId: MongoID 6 | 7 | "Created document" @@ -96,7 +96,7 @@ exports[` 6`] = ` 5 | recordId: MongoID 6 | > 7 | "Created document" - | ^ Unexpected inline description + | ^ Unexpected inline description 8 | record: User 9 | } 10 |