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): naming-convention null pattern #1450

Merged
merged 1 commit into from Jan 14, 2020
Merged

fix(eslint-plugin): naming-convention null pattern #1450

merged 1 commit into from Jan 14, 2020

Conversation

jonathanrdelgado
Copy link
Contributor

I just switched over to the new naming-convention rule (which is pretty awesome), I was getting an exception TypeError: Cannot read property 'type' of null, here is a quick repo:

const match = 'test'.match(/test/);
const [, key, value] = match;

With the minimum configuration of

{
  selector: 'default',
  format: ['camelCase'],
}

This is the case because the AST_NODE_TYPES.ArrayPattern was returning an array of elements in which the first element is null, then, when we recursively step back into getIdentifiersFromPattern, we're immediately evaluating null.type.

The solution I'm proposing is just filtering out those null elements in the loop prior to recursion. I added a regression test as well.

Thank you!

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @jonathanrdelgado!

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.

@bradzacher bradzacher added the bug Something isn't working label Jan 14, 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.

Nice catch! thanks for fixing this.
Turns out the types for ArrayPattern are wrong - I didn't even realise! I'll submit a separate PR to fix this.

@codecov
Copy link

codecov bot commented Jan 14, 2020

Codecov Report

Merging #1450 into master will increase coverage by <.01%.
The diff coverage is 100%.

@@            Coverage Diff            @@
##           master   #1450      +/-   ##
=========================================
+ Coverage   94.09%   94.1%   +<.01%     
=========================================
  Files         143     143              
  Lines        6457    6458       +1     
  Branches     1823    1824       +1     
=========================================
+ Hits         6076    6077       +1     
  Misses        204     204              
  Partials      177     177
Impacted Files Coverage Δ
...kages/eslint-plugin/src/rules/naming-convention.ts 87.88% <100%> (+0.03%) ⬆️

@bradzacher bradzacher merged commit 4726605 into typescript-eslint:master Jan 14, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 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