Skip to content

Commit 6cc7d06

Browse files
committed
avoid using globalThis with process
1 parent d766c8e commit 6cc7d06

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

.eslintrc.cjs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/** @type {import('eslint').Linter.Config} */
12
module.exports = {
23
parserOptions: {
34
sourceType: 'script',
@@ -347,7 +348,15 @@ module.exports = {
347348
'no-restricted-globals': 'off',
348349
'no-restricted-imports': 'off',
349350
'no-restricted-properties': 'off',
350-
'no-restricted-syntax': 'off',
351+
'no-restricted-syntax': [
352+
'error',
353+
{
354+
selector:
355+
'MemberExpression[object.name="globalThis"][property.name="process"]',
356+
message:
357+
"Never use `process` with `globalThis` because bundlers incorrectly replace it and doesn't tree shake unused code",
358+
},
359+
],
351360
'no-return-assign': 'error',
352361
'no-return-await': 'error',
353362
'no-script-url': 'error',
@@ -494,6 +503,8 @@ module.exports = {
494503
plugins: ['@typescript-eslint', 'eslint-plugin-tsdoc'],
495504
extends: ['plugin:import/typescript'],
496505
rules: {
506+
// 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
507+
'no-undef': 'off',
497508
//////////////////////////////////////////////////////////////////////////
498509
// `eslint-plugin-tsdoc` rule list based on `v0.2.x`
499510
// https://github.com/microsoft/tsdoc/tree/master/eslint-plugin

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@
1616
/npmEsmDist
1717
/denoDist
1818
/websiteDist
19+
.idea/

src/jsutils/instanceOf.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ import { inspect } from './inspect.js';
88
*/
99
export const instanceOf: (value: unknown, constructor: Constructor) => boolean =
1010
/* c8 ignore next 6 */
11-
// FIXME: https://github.com/graphql/graphql-js/issues/2317
12-
globalThis.process?.env.NODE_ENV === 'production'
11+
process.env.NODE_ENV === 'production'
1312
? function instanceOf(value: unknown, constructor: Constructor): boolean {
1413
return value instanceof constructor;
1514
}

0 commit comments

Comments
 (0)