Skip to content

Commit

Permalink
Remove js-beautify and improve ESLint config (#590)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
SpaceK33z authored Sep 4, 2016
1 parent d6bfdd6 commit 0b625b9
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 65 deletions.
64 changes: 42 additions & 22 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,28 +1,48 @@
{
"env": {
"node": true
"node": true,
"browser": true
},
"plugins": [
"nodeca"
],
"rules": {
"strict": 0,
"camelcase": 0,
"curly": 0,
"indent": [0, "tab"],
"nodeca/indent": [2, "tabs", 1],
"eol-last": 2,
"no-shadow": 0,
"no-redeclare": 2,
"no-extra-bind": 2,
"no-empty": 0,
"no-process-exit": 2,
"no-underscore-dangle": 0,
"no-use-before-define": 0,
"no-unused-vars": 0,
"consistent-return": 0,
"no-inner-declarations": 2,
"no-loop-func": 2,
"space-before-function-paren": [2, "never"]
"indent": [2, "tab", { "SwitchCase": 1 }],
"brace-style": ["error", "1tbs"],
"no-eval": "error",
"eol-last": "error",
"no-redeclare": "error",
"no-extra-bind": "error",
"no-process-exit": "error",
"no-inner-declarations": "warn",
"no-loop-func": "warn",
"no-undef": "error",
"no-trailing-spaces": "error",
"space-before-function-paren": ["error", "never"],
"no-multi-spaces": "error",
"space-in-parens": "error",
"space-before-blocks": "error",
"no-unused-vars": "error",
"no-dupe-keys": "error",
"valid-typeof": "error",
"space-infix-ops": "error",
"no-negated-in-lhs": "error",
"no-octal": "error",
"no-regex-spaces": "error",
"no-self-assign": "error",
"no-sparse-arrays": "error",
"no-unexpected-multiline": "error",
"no-unreachable": "error",
"no-extra-semi": "error",
"no-func-assign": "error",
"no-invalid-regexp": "error",
"keyword-spacing": ["error", {
"after": false,
"overrides": {
"try": {"after": true},
"else": {"after": true},
"case": {"after": true},
"return": {"after": true},
"finally": {"after": true},
"do": {"after": true}
}
}]
}
}
25 changes: 0 additions & 25 deletions .jsbeautifyrc

This file was deleted.

3 changes: 1 addition & 2 deletions bin/webpack-dev-server.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env node

var path = require("path");
var url = require("url");
var open = require("open");
var fs = require("fs");

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

function processOptions(wpOpt) {
//process Promise
// process Promise
if(typeof wpOpt.then === "function") {
wpOpt.then(processOptions).catch(function(err) {
console.error(err.stack || err);
Expand Down
1 change: 1 addition & 0 deletions client/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* global __resourceQuery */
var url = require('url');
var SockJS = require("sockjs-client");
var stripAnsi = require('strip-ansi');
Expand Down
4 changes: 2 additions & 2 deletions client/live.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var newConnection = function(handlers) {
};

$(function() {
var body = $("body").html(require("./page.pug")());
$("body").html(require("./page.pug")());
var status = $("#status");
var okness = $("#okness");
var $errors = $("#errors");
Expand Down Expand Up @@ -75,7 +75,7 @@ $(function() {
$errors.hide();
reloadApp();
},
warnings: function(warnings) {
warnings: function() {
okness.text("Warnings while compiling.");
$errors.hide();
reloadApp();
Expand Down
4 changes: 2 additions & 2 deletions examples/hmr/hmr.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require("./example");

if (module.hot) {
if(module.hot) {
module.hot.accept(function(err) {
if (err) {
if(err) {
console.error("Cannot apply hot update", err);
}
});
Expand Down
2 changes: 0 additions & 2 deletions examples/node-api-middleware/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
var path = require('path');

module.exports = {
context: __dirname,
entry: ["./app.js", "../../client/index.js?http://localhost:8080/"],
Expand Down
2 changes: 0 additions & 2 deletions examples/node-api-simple/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
var path = require('path');

module.exports = {
context: __dirname,
entry: ["./app.js", "../../client/index.js?http://localhost:8080/"],
Expand Down
2 changes: 1 addition & 1 deletion examples/proxy-advanced/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
'^/api': ''
},
bypass: function(req) {
if (req.url === '/api/nope') {
if(req.url === '/api/nope') {
return '/bypass.html';
}
}
Expand Down
10 changes: 3 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,10 @@
"yargs": "^4.7.1"
},
"devDependencies": {
"beautify-lint": "^1.0.4",
"css-loader": "~0.24.0",
"eslint": "^2.10.1",
"eslint-plugin-nodeca": "^1.0.3",
"eslint": "^3.4.0",
"file-loader": "~0.9.0",
"jquery": "^2.2.0",
"js-beautify": "^1.6.3",
"less": "^2.5.1",
"less-loader": "~2.2.0",
"pug": "^2.0.0-beta5",
Expand All @@ -54,8 +51,7 @@
"scripts": {
"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",
"lint": "eslint bin lib test examples client/{index,live,webpack.config}.js",
"beautify-lint": "beautify-lint lib/**.js bin/**.js client/{index,live,webpack.config}.js",
"beautify": "beautify-rewrite lib/**.js bin/**.js client/{index,live,webpack.config}.js",
"travis": "npm run lint && npm run beautify-lint && node lib/Server.js"
"beautify": "npm run lint -- --fix",
"travis": "npm run lint && node lib/Server.js"
}
}

0 comments on commit 0b625b9

Please sign in to comment.