standard-loader
raw JSON → 7.0.0 verified Sat Apr 25 auth: no javascript
A webpack loader that lints JavaScript code using JavaScript Standard Style (standard). Version 7.0.0 is current, with maintenance as needed. It integrates with webpack 2+ (webpack 1 dropped in v6). Key differentiators: leverages the popular 'standard' style guide, supports custom parsers like babel-eslint, emits detailed warnings/errors with snazzy output, and follows the conventional module format for webpack loaders.
Common errors
error Error: Cannot find module 'standard' ↓
cause Missing peer dependency 'standard'.
fix
npm install --save-dev standard
error Module build failed: Error: No matching loader for 'standard-loader' ↓
cause Loader not configured in webpack rules.
fix
Add standard-loader to module.rules with enforce: 'pre'.
error WARNING: Failed to load parser 'babel-eslint' ↓
cause Parser not installed.
fix
npm install --save-dev babel-eslint
Warnings
breaking webpack 1 support dropped in version 6.0.0. Use 5.x branch for webpack 1. ↓
fix Upgrade to webpack 2+ or use standard-loader@5.x.
deprecated Option 'emitErrors' is deprecated; use 'error' instead. ↓
fix Replace 'emitErrors: true' with 'error: true'.
gotcha Loader must be placed in 'rules' array, not 'loaders'. ↓
fix Use module.rules, not module.loaders.
gotcha standard must be installed as a peer dependency; not included automatically. ↓
fix Run 'npm install --save-dev standard-loader standard'.
Install
npm install standard-loader yarn add standard-loader pnpm add standard-loader Imports
- loader wrong
const standardLoader = require('standard-loader')correctimport 'standard-loader' - webpack config wrong
module.exports = { module: { loaders: [ { test: /\.jsx?$/, loader: 'standard' } ] } }correctmodule.exports = { module: { rules: [ { enforce: 'pre', test: /\.jsx?$/, loader: 'standard-loader', options: {} } ] } } - options wrong
options: { parser: 'babel-eslint', emitErrors: true }correctoptions: { parser: 'babel-eslint', error: false, snazzy: true, standard: 'standard' }
Quickstart
// webpack.config.js
module.exports = {
module: {
rules: [
{
enforce: 'pre',
test: /\.jsx?$/,
loader: 'standard-loader',
exclude: /node_modules/,
options: {
parser: 'babel-eslint',
snazzy: true
}
}
]
}
};