0

在我用于项目的 pom.xml 文件中,我为 jsLint 设置了以下内容:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>jslint-maven-plugin</artifactId>
    <version>1.0.1</version>
    <executions>
            <execution>
                    <goals>
                            <goal>jslint</goal>
                            <goal>test-jslint</goal>
                    </goals>
            </execution>
    </executions>
    <configuration>

            <excludes>
                    <exclude>**/vendor/*</exclude>
            </excludes>
    </configuration>
</plugin>

在我的 js 文件的顶部,我有以下内容:

/*jslint nomen: true, browser: true, devel: true*/

在文件中,我有一个名为:

Api.prototype._call = function (query) {...};

我这样称呼:

Api.prototype.product = function (options) {
            ...
            return this._call(query);
        };

现在对于奇怪的事情......

如果我用它编译它,mvn clean install我会收到以下错误消息:

api.js:45:29:Unexpected dangling '_' in '_call'.

但是,如果我恢复 nomen 的标志,说nomen: falsemvn 不会抱怨!

另一方面,这导致 IntelliJ_call用红色标记标记代码的一部分,因为它正在使用 jsLint。

4

1 回答 1

0

它肯定看起来像“jslint-maven-plugin”插件中的一个错误。

官方 JSLint 文档说 nomen 是“true如果不应该检查名称的首字母或尾随下划线” 。您还可以使用jslint.com 上的选项复选框进行验证

“jslint-maven-plugin”源代码似乎是倒退的:如果你在源代码中搜索“nomen” ,你会看到他们把它映射到一个叫做的东西disallowDanglingUnderbarInIdentifiers——与什么意思相反。nomen(我不完全确定这如何转化为覆盖JS 文件的配置设置,但它确实看起来很可疑)。

看起来你可以在插件上提交一个错误,如果这是任何安慰的话。

于 2013-11-08T04:46:31.140 回答