1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-04 23:58:01 +00:00

Add Run ESLint As A Preloader as a webpack til

This commit is contained in:
jbranchaud
2016-03-19 11:40:53 -05:00
parent dd20607329
commit fb1956c5de
2 changed files with 31 additions and 1 deletions

View File

@@ -0,0 +1,29 @@
# Run ESLint As A Preloader
You may already be running [ESLint](http://eslint.org/) manually or as a
script command via `npm`. You can also include it as part of the Webpack
build process. By adding it as a *preloader*, Webpack will lint your
JavaScript files before running other loaders. The results of
linting will be reported in the terminal. Assuming you've already installed
`eslint` and set up your `.eslintrc` file, all you need to do is `npm
install --save-dev eslint-loader` and then add something like the following
to your `webpack.config.js` file:
```javascript
module: {
preLoaders: [
{
test: /\.js$/,
loaders: ['eslint'],
exclude: /node_modules/,
}
],
...
}
```
Running something like `webpack -w` will now lint your JavaScript before
running other loaders.
Depending on your project, you may also want to include `babel-eslint` and
`eslint-plugin-react` with your setup.