是否有办法在写CoffeeScript时捕获错别字 [英] Is there a way to catch typos when writing CoffeeScript

查看:103
本文介绍了是否有办法在写CoffeeScript时捕获错别字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个小CoffeeScript包含拼写错误

This small CoffeeScript contains a typo

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

目的是提醒咖啡,茶,柠檬水,但结果是咖啡,茶。
生成的JavaScript仍然有效并传递JSLint;它声明变量在使用之前,
是好的,但它的错误变量。

The intention was to alert "Coffee, Tea, Lemonade" but the result is instead "Coffee, Tea". The generated JavaScript is still valid and passes JSLint; it declares the variables before usage which is good, but its the wrong variables.

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

如果相同的示例是用纯JavaScript编写的,那么JSLint会捕获错误:

If the same example was written in plain JavaScript then JSLint would catch the 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";

问题:是否有办法保留错误所以我可以找到他们?我很想看到像JSLint这样的工具仍然可以工作。

To the question: Is there a way to keep the errors I make so that I can find them? I would love to see tools like JSLint still work.

也试过 http://www.coffeelint.org/ ,它告诉我您的代码不存在!

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

推荐答案

您可以使用支持标识符拼写检查的IDE,例如IntelliJ IDEA,其中BTW有一个用于CoffeScript编辑的插件。

You can use IDE which supports identifier spellchecking, for example, IntelliJ IDEA which BTW has a plugin for CoffeScript editing.

这篇关于是否有办法在写CoffeeScript时捕获错别字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆