mavenjslintmojo

Does Mojo use jslint nomen flag backwards?


In my pom.xml file which I use for my project I've set the following up for 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>

And at the top of my js-file I have the following:

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

And within the file I have a method called:

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

Which I call like this:

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

And now for the strange things...

If I compile this with mvn clean install I get the following error message:

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

But if I revert the flag for nomen to say nomen: false mvn does not complain!

This on the other hand leads to that IntelliJ marks the _call part of the code with a red marker since it is beaking jsLint.


Solution

  • It certainly looks like a bug in the "jslint-maven-plugin" plugin.

    The official JSLint docs say nomen is "true if names should not be checked for initial or trailing underbars." You can also verify that with the options checkboxes on jslint.com.

    The "jslint-maven-plugin" source code appears to have it backwards: if you search for "nomen" in the source code, you'll see they have it mapped to something called disallowDanglingUnderbarInIdentifiers -- the inverse of what nomen means. (I'm not entirely sure how that translates into overriding the config settings in the JS file, but it certainly seems suspicious).

    It looks like you can file a bug here on the plugin, if that's any consolation.