SagiLow
SagiLow

Reputation: 6029

ESlint rule for function names with TypeScript (camelCase with lower case for first letter)

Following these guidelines (and almost any other), functions and var names should use lowerCamelCase while Class (and c'tors) names should use UpperCamelCase.

I've looked for an ESLint rule to enforce this convention but the closest I've found is id-match which doesn't seem to distinguish between function, var, or class.

Is there a better rule? Should I be using the id-match rule along with new-cap rule? (feels dirty)

Upvotes: 1

Views: 1652

Answers (2)

ekcrisp
ekcrisp

Reputation: 1911

This is now supported, use the defined selectors such as "variable" and "typeLike" to the add rules

https://typescript-eslint.io/rules/naming-convention/

Upvotes: 0

FranBran
FranBran

Reputation: 1027

Unfortunately it seems like there is no better option at the moment...

Unfortunately, it looks like there wasn't enough interest from the team or community to implement this change. While we wish we'd be able to accommodate everyone's requests, we do need to prioritize. We've found that issues failing to reach accepted status after 21 days tend to never be accepted, and as such, we close those issues. This doesn't mean the idea isn't interesting or useful, just that it's not something the team can commit to. https://github.com/eslint/eslint/issues/10473

Upvotes: 1

Related Questions