Skip to content
This repository was archived by the owner on Jul 27, 2021. It is now read-only.

Commit 637eb84

Browse files
author
stavalfi
committed
#91 - recommending different eslint formatter and updated sandbox dependencies
1 parent 273ca3b commit 637eb84

11 files changed

+4129
-41
lines changed

.eslintignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
_sandbox
2+
test

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules/
22
.log
3+
.idea

README.md

+30-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,33 @@ errors get handled, please open a [PR](https://help.github.com/articles/creating
1919
npm install friendly-errors-webpack-plugin --save-dev
2020
```
2121

22+
##### Recommandetion
23+
24+
```bash
25+
npm install eslint-formatter-friendly --save-dev
26+
```
27+
28+
This is a different (non-default) eslint-loader formatter to show warnings and errors:
29+
30+
```javascript
31+
{
32+
loader: 'eslint-loader',
33+
options: {
34+
// ...
35+
formatter: require('eslint-formatter-friendly')
36+
}
37+
}
38+
```
39+
40+
The errors will look like this now:
41+
42+
![](https://i.imgur.com/Lfi6nMX.png)
43+
44+
instead of: (with the default eslint-loader formatter):
45+
46+
![](https://i.imgur.com/nw1ilxF.png)
47+
48+
2249
### Basic usage
2350

2451
Simply add `FriendlyErrorsWebpackPlugin` to the plugin section in your Webpack config.
@@ -52,6 +79,8 @@ If you use the webpack-dev-server, there is a setting in webpack's ```devServer`
5279
```javascript
5380
// webpack config root
5481
{
82+
// ...
83+
stats:'none', // if you don't run webpack from webpack-dev-server
5584
// ...
5685
devServer: {
5786
// ...
@@ -78,7 +107,7 @@ _Thanks to [webpack-dashboard](https://github.com/FormidableLabs/webpack-dashboa
78107

79108
![success](http://i.imgur.com/MkUEhYz.gif)
80109

81-
### eslint-loader errors
110+
### eslint-loader errors (with the default eslint-loader formatter)
82111

83112
![lint](http://i.imgur.com/xYRkldr.gif)
84113

_sandbox/.eslintrc

+20-15
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
{
2-
"root": true,
3-
"parser": "babel-eslint",
4-
"env": {
5-
"browser": true,
6-
"commonjs": true,
7-
"es6": true,
8-
"jest": true,
9-
"node": true
10-
},
2+
"parser": "@typescript-eslint/parser",
113
"parserOptions": {
124
"ecmaVersion": 6,
13-
"sourceType": "module"
5+
"sourceType": "module",
6+
"ecmaFeatures": {
7+
"classes": true,
8+
"modules": true,
9+
"legacyDecorators": true,
10+
"jsx": true
11+
}
12+
},
13+
"env": {
14+
"es6": true,
15+
"browser": true,
16+
"node": true,
17+
"mocha": true
1418
},
19+
"plugins": ["react", "@typescript-eslint"],
20+
"extends": [
21+
"eslint:recommended"
22+
],
1523
"rules": {
16-
// http://eslint.org/docs/rules/
17-
"no-unused-expressions": "warn",
18-
"no-unused-labels": "warn",
19-
"no-unused-vars": ["warn", { "vars": "local", "args": "none" }]
24+
"@typescript-eslint/no-unused-vars": "off"
2025
}
21-
}
26+
}

_sandbox/index.js

-9
This file was deleted.

_sandbox/index.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
3+
require('./my-app.tsx')

_sandbox/my-app.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const x =1
2+
console.log(x)
3+
4+
console.log(x+1)
5+

_sandbox/package.json

+24-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,29 @@
55
"repository": {},
66
"license": "MIT",
77
"scripts": {
8-
"start": "node watch.js"
8+
"start": "webpack --mode development --watch"
9+
},
10+
"devDependencies": {
11+
"@babel/core": "^7.4.4",
12+
"@babel/parser": "^7.4.4",
13+
"@babel/preset-react": "^7.0.0",
14+
"@typescript-eslint/eslint-plugin": "^1.10.2",
15+
"@typescript-eslint/parser": "^1.10.2",
16+
"babel-eslint": "^10.0.1",
17+
"babel-loader": "^8.0.5",
18+
"babel-preset-react": "^6.23.0",
19+
"eslint": "^5.16.0",
20+
"eslint-formatter-friendly": "^6.0.0",
21+
"eslint-loader": "^2.1.2",
22+
"eslint-plugin-react": "^7.13.0",
23+
"prettier": "^1.18.2",
24+
"typescript": "^3.5.2",
25+
"webpack": "^4.31.0",
26+
"webpack-cli": "^3.3.4"
27+
},
28+
"dependencies": {
29+
"@types/node": "^12.0.8",
30+
"react": "^16.8.6",
31+
"react-dom": "^16.8.6"
932
}
1033
}

_sandbox/webpack.config.js

+19-14
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,34 @@
11
const FriendlyErrorsWebpackPlugin = require('../index');
2+
const friendlyEslintFormatter = require('eslint-formatter-friendly')
23

34
module.exports = {
4-
entry: __dirname + "/index.js",
5+
entry: __dirname + "/index.tsx",
56
output: {
67
path: __dirname + "/dist",
78
filename: "bundle.js"
89
},
10+
stats:'none',
911
plugins: [
1012
new FriendlyErrorsWebpackPlugin()
1113
],
1214
module: {
13-
loaders: [
15+
rules: [
1416
{
15-
test: /\.js$/,
16-
loader: 'eslint-loader',
17-
enforce: 'pre',
18-
include: __dirname
19-
},
20-
{
21-
test: /\.jsx?$/,
22-
loader: 'babel-loader',
23-
query: {
24-
presets: ['react'],
25-
},
26-
exclude: /node_modules/
17+
test: /\.(ts|js)x?$/,
18+
exclude: /(node_module|dist)/,
19+
use: [
20+
{
21+
loader: 'babel-loader',
22+
options: {
23+
presets: ['@babel/preset-react'],
24+
},
25+
},
26+
{
27+
loader: 'eslint-loader',
28+
options: {
29+
}
30+
},
31+
],
2732
}
2833
]
2934
}

0 commit comments

Comments
 (0)