A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://npmjs.com/package/jshint-loader below:

jshint-loader - npm

jshint Loader

jshint loader for Webpack.

Install

npm i jshint-loader --save

Usage

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

module.exports = {

    module: {

        preLoaders: [

            {

                test: /\.js$/, 

                exclude: /node_modules/, 

                loader: "jshint-loader"

            }

        ]

    },

 

    

    jshint: {

        

        

        camelcase: true,

 

        

        

        emitErrors: false,

 

        

        

        

        failOnHint: false,

 

        

        reporter: function(errors) { }

    }

}

Custom reporter

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

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

The reporter function will be passed an array of errors/warnings produced by jshint with the following structure:

[

{

    id:        [string, usually '(error)'],

    code:      [string, error/warning code],

    reason:    [string, error/warning message],

    evidence:  [string, a piece of code that generated this error]

    line:      [number]

    character: [number]

    scope:     [string, message scope;

                usually '(main)' unless the code was eval'ed]

 

    [+ a few other legacy fields that you don't need to worry about.]

},

]

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.

Note: jshint reporters are not compatible with jshint-loader! This is due to the fact that reporter input is only processed from one file; not multiple files. Error reporting in this manner differs from tranditional reporters for jshint since the loader plugin (i.e. jshint-loader) is executed for each source file; and thus the reporter is executed for each file.

The output in webpack CLI will usually be:

...

 

WARNING in ./path/to/file.js

<reporter output>

 

...

`

Maintainers

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4