Is there a way to catch typos when writing CoffeeScript

This little CoffeeScript contains a typo

drinks = "Coffee" drinks = drinks + ", " + "Tea" drinsk = drinks + ", " + "Lemonade" alert drinks 

The goal was to warn "Coffee, tea, lemonade", but instead it turns out "Coffee, tea." The generated JavaScript is still valid and passes JSLint; he declares variables before use, which is good, but his variables are incorrect.

 var drinks, drinsk; drinks = "Coffee"; drinks = drinks + ", " + "Tea"; drinsk = drinks + ", " + "Lemonade"; alert(drinks); 

If the same example was written in plain JavaScript, JSLint would catch an error:

 var drinks; drinks = "Coffee"; drinks = drinks + ", " + "Tea"; drinsk = drinks + ", " + "Lemonade"; alert(drinks); ------------------ Problem at line 4 character 1: 'drinsk' was used before it was defined. drinsk = drinks + ", " + "Lemonade"; 

To the question: Is there a way to save the errors that I create so that they can be found? I would love to see tools like JSLint still work.

Also tried http://www.coffeelint.org/ and he tells me: "Your code is free!"

+4
source share
2 answers

You can use an IDE that supports spelling on an identifier, such as IntelliJ IDEA, which BTW has a CoffeScript editing plugin for.

+4
source

I would solve this by writing specifications for your JavaScript. Tools like Lint are great, but there are many more mistakes you can make.

Personally, I use jasmine through jasmine-headless-webkit for this

+2
source

Source: https://habr.com/ru/post/1403026/


All Articles