diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 22a8050c4d..1ee989b4ea 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -1,3 +1,4 @@ +/** @type {import('eslint').Linter.Config} */ module.exports = { parserOptions: { sourceType: 'script', @@ -347,7 +348,15 @@ module.exports = { 'no-restricted-globals': 'off', 'no-restricted-imports': 'off', 'no-restricted-properties': 'off', - 'no-restricted-syntax': 'off', + 'no-restricted-syntax': [ + 'error', + { + selector: + 'MemberExpression[property.name="env"] > .object[object.name="globalThis"][property.name="process"]', + message: + "Never use `process.env` with `globalThis` because bundlers incorrectly replace it and doesn't tree shake unused code", + }, + ], 'no-return-assign': 'error', 'no-return-await': 'error', 'no-script-url': 'error', @@ -494,6 +503,8 @@ module.exports = { plugins: ['@typescript-eslint', 'eslint-plugin-tsdoc'], extends: ['plugin:import/typescript'], rules: { + // https://typescript-eslint.io/linting/troubleshooting/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors + 'no-undef': 'off', ////////////////////////////////////////////////////////////////////////// // `eslint-plugin-tsdoc` rule list based on `v0.2.x` // https://github.com/microsoft/tsdoc/tree/master/eslint-plugin diff --git a/.gitignore b/.gitignore index b3a652de18..d42f24fa55 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ /npmEsmDist /denoDist /websiteDist +.idea/ diff --git a/src/jsutils/instanceOf.ts b/src/jsutils/instanceOf.ts index 489d63f42d..4307b310a6 100644 --- a/src/jsutils/instanceOf.ts +++ b/src/jsutils/instanceOf.ts @@ -8,8 +8,7 @@ import { inspect } from './inspect.js'; */ export const instanceOf: (value: unknown, constructor: Constructor) => boolean = /* c8 ignore next 6 */ - // FIXME: https://github.com/graphql/graphql-js/issues/2317 - globalThis.process?.env.NODE_ENV === 'production' + globalThis.process !== undefined && process.env.NODE_ENV === 'production' ? function instanceOf(value: unknown, constructor: Constructor): boolean { return value instanceof constructor; }