When I add eslint to a project, I am getting eslint errors straight away because eslint thinks 'graphql' is an undefined variable.
......./page.js
33:26 error 'graphql' is not defined no-undef
✖ 1 problem (1 error, 0 warnings)
Is there anyway around this? I am using GatsbyV1.
Hi,
This is because Eslint doesn't know that Gatsby will handle and extract graphql statements during build. To Eslint it simply looks like you forgot the define the variable.
The simplest way around this is to add /* global graphql */ in your file.
But assigning graphql as a global in your .eslintrc is probably preferable.
{
"globals": {
"graphql": false
}
}
You can read more about the no-undef rule here or assigning globals here.
@gabbes Thank you!
Most helpful comment
Hi,
This is because Eslint doesn't know that Gatsby will handle and extract graphql statements during build. To Eslint it simply looks like you forgot the define the variable.
The simplest way around this is to add
/* global graphql */in your file.But assigning graphql as a global in your .eslintrc is probably preferable.
You can read more about the no-undef rule here or assigning globals here.