Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

[typescript/prefer-pascal-case-enum] Fix an issue with undefined name #517

Merged
merged 1 commit into from
Feb 11, 2020

Conversation

alexandcote
Copy link
Contributor

Fix: #516

  1. We use the node value when the name is undefined. When the key of the enum is declared as a string, the name is undefined
  2. We check if the identifier is defined before we pass the value to the pascalCase function.

You can find more context in the issue.

@alexandcote alexandcote self-assigned this Jan 20, 2020
@alexandcote alexandcote requested a review from cartogram January 20, 2020 17:51
@@ -8,7 +8,6 @@ const ruleTester = new RuleTester({

function errorWithName(name) {
return {
type: 'Identifier',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had to remove this check because when the key is a string, the type of the error is Literal

Copy link
Contributor

Choose a reason for hiding this comment

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

That makes sense

@alexandcote alexandcote requested a review from marutypes February 3, 2020 22:31
Copy link
Contributor

@cartogram cartogram left a comment

Choose a reason for hiding this comment

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

Sorry it took me so long to get to this :(

LGTM! Could you please add a Changelog entry? Let's work together to do a patch release once this is merged. I'd like to get this out to folks quickly. Thanks again ❤️

@@ -8,7 +8,6 @@ const ruleTester = new RuleTester({

function errorWithName(name) {
return {
type: 'Identifier',
Copy link
Contributor

Choose a reason for hiding this comment

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

That makes sense

@alexandcote alexandcote force-pushed the fix_pascal_case branch 2 times, most recently from 573b02a to d098e03 Compare February 4, 2020 15:49
@alexandcote alexandcote merged commit d7a23a9 into master Feb 11, 2020
@alexandcote alexandcote deleted the fix_pascal_case branch February 11, 2020 23:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug with [typescript/prefer-pascal-case-enum] and string keys
2 participants