Navigation Menu

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

fix(eslint-plugin): [unbound-method] fix crash due to missing Intl #2090

Merged
merged 1 commit into from May 25, 2020
Merged

Conversation

eeeee
Copy link
Contributor

@eeeee eeeee commented May 24, 2020

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. This rule however does expect all SUPPORTED_GLOBALS including Intl to always exist. 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 (<anonymous>)
    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.

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 (<anonymous>)
      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.
@typescript-eslint
Copy link
Contributor

Thanks for the PR, @eeeee!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day.

@codecov
Copy link

codecov bot commented May 24, 2020

Codecov Report

Merging #2090 into master will decrease coverage by 0.02%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##           master    #2090      +/-   ##
==========================================
- Coverage   93.45%   93.43%   -0.03%     
==========================================
  Files         171      171              
  Lines        7747     7749       +2     
  Branches     2210     2211       +1     
==========================================
  Hits         7240     7240              
- Misses        242      243       +1     
- Partials      265      266       +1     
Flag Coverage Δ
#unittest 93.43% <0.00%> (-0.03%) ⬇️
Impacted Files Coverage Δ
packages/eslint-plugin/src/rules/unbound-method.ts 92.30% <0.00%> (-2.94%) ⬇️

@bradzacher bradzacher added the bug Something isn't working label May 25, 2020
Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't realise it was so common for users to build their own copy of nodejs.
You're like the 5th user to run into this issue (#1944).

I'm okay with this fix.

@bradzacher bradzacher changed the title fix(eslint-plugin): fix crash in unbound-method due to missing Intl fix(eslint-plugin): [unbound-method] fix crash due to missing Intl May 25, 2020
@bradzacher bradzacher merged commit f2fa82c into typescript-eslint:master May 25, 2020
@eeeee
Copy link
Contributor Author

eeeee commented May 25, 2020

Ah, the fix seemed straightforward so I didn't think of searching closed issues. As for "build their own copy of nodejs", can't speak for the others but I'm doing this because I'm running Gentoo - disabling the "icu" USE flag for the net-libs/nodejs ebuild causes node to be compiled --with-intl=none

@eeeee eeeee deleted the patch-1 branch May 25, 2020 18:50
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants