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

naming-convention: Object properties are not linted #110

Open
funky-jojo opened this issue Feb 9, 2019 · 1 comment
Open

naming-convention: Object properties are not linted #110

funky-jojo opened this issue Feb 9, 2019 · 1 comment

Comments

@funky-jojo
Copy link

I have rules that set the naming-convention to camelCase by default, but it does not work for object variables.

Example: The Test name should be flagged as a rule violation, but it is not.

        let foo = {
            Test: ""
        };

        let a = foo.Test;

Here is the rule I am using:

{"type": "default", "format": "camelCase", "leadingUnderscore": "forbid", "trailingUnderscore": "forbid"},

@ajafff
Copy link
Owner

ajafff commented Feb 19, 2019

The rule currently doesn't check object literal properties.
Typically there is a contextual type for the object literal, i.e. the variable you are assigning the object to is typed by an interface. If that interface is declared in your code, it is already linted by this rule. If it's from an external dependency, you most likely don't have control over the naming.

For example GitHub's API uses snake_case for option properties. You need to follow this naming convention when using the API but don't want to change the rule for the rest of your code. Therefore I think linting object literal properties is not a good idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants