Skip to content

Commit fb1956c

Browse files
committed
Add Run ESLint As A Preloader as a webpack til
1 parent dd20607 commit fb1956c

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ variety of languages and technologies. These are things that don't really
77
warrant a full blog post. These are mostly things I learn by pairing with
88
smart people at [Hashrocket](http://hashrocket.com/).
99

10-
_368 TILs and counting..._
10+
_369 TILs and counting..._
1111

1212
---
1313

@@ -446,6 +446,7 @@ _368 TILs and counting..._
446446

447447
## Webpack
448448

449+
- [Run ESLint As A Preloader](webpack/run-eslint-as-a-preloader.md)
449450
- [Use A Specific Config File](webpack/use-a-specific-config-file.md)
450451

451452
## Usage

webpack/run-eslint-as-a-preloader.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Run ESLint As A Preloader
2+
3+
You may already be running [ESLint](http://eslint.org/) manually or as a
4+
script command via `npm`. You can also include it as part of the Webpack
5+
build process. By adding it as a *preloader*, Webpack will lint your
6+
JavaScript files before running other loaders. The results of
7+
linting will be reported in the terminal. Assuming you've already installed
8+
`eslint` and set up your `.eslintrc` file, all you need to do is `npm
9+
install --save-dev eslint-loader` and then add something like the following
10+
to your `webpack.config.js` file:
11+
12+
```javascript
13+
module: {
14+
preLoaders: [
15+
{
16+
test: /\.js$/,
17+
loaders: ['eslint'],
18+
exclude: /node_modules/,
19+
}
20+
],
21+
...
22+
}
23+
```
24+
25+
Running something like `webpack -w` will now lint your JavaScript before
26+
running other loaders.
27+
28+
Depending on your project, you may also want to include `babel-eslint` and
29+
`eslint-plugin-react` with your setup.

0 commit comments

Comments
 (0)