Skip to content

kentcdodds/eslint-loader

 
 

Repository files navigation

eslint-loader Build Status

eslint loader for webpack

Install

$ npm install eslint-loader

Usage

In your webpack configuration

module.exports = {
  // ...
  module: {
    loaders: [
      {test: /\.js$/, loader: "eslint-loader", exclude: /node_modules/}
    ]
  }
  // ...
}

Options

You can pass directly some eslint options by adding an eslint entry in you webpack config:

module.exports = {
  eslint: {
    configFile: 'path/.eslintrc'
  }
}

reporter (default: eslint stylish reporter)

Loader accepts a function that will have one argument: an array of eslint messages (object). The function must return the output as a string. You can use official eslint reporters. Please note that every lines with the filename will be skipped from output because of the way the loader use eslint (just with a string of text, not a file - so no filename available)

module.exports = {
  entry: "...",
  module: {
    // ...
  }
  eslint: {
    // several examples !

    // default value
    reporter: require("eslint/lib/formatters/stylish"),

    // community reporter
    reporter: require("eslint-friendly-formatter"),

    // custom reporter
    reporter: function(results) {
      // `results` format is available here
      // http://eslint.org/docs/developer-guide/nodejs-api.html#executeonfiles()
      
      // you should return a string
      // DO NOT USE console.*() directly !
      return "OUTPUT"
    }
  }
}

Errors and Warning

By default the loader will auto adjust error reporting depending on eslint errors/warnings counts. You can still force this behavior by using emitError or emitWarning options:

emitError (default: false)

Loader will always returns errors if this option is set to true.

module.exports = {
  entry: "...",
  module: {
    // ...
  }
  eslint: {
    emitErrors: true
  }
}
emitWarning (default: false)

Loader will always returns warning if option is set to true.

quiet (default: false)

Loader will process and report errors only and ignore warnings if this option is set to true

module.exports = {
  entry: "...",
  module: {
    // ...
  }
  eslint: {
    quiet: true
  }
}

About

eslint loader (for webpack)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%