Skip to content

Commit 644e3a0

Browse files
SpaceK33zTheLarkInn
authored andcommitted
Upgrade eslint (webpack#3626)
* Upgrade eslint * Pin down eslint version * Temporary fix for difference between js-beautify and eslint js-beautify suddenly requires a space between `while` here, but everywhere else we use it without space. * Remove redundant rules (present in eslint:recommended) * Add rules comparable to js-beautify rules to eslint * Add some forgotten files * Ugh, fix some differences between eslint and js-beautify the nuclear way * Add back variables
1 parent 7f90586 commit 644e3a0

13 files changed

+54
-44
lines changed

.eslintrc

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,40 @@
88
"es6": true
99
},
1010
"rules": {
11-
"strict": 0,
12-
"camelcase": 0,
13-
"curly": 0,
14-
"indent": [2, "tab", { "SwitchCase": 1 }],
15-
"eol-last": 1,
16-
"no-shadow": 0,
17-
"no-redeclare": 2,
18-
"no-extra-bind": 1,
19-
"no-empty": 0,
20-
"no-process-exit": 1,
21-
"no-underscore-dangle": 0,
22-
"no-use-before-define": 0,
23-
"no-undef": 2,
24-
"no-unused-vars": 0,
25-
"consistent-return": 0,
26-
"no-inner-declarations": 1,
27-
"no-loop-func": 1,
28-
"space-before-function-paren": [2, "never"],
29-
"space-before-blocks": [2, "always"],
30-
"space-before-keywords": [2, "always"],
31-
"no-console": 0,
32-
"comma-dangle": 0,
33-
"no-unexpected-multiline": 2,
34-
"valid-jsdoc": 2
11+
"quotes": ["error", "double"],
12+
"no-undef": "error",
13+
"brace-style": "error",
14+
"eol-last": "error",
15+
"indent": ["error", "tab", { "SwitchCase": 1 }],
16+
"no-extra-bind": "warn",
17+
"no-empty": "off",
18+
"no-multiple-empty-lines": "error",
19+
"no-multi-spaces": "error",
20+
"no-process-exit": "warn",
21+
"space-in-parens": "error",
22+
"no-trailing-spaces": "error",
23+
"no-use-before-define": "off",
24+
"no-unused-vars": "off",
25+
"key-spacing": "error",
26+
"space-infix-ops": "error",
27+
"no-unsafe-negation": "error",
28+
"no-loop-func": "warn",
29+
"space-before-function-paren": ["error", "never"],
30+
"space-before-blocks": "error",
31+
"object-curly-spacing": ["error", "always"],
32+
"keyword-spacing": ["error", {
33+
"after": false,
34+
"overrides": {
35+
"try": {"after": true},
36+
"else": {"after": true},
37+
"throw": {"after": true},
38+
"case": {"after": true},
39+
"return": {"after": true},
40+
"finally": {"after": true},
41+
"do": {"after": true}
42+
}
43+
}],
44+
"no-console": "off",
45+
"valid-jsdoc": "error"
3546
}
3647
}

bin/convert-argv.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module.exports = function(yargs, argv, convertOptions) {
2424
var configFileLoaded = false;
2525
var configFiles = [];
2626
var extensions = Object.keys(interpret.extensions).sort(function(a, b) {
27-
return a === '.js' ? -1 : b === '.js' ? 1 : a.length - b.length;
27+
return a === ".js" ? -1 : b === ".js" ? 1 : a.length - b.length;
2828
});
2929
var defaultConfigFiles = ["webpack.config", "webpackfile"].map(function(filename) {
3030
return extensions.map(function(ext) {

bin/webpack.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,13 +344,13 @@ function processOptions(options) {
344344
var primaryOptions = !Array.isArray(options) ? options : options[0];
345345
var watchOptions = primaryOptions.watchOptions || primaryOptions.watch || {};
346346
if(watchOptions.stdin) {
347-
process.stdin.on('end', function() {
347+
process.stdin.on("end", function() {
348348
process.exit(0); // eslint-disable-line
349349
});
350350
process.stdin.resume();
351351
}
352352
compiler.watch(watchOptions, compilerCallback);
353-
console.log('\nWebpack is watching the files…\n');
353+
console.log("\nWebpack is watching the files…\n");
354354
} else
355355
compiler.run(compilerCallback);
356356

lib/Dependency.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function Dependency() {
77
}
88
module.exports = Dependency;
99

10-
Dependency.prototype.isEqualResource = function( /* other */ ) {
10+
Dependency.prototype.isEqualResource = function(other) {
1111
return false;
1212
};
1313

lib/ExternalModuleFactoryPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ ExternalModuleFactoryPlugin.prototype.apply = function(normalModuleFactory) {
5656
var async = true;
5757
if(i >= externals.length) return callback();
5858
handleExternals(externals[i++], handleExternalsAndCallback);
59-
} while (!async);
59+
} while (!async); // eslint-disable-line keyword-spacing
6060
async = false;
6161
}());
6262
return;

lib/MainTemplate.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function MainTemplate(outputOptions) {
4444
source.add(")");
4545
return source;
4646
});
47-
this.plugin("local-vars", function(source /*, chunk, hash*/ ) {
47+
this.plugin("local-vars", function(source, chunk, hash) {
4848
return this.asString([
4949
source,
5050
"// The module cache",
@@ -88,7 +88,7 @@ function MainTemplate(outputOptions) {
8888
"return module.exports;"
8989
]);
9090
});
91-
this.plugin("module-obj", function( /*source, chunk, hash, varModuleId*/ ) {
91+
this.plugin("module-obj", function(source, chunk, hash, varModuleId) {
9292
return this.asString([
9393
"i: moduleId,",
9494
"l: false,",

lib/Module.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ Module.prototype.toString = function() {
153153
return "Module[" + (this.id || this.debugId) + "]";
154154
};
155155

156-
Module.prototype.needRebuild = function( /* fileTimestamps, contextTimestamps */ ) {
156+
Module.prototype.needRebuild = function(fileTimestamps, contextTimestamps) {
157157
return true;
158158
};
159159

lib/NewWatchingPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
MIT License http://www.opensource.org/licenses/mit-license.php
33
Author Tobias Koppers @sokra
44
*/
5-
'use strict';
5+
"use strict";
66

77
class NewWatchingPlugin {
88
apply(compiler) {

lib/OptionsApply.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
function OptionsApply() {}
66
module.exports = OptionsApply;
77

8-
OptionsApply.prototype.process = function( /* options, compiler */ ) {
8+
OptionsApply.prototype.process = function(options, compiler) {
99

1010
};

lib/Parser.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,15 +326,15 @@ Parser.prototype.initializeEvaluating = function() {
326326
}
327327

328328
this.plugin("evaluate TemplateLiteral", function(node) {
329-
var parts = getSimplifiedTemplateResult.call(this, 'cooked', node.quasis, node.expressions);
329+
var parts = getSimplifiedTemplateResult.call(this, "cooked", node.quasis, node.expressions);
330330
if(parts.length == 1) {
331331
return parts[0].setRange(node.range);
332332
}
333333
return new BasicEvaluatedExpression().setTemplateString(parts).setRange(node.range);
334334
});
335335
this.plugin("evaluate TaggedTemplateExpression", function(node) {
336-
if(this.evaluateExpression(node.tag).identifier !== 'String.raw') return;
337-
var parts = getSimplifiedTemplateResult.call(this, 'raw', node.quasi.quasis, node.quasi.expressions);
336+
if(this.evaluateExpression(node.tag).identifier !== "String.raw") return;
337+
var parts = getSimplifiedTemplateResult.call(this, "raw", node.quasi.quasis, node.quasi.expressions);
338338
return new BasicEvaluatedExpression().setTemplateString(parts).setRange(node.range);
339339
});
340340
}, this);

0 commit comments

Comments
 (0)