refactor(eslint): Added no-unsed-vars, env specific .eslintrc's for buildin & hot (#3636)

* refactor(eslint): Added no-unsed-vars, env specific .eslintrc's for buildin & hot

* This change allows for buildin to now be part of the lint test by addition of an extra .eslintrc file which extends existing but sets es6 to false
* Turned on no-unused-vars for eslint, and then removed all warnings from turning that feature on
* Was getting notified of errors in "quote" property in eslintrc, so changed to correct value from error to 2.

* beautify

* swap invalid eslint config val
This commit is contained in:
Sean Larkin 2016-12-30 09:43:49 -06:00 committed by GitHub
parent 644afe6319
commit aa8d01bf8d
37 changed files with 37 additions and 71 deletions

View File

@ -21,7 +21,7 @@
"space-in-parens": "error",
"no-trailing-spaces": "error",
"no-use-before-define": "off",
"no-unused-vars": "off",
"no-unused-vars": ["error", {"args": "none"}],
"key-spacing": "error",
"space-infix-ops": "error",
"no-unsafe-negation": "error",

View File

@ -2,7 +2,6 @@ var path = require("path");
var fs = require("fs");
fs.existsSync = fs.existsSync || path.existsSync;
var interpret = require("interpret");
var WebpackOptionsDefaulter = require("../lib/WebpackOptionsDefaulter");
module.exports = function(yargs, argv, convertOptions) {
@ -226,12 +225,6 @@ module.exports = function(yargs, argv, convertOptions) {
});
}
function mapArgToPath(name, optionName) {
ifArg(name, function(str) {
options[optionName || name] = path.resolve(str);
});
}
function loadPlugin(name) {
var loadUtils = require("loader-utils");
var args = null;

7
buildin/.eslintrc Normal file
View File

@ -0,0 +1,7 @@
{
"env": {
"node": true,
"es6": false,
"browser": true
}
}

View File

@ -1 +1,3 @@
module.exports = function() { throw new Error("define cannot be used indirect"); };
module.exports = function() {
throw new Error("define cannot be used indirect");
};

View File

@ -1 +1,2 @@
/* globals __webpack_amd_options__ */
module.exports = __webpack_amd_options__;

View File

@ -1,7 +1,9 @@
var g;
// This works in non-strict mode
g = (function() { return this; })();
g = (function() {
return this;
})();
try {
// This works if eval is allowed (see CSP)

View File

@ -7,12 +7,16 @@ module.exports = function(module) {
Object.defineProperty(module, "loaded", {
enumerable: true,
configurable: false,
get: function() { return module.l; }
get: function() {
return module.l;
}
});
Object.defineProperty(module, "id", {
enumerable: true,
configurable: false,
get: function() { return module.i; }
get: function() {
return module.i;
}
});
module.webpackPolyfill = 1;
}

View File

@ -1 +1,4 @@
module.exports = function() { return __webpack_require__; };
/* globals __webpack_require__ */
module.exports = function() {
return __webpack_require__;
};

7
hot/.eslintrc Normal file
View File

@ -0,0 +1,7 @@
{
"env": {
"node": true,
"es6": false,
"browser": true
}
}

View File

@ -2,7 +2,7 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
/*globals window __webpack_hash__ */
/*globals __webpack_hash__ */
if(module.hot) {
var lastHash;
var upToDate = function upToDate() {

View File

@ -2,7 +2,6 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
var path = require("path");
var ConstDependency = require("./dependencies/ConstDependency");
var NullFactory = require("./NullFactory");

View File

@ -740,8 +740,6 @@ Compilation.prototype.assignIndex = function assignIndex(module) {
};
Compilation.prototype.assignDepth = function assignDepth(module) {
var _this = this;
function assignDepthToModule(module, depth) {
// enter module
if(typeof module.depth === "number" && module.depth <= depth) return;
@ -760,8 +758,6 @@ Compilation.prototype.assignDepth = function assignDepth(module) {
}
function assignDepthToDependencyBlock(block, depth) {
var allDependencies = [];
function iteratorDependency(d) {
assignDepthToDependency(d, depth);
}

View File

@ -6,7 +6,6 @@ var path = require("path");
var Tapable = require("tapable");
var Compilation = require("./Compilation");
var Resolver = require("enhanced-resolve/lib/Resolver");
var NormalModuleFactory = require("./NormalModuleFactory");
var ContextModuleFactory = require("./ContextModuleFactory");

View File

@ -2,9 +2,6 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
var path = require("path");
var async = require("async");
function FlagInitialModulesAsUsedPlugin() {}
module.exports = FlagInitialModulesAsUsedPlugin;
FlagInitialModulesAsUsedPlugin.prototype.apply = function(compiler) {

View File

@ -3,7 +3,6 @@
Author Tobias Koppers @sokra
*/
var ConcatSource = require("webpack-sources").ConcatSource;
var PrefixSource = require("webpack-sources").PrefixSource;
function FunctionModuleTemplatePlugin() {}
module.exports = FunctionModuleTemplatePlugin;

View File

@ -3,7 +3,6 @@
Author Tobias Koppers @sokra
*/
var ConcatSource = require("webpack-sources").ConcatSource;
var Template = require("./Template");
function JsonpChunkTemplatePlugin() {}
module.exports = JsonpChunkTemplatePlugin;

View File

@ -3,7 +3,6 @@
Author Tobias Koppers @sokra
*/
var ConcatSource = require("webpack-sources").ConcatSource;
var Template = require("./Template");
function JsonpHotUpdateChunkTemplatePlugin() {}
module.exports = JsonpHotUpdateChunkTemplatePlugin;

View File

@ -27,7 +27,6 @@ JsonpMainTemplatePlugin.prototype.apply = function(mainTemplate) {
return source;
});
mainTemplate.plugin("jsonp-script", function(_, chunk, hash) {
var filename = this.outputOptions.filename;
var chunkFilename = this.outputOptions.chunkFilename;
var chunkMaps = chunk.getChunkMaps();
var crossOriginLoading = this.outputOptions.crossOriginLoading;
@ -81,7 +80,6 @@ JsonpMainTemplatePlugin.prototype.apply = function(mainTemplate) {
]);
});
mainTemplate.plugin("require-ensure", function(_, chunk, hash) {
var chunkFilename = this.outputOptions.chunkFilename;
return this.asString([
"if(installedChunks[chunkId] === 0)",
this.indent([

View File

@ -4,7 +4,6 @@
*/
var path = require("path");
var async = require("async");
var HarmonyModulesHelpers = require("./dependencies/HarmonyModulesHelpers");
function LibManifestPlugin(options) {
this.options = options;

View File

@ -5,7 +5,6 @@
var DependenciesBlock = require("./DependenciesBlock");
var ModuleReason = require("./ModuleReason");
var Template = require("./Template");
var HarmonyModulesHelpers = require("./dependencies/HarmonyModulesHelpers");
var debugId = 1000;

View File

@ -27,15 +27,6 @@ function setProperty(obj, name, value) {
obj[name.pop()] = value;
}
function hasProperty(obj, name, value) {
name = name.split(".");
for(var i = 0; i < name.length - 1; i++) {
obj = obj[name[i]];
if(typeof obj != "object" || !obj) return false;
}
return Object.prototype.hasOwnProperty.call(obj, name.pop());
}
OptionsDefaulter.prototype.process = function(options) {
var addItemTo = function addItemTo(list) {
return function(item) {

View File

@ -5,7 +5,6 @@
"use strict"
const ConstDependency = require("./dependencies/ConstDependency");
const NullFactory = require("./NullFactory");
class UseStrictPlugin {
apply(compiler) {

View File

@ -123,15 +123,6 @@ function getSchemaPart(path, parents, additionalPath) {
return schemaPart;
}
function getSchemaPartText2(path, parents, additionalPath) {
var schemaPart = getSchemaPart(path, parents, additionalPath);
while(schemaPart.$ref) schemaPart = getSchemaPart(schemaPart.$ref);
var schemaText = WebpackOptionsValidationError.formatSchema(schemaPart);
if(schemaPart.description)
schemaText += "\n" + schemaPart.description;
return schemaText;
}
function getSchemaPartText(schemaPart, additionalPath) {
if(additionalPath) {
for(var i = 0; i < additionalPath.length; i++) {

View File

@ -3,7 +3,6 @@
Author Tobias Koppers @sokra
*/
var NullDependency = require("./NullDependency");
var HarmonyModulesHelpers = require("./HarmonyModulesHelpers");
function HarmonyImportSpecifierDependency(importDependency, importedVar, id, name, range) {
NullDependency.call(this);

View File

@ -4,11 +4,6 @@
*/
var ImportDependency = require("./ImportDependency");
var ImportContextDependency = require("./ImportContextDependency");
var UnsupportedFeatureWarning = require("../UnsupportedFeatureWarning");
var ConstDependency = require("./ConstDependency");
var BasicEvaluatedExpression = require("../BasicEvaluatedExpression");
var ImportParserPlugin = require("./ImportParserPlugin");
function ImportPlugin(options) {

View File

@ -12,11 +12,7 @@ function SystemPlugin(options) {
module.exports = SystemPlugin;
SystemPlugin.prototype.apply = function(compiler) {
var options = this.options;
compiler.plugin("compilation", function(compilation, params) {
var normalModuleFactory = params.normalModuleFactory;
var contextModuleFactory = params.contextModuleFactory;
params.normalModuleFactory.plugin("parser", function(parser, parserOptions) {
if(typeof parserOptions.system !== "undefined" && !parserOptions.system)

View File

@ -3,7 +3,6 @@
Author Tobias Koppers @sokra
*/
var NullDependency = require("./NullDependency");
var DepBlockHelpers = require("./DepBlockHelpers");
function UnsupportedDependency(request, range) {
NullDependency.call(this);

View File

@ -18,7 +18,7 @@ module.exports = function() {
return Promise.resolve(update);
}
function hotDisposeChunk(chunkId) {
function hotDisposeChunk(chunkId) { //eslint-disable-line no-unused-vars
delete installedChunks[chunkId];
}
};

View File

@ -34,7 +34,7 @@ module.exports = function() {
});
}
function hotDisposeChunk(chunkId) {
function hotDisposeChunk(chunkId) { //eslint-disable-line no-unused-vars
delete installedChunks[chunkId];
}
};

View File

@ -46,7 +46,6 @@ NodeMainTemplatePlugin.prototype.apply = function(mainTemplate) {
return source;
});
mainTemplate.plugin("require-ensure", function(_, chunk, hash) {
var filename = this.outputOptions.filename;
var chunkFilename = this.outputOptions.chunkFilename;
var chunkMaps = chunk.getChunkMaps();
var insertMoreModules = [

View File

@ -76,7 +76,6 @@ NodeSourcePlugin.prototype.apply = function(compiler) {
});
});
compiler.plugin("after-resolvers", function(compiler) {
var alias = {};
Object.keys(nodeLibsBrowser).forEach(function(lib) {
if(options[lib] !== false) {
compiler.resolvers.normal.apply(

View File

@ -157,7 +157,6 @@ AggressiveSplittingPlugin.prototype.apply = function(compiler) {
compilation.plugin("record-hash", function(records) {
// 3. save to made splittings to records
var minSize = _this.options.minSize;
var maxSize = _this.options.maxSize;
if(!records.aggressiveSplits) records.aggressiveSplits = [];
compilation.chunks.forEach(function(chunk) {
if(chunk.hasEntryModule()) return;

View File

@ -2,8 +2,6 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Sean Larkin @thelarkinn
*/
var path = require("path");
var EntrypointsOverSizeLimitWarning = require("./EntrypointsOverSizeLimitWarning");
var AssetsOverSizeLimitWarning = require("./AssetsOverSizeLimitWarning");
var NoAsyncChunksWarning = require("./NoAsyncChunksWarning");

View File

@ -8,6 +8,5 @@ function WebEnvironmentPlugin(inputFileSystem, outputFileSystem) {
}
module.exports = WebEnvironmentPlugin;
WebEnvironmentPlugin.prototype.apply = function(compiler) {
var inputFileSystem = compiler.inputFileSystem = this.inputFileSystem;
compiler.outputFileSystem = this.outputFileSystem;
};

View File

@ -51,7 +51,7 @@ module.exports = function() {
});
}
function hotDisposeChunk(chunkId) {
function hotDisposeChunk(chunkId) { //eslint-disable-line no-unused-vars
delete installedChunks[chunkId];
}
};

View File

@ -28,7 +28,6 @@ WebWorkerMainTemplatePlugin.prototype.apply = function(mainTemplate) {
return source;
});
mainTemplate.plugin("require-ensure", function(_, chunk, hash) {
var filename = this.outputOptions.filename;
var chunkFilename = this.outputOptions.chunkFilename;
return this.asString([
"// \"1\" is the signal for \"already loaded\"",

View File

@ -89,7 +89,7 @@
"build:examples": "cd examples && node buildAll.js",
"pretest": "npm run lint-files",
"lint-files": "npm run lint && npm run beautify-lint",
"lint": "eslint lib bin hot",
"lint": "eslint lib bin hot buildin",
"beautify-lint": "beautify-lint 'lib/**/*.js' 'hot/**/*.js' 'bin/**/*.js' 'benchmark/*.js' 'test/*.js'",
"nsp": "nsp check --output summary",
"cover": "node --harmony ./node_modules/.bin/istanbul cover -x '**/*.runtime.js' node_modules/mocha/bin/_mocha",