arrow functions, remove or improve eslint-disable comments

This commit is contained in:
Tobias Koppers 2018-06-27 13:48:13 +02:00
parent 408c4ca9ef
commit ad8f496745
19 changed files with 76 additions and 70 deletions

View File

@ -159,8 +159,13 @@ if (installedClis.length === 0) {
} else if (installedClis.length === 1) { } else if (installedClis.length === 1) {
const path = require("path"); const path = require("path");
const pkgPath = require.resolve(`${installedClis[0].package}/package.json`); const pkgPath = require.resolve(`${installedClis[0].package}/package.json`);
const pkg = require(pkgPath); // eslint-disable-line // eslint-disable-next-line node/no-missing-require
require(path.resolve(path.dirname(pkgPath), pkg.bin[installedClis[0].binName])); // eslint-disable-line const pkg = require(pkgPath);
// eslint-disable-next-line node/no-missing-require
require(path.resolve(
path.dirname(pkgPath),
pkg.bin[installedClis[0].binName]
));
} else { } else {
console.warn( console.warn(
`You have installed ${installedClis `You have installed ${installedClis

View File

@ -305,7 +305,7 @@ class Chunk {
if (this._modules.size < otherChunk._modules.size) return 1; if (this._modules.size < otherChunk._modules.size) return 1;
const a = this._modules[Symbol.iterator](); const a = this._modules[Symbol.iterator]();
const b = otherChunk._modules[Symbol.iterator](); const b = otherChunk._modules[Symbol.iterator]();
// eslint-disable-next-line // eslint-disable-next-line no-constant-condition
while (true) { while (true) {
const aItem = a.next(); const aItem = a.next();
const bItem = b.next(); const bItem = b.next();

View File

@ -401,7 +401,7 @@ class ChunkGroup {
if (this.chunks.length < otherGroup.chunks.length) return 1; if (this.chunks.length < otherGroup.chunks.length) return 1;
const a = this.chunks[Symbol.iterator](); const a = this.chunks[Symbol.iterator]();
const b = otherGroup.chunks[Symbol.iterator](); const b = otherGroup.chunks[Symbol.iterator]();
// eslint-disable-next-line // eslint-disable-next-line no-constant-condition
while (true) { while (true) {
const aItem = a.next(); const aItem = a.next();
const bItem = b.next(); const bItem = b.next();

View File

@ -89,11 +89,11 @@ const iterationOfArrayCallback = (arr, fn) => {
} }
}; };
function addAllToSet(set, otherSet) { const addAllToSet = (set, otherSet) => {
for (const item of otherSet) { for (const item of otherSet) {
set.add(item); set.add(item);
} }
} };
class Compilation extends Tapable { class Compilation extends Tapable {
constructor(compiler) { constructor(compiler) {

View File

@ -10,12 +10,16 @@ const ParserHelpers = require("./ParserHelpers");
const NullFactory = require("./NullFactory"); const NullFactory = require("./NullFactory");
const REPLACEMENTS = { const REPLACEMENTS = {
__webpack_hash__: "__webpack_require__.h", // eslint-disable-line camelcase // eslint-disable-next-line camelcase
__webpack_chunkname__: "__webpack_require__.cn" // eslint-disable-line camelcase __webpack_hash__: "__webpack_require__.h",
// eslint-disable-next-line camelcase
__webpack_chunkname__: "__webpack_require__.cn"
}; };
const REPLACEMENT_TYPES = { const REPLACEMENT_TYPES = {
__webpack_hash__: "string", // eslint-disable-line camelcase // eslint-disable-next-line camelcase
__webpack_chunkname__: "string" // eslint-disable-line camelcase __webpack_hash__: "string",
// eslint-disable-next-line camelcase
__webpack_chunkname__: "string"
}; };
class ExtendedAPIPlugin { class ExtendedAPIPlugin {

View File

@ -64,7 +64,7 @@ class ExternalModuleFactoryPlugin {
asyncFlag = true; asyncFlag = true;
if (i >= externals.length) return callback(); if (i >= externals.length) return callback();
handleExternals(externals[i++], handleExternalsAndCallback); handleExternals(externals[i++], handleExternalsAndCallback);
} while (!asyncFlag); // eslint-disable-line keyword-spacing } while (!asyncFlag);
asyncFlag = false; asyncFlag = false;
}; };

View File

@ -5,12 +5,15 @@
/*global $hash$ $requestTimeout$ installedModules $require$ hotDownloadManifest hotDownloadUpdateChunk hotDisposeChunk modules */ /*global $hash$ $requestTimeout$ installedModules $require$ hotDownloadManifest hotDownloadUpdateChunk hotDisposeChunk modules */
module.exports = function() { module.exports = function() {
var hotApplyOnUpdate = true; var hotApplyOnUpdate = true;
var hotCurrentHash = $hash$; // eslint-disable-line no-unused-vars // eslint-disable-next-line no-unused-vars
var hotCurrentHash = $hash$;
var hotRequestTimeout = $requestTimeout$; var hotRequestTimeout = $requestTimeout$;
var hotCurrentModuleData = {}; var hotCurrentModuleData = {};
var hotCurrentChildModule; // eslint-disable-line no-unused-vars var hotCurrentChildModule;
var hotCurrentParents = []; // eslint-disable-line no-unused-vars // eslint-disable-next-line no-unused-vars
var hotCurrentParentsTemp = []; // eslint-disable-line no-unused-vars var hotCurrentParents = [];
// eslint-disable-next-line no-unused-vars
var hotCurrentParentsTemp = [];
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
function hotCreateRequire(moduleId) { function hotCreateRequire(moduleId) {
@ -199,8 +202,8 @@ module.exports = function() {
}); });
hotUpdate = {}; hotUpdate = {};
/*foreachInstalledChunks*/ /*foreachInstalledChunks*/
// eslint-disable-next-line no-lone-blocks
{ {
// eslint-disable-line no-lone-blocks
/*globals chunkId */ /*globals chunkId */
hotEnsureUpdateChunk(chunkId); hotEnsureUpdateChunk(chunkId);
} }

View File

@ -75,13 +75,13 @@ normalized:
"use strict"; "use strict";
const notMatcher = matcher => { const notMatcher = matcher => {
return function(str) { return str => {
return !matcher(str); return !matcher(str);
}; };
}; };
const orMatcher = items => { const orMatcher = items => {
return function(str) { return str => {
for (let i = 0; i < items.length; i++) { for (let i = 0; i < items.length; i++) {
if (items[i](str)) return true; if (items[i](str)) return true;
} }
@ -90,7 +90,7 @@ const orMatcher = items => {
}; };
const andMatcher = items => { const andMatcher = items => {
return function(str) { return str => {
for (let i = 0; i < items.length; i++) { for (let i = 0; i < items.length; i++) {
if (!items[i](str)) return false; if (!items[i](str)) return false;
} }

View File

@ -108,10 +108,11 @@ class Stats {
if (typeof item === "string") { if (typeof item === "string") {
const regExp = new RegExp( const regExp = new RegExp(
`[\\\\/]${item.replace( `[\\\\/]${item.replace(
// eslint-disable-next-line no-useless-escape
/[-[\]{}()*+?.\\^$|]/g, /[-[\]{}()*+?.\\^$|]/g,
"\\$&" "\\$&"
)}([\\\\/]|$|!|\\?)` )}([\\\\/]|$|!|\\?)`
); // eslint-disable-line no-useless-escape );
return ident => regExp.test(ident); return ident => regExp.test(ident);
} }
if (item && typeof item === "object" && typeof item.test === "function") { if (item && typeof item === "object" && typeof item.test === "function") {

View File

@ -107,14 +107,14 @@ class UmdMainTemplatePlugin {
requiredExternals = externals; requiredExternals = externals;
} }
function replaceKeys(str) { const replaceKeys = str => {
return mainTemplate.getAssetPath(str, { return mainTemplate.getAssetPath(str, {
hash, hash,
chunk chunk
}); });
} };
function externalsDepsArray(modules) { const externalsDepsArray = modules => {
return `[${replaceKeys( return `[${replaceKeys(
modules modules
.map(m => .map(m =>
@ -124,9 +124,9 @@ class UmdMainTemplatePlugin {
) )
.join(", ") .join(", ")
)}]`; )}]`;
} };
function externalsRootArray(modules) { const externalsRootArray = modules => {
return replaceKeys( return replaceKeys(
modules modules
.map(m => { .map(m => {
@ -136,9 +136,9 @@ class UmdMainTemplatePlugin {
}) })
.join(", ") .join(", ")
); );
} };
function externalsRequireArray(type) { const externalsRequireArray = type => {
return replaceKeys( return replaceKeys(
externals externals
.map(m => { .map(m => {
@ -166,20 +166,20 @@ class UmdMainTemplatePlugin {
}) })
.join(", ") .join(", ")
); );
} };
function externalsArguments(modules) { const externalsArguments = modules => {
return modules return modules
.map( .map(
m => m =>
`__WEBPACK_EXTERNAL_MODULE_${Template.toIdentifier(`${m.id}`)}__` `__WEBPACK_EXTERNAL_MODULE_${Template.toIdentifier(`${m.id}`)}__`
) )
.join(", "); .join(", ");
} };
function libraryName(library) { const libraryName = library => {
return JSON.stringify(replaceKeys([].concat(library).pop())); return JSON.stringify(replaceKeys([].concat(library).pop()));
} };
let amdFactory; let amdFactory;
if (optionalExternals.length > 0) { if (optionalExternals.length > 0) {

View File

@ -332,7 +332,6 @@ class WebpackOptionsValidationError extends WebpackError {
} }
return baseMessage; return baseMessage;
} else { } else {
// eslint-disable-line no-fallthrough
return `${dataPath} ${err.message} (${JSON.stringify( return `${dataPath} ${err.message} (${JSON.stringify(
err, err,
null, null,

View File

@ -5,7 +5,8 @@ const schema = require("../../schemas/plugins/debug/ProfilingPlugin.json");
let inspector = undefined; let inspector = undefined;
try { try {
inspector = require("inspector"); // eslint-disable-line node/no-missing-require // eslint-disable-next-line node/no-missing-require
inspector = require("inspector");
} catch (e) { } catch (e) {
console.log("Unable to CPU profile in < node 8.0"); console.log("Unable to CPU profile in < node 8.0");
} }
@ -84,7 +85,7 @@ class Profiler {
* @param {string} outputPath The location where to write the log. * @param {string} outputPath The location where to write the log.
* @returns {Trace} The trace object * @returns {Trace} The trace object
*/ */
function createTrace(outputPath) { const createTrace = outputPath => {
const trace = new Tracer({ const trace = new Tracer({
noStream: true noStream: true
}); });
@ -139,7 +140,7 @@ function createTrace(outputPath) {
trace.destroy(); trace.destroy();
} }
}; };
} };
const pluginName = "ProfilingPlugin"; const pluginName = "ProfilingPlugin";
@ -354,7 +355,6 @@ const makeNewProfiledTapFn = (hookName, tracer, { name, type, fn }) => {
switch (type) { switch (type) {
case "promise": case "promise":
return (...args) => { return (...args) => {
// eslint-disable-line
const id = ++tracer.counter; const id = ++tracer.counter;
tracer.trace.begin({ tracer.trace.begin({
name, name,
@ -373,7 +373,6 @@ const makeNewProfiledTapFn = (hookName, tracer, { name, type, fn }) => {
}; };
case "async": case "async":
return (...args) => { return (...args) => {
// eslint-disable-line
const id = ++tracer.counter; const id = ++tracer.counter;
tracer.trace.begin({ tracer.trace.begin({
name, name,
@ -392,7 +391,6 @@ const makeNewProfiledTapFn = (hookName, tracer, { name, type, fn }) => {
}; };
case "sync": case "sync":
return (...args) => { return (...args) => {
// eslint-disable-line
const id = ++tracer.counter; const id = ++tracer.counter;
// Do not instrument ourself due to the CPU // Do not instrument ourself due to the CPU
// profile needing to be the last event in the trace. // profile needing to be the last event in the trace.

View File

@ -23,17 +23,17 @@ const isBoundFunctionExpression = expr => {
return true; return true;
}; };
function isUnboundFunctionExpression(expr) { const isUnboundFunctionExpression = expr => {
if (expr.type === "FunctionExpression") return true; if (expr.type === "FunctionExpression") return true;
if (expr.type === "ArrowFunctionExpression") return true; if (expr.type === "ArrowFunctionExpression") return true;
return false; return false;
} };
function isCallable(expr) { const isCallable = expr => {
if (isUnboundFunctionExpression(expr)) return true; if (isUnboundFunctionExpression(expr)) return true;
if (isBoundFunctionExpression(expr)) return true; if (isBoundFunctionExpression(expr)) return true;
return false; return false;
} };
class AMDDefineDependencyParserPlugin { class AMDDefineDependencyParserPlugin {
constructor(options) { constructor(options) {
@ -80,7 +80,6 @@ class AMDDefineDependencyParserPlugin {
request request
)) ))
) { ) {
// eslint-disable-line no-cond-assign
dep = new LocalModuleDependency(localModule, undefined, false); dep = new LocalModuleDependency(localModule, undefined, false);
dep.loc = expr.loc; dep.loc = expr.loc;
parser.state.current.addDependency(dep); parser.state.current.addDependency(dep);
@ -121,7 +120,6 @@ class AMDDefineDependencyParserPlugin {
namedModule namedModule
)) ))
) { ) {
// eslint-disable-line no-cond-assign
dep = new LocalModuleDependency(localModule, param.range, false); dep = new LocalModuleDependency(localModule, param.range, false);
} else { } else {
dep = this.newRequireItemDependency(param.string, param.range); dep = this.newRequireItemDependency(param.string, param.range);

View File

@ -79,7 +79,6 @@ class AMDRequireDependenciesBlockParserPlugin {
request request
)) ))
) { ) {
// eslint-disable-line no-cond-assign
dep = new LocalModuleDependency(localModule, undefined, false); dep = new LocalModuleDependency(localModule, undefined, false);
dep.loc = expr.loc; dep.loc = expr.loc;
parser.state.current.addDependency(dep); parser.state.current.addDependency(dep);
@ -127,7 +126,6 @@ class AMDRequireDependenciesBlockParserPlugin {
param.string param.string
)) ))
) { ) {
// eslint-disable-line no-cond-assign
dep = new LocalModuleDependency(localModule, param.range, false); dep = new LocalModuleDependency(localModule, param.range, false);
} else { } else {
dep = this.newRequireItemDependency(param.string, param.range); dep = this.newRequireItemDependency(param.string, param.range);

View File

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

View File

@ -5,7 +5,7 @@
* @param {Set[]} sets an array of sets being checked for shared elements * @param {Set[]} sets an array of sets being checked for shared elements
* @returns {Set<TODO>} returns a new Set containing the intersecting items * @returns {Set<TODO>} returns a new Set containing the intersecting items
*/ */
function intersect(sets) { const intersect = sets => {
if (sets.length === 0) return new Set(); if (sets.length === 0) return new Set();
if (sets.length === 1) return new Set(sets[0]); if (sets.length === 1) return new Set(sets[0]);
let minSize = Infinity; let minSize = Infinity;
@ -28,7 +28,7 @@ function intersect(sets) {
} }
} }
return current; return current;
} };
/** /**
* Checks if a set is the subset of another set * Checks if a set is the subset of another set
@ -36,13 +36,13 @@ function intersect(sets) {
* @param {Set<TODO>} smallSet the set whos elements might be contained inside of bigSet * @param {Set<TODO>} smallSet the set whos elements might be contained inside of bigSet
* @returns {boolean} returns true if smallSet contains all elements inside of the bigSet * @returns {boolean} returns true if smallSet contains all elements inside of the bigSet
*/ */
function isSubset(bigSet, smallSet) { const isSubset = (bigSet, smallSet) => {
if (bigSet.size < smallSet.size) return false; if (bigSet.size < smallSet.size) return false;
for (const item of smallSet) { for (const item of smallSet) {
if (!bigSet.has(item)) return false; if (!bigSet.has(item)) return false;
} }
return true; return true;
} };
exports.intersect = intersect; exports.intersect = intersect;
exports.isSubset = isSubset; exports.isSubset = isSubset;

View File

@ -10,7 +10,7 @@ const WebAssemblyUtils = require("./WebAssemblyUtils");
/** @typedef {import("../Module")} Module */ /** @typedef {import("../Module")} Module */
// Get all wasm modules // Get all wasm modules
function getAllWasmModules(chunk) { const getAllWasmModules = chunk => {
const wasmModules = chunk.getAllAsyncChunks(); const wasmModules = chunk.getAllAsyncChunks();
const array = []; const array = [];
for (const chunk of wasmModules) { for (const chunk of wasmModules) {
@ -22,7 +22,7 @@ function getAllWasmModules(chunk) {
} }
return array; return array;
} };
/** /**
* generates the import object function for a module * generates the import object function for a module
@ -30,7 +30,7 @@ function getAllWasmModules(chunk) {
* @param {boolean} mangle mangle imports * @param {boolean} mangle mangle imports
* @returns {string} source code * @returns {string} source code
*/ */
function generateImportObject(module, mangle) { const generateImportObject = (module, mangle) => {
const waitForInstances = new Map(); const waitForInstances = new Map();
const properties = []; const properties = [];
const usedWasmDependencies = WebAssemblyUtils.getUsedDependencies( const usedWasmDependencies = WebAssemblyUtils.getUsedDependencies(
@ -151,7 +151,7 @@ function generateImportObject(module, mangle) {
"}," "},"
]); ]);
} }
} };
class WasmMainTemplatePlugin { class WasmMainTemplatePlugin {
constructor({ generateLoadBinaryCode, supportsStreaming, mangleImports }) { constructor({ generateLoadBinaryCode, supportsStreaming, mangleImports }) {

View File

@ -32,21 +32,21 @@ const WebAssemblyExportImportedDependency = require("../dependencies/WebAssembly
* @param {ArrayBuffer} ab - original binary * @param {ArrayBuffer} ab - original binary
* @returns {ArrayBufferTransform} transform * @returns {ArrayBufferTransform} transform
*/ */
function preprocess(ab) { const preprocess = ab => {
const optBin = shrinkPaddedLEB128(new Uint8Array(ab)); const optBin = shrinkPaddedLEB128(new Uint8Array(ab));
return optBin.buffer; return optBin.buffer;
} };
/** /**
* @template T * @template T
* @param {Function[]} fns transforms * @param {Function[]} fns transforms
* @returns {Function} composed transform * @returns {Function} composed transform
*/ */
function compose(...fns) { const compose = (...fns) => {
return fns.reduce((prevFn, nextFn) => { return fns.reduce((prevFn, nextFn) => {
return value => nextFn(prevFn(value)); return value => nextFn(prevFn(value));
}, value => value); }, value => value);
} };
// TODO replace with @callback // TODO replace with @callback
@ -70,7 +70,7 @@ const removeStartFunc = state => bin => {
* @param {Object} ast - Module's AST * @param {Object} ast - Module's AST
* @returns {Array<t.ModuleImport>} - nodes * @returns {Array<t.ModuleImport>} - nodes
*/ */
function getImportedGlobals(ast) { const getImportedGlobals = ast => {
const importedGlobals = []; const importedGlobals = [];
t.traverse(ast, { t.traverse(ast, {
@ -82,9 +82,9 @@ function getImportedGlobals(ast) {
}); });
return importedGlobals; return importedGlobals;
} };
function getCountImportedFunc(ast) { const getCountImportedFunc = ast => {
let count = 0; let count = 0;
t.traverse(ast, { t.traverse(ast, {
@ -96,7 +96,7 @@ function getCountImportedFunc(ast) {
}); });
return count; return count;
} };
/** /**
* Get next type index * Get next type index
@ -104,7 +104,7 @@ function getCountImportedFunc(ast) {
* @param {Object} ast - Module's AST * @param {Object} ast - Module's AST
* @returns {t.Index} - index * @returns {t.Index} - index
*/ */
function getNextTypeIndex(ast) { const getNextTypeIndex = ast => {
const typeSectionMetadata = t.getSectionMetadata(ast, "type"); const typeSectionMetadata = t.getSectionMetadata(ast, "type");
if (typeof typeSectionMetadata === "undefined") { if (typeof typeSectionMetadata === "undefined") {
@ -112,7 +112,7 @@ function getNextTypeIndex(ast) {
} }
return t.indexLiteral(typeSectionMetadata.vectorOfSize.value); return t.indexLiteral(typeSectionMetadata.vectorOfSize.value);
} };
/** /**
* Get next func index * Get next func index
@ -125,7 +125,7 @@ function getNextTypeIndex(ast) {
* @param {Number} countImportedFunc - number of imported funcs * @param {Number} countImportedFunc - number of imported funcs
* @returns {t.Index} - index * @returns {t.Index} - index
*/ */
function getNextFuncIndex(ast, countImportedFunc) { const getNextFuncIndex = (ast, countImportedFunc) => {
const funcSectionMetadata = t.getSectionMetadata(ast, "func"); const funcSectionMetadata = t.getSectionMetadata(ast, "func");
if (typeof funcSectionMetadata === "undefined") { if (typeof funcSectionMetadata === "undefined") {
@ -135,7 +135,7 @@ function getNextFuncIndex(ast, countImportedFunc) {
const vectorOfSize = funcSectionMetadata.vectorOfSize.value; const vectorOfSize = funcSectionMetadata.vectorOfSize.value;
return t.indexLiteral(vectorOfSize + countImportedFunc); return t.indexLiteral(vectorOfSize + countImportedFunc);
} };
/** /**
* Create a init instruction for a global * Create a init instruction for a global

View File

@ -9,7 +9,7 @@ const WebEnvironmentPlugin = require("./web/WebEnvironmentPlugin");
const WebpackOptionsApply = require("./WebpackOptionsApply"); const WebpackOptionsApply = require("./WebpackOptionsApply");
const WebpackOptionsDefaulter = require("./WebpackOptionsDefaulter"); const WebpackOptionsDefaulter = require("./WebpackOptionsDefaulter");
function webpack(options, callback) { const webpack = (options, callback) => {
new WebpackOptionsDefaulter().process(options); new WebpackOptionsDefaulter().process(options);
const compiler = new Compiler(); const compiler = new Compiler();
@ -22,7 +22,7 @@ function webpack(options, callback) {
compiler.run(callback); compiler.run(callback);
} }
return compiler; return compiler;
} };
module.exports = webpack; module.exports = webpack;
webpack.WebpackOptionsDefaulter = WebpackOptionsDefaulter; webpack.WebpackOptionsDefaulter = WebpackOptionsDefaulter;