Or Barmatz
Or Barmatz

Reputation: 307

JSHint error when running Grunt with QUnit

I am running a Grunt build with JSHint and QUnit. On my first test run I get the following:

Running "jshint:files" (jshint) task
Linting test/libs/qunit-1.11.0.js...ERROR
[L661:C22] W069: ['throws'] is better written in dot notation.
QUnit.raises = assert[ "throws" ];
[L1590:C33] W103: The '__proto__' property is deprecated.
      return obj.__proto__;

Warning: Task "jshint:files" failed. Use --force to continue.

Aborted due to warnings.

Besides editing the QUnit source code and using --force, what can I do with this?

Upvotes: 1

Views: 2798

Answers (1)

James Allardice
James Allardice

Reputation: 166041

To expand upon my comment, assuming Grunt >0.4 and the grunt-contrib-jshint plugin, you can select specific files to run JSHint against. The JSHint Grunt plugin accepts standard glob patterns:

grunt.initConfig({
    jshint: {
        all: [
            'Gruntfile.js',
            'lib/**/*.js',
            'test/**/*.js'
        ]
    }
});

That example (from the JSHint Grunt plugin readme) will select any .js file within the lib and test directories (and their subdirectories), as well as the Gruntfile.js file. I would suggest moving 3rd party libraries out of your main lib directory. A common convention is to add a vendor directory for such scripts.

If the 3rd party scripts you rely upon are available via npm, you could also simply include them in your package.json file, and obviously leave the node_modules directory out of your Grunt config. It would then be up to your build process to move the necessary files into the right place within your app structure.

Upvotes: 2

Related Questions