eslint-plugin-graphql icon indicating copy to clipboard operation
eslint-plugin-graphql copied to clipboard

Empty Enum Values cause error

Open tonnenpinguin opened this issue 6 years ago • 0 comments
trafficstars

Hi!

In our schema we have an enum value that amongs others defines an empty string as valid value (relevant section of the generated schema.json below).

When running lint this causes the following error:

Error: Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but "" does not.
    at assertValidSchema (/home/berni/src/oldspice/node_modules/graphql/type/validate.js:71:11)
    at validate (/home/berni/src/oldspice/node_modules/graphql/validation/validate.js:55:35)
    at handleTemplateTag (/home/berni/src/oldspice/node_modules/eslint-plugin-graphql/lib/createRule.js:133:57)
    at TaggedTemplateExpression (/home/berni/src/oldspice/node_modules/eslint-plugin-graphql/lib/createRule.js:226:20)
    at listeners.(anonymous function).forEach.listener (/home/berni/src/oldspice/apps/backoffice/lib/web/assets/node_modules/eslint/lib/util/safe-emitter.js:45:58)
    at Array.forEach (<anonymous>)
    at Object.emit (/home/berni/src/oldspice/apps/backoffice/lib/web/assets/node_modules/eslint/lib/util/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/home/berni/src/oldspice/apps/backoffice/lib/web/assets/node_modules/eslint/lib/util/node-event-generator.js:251:26)
    at NodeEventGenerator.applySelectors (/home/berni/src/oldspice/apps/backoffice/lib/web/assets/node_modules/eslint/lib/util/node-event-generator.js:280:22)
    at NodeEventGenerator.enterNode (/home/berni/src/oldspice/apps/backoffice/lib/web/assets/node_modules/eslint/lib/util/node-event-generator.js:294:14)
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @spice/[email protected] lint: `eslint --max-warnings=0 src --ext .js,.jsx`
npm ERR! Exit status 2
[...]
        {
          "possibleTypes": null,
          "name": "VariableKind",
          "kind": "ENUM",
          "interfaces": null,
          "inputFields": null,
          "fields": null,
          "enumValues": [
            {
              "name": "",
              "isDeprecated": false,
              "description": null,
              "deprecationReason": null
            },
            {
              "name": "ONE",
              "isDeprecated": false,
              "description": null,
              "deprecationReason": null
            },
[...]

Is this the expected behaviour?

Thanks!

I'm running on version 3.0.1

tonnenpinguin avatar Dec 06 '18 17:12 tonnenpinguin