Skip to content

Commit

Permalink
Remove unneeded arguments checks
Browse files Browse the repository at this point in the history
  • Loading branch information
ooflorent committed Jul 6, 2018
1 parent 6623a2e commit 112af1e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 24 deletions.
10 changes: 2 additions & 8 deletions lib/BannerPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,7 @@ const wrapComment = str => {
};

class BannerPlugin {
constructor(options) {
if (arguments.length > 1) {
throw new Error(
"BannerPlugin only takes one argument (pass an options object)"
);
}

constructor(options = {}) {
validateOptions(schema, options, "Banner Plugin");

if (typeof options === "string" || typeof options === "function") {
Expand All @@ -38,7 +32,7 @@ class BannerPlugin {
};
}

this.options = options || {};
this.options = options;

if (typeof options.banner === "function") {
const getBanner = this.options.banner;
Expand Down
17 changes: 10 additions & 7 deletions lib/EvalSourceMapDevToolPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,25 @@
const EvalSourceMapDevToolModuleTemplatePlugin = require("./EvalSourceMapDevToolModuleTemplatePlugin");
const SourceMapDevToolModuleOptionsPlugin = require("./SourceMapDevToolModuleOptionsPlugin");

/** @typedef {import("./Compiler")} Compiler */

class EvalSourceMapDevToolPlugin {
constructor(options) {
if (arguments.length > 1) {
throw new Error(
"EvalSourceMapDevToolPlugin only takes one argument (pass an options object)"
);
}
/**
* @param {TODO} options Options object
*/
constructor(options = {}) {
if (typeof options === "string") {
options = {
append: options
};
}
if (!options) options = {};
this.options = options;
}

/**
* @param {Compiler} compiler Webpack Compiler
* @returns {void}
*/
apply(compiler) {
const options = this.options;
compiler.hooks.compilation.tap(
Expand Down
11 changes: 2 additions & 9 deletions lib/SourceMapDevToolPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,9 @@ const getTaskForFile = (file, chunk, options, compilation) => {
};

class SourceMapDevToolPlugin {
constructor(options) {
if (arguments.length > 1) {
throw new Error(
"SourceMapDevToolPlugin only takes one argument (pass an options object)"
);
}

validateOptions(schema, options || {}, "SourceMap DevTool Plugin");
constructor(options = {}) {
validateOptions(schema, options, "SourceMap DevTool Plugin");

if (!options) options = {};
this.sourceMapFilename = options.filename;
this.sourceMappingURLComment =
options.append === false
Expand Down

0 comments on commit 112af1e

Please sign in to comment.