Is there an atom package that alerts for similar but non-identical variables?


#1

I have realized that I often miss-spell variables names throughout my codes. I can’t find package that would alert me for similar variable names:

var someCoolName = 0;
//other code

function whatever(){
   pass;
}

somCoolName++;

In this case, it would be helpful to highlight the similar names someCoolName and somCoolName.

Have you come across a package that does this or do you know of another tool that would help with this?


#2

Have you heard of linters? They should alert you if you type a variable name that doesn’t exist, as well as keep your code looking nice. Since it looks like you’re writing JavaScript maybe try installing the atom-ide-ui, ide-typescript, and linter-eslint packages.

  • atom-ide-ui is the underlying UI
  • ide-typescript will give you warnings about compilation errors (what you’re asking for, and despite its name does not require that your code be TypeScript)
  • linter-eslint will also do that to some extent but additionally allows you to choose a code style so that everything is consistent (learn more at https://eslint.org/)

#3

It’s not quite what I was looking for. This allows to “find references” but I was looking for automatically highlighting undefined variables. But I figure that “strict mode” in javascript will solve this. Anyway, it would have been cool to have the editor take over this job.

Thanks Wliu


#4

eslint does that but requires some configuration. Check linter-eslint readme under Using ESLint for more information.