/broccoli-lint-eslint

Integrates JavaScript linting with ESLint as part of your Broccoli build pipeline.

Primary LanguageJavaScriptMIT LicenseMIT

broccoli-lint-eslint

Latest NPM release TravisCI Build Status License Dependencies Dev Dependencies

Lint JavaScript with ESLint as part of your Broccoli build pipeline.

Most of the test setup and the build configuration is based on sindresorhus/grunt-eslint. The internal validation is heavily inspired by eslint cli.js.

Installation

As of 3.0.0, broccoli-lint-eslint uses versions of eslint greater than 3.0.0. Because eslint@3.0.0 dropped support for Node versions below 4, you may need to use the latest 2.x version of broccoli-lint-eslint (which uses eslint@2.13.1), if your support needs also fall below Node v4:

npm install broccoli-lint-eslint@2.4.1

If versions of Node >= 4 suit your needs, you can safely install the latest version of broccoli-lint-eslint:

npm install --save-dev broccoli-lint-eslint

Usage

var eslint = require('broccoli-lint-eslint');
var outputNode = eslint(inputNode, options);

API

  • inputNode A Broccoli node

  • options {Object}

    • format {string|function}: The path, or function reference, to a custom formatter (See eslint/tree/master/lib/formatters for alternatives).

      Default: 'eslint/lib/formatters/stylish'

    • testGenerator {function(relativePath, errors), returns reporter output string}: The function used to generate test modules. You can provide a custom function for your client side testing framework of choice.

      Default: null

      • relativePath - The relative path to the file being tested.
      • errors - An array of eslint error objects found.

      Example usage:

      var path = require('path');
      
      function testGenerator(relativePath, errors) {
        return "module('" + path.dirname(relativePath) + '");";
               "test('" + relativePath + "' should pass jshint', function() { " +
               "  ok(passed, moduleName+" should pass jshint."+(errors ? "\n"+errors : '')); " +
               "});
      };
      
      return eslint(inputNode, {
        options: {
          configFile: this.jshintrc.app + '/eslint.json',
          rulesdir: this.jshintrc.app
        },
        testGenerator: testGenerator
      });
    • throwOnError {boolean}: Cause exception error on first severe error.

      Default: false

    • options {options}: Options native to ESLint CLI that broccoli-lint-eslint makes use of:

      • configFile {string}: Path to eslint configuration file.

        Default: ./eslintrc

      • rulePaths {Array}: Paths to a directory with custom rules. Your custom rules will be used in addition to the built-in ones. Recommended read: Working with Rules.

        Default: built-in rules directory

      • ignore {boolean}: false disables use of .eslintignore, ignorePath and ignorePattern

        Default: true