-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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: Add exceptions option to camelcase. #9684
Conversation
For your example, you can use a regular object literal const mysql = require('mysql');
const pool = mysql.createPool();
const accountId = 'value';
const messageCause = 'dbas like underscores';
pool.query('INSERT INTO account_log SET ?', {account_id: accountId, message_cause: messageCause}, err => {
if (err) {
throw err;
}
pool.end();
}); which will avoid the issue altogether. |
@j-f1 I just tried your code, it still produces errors when camelcase is enabled. |
Why can't this just be made to be more generic and have an option called To clarify, this rule would be the exact same as
is allowed https://eslint.org/docs/rules/camelcase#always I actually came here to make a feature request for this and found this issue. It seems much needed. Edit: Wow I'm dumb, this already exists, thanks @j-f1 -- sorry for the hijack |
That’s what the |
As @j-f1 mentioned, this should pass with |
The point of my patch is to allow specific camel case symbols to be used anywhere. If I'm dealing with a database which uses time_id I don't care where time_id is used, variables, symbols or parameters. I don't want to allow all camel case property names, only the names from the database. |
@coreyfarell Maybe you want to take a look at the |
In theory the id-match rule could work. It looks difficult to use but I'm going to close this PR because it feels like a waste of time. |
What is the purpose of this pull request? (put an "X" next to item)
[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[X] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:
please explain:
What rule do you want to change?
camelcase
Does this change cause the rule to produce more or fewer warnings?
It can cause fewer warnings to be produced if the new option is used.
How will the change be implemented? (New option, new default behavior, etc.)?
A new option "exceptions" can be provided to the camelcase rule.
Please provide some example code that this change will affect:
What does the rule currently do for this code?
The camelcase rule must be disabled when dealing with outside code that requires use of underscored names.
What will the rule do after it's changed?
After the change the example above would be able to include the option
"exceptions": ["account_id", "message_cause"]
in thecamelcase
options object instead of disabling it entirely.What changes did you make? (Give an overview)
Add support for "exceptions" to be provided in the camelcase options object, ignore any identifiers listed in the object.
Is there anything you'd like reviewers to focus on?
Nothing I can think of.