UNPKG

@graphql-eslint/eslint-plugin

Version:
73 lines (68 loc) 1.59 kB
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _indexjs = require('../unique-fragment-name/index.js'); const RULE_ID = "unique-operation-name"; const rule = { meta: { type: "suggestion", docs: { category: "Operations", description: "Enforce unique operation names across your project.", url: `https://the-guild.dev/graphql/eslint/rules/${RULE_ID}`, requiresSiblings: true, recommended: true, examples: [ { title: "Incorrect", code: ( /* GraphQL */ ` # foo.query.graphql query user { user { id } } # bar.query.graphql query user { me { id } } ` ) }, { title: "Correct", code: ( /* GraphQL */ ` # foo.query.graphql query user { user { id } } # bar.query.graphql query me { me { id } } ` ) } ] }, messages: { [RULE_ID]: 'Operation named "{{ documentName }}" already defined in:\n{{ summary }}' }, schema: [] }, create(context) { return { "OperationDefinition[name!=undefined]"(node) { _indexjs.checkNode.call(void 0, context, node, RULE_ID); } }; } }; exports.rule = rule;