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
Conversation
@lordgiotto, thanks for your PR! By analyzing the annotation information on this pull request, we identified @vitorbal, @nzakas and @iancmyers to be potential reviewers |
LGTM |
message: "Identifier 'no_camelcased' is not in camel case.", | ||
type: "Identifier" | ||
} | ||
] |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, looking great!
LGTM |
LGTM, just waiting another day to let others review. |
}, | ||
{ | ||
code: "import { no_camelcased as camelCased, anoterCamelCased } from \"external-module\";", | ||
parserOptions: { ecmaVersion: 6, sourceType: "module" } |
There was a problem hiding this comment.
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?
LGTM |
LGTM |
1 similar comment
LGTM |
Thanks for contributing, @lordgiotto! Code changes looks great. Can you add a description of this behavior to the docs for the rule? |
LGTM |
@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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, thank you :)
@lordgiotto Your English is great. One tiny, tiny nitpick, but otherwise the docs look really good to me. Thanks! |
LGTM |
Looks like the tests are failing, but doesn't seem like it's because of anything in this PR:
|
huh, I didn't know that we check for license on indirect dependencies also. I always thought we only checked for direct dependencies. |
Very strange, this is my output of |
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. |
@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.
LGTM |
@kaicataldo I pushed a new commit with the correct message and this time it passed all the test. Weird :) |
@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! |
@lordgiotto thanks a lot for your contribution! We really appreciate it 🎉 |
Thank you @vitorbal and all the reviewers, it was a pleasure :) |
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.