Skip to content

Commit 0b625b9

Browse files
authored
Remove js-beautify and improve ESLint config (#590)
Before, there were two linters doing the same thing: linting and fixing lint errors. Now, there is only one, ESLint. The js-beautify config is merged in the ESLint config as best as I could do. There is almost no documentation about the rules of js-beautify, so this was a bit hard. ESLint was updated to v3, which provides auto-fixing of some rules. I also checked the new ESLint config against the main webpack repo. This caused some extra linting errors (~40), but these were all valid violations.
1 parent d6bfdd6 commit 0b625b9

File tree

10 files changed

+52
-65
lines changed

10 files changed

+52
-65
lines changed

.eslintrc

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,48 @@
11
{
22
"env": {
3-
"node": true
3+
"node": true,
4+
"browser": true
45
},
5-
"plugins": [
6-
"nodeca"
7-
],
86
"rules": {
9-
"strict": 0,
10-
"camelcase": 0,
11-
"curly": 0,
12-
"indent": [0, "tab"],
13-
"nodeca/indent": [2, "tabs", 1],
14-
"eol-last": 2,
15-
"no-shadow": 0,
16-
"no-redeclare": 2,
17-
"no-extra-bind": 2,
18-
"no-empty": 0,
19-
"no-process-exit": 2,
20-
"no-underscore-dangle": 0,
21-
"no-use-before-define": 0,
22-
"no-unused-vars": 0,
23-
"consistent-return": 0,
24-
"no-inner-declarations": 2,
25-
"no-loop-func": 2,
26-
"space-before-function-paren": [2, "never"]
7+
"indent": [2, "tab", { "SwitchCase": 1 }],
8+
"brace-style": ["error", "1tbs"],
9+
"no-eval": "error",
10+
"eol-last": "error",
11+
"no-redeclare": "error",
12+
"no-extra-bind": "error",
13+
"no-process-exit": "error",
14+
"no-inner-declarations": "warn",
15+
"no-loop-func": "warn",
16+
"no-undef": "error",
17+
"no-trailing-spaces": "error",
18+
"space-before-function-paren": ["error", "never"],
19+
"no-multi-spaces": "error",
20+
"space-in-parens": "error",
21+
"space-before-blocks": "error",
22+
"no-unused-vars": "error",
23+
"no-dupe-keys": "error",
24+
"valid-typeof": "error",
25+
"space-infix-ops": "error",
26+
"no-negated-in-lhs": "error",
27+
"no-octal": "error",
28+
"no-regex-spaces": "error",
29+
"no-self-assign": "error",
30+
"no-sparse-arrays": "error",
31+
"no-unexpected-multiline": "error",
32+
"no-unreachable": "error",
33+
"no-extra-semi": "error",
34+
"no-func-assign": "error",
35+
"no-invalid-regexp": "error",
36+
"keyword-spacing": ["error", {
37+
"after": false,
38+
"overrides": {
39+
"try": {"after": true},
40+
"else": {"after": true},
41+
"case": {"after": true},
42+
"return": {"after": true},
43+
"finally": {"after": true},
44+
"do": {"after": true}
45+
}
46+
}]
2747
}
2848
}

.jsbeautifyrc

Lines changed: 0 additions & 25 deletions
This file was deleted.

bin/webpack-dev-server.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env node
22

33
var path = require("path");
4-
var url = require("url");
54
var open = require("open");
65
var fs = require("fs");
76

@@ -130,7 +129,7 @@ var wpOpt = require("webpack/bin/convert-argv")(yargs, argv, {
130129
});
131130

132131
function processOptions(wpOpt) {
133-
//process Promise
132+
// process Promise
134133
if(typeof wpOpt.then === "function") {
135134
wpOpt.then(processOptions).catch(function(err) {
136135
console.error(err.stack || err);

client/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* global __resourceQuery */
12
var url = require('url');
23
var SockJS = require("sockjs-client");
34
var stripAnsi = require('strip-ansi');

client/live.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ var newConnection = function(handlers) {
2828
};
2929

3030
$(function() {
31-
var body = $("body").html(require("./page.pug")());
31+
$("body").html(require("./page.pug")());
3232
var status = $("#status");
3333
var okness = $("#okness");
3434
var $errors = $("#errors");
@@ -75,7 +75,7 @@ $(function() {
7575
$errors.hide();
7676
reloadApp();
7777
},
78-
warnings: function(warnings) {
78+
warnings: function() {
7979
okness.text("Warnings while compiling.");
8080
$errors.hide();
8181
reloadApp();

examples/hmr/hmr.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
require("./example");
22

3-
if (module.hot) {
3+
if(module.hot) {
44
module.hot.accept(function(err) {
5-
if (err) {
5+
if(err) {
66
console.error("Cannot apply hot update", err);
77
}
88
});

examples/node-api-middleware/webpack.config.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
var path = require('path');
2-
31
module.exports = {
42
context: __dirname,
53
entry: ["./app.js", "../../client/index.js?http://localhost:8080/"],

examples/node-api-simple/webpack.config.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
var path = require('path');
2-
31
module.exports = {
42
context: __dirname,
53
entry: ["./app.js", "../../client/index.js?http://localhost:8080/"],

examples/proxy-advanced/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = {
1010
'^/api': ''
1111
},
1212
bypass: function(req) {
13-
if (req.url === '/api/nope') {
13+
if(req.url === '/api/nope') {
1414
return '/bypass.html';
1515
}
1616
}

package.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,10 @@
2222
"yargs": "^4.7.1"
2323
},
2424
"devDependencies": {
25-
"beautify-lint": "^1.0.4",
2625
"css-loader": "~0.24.0",
27-
"eslint": "^2.10.1",
28-
"eslint-plugin-nodeca": "^1.0.3",
26+
"eslint": "^3.4.0",
2927
"file-loader": "~0.9.0",
3028
"jquery": "^2.2.0",
31-
"js-beautify": "^1.6.3",
3229
"less": "^2.5.1",
3330
"less-loader": "~2.2.0",
3431
"pug": "^2.0.0-beta5",
@@ -54,8 +51,7 @@
5451
"scripts": {
5552
"prepublish": "webpack ./client/live.js client/live.bundle.js --color --config client/webpack.config.js -p && webpack ./client/index.js client/index.bundle.js --color --config client/webpack.config.js -p",
5653
"lint": "eslint bin lib test examples client/{index,live,webpack.config}.js",
57-
"beautify-lint": "beautify-lint lib/**.js bin/**.js client/{index,live,webpack.config}.js",
58-
"beautify": "beautify-rewrite lib/**.js bin/**.js client/{index,live,webpack.config}.js",
59-
"travis": "npm run lint && npm run beautify-lint && node lib/Server.js"
54+
"beautify": "npm run lint -- --fix",
55+
"travis": "npm run lint && node lib/Server.js"
6056
}
6157
}

0 commit comments

Comments
 (0)