Is there a way to catch typos when writing CoffeeScript(编写 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/ 它告诉我你的代码是 lint免费!"
Also tried http://www.coffeelint.org/ and it tells me "Your code is lint free!"
推荐答案
您可以使用支持标识符拼写检查的IDE,例如IntelliJ IDEA,顺便说一句,它有一个用于CoffeScript编辑的插件.
You can use IDE which supports identifier spellchecking, for example, IntelliJ IDEA which BTW has a plugin for CoffeScript editing.
这篇关于编写 CoffeeScript 时有没有办法捕捉错别字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:编写 CoffeeScript 时有没有办法捕捉错别字
基础教程推荐
- 悬停时滑动输入并停留几秒钟 2022-01-01
- 当用户滚动离开时如何暂停 youtube 嵌入 2022-01-01
- 在 JS 中获取客户端时区(不是 GMT 偏移量) 2022-01-01
- 我什么时候应该在导入时使用方括号 2022-01-01
- 有没有办法使用OpenLayers更改OpenStreetMap中某些要素 2022-09-06
- 在for循环中使用setTimeout 2022-01-01
- Karma-Jasmine:如何正确监视 Modal? 2022-01-01
- 动态更新多个选择框 2022-01-01
- 角度Apollo设置WatchQuery结果为可用变量 2022-01-01
- 响应更改 div 大小保持纵横比 2022-01-01