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

camelcase: new allow option strips underscores before checking name #11000

Closed
lukeapage opened this issue Oct 21, 2018 · 0 comments
Closed

camelcase: new allow option strips underscores before checking name #11000

lukeapage opened this issue Oct 21, 2018 · 0 comments

Comments

@lukeapage
Copy link
Contributor

@lukeapage lukeapage commented Oct 21, 2018

Tell us about your environment

  • ESLint Version: 3.7.0
  • Node Version: 8
  • npm Version: 6

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

Please show your full configuration:

Configuration
        "camelcase": [
            "error",
            {
                "properties": "always",
                "allow": ["webpack_public_path", "UNSAFE_componentWillMount", "UNSAFE_componentWillRecieveProps", "UNSAFE_componentWillUpdate"]
            }
        ],

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

__webpack_public_path__ = config.publicPath;

What did you expect to happen?

No Errors

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

An error occurred.

Its quite clear from the code what went wrong:

                /*
                 * Leading and trailing underscores are commonly used to flag
                 * private/protected identifiers, strip them
                 */
                const name = node.name.replace(/^_+|_+$/g, ""),
                    effectiveParent = (node.parent.type === "MemberExpression") ? node.parent.parent : node.parent;

                // First, we ignore the node if it match the ignore list
                if (isAllowed(name)) {
                    return;
                }

It strips _ only when there is more than one at the beginning or end. This is quite counter intuitive that I need to also strip them for the allow option.

lukeapage added a commit to lukeapage/eslint that referenced this issue Oct 21, 2018
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators May 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant