From 42718d77d9c2d9e301b8e5a9b3c777abb1d683c8 Mon Sep 17 00:00:00 2001 From: eeeee Date: Sun, 24 May 2020 14:45:25 -0700 Subject: [PATCH] fix crash in unbound-method due to missing Intl When Node.js is compiled with the "--with-intl=none" option ( https://nodejs.org/api/intl.html#intl_options_for_building_node_js ) it will not have the Intl global. As a result, any attempt to run eslint would result in an error like: TypeError: Failed to load plugin '@typescript-eslint' declared in '.eslintrc.js': Cannot convert undefined or null to object Referenced from: /home/dev/web/.eslintrc.js at Function.getOwnPropertyNames () at /home/dev/web/node_modules/@typescript-eslint/eslint-plugin/dist/rules/unbound-method.js:91:19 We can silently ignore missing globals as a workaround. --- 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(