From 97c95124b17ec42b62917a65c94fd528c69c7cfe Mon Sep 17 00:00:00 2001 From: Laurin Quast Date: Mon, 9 May 2022 14:37:43 +0200 Subject: [PATCH] fix: only access Node.js globals if available (#3501) * fix: only access Node.js global if available * chore: adjust eslint config according to experts --- .eslintrc.yml | 8 ++++++++ src/jsutils/instanceOf.ts | 3 +-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index 6a53f807ba..77a4e0d43b 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -743,3 +743,11 @@ overrides: # Ignore docusarus related webpack aliases import/no-unresolved: ['error', { 'ignore': ['^@theme', '^@docusaurus', '^@generated'] }] + - files: + - website/docusaurus.config.js + - website/sidebars.js + - integrationTests/**/* + - benchmark/**/* + - resources/**/* + env: + node: true diff --git a/src/jsutils/instanceOf.ts b/src/jsutils/instanceOf.ts index a4456c679d..b917cfc3bf 100644 --- a/src/jsutils/instanceOf.ts +++ b/src/jsutils/instanceOf.ts @@ -9,8 +9,7 @@ import { inspect } from './inspect'; export const instanceOf: (value: unknown, constructor: Constructor) => boolean = /* c8 ignore next 6 */ // FIXME: https://github.com/graphql/graphql-js/issues/2317 - // eslint-disable-next-line no-undef - process.env.NODE_ENV === 'production' + globalThis.process?.env.NODE_ENV === 'production' ? function instanceOf(value: unknown, constructor: Constructor): boolean { return value instanceof constructor; }