DEV Community

loading...

Discussion on: Stop Using "data" as a Variable Name

Collapse
ricardo profile image
Ricardo Luz

Hey Devin, thanks for sharing your thoughts in this outstanding article! You commented about use lint to enforce some name patterns. However, I never heard about some linter that does that, do you know someone? Otherwise, it's a great idea to a new open source project! I am already using a vscode plugin to typo check, and it's helping me to avoid this kind of errors once English isn't my mother tongue, as well as find errors left by other devs and fix it.

Collapse
dcwither profile image
Devin Witherspoon Author

I’m not sure if there’s any open source project doing this or if it’s even feasible to do in a generic manner. Some things like checking for returning a promise/async function to avoid get would be easy enough.

Taking advantage of team conventions, you could enforce that there is a prefix on functions, and that some prefixes are applied correctly - though there’s a limit to how much you can do here(e.g. you could enforce that if it returns a Boolean literal it must begin with is, can, or should, but that doesn’t cover all cases).

Because this kind of linter would benefit from knowing team conventions, I don’t think it would be very effective as an open source project.