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: camelcase rule fix for import declarations (fixes #6755) #6784

Merged
merged 1 commit into from Aug 1, 2016

Conversation

lordgiotto
Copy link
Contributor

Fixes #6755

Calmecase rule now doesn't report an error if camelcased identifier is imported with a camecased alias. Otherwhise it reports an error as expected.

@mention-bot
Copy link

@lordgiotto, thanks for your PR! By analyzing the annotation information on this pull request, we identified @vitorbal, @nzakas and @iancmyers to be potential reviewers

@eslintbot
Copy link

LGTM

message: "Identifier 'no_camelcased' is not in camel case.",
type: "Identifier"
}
]
Copy link
Member

Choose a reason for hiding this comment

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

Could you add a test for import { no_camelcased as no_camel_cased } from \"external module\"; as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I added that test and slightly changed the rule check to not report the error twice: now it only checks local identifier (that is the one we care about) and never the imported one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vitorbal Added both the tests you suggested :)

Copy link
Member

Choose a reason for hiding this comment

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

thanks, looking great!

@eslintbot
Copy link

LGTM

@nzakas
Copy link
Member

nzakas commented Jul 28, 2016

LGTM, just waiting another day to let others review.

},
{
code: "import { no_camelcased as camelCased, anoterCamelCased } from \"external-module\";",
parserOptions: { ecmaVersion: 6, sourceType: "module" }
Copy link
Member

Choose a reason for hiding this comment

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

Sorry for not asking this before, could you also add a test for import { camelCased } from \"external module\"; as well, just in case?

@eslintbot
Copy link

LGTM

@eslintbot
Copy link

LGTM

1 similar comment
@vitorbal
Copy link
Member

vitorbal commented Jul 29, 2016

LGTM

@kaicataldo
Copy link
Member

Thanks for contributing, @lordgiotto! Code changes looks great. Can you add a description of this behavior to the docs for the rule?

@eslintbot
Copy link

LGTM

@lordgiotto
Copy link
Contributor Author

@kaicataldo Docs updated! Please, let me know if what I wrote is acceptable: since english is not my mother thong, even it's good enough to communicate, it could be not good enough to write official documentation :P

@@ -4,7 +4,7 @@ When it comes to naming variables, style guides generally fall into one of two c

## Rule Details

This rule looks for any underscores (`_`) located within the source code. It ignores leading and trailing underscores and only checks those in the middle of a variable name. If ESLint decides that the variable is a constant (all uppercase), then no warning will be thrown. Otherwise, a warning will be thrown. This rule only flags definitions and assignments but not function calls.
This rule looks for any underscores (`_`) located within the source code. It ignores leading and trailing underscores and only checks those in the middle of a variable name. If ESLint decides that the variable is a constant (all uppercase), then no warning will be thrown. Otherwise, a warning will be thrown. This rule only flags definitions and assignments but not function calls. In case of es6 `import` statements, this rule only targets the name of the variable that will be imported into the local module scope.
Copy link
Member

Choose a reason for hiding this comment

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

This looks great to me! Could we make it ES6 instead of es6 for consistency with our other documentation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed, thank you :)

@kaicataldo
Copy link
Member

@lordgiotto Your English is great. One tiny, tiny nitpick, but otherwise the docs look really good to me. Thanks!

@eslintbot
Copy link

LGTM

@kaicataldo
Copy link
Member

Looks like the tests are failing, but doesn't seem like it's because of anything in this PR:

Validating licenses
undefined license for circular-json@0.3.0 is impermissible.
npm ERR! Test failed.  See above for more details.

@gyandeeps
Copy link
Member

huh, I didn't know that we check for license on indirect dependencies also. I always thought we only checked for direct dependencies.

@lordgiotto
Copy link
Contributor Author

lordgiotto commented Aug 1, 2016

Very strange, this is my output of npm test: no licenses errors.
eslint-test.txt

@nzakas
Copy link
Member

nzakas commented Aug 1, 2016

Hmm, can someone track down where that dependency is building pulled in?

Also, note for whomever ends up merging: The commit message should begin with "Update:" since it adds new default functionality.

@lordgiotto
Copy link
Contributor Author

@nzakas ok, i'll change commit message, I misunderstood the guide and used 'fix' since it was referred to an issue marked as bug, sorry.

Calmecase rule now doesn't report an error if camelcased identifier
is imported with a camecased alias. Otherwhise it reports an error
as expected.
@eslintbot
Copy link

LGTM

@lordgiotto
Copy link
Contributor Author

@kaicataldo I pushed a new commit with the correct message and this time it passed all the test. Weird :)

@gyandeeps gyandeeps merged commit e524d16 into eslint:master Aug 1, 2016
@platinumazure
Copy link
Member

@lordgiotto We managed to get a PR into the upstream project that was causing the test failures, and now everything is fixed. 😄 Thanks for your patience!

@vitorbal
Copy link
Member

vitorbal commented Aug 1, 2016

@lordgiotto thanks a lot for your contribution! We really appreciate it 🎉

@lordgiotto
Copy link
Contributor Author

Thank you @vitorbal and all the reviewers, it was a pleasure :)

@lordgiotto lordgiotto deleted the issue6755 branch August 4, 2016 13:46
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants