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

Cannot read property 'getSchema' of undefined

Open patsissons opened this issue 7 years ago • 0 comments
trafficstars

If you run eslint on a graphql project with the graphql plugin but with a file set that does not include any graphql lintable files this error occurs. The issue is that eslint is just feeding all of its files to the graphql rule and the rule assumes that all files received should be linted, so when a file is received that is not included in the graphql schema map it is assumed that there will be a valid project config when there is not. The error occurs when it calls getSchema on the undefined project config.

Repro Steps

  • echo "module.exports={foo:'bar'};" > test.js
  • echo '{"schemaPath":"schema.graphql","include":"**/*Query.graphql"}' > .graphqlconfig
  • eslint --plugin graphql --rule "{'graphql/template-strings': 'error'}" .

Issue Labels

  • [x] has-reproduction
  • [ ] feature
  • [ ] docs
  • [ ] blocking
  • [ ] good first issue

patsissons avatar Sep 26 '18 18:09 patsissons