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
Update: camelcase rule ignoreList added #10783
Conversation
lib/rules/camelcase.js
Outdated
* @private | ||
*/ | ||
function isIgnored(name) { | ||
return ignoreList.findIndex( |
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.
It's better to use !ignoreList.includes(/* */)
.
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.
The problem with includes is that I cannot execute a function to check values.
I need findIndex to check the ignoreList (soon renamed to allowedList) regular expressions.
Hi @Shudrum, thanks for contributing and apologies for letting this sit so long. It looks like a separate issue was created (#10503), where the ESLint team eventually accepted a slightly different proposal. Would you be willing to make some changes to this PR to follow that proposal? Or, if you think the proposal we accepted does not cover the use cases you had envisioned in this PR, would you be willing to leave a comment and explain what might need to be changed? If you're busy and no longer have time to work on this, that's okay too. Thanks and sorry again for letting this slip through the cracks. |
If I have understood: The other PR allow a list of authorised variables:
Mine do the same thing, but allow also regex:
As asked by @sindresorhus: #10503 (comment) I think this is the best way to manage this option. I will update my PR from the review, also, I will change |
PR updated. Maybe I missed something, do not hesitate. |
Thanks for the PR! Sorry for the long wait. |
I was the CTO / Main maintainer of PrestaShop during some time… I'll NEVER say anything about merging / delay answers. It was really hard, slower, and I got way less Issues / PR as you. Good job guys, and thank you! |
I added
eslint -v is |
Just to be sure, are you using that version of eslint directly @shuotongli? If you are using it indirectly, such as via an editor, it is possible that the program is using its own version of eslint. |
Thank you for your response @Brandon-Beck ! I'm running linting in the terminal while having this error msg. So I suppose I'm using it directly. |
Inside a terminal, navigate to your project's directory and then run If you still get the error, and the version still shows as v5.7.0, then you probably have a different problem that someone more knowledgeable here will need to address. If it works, then your sublime plugin may be set to use a different version of eslint (perhaps one local to the current project). Depending what plugin your using, and how you configured it (if applicable), it may already be using the systems eslint. |
This is the terminal output:
|
Try again with |
|
Just to be sure, you did replace that with your actual eslintrc path? Double check for spelling errors with ls or cat |
I couldn't find the eslintrc file in the package that I want to edit. |
It is probably hidden (.eslintrc.js, .eslintrc.json, .eslintrc.yaml, or perhaps even just plain .eslintrc), sorry, forgot to mention that. Try ls -a to see hidden files |
What is the purpose of this pull request? (put an "X" next to item)
[ ] Documentation update
[ ] Bug fix
[ ] New rule
[X] Changes an existing rule
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:
What rule do you want to change?
camelcase
Does this change cause the rule to produce more or fewer warnings?
No, only less if used.
How will the change be implemented? (New option, new default behavior, etc.)?
New option to the rule.
Please provide some example code that this change will affect:
What does the rule currently do for this code?
It throw an error:
Identifier 'UNSAFE_componentWillMount' is not in camel case.
What will the rule do after it's changed?
Using the added option:
{ ignoreList: ["UNSAFE_componentWillMount"] }
will allow this method name.What changes did you make? (Give an overview)
Camel case is used, more and more, but there is still many use of underscore, basically for:
_id
for MongoDBuser_id
UNSAFE_componentWillMount
I have seen some discussions, it seems that people is trying to find the best way to do what this update add:
_id
, with the option{ ignoreList: ["_id$"] }
UNSAFE_
, with the option{ ignoreList: ["^UNSAFE_"] }
{ ignoreList: ["_main_contex_"] }
Basically, it allow to ignore specific variables, and/or regexp pattern, simply.
One of the discussions, for example: #9435
Also: I've seen this PR: #10503, after my work :( But I prefer mine, do not hesitate to close this one. My bad.
Is there anything you'd like reviewers to focus on?
Tests, I have added some tests for my rule, but no overkill tests basically cover some already covered scenarios.