From f2fa82c532ae858ccfb064268cfcc9df657a54be Mon Sep 17 00:00:00 2001 From: eeeee Date: Mon, 25 May 2020 08:28:37 -0700 Subject: [PATCH] fix(eslint-plugin): [unbound-method] fix crash due to missing `Intl` (#2090) --- packages/eslint-plugin/src/rules/unbound-method.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/eslint-plugin/src/rules/unbound-method.ts b/packages/eslint-plugin/src/rules/unbound-method.ts index c27f732ca34..ade04229887 100644 --- a/packages/eslint-plugin/src/rules/unbound-method.ts +++ b/packages/eslint-plugin/src/rules/unbound-method.ts @@ -82,6 +82,11 @@ const SUPPORTED_GLOBALS = [ 'Intl', ] as const; const nativelyBoundMembers = SUPPORTED_GLOBALS.map(namespace => { + if (!(namespace in global)) { + // node.js might not have namespaces like Intl depending on compilation options + // https://nodejs.org/api/intl.html#intl_options_for_building_node_js + return []; + } const object = global[namespace]; return Object.getOwnPropertyNames(object) .filter(