File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ variety of languages and technologies. These are things that don't really
7
7
warrant a full blog post. These are mostly things I learn by pairing with
8
8
smart people at [ Hashrocket] ( http://hashrocket.com/ ) .
9
9
10
- _ 368 TILs and counting..._
10
+ _ 369 TILs and counting..._
11
11
12
12
---
13
13
@@ -446,6 +446,7 @@ _368 TILs and counting..._
446
446
447
447
## Webpack
448
448
449
+ - [ Run ESLint As A Preloader] ( webpack/run-eslint-as-a-preloader.md )
449
450
- [ Use A Specific Config File] ( webpack/use-a-specific-config-file.md )
450
451
451
452
## Usage
Original file line number Diff line number Diff line change
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.
You can’t perform that action at this time.
0 commit comments