tslint-consistent-codestyle
tslint-consistent-codestyle copied to clipboard
naming-convention: Object properties are not linted
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"},
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.