You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Compound words are formed by joining together two or more other words. Closed-form compound words do that without a hyphen/space. They are words in their own right, and should be treated as such when applying programming casing conventions.
Time and again I see these words incorrectly treated as separate words for the purpose of camelCase. This causes the following problems:
confusion and bugs when code using one form interacts with code using the other form
spread of incorrect form throughout codebase in the name of consistency
Some of these are arguably OK, others are definitely not.
Existing solutions
The ESLint rule id-blacklist can be configured to disallow a list of identifiers. It has some limitations (by design) which make it less than ideal for this problem:
Only works on complete names, i.e. would not detect isInViewPort
ESLint rule options configured in a shareable config cannot be extended/merged by an extending config; the entire options object must be copied into the extending config.
The text was updated successfully, but these errors were encountered:
I think it's more common when developers with less good English are (or previously were) working on a project.
A clever approach for the word list might analyse a Hunspell dictionary to identify compound words, either at plugin build-time or at runtime. I'm not convinced that effort would be justified, so a manual list of words that come up in development would be simpler and sufficient.
This rule would fail when the constituent part of closed-form compound words are capitalised.
Fail
Pass
Problem statement
Compound words are formed by joining together two or more other words. Closed-form compound words do that without a hyphen/space. They are words in their own right, and should be treated as such when applying programming casing conventions.
Time and again I see these words incorrectly treated as separate words for the purpose of camelCase. This causes the following problems:
Examples
Standalone: callBack, dataBase, fileName, lookUp, offLine, onLine, overRide, passWord, payLoad, placeHolder, preView, setUp, unSubscribe, userName, viewPort, weekEnd
Combined: isInViewPort, showPreView, isOnLine
Some of these are arguably OK, others are definitely not.
Existing solutions
The ESLint rule id-blacklist can be configured to disallow a list of identifiers. It has some limitations (by design) which make it less than ideal for this problem:
isInViewPort
The text was updated successfully, but these errors were encountered: