【问题标题】:Eclipse JavaScript code formatter and JSHint anonymous function format conflictEclipse JavaScript 代码格式化程序和 JSHint 匿名函数格式冲突
【发布时间】:2012-03-05 23:15:37
【问题描述】:

我正在使用 Eclipse(版本 Indigo)JavaScript 代码格式化程序并使用带有 white: true 选项的 jshint-eclipse 插件进行代码约定验证。

Eclipse 代码格式化程序和 JSHint 插件与匿名函数声明格式冲突。 JavaScript 代码格式化程序格式化匿名函数,如下所示:

var f1 = function() {
};

但是 jshint-eclipse 插件会给出“函数后缺少空格”的警告。 这个插件的正确格式是:

var f1 = function () {
};

注意函数后面的空格

有没有办法用 eclipse 来格式化匿名函数声明而不是常规函数声明。我想在匿名函数的“函数”之后添加一个空格,但不是普通函数。

谢谢。

更新一个相关的 Eclipse 错误是 here

【问题讨论】:

    标签: eclipse anonymous-function jslint formatter jsdt


    【解决方案1】:

    这里有一个错误:https://bugs.eclipse.org/bugs/show_bug.cgi?id=315507

    修复了 Aptana 中的类似错误:http://jira.appcelerator.org/browse/APSTUD-3792

    我为此制定了一个补丁:https://github.com/eclipse/webtools.jsdt.core/pull/1 希望很快会被合并和发布。

    【讨论】:

      【解决方案2】:

      检查 White Space 选项卡上的 JavaScript 格式化首选项(Preference->JavaScript->Code Style->Formatter)中的函数声明。

      【讨论】:

      • 感谢您回答 nitind。我检查了,但无法为匿名函数声明和常规函数声明分别设置声明格式。
      猜你喜欢
      • 2012-11-23
      • 2011-08-26
      • 1970-01-01
      • 1970-01-01
      • 2019-10-29
      • 2020-03-23
      • 1970-01-01
      • 1970-01-01
      • 2016-10-09
      相关资源
      最近更新 更多