Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid using process.env with globalThis #3927

Closed
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
parserOptions: {
sourceType: 'script',
Expand Down Expand Up @@ -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[object.name="globalThis"][property.name="process"]',
message:
"Never use `process` 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',
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
/npmEsmDist
/denoDist
/websiteDist
.idea/
3 changes: 1 addition & 2 deletions src/jsutils/instanceOf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
typeof process === 'undefined' || process.env.NODE_ENV === 'production'
dimaMachina marked this conversation as resolved.
Show resolved Hide resolved
? function instanceOf(value: unknown, constructor: Constructor): boolean {
return value instanceof constructor;
}
Expand Down