Skip to content

kylewelsby/karma-jshint-preprocessor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

karma-jshint-preprocessor

Code Climate Dependency Status Build Status

Preprocessor / Plugin for Karma to check JavaScript syntax on the fly.

NPM Package Stats

Installation

The easiest way is to keep karma-jshint-preprocessor as a devDependency in your package.json.

{
  "devDependencies": {
    "karma": "~0.10",
    "karma-jshint-preprocessor": "~0.1"
  }
}

You can simply do it by:

npm install karma-jshint-preprocessor --save-dev

Usage

In your karma.conf.js file, specify the files you want to have lint'ed in the preprocessor section like this.

...
preprocessors: {
  '*.js': ['jshint']
}
...

Optional jshintrc

Read an optional jshintrc property from the karma config to force a .jshintrc file to be used by jshint.

module.exports = function (config) {
  config.set({
    // ...
    jshintPreprocessor: {
      jshintrc: './.jshintrc'
    },
    // ...
  });
};

Thanks to Kl0tl for adding jshintrc path support.

JSHint configuration is read from a JSON formatted .jshintrc file within your project

Cancel build

Cancel the current build if a linting error has occurred. This can be useful on CI servers.

module.exports = function (config) {
  config.set({
    // ...
    jshintPreprocessor: {
      stopOnError: true
    },
    // ...
  });
};
Example .jshintrc file.
{
    "undef": true,
    "globals": {
        "angular": true
    }
}

View the full list of JSHint options.


For more information on Karma see the karma homepage.

About

Check Syntax of JavaScript using JSHint.

Resources

License

Stars

Watchers

Forks

Packages

No packages published