GithubHelp home page GithubHelp logo

coffeelint-loader's Introduction

coffeelint loader for webpack

Usage

Apply the coffeelint loader as pre/postLoader in your webpack configuration:

module.exports = {
	module: {
		preLoaders: [
			{
				test: /\.coffee$/, // include .coffee files
				exclude: /node_modules/, // exclude any and all files in the node_modules folder
				loader: "coffeelint-loader"
			}
		]
	},

	// more options in the optional coffeelint object
	coffeelint: {
		// any coffeelint option http://www.coffeelint.com/#options
		// i. e.
		camel_case_classes: 'error',

		// coffeelint errors are displayed by default as warnings
		// set emitErrors to true to display them as errors
		emitErrors: false,

		// coffeelint to not interrupt the compilation
		// if you want any file with coffeelint errors to fail
		// set failOnErrors to true
		failOnErrors: false,

    // same as failOnErrors but will throw an exception for
    // warnings as well
		failOnWarns: false,

		// custom reporter function
		reporter: function(results) {
      var errors = result.error;
      war warns = result.warn;
    }
	}
}

Custom reporter

By default, coffeelint-loader will provide a default reporter.

However, if you prefer a custom reporter, pass a function under the reporter key in coffeelint options. (see usage above)

The reporter function will be passed an object containing error and warn arrays produced by coffeelint with the following structure:

{
  error: [
    {
        rule :      'Name of the violated rule',
        lineNumber: 'Number of the line that caused the violation',
        level:      'The severity level of the violated rule',
        message:    'Information about the violated rule',
        context:    'Optional details about why the rule was violated'
    }
    //...
  ],
  warn: [
    {
      //...
    },
    //...
  ]
}

The reporter function will be excuted with the loader context as this. You may emit messages using this.emitWarning(...) or this.emitError(...). See webpack docs on loader context.

The output in webpack CLI will usually be:

...

WARNING in ./path/to/file.js
<reporter output>

...

License

MIT (http://www.opensource.org/licenses/mit-license.php)

coffeelint-loader's People

Contributors

airwin avatar bline avatar coobaha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

coffeelint-loader's Issues

failOnErrors doesn't work as expected

I tracked down where it's used

if(failOnErrors && result.error.length || failOnWarns && result.warn.length)

Problem is, that result.error will be always an object due to result[data[i].level] = data[i] so that above condition will never succeed.

Add to NPM?

Hi,

I can't see the package listed on NPM? Any chance you can publish it please?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.