Registry / testing / jshint-loader

jshint-loader

JSON →
library0.8.4jsnpmunverified

jshint-loader is a Webpack loader that integrates JSHint linting into the Webpack build process. The current stable version is 0.8.4, released in February 2017, with no further updates. It runs JSHint as a pre-loader to check JavaScript files before bundling. Key differentiators: it supports custom reporters and can emit errors or warnings, but reporters are not compatible with standard JSHint reporters. It requires JSHint as a peer dependency.

npm install jshint-loader
INSTALL
IMPORT
SIG · JSHINT-LOADER
J
jshint-loader
testingjavascriptv0.8.4
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
module.exports = { module: { preLoaders: [{ test: /\.js$/, exclude: /node_modules/, loader: 'jshint-loader' }] } }
const jshintLoader = require('jshint-loader');
Loader is used via Webpack config, not imported directly.
jshint config object
module.exports = { jshint: { camelcase: true } }
const jshint = require('jshint-loader').config;
Options are placed under the 'jshint' key in Webpack config.
reporter function
module.exports = { jshint: { reporter: function(errors) { this.emitWarning(errors[0].reason); } } }
// Using standard JSHint reporter like 'jshint-stylish'
Reporter receives array of errors and uses loader context (this.emitWarning/Error). Standard JSHint reporters are not compatible.

Install jshint-loader and jshint, then configure Webpack to run JSHint as a pre-loader with options.

npm install jshint-loader jshint --save-dev // webpack.config.js module.exports = { module: { preLoaders: [ { test: /\.js$/, exclude: /node_modules/, loader: 'jshint-loader' } ] }, jshint: { curly: true, eqeqeq: true, emitErrors: true, failOnHint: false } };
Debug
Known issues
breakingIn Webpack 1, preLoaders key is used; in Webpack 2+ it has been replaced by 'rules' with 'enforce: pre'.
fix
For Webpack 2+, use: rules: [{ test: /\.js$/, enforce: 'pre', exclude: /node_modules/, loader: 'jshint-loader' }]
affects: >=1.0.0 <2.0.0
deprecatedWebpack 2+ deprecated preLoaders in favor of enforce: pre.
fix
Use module.rules with enforce: 'pre' instead of preLoaders.
affects: >=2.0.0
gotchaStandard JSHint reporters are not compatible with jshint-loader. They will not produce output.
fix
Implement a custom reporter function that uses this.emitWarning() or this.emitError()
affects: >=0.8.0
gotchaLoader will not run on files excluded by /node_modules/ unless explicitly included.
fix
Ensure test pattern includes files you want linted and exclude node_modules.
affects: >=0.8.0
Errors
Common errors & fixes
Module parse failed: Unexpected token (1:2) You may need an appropriate loader to handle this file type.
jshint-loader is used as pre-loader but Webpack 2+ expects 'enforce: pre' instead of preLoaders.
fix
Update config: module: { rules: [{ test: /\.js$/, enforce: 'pre', loader: 'jshint-loader' }] }
ERROR in ./src/app.js Module build failed: TypeError: Cannot read property 'length' of undefined
jshint options object is missing or malformed.
fix
Ensure jshint key in config is an object with valid options.
WARNING: No reporter specified. Using default.
Custom reporter function may not be passed correctly or is not exporting properly.
fix
Check that reporter is a function set under jshint.reporter.
Upgrade
Version history
0.8.4latest on npm
Audit
Dependencies
jshintrequiredpeer dependency required to perform linting
Agent activity
15 hits · last 30 days
node
12
Amazon
1
Resources
jshint-loader — npm install jshint-loader · libregistry