question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The camelcase rule does not allow leading/trailing underscores for variable names

See original GitHub issue

Tell us about your environment

  • ESLint Version: v4.13.0
  • Node Version: v8.9.3
  • npm Version: v5.5.1

What parser (default, Babel-ESLint, etc.) are you using? default

Please show your full configuration:

Configuration
{
    "parserOptions": {
        "ecmaVersion": 8,
        "sourceType": "module",
        "ecmaFeatures": {}
    },
    "rules": {
        "camelcase": 2
    },
    "env": {}
}

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

Contents of test.js:

function shouldAllowUndercoreVars() {
	let { _value } = this;
	return _value;
}
shouldAllowUndercoreVars()

Shell command used:

eslint test.js

This is currently reproducible on the eslint demo site: https://eslint.org/demo/#eyJ0ZXh0IjoiZnVuY3Rpb24gc2hvdWxkQWxsb3dVbmRlcmNvcmVWYXJzKCkge1xuXHRsZXQgeyBfdmFsdWUgfSA9IHRoaXM7XG5cdHJldHVybiBfdmFsdWU7XG59XG5zaG91bGRBbGxvd1VuZGVyY29yZVZhcnMoKSIsIm9wdGlvbnMiOnsicGFyc2VyT3B0aW9ucyI6eyJlY21hVmVyc2lvbiI6OCwic291cmNlVHlwZSI6Im1vZHVsZSIsImVjbWFGZWF0dXJlcyI6e319LCJydWxlcyI6eyJjYW1lbGNhc2UiOjJ9LCJlbnYiOnt9fX0=

What did you expect to happen? I would have expected it to allow the variable name based on the camelcase docs docs quoted below:

It ignores leading and trailing underscores and only checks those in the middle of a variable name.

What actually happened? Please include the actual, raw output from ESLint.

/Users/kyle/tmp/test.js
  2:8  error  Identifier '_value' is not in camel case  camelcase

✖ 1 problem (1 error, 0 warnings)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

5reactions
platinumazurecommented, Dec 9, 2017

I’m hoping the team agrees that this should justify a patch release; if so, that patch release will probably occur sometime on Monday. Thanks for your patience and thank you also for testing the change!

3reactions
platinumazurecommented, Dec 9, 2017

Agreed, this seems to only apply to destructuring however.

No lint errors:

const _value = true;

Has lint errors (incorrectly):

const { _value } = obj;

@KylePDavis Does this occur in 4.12.x for you? Wondering if this was a side-effect of #9468.

Read more comments on GitHub >

github_iconTop Results From Across the Web

camelcase - ESLint - Pluggable JavaScript Linter
It ignores leading and trailing underscores and only checks those in the middle of a variable name. If ESLint decides that the variable...
Read more >
TSLint : variable name must be in camelcase or uppercase
You can solve the problem by editing your tslint.json and adding "allow-leading-underscore" to the "variable-name" array of your "rules" .
Read more >
variable-name - Rule
"allow-leading-underscore" allows underscores at the beginning (only has an effect if “check-format” specified); "allow-pascal-case" allows PascalCase in ...
Read more >
Enforces naming conventions for everything across a ... - GitLab
This rule allows you to enforce conventions for any identifier, ... forbid - a leading/trailing underscore is not allowed at all.
Read more >
What is snake case? - TheServerSide.com
A developer should never use a leading or trailing underscore with snake case. A leading or trailing underscore in a variable name is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found