diff --git a/CHANGELOG.md b/CHANGELOG.md index f40d9ad..150ba16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -118,17 +118,17 @@ merge.smart( loaders: [ { test: /\.js$/, - loaders: ["babel"] - } - ] + loaders: ["babel"], + }, + ], }, { loaders: [ { test: /\.js$/, - loaders: ["react-hot", "babel"] - } - ] + loaders: ["react-hot", "babel"], + }, + ], } ); // will become @@ -137,8 +137,8 @@ merge.smart( { test: /\.js$/, // order of second argument is respected - loaders: ["react-hot", "babel"] - } + loaders: ["react-hot", "babel"], + }, ]; } ``` @@ -199,10 +199,10 @@ const output = merge.smartStrategy( ```javascript const a = { - entry: ["foo"] + entry: ["foo"], }; const b = { - entry: [] + entry: [], }; merge(a, b); // Yields a result, not b like before. diff --git a/README.md b/README.md index f5ad9ec..71b7f5f 100644 --- a/README.md +++ b/README.md @@ -157,14 +157,14 @@ const output = mergeWithCustomize({ customizeArray: unique( "plugins", ["HotModuleReplacementPlugin"], - plugin => plugin.constructor && plugin.constructor.name - ) + (plugin) => plugin.constructor && plugin.constructor.name + ), })( { - plugins: [new webpack.HotModuleReplacementPlugin()] + plugins: [new webpack.HotModuleReplacementPlugin()], }, { - plugins: [new webpack.HotModuleReplacementPlugin()] + plugins: [new webpack.HotModuleReplacementPlugin()], } ); @@ -182,10 +182,10 @@ const a = { rules: [ { test: /\.css$/, - use: [{ loader: "style-loader" }, { loader: "sass-loader" }] - } - ] - } + use: [{ loader: "style-loader" }, { loader: "sass-loader" }], + }, + ], + }, }; const b = { module: { @@ -196,13 +196,13 @@ const b = { { loader: "style-loader", options: { - modules: true - } - } - ] - } - ] - } + modules: true, + }, + }, + ], + }, + ], + }, }; const result = { module: { @@ -213,14 +213,14 @@ const result = { { loader: "style-loader", options: { - modules: true - } + modules: true, + }, }, - { loader: "sass-loader" } - ] - } - ] - } + { loader: "sass-loader" }, + ], + }, + ], + }, }; assert.deepStrictEqual( @@ -230,10 +230,10 @@ assert.deepStrictEqual( test: "match", use: { loader: "match", - options: "replace" - } - } - } + options: "replace", + }, + }, + }, })(a, b), result ); diff --git a/helpers/customize-tests.ts b/helpers/customize-tests.ts index 23f3d88..226ffa1 100644 --- a/helpers/customize-tests.ts +++ b/helpers/customize-tests.ts @@ -1,240 +1,240 @@ import assert from "assert"; function mergeStrategyTests(merge) { - it("should allow setting to array append", function() { + it("should allow setting to array append", function () { const a = { - entry: ["foo", "bar", "baz"] + entry: ["foo", "bar", "baz"], }; const b = { - entry: ["zoo"] + entry: ["zoo"], }; const result = { - entry: ["foo", "bar", "baz", "zoo"] + entry: ["foo", "bar", "baz", "zoo"], }; assert.deepStrictEqual( merge({ - entry: "append" + entry: "append", })(a, b), result ); }); - it("should allow setting to array prepend", function() { + it("should allow setting to array prepend", function () { const a = { - entry: ["foo", "bar", "baz"] + entry: ["foo", "bar", "baz"], }; const b = { - entry: ["zoo"] + entry: ["zoo"], }; const result = { - entry: ["zoo", "foo", "bar", "baz"] + entry: ["zoo", "foo", "bar", "baz"], }; assert.deepStrictEqual( merge({ - entry: "prepend" + entry: "prepend", })(a, b), result ); }); - it("should allow setting to object append", function() { + it("should allow setting to object append", function () { const a = { entry: { - foo: "bar" - } + foo: "bar", + }, }; const b = { entry: { - bar: "baz" - } + bar: "baz", + }, }; const result = { entry: { foo: "bar", - bar: "baz" - } + bar: "baz", + }, }; assert.deepStrictEqual( Object.keys( merge({ - entry: "append" + entry: "append", })(a, b).entry ), Object.keys(result.entry) ); }); - it("should allow setting to object prepend", function() { + it("should allow setting to object prepend", function () { const a = { entry: { - foo: "bar" - } + foo: "bar", + }, }; const b = { entry: { - bar: "baz" - } + bar: "baz", + }, }; const result = { entry: { bar: "baz", - foo: "bar" - } + foo: "bar", + }, }; assert.deepStrictEqual( Object.keys( merge({ - entry: "prepend" + entry: "prepend", })(a, b).entry ), Object.keys(result.entry) ); }); - it("should allow replace strategy for arrays", function() { + it("should allow replace strategy for arrays", function () { const a = { - entry: ["foo"] + entry: ["foo"], }; const b = { - entry: ["bar"] + entry: ["bar"], }; const result = { - entry: ["bar"] + entry: ["bar"], }; assert.deepStrictEqual( Object.keys( merge({ - entry: "replace" + entry: "replace", })(a, b).entry ), Object.keys(result.entry) ); }); - it("should allow replace strategy for objects", function() { + it("should allow replace strategy for objects", function () { const a = { entry: { - foo: "bar" - } + foo: "bar", + }, }; const b = { entry: { - bar: "baz" - } + bar: "baz", + }, }; const result = { entry: { - bar: "baz" - } + bar: "baz", + }, }; assert.deepStrictEqual( Object.keys( merge({ - entry: "replace" + entry: "replace", })(a, b).entry ), Object.keys(result.entry) ); }); - it("should merge functions returning arrays with prepend", function() { + it("should merge functions returning arrays with prepend", function () { const a = { postcss() { return ["a"]; - } + }, }; const b = { postcss() { return ["b"]; - } + }, }; const expected = ["b", "a"]; assert.deepStrictEqual( merge({ - postcss: "prepend" + postcss: "prepend", })(a, b).postcss(), expected ); }); - it("should merge functions returning objects with prepend", function() { + it("should merge functions returning objects with prepend", function () { const a = { postcss() { return { - a: "foo" + a: "foo", }; - } + }, }; const b = { postcss() { return { - b: "bar" + b: "bar", }; - } + }, }; const result = { postcss() { return { b: "bar", - a: "foo" + a: "foo", }; - } + }, }; assert.deepStrictEqual( Object.keys( merge({ - postcss: "prepend" + postcss: "prepend", })(a, b).postcss() ), Object.keys(result.postcss()) ); }); - it("should merge functions returning arrays with replace", function() { + it("should merge functions returning arrays with replace", function () { const a = { postcss() { return ["a"]; - } + }, }; const b = { postcss() { return ["b"]; - } + }, }; const expected = ["b"]; assert.deepStrictEqual( merge({ - postcss: "replace" + postcss: "replace", })(a, b).postcss(), expected ); }); - it("should merge functions returning objects with replace", function() { + it("should merge functions returning objects with replace", function () { const a = { postcss() { return ["a"]; - } + }, }; const b = { postcss() { return ["b"]; - } + }, }; const expected = ["b"]; assert.deepStrictEqual( merge({ - postcss: "replace" + postcss: "replace", })(a, b).postcss(), expected ); diff --git a/helpers/merge-multiple-tests.ts b/helpers/merge-multiple-tests.ts index 32952b6..36f9c42 100644 --- a/helpers/merge-multiple-tests.ts +++ b/helpers/merge-multiple-tests.ts @@ -1,88 +1,88 @@ import assert from "assert"; function multipleTests(merge) { - it("should override objects", function() { + it("should override objects", function () { const a = { client: { - entry: "./client.js" - } + entry: "./client.js", + }, }; const b = { client: { - entry: "./replaced.js" - } + entry: "./replaced.js", + }, }; const result = [ { - entry: "./replaced.js" - } + entry: "./replaced.js", + }, ]; assert.deepStrictEqual(merge(a, b), result); }); - it("should add new objects if not existing", function() { + it("should add new objects if not existing", function () { const a = { client: { - entry: "./client.js" + entry: "./client.js", }, server: { - entry: "./server.js" - } + entry: "./server.js", + }, }; const b = { client: { - entry: "./replaced.js" - } + entry: "./replaced.js", + }, }; const result = [ { - entry: "./replaced.js" + entry: "./replaced.js", }, { - entry: "./server.js" - } + entry: "./server.js", + }, ]; assert.deepStrictEqual(merge(a, b), result); }); - it("should add different configurations without merging", function() { + it("should add different configurations without merging", function () { const a = { client: { - entry: "./client.js" - } + entry: "./client.js", + }, }; const b = { server: { - entry: "./server.js" - } + entry: "./server.js", + }, }; const result = [ { - entry: "./client.js" + entry: "./client.js", }, { - entry: "./server.js" - } + entry: "./server.js", + }, ]; assert.deepStrictEqual(merge(a, b), result); }); - it("should work with an array of objects", function() { + it("should work with an array of objects", function () { const a = { client: { - entry: ["./client.js", "./client2.js"] + entry: ["./client.js", "./client2.js"], }, server: { - entry: ["./server.js", "./server2.js"] - } + entry: ["./server.js", "./server2.js"], + }, }; const b = { client: { - entry: ["./replaced.js", "./replaced2.js"] - } + entry: ["./replaced.js", "./replaced2.js"], + }, }; const result = [ { @@ -90,80 +90,80 @@ function multipleTests(merge) { "./client.js", "./client2.js", "./replaced.js", - "./replaced2.js" - ] + "./replaced2.js", + ], }, { - entry: ["./server.js", "./server2.js"] - } + entry: ["./server.js", "./server2.js"], + }, ]; assert.deepStrictEqual(merge(a, b), result); }); - it("should deeply merge objects", function() { + it("should deeply merge objects", function () { const a = { client: { entry: { - main: "./client.js" - } + main: "./client.js", + }, }, server: { entry: { - main: "./server.js" - } - } + main: "./server.js", + }, + }, }; const b = { client: { entry: { - main: "./replaced.js" - } - } + main: "./replaced.js", + }, + }, }; const result = [ { entry: { - main: "./replaced.js" - } + main: "./replaced.js", + }, }, { entry: { - main: "./server.js" - } - } + main: "./server.js", + }, + }, ]; assert.deepStrictEqual(merge(a, b), result); }); - it("should merge where keys exist and add where not", function() { + it("should merge where keys exist and add where not", function () { const a = { client: { - entry: "./client.js" + entry: "./client.js", }, server: { - entry: "./server.js" - } + entry: "./server.js", + }, }; const b = { server: { - entry: "./replaced.js" + entry: "./replaced.js", }, test: { - entry: "./test.js" - } + entry: "./test.js", + }, }; const result = [ { - entry: "./client.js" + entry: "./client.js", }, { - entry: "./replaced.js" + entry: "./replaced.js", }, { - entry: "./test.js" - } + entry: "./test.js", + }, ]; assert.deepStrictEqual(merge(a, b), result); diff --git a/helpers/merge-tests.ts b/helpers/merge-tests.ts index 36560ff..a0cc94f 100644 --- a/helpers/merge-tests.ts +++ b/helpers/merge-tests.ts @@ -2,89 +2,89 @@ import assert from "assert"; import webpack from "webpack"; function mergeTests(merge) { - it("should return the same config", function() { + it("should return the same config", function () { const config = { entry: { - app: "app" + app: "app", }, output: { path: "build", - filename: "[name].js" + filename: "[name].js", }, - plugins: [] + plugins: [], }; assert.deepStrictEqual(merge(config), config); }); - it("should append arrays of multiple objects by default", function() { + it("should append arrays of multiple objects by default", function () { const a = { - foo: ["a"] + foo: ["a"], }; const b = { - foo: ["b"] + foo: ["b"], }; const c = { - foo: ["c"] + foo: ["c"], }; const result = { - foo: ["a", "b", "c"] + foo: ["a", "b", "c"], }; assert.deepStrictEqual(merge(a, b, c), result); }); - it("should work with an array of objects", function() { + it("should work with an array of objects", function () { const a = { - foo: ["a"] + foo: ["a"], }; const b = { - foo: ["b"] + foo: ["b"], }; const c = { - foo: ["c"] + foo: ["c"], }; const result = { - foo: ["a", "b", "c"] + foo: ["a", "b", "c"], }; assert.deepStrictEqual(merge([a, b, c]), result); }); - it("should override objects", function() { + it("should override objects", function () { const a = { - foo: "a" + foo: "a", }; const result = { - foo: "b" + foo: "b", }; assert.deepStrictEqual(merge(a, result), result); }); - it("should append arrays by default", function() { + it("should append arrays by default", function () { const a = { - foo: ["a"] + foo: ["a"], }; const b = { - foo: ["b"] + foo: ["b"], }; const result = { - foo: ["a", "b"] + foo: ["a", "b"], }; assert.deepStrictEqual(merge(a, b), result); }); - it("should append arrays without mutating", function() { + it("should append arrays without mutating", function () { const a = { - foo: ["a"] + foo: ["a"], }; const b = { - foo: ["b"] + foo: ["b"], }; const result = { - foo: ["a", "b"] + foo: ["a", "b"], }; // this should not mutate @@ -93,80 +93,80 @@ function mergeTests(merge) { assert.deepStrictEqual(merge(a, b), result); }); - it("should override objects of multiple objects", function() { + it("should override objects of multiple objects", function () { const a = { - foo: "a" + foo: "a", }; const b = { - foo: "b" + foo: "b", }; const result = { - foo: "c" + foo: "c", }; assert.deepStrictEqual(merge(a, b, result), result); }); - it("should deeply merge objects", function() { + it("should deeply merge objects", function () { const a = { - foo: { bar: "a" } + foo: { bar: "a" }, }; const b = { - foo: { baz: "b" } + foo: { baz: "b" }, }; const result = { foo: { bar: "a", - baz: "b" - } + baz: "b", + }, }; assert.deepStrictEqual(merge(a, b), result); }); - it("should not error when there are no matching loaders", function() { + it("should not error when there are no matching loaders", function () { const a = { loaders: [ { test: /\.js$/, - loader: "a" - } - ] + loader: "a", + }, + ], }; const b = { loaders: [ { test: /\.css$/, - loader: "b" - } - ] + loader: "b", + }, + ], }; const result = { loaders: [ { test: /\.js$/, - loader: "a" + loader: "a", }, { test: /\.css$/, - loader: "b" - } - ] + loader: "b", + }, + ], }; assert.deepStrictEqual(merge(a, b), result); }); - it("should not mutate inputs", function() { + it("should not mutate inputs", function () { const a = { output: { - filename: "bundle.js" - } + filename: "bundle.js", + }, }; const b = { output: { - path: "path/b" - } + path: "path/b", + }, }; const aClone = JSON.parse(JSON.stringify(a)); @@ -175,88 +175,88 @@ function mergeTests(merge) { assert.deepStrictEqual(a, aClone); }); - it("should not allow overriding with an empty array", function() { + it("should not allow overriding with an empty array", function () { const a = { - entry: ["foo"] + entry: ["foo"], }; const b = { - entry: [] + entry: [], }; assert.deepStrictEqual(merge(a, b), a); }); - it("should not allow overriding with an empty object", function() { + it("should not allow overriding with an empty object", function () { const a = { entry: { - a: "foo" - } + a: "foo", + }, }; const b = { - entry: {} + entry: {}, }; assert.deepStrictEqual(merge(a, b), a); }); - it("should merge functions that return arrays", function() { + it("should merge functions that return arrays", function () { const a = { postcss() { return ["a"]; - } + }, }; const b = { postcss() { return ["b"]; - } + }, }; const expected = ["a", "b"]; assert.deepStrictEqual(merge(a, b).postcss(), expected); }); - it("should merge functions that return objects", function() { + it("should merge functions that return objects", function () { const a = { postcss() { return { - a: "foo" + a: "foo", }; - } + }, }; const b = { postcss() { return { - b: "bar" + b: "bar", }; - } + }, }; const expected = { a: "foo", - b: "bar" + b: "bar", }; assert.deepStrictEqual(merge(a, b).postcss(), expected); }); - it("should merge functions that take arguments", function() { + it("should merge functions that take arguments", function () { const a = { postcss(arg) { return [arg]; - } + }, }; const b = { postcss(arg) { return [arg + 1, arg + 2]; - } + }, }; const expected = ["a", "a1", "a2"]; assert.deepStrictEqual(merge(a, b).postcss("a"), expected); }); - it("should not mutate inputs with mismatched keys", function() { + it("should not mutate inputs with mismatched keys", function () { const a = { - entry: {} + entry: {}, }; const b = {}; @@ -269,34 +269,34 @@ function mergeTests(merge) { assert.deepStrictEqual(a, aClone); }); - it("should not mutate plugins #106", function() { + it("should not mutate plugins #106", function () { const config1 = { entry: { page1: "src/page1", - page2: "src/page2" + page2: "src/page2", }, output: { path: "dist", - publicPath: "/" - } + publicPath: "/", + }, }; const config2 = { entry: { page3: "src/page3", - page4: "src/page4" + page4: "src/page4", }, output: { path: "dist", - publicPath: "/" - } + publicPath: "/", + }, }; const enhance = { plugins: [ new webpack.IgnorePlugin({ resourceRegExp: /^\.\/locale$/, - contextRegExp: /moment$/ - }) - ] + contextRegExp: /moment$/, + }), + ], }; const result1 = merge(config1, enhance); diff --git a/package-lock.json b/package-lock.json index eeb8420..ba60027 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6841,9 +6841,9 @@ "dev": true }, "prettier": { - "version": "1.19.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz", - "integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.1.2.tgz", + "integrity": "sha512-16c7K+x4qVlJg9rEbXl7HEGmQyZlG4R9AgP+oHKRMsMsuk8s+ATStlf1NpDqyBI1HpVyfjLOeMhH2LvuNvV5Vg==", "dev": true }, "prettier-linter-helpers": { @@ -8752,6 +8752,12 @@ "typescript": "^3.7.3" }, "dependencies": { + "prettier": { + "version": "1.19.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz", + "integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==", + "dev": true + }, "tslib": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", diff --git a/package.json b/package.json index ed53fd5..fe2107f 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "devDependencies": { "@types/estree": "0.0.45", "husky": "^4.3.0", + "prettier": "^2.1.2", "tsdx": "^0.14.1", "tslib": "^2.0.3", "typescript": "^4.0.5", diff --git a/src/index.ts b/src/index.ts index 6987b07..424e93d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -71,7 +71,7 @@ function mergeWithCustomize( function customizeArray(rules: { [s: string]: CustomizeRule }) { return (a: any, b: any, key: Key) => { const matchedRule = - Object.keys(rules).find(rule => wildcard(rule, key)) || ""; + Object.keys(rules).find((rule) => wildcard(rule, key)) || ""; if (matchedRule) { switch (rules[matchedRule]) { @@ -94,7 +94,7 @@ function mergeWithRules(rules: Rules) { customizeArray: (a: any, b: any, key: Key) => { let currentRule: CustomizeRule | Rules = rules; - key.split(".").forEach(k => { + key.split(".").forEach((k) => { if (!currentRule) { return; } @@ -107,7 +107,7 @@ function mergeWithRules(rules: Rules) { } return undefined; - } + }, }); } @@ -116,7 +116,7 @@ const isArray = Array.isArray; function mergeWithRule({ currentRule, a, - b + b, }: { currentRule: CustomizeRule | Rules; a: any; @@ -127,7 +127,7 @@ function mergeWithRule({ } const bAllMatches: any[] = []; - const ret = a.map(ao => { + const ret = a.map((ao) => { if (!isPlainObject(currentRule)) { return ao; } @@ -143,9 +143,9 @@ function mergeWithRule({ } }); - const bMatches = b.filter(o => { + const bMatches = b.filter((o) => { const matches = rulesToMatch.every( - rule => ao[rule]?.toString() === o[rule]?.toString() + (rule) => ao[rule]?.toString() === o[rule]?.toString() ); if (matches) { @@ -189,7 +189,7 @@ function mergeWithRule({ // Use .flat(); starting from Node 12 const b = bMatches - .map(o => o[k]) + .map((o) => o[k]) .reduce( (acc, val) => isArray(acc) && isArray(val) ? [...acc, ...val] : acc, @@ -204,7 +204,7 @@ function mergeWithRule({ return ret; }); - return ret.concat(b.filter(o => !bAllMatches.includes(o))); + return ret.concat(b.filter((o) => !bAllMatches.includes(o))); } function last(arr) { @@ -233,5 +233,5 @@ export { merge as default, mergeWithCustomize, mergeWithRules, - unique + unique, }; diff --git a/src/join-arrays.ts b/src/join-arrays.ts index 26ab578..56dd0ea 100644 --- a/src/join-arrays.ts +++ b/src/join-arrays.ts @@ -8,7 +8,7 @@ const isArray = Array.isArray; export default function joinArrays({ customizeArray, customizeObject, - key + key, }: { customizeArray?: Customize; customizeObject?: Customize; @@ -41,7 +41,7 @@ export default function joinArrays({ joinArrays({ customizeArray, customizeObject, - key: newKey + key: newKey, }) ) ); diff --git a/src/merge-with.ts b/src/merge-with.ts index b6bead5..ce85075 100644 --- a/src/merge-with.ts +++ b/src/merge-with.ts @@ -2,7 +2,7 @@ function mergeWith(objects: object[], customizer) { const [first, ...rest] = objects; let ret = first; - rest.forEach(a => { + rest.forEach((a) => { ret = mergeTo(ret, a, customizer); }); @@ -14,7 +14,7 @@ function mergeTo(a, b, customizer) { Object.keys(a) .concat(Object.keys(b)) - .forEach(k => { + .forEach((k) => { const v = customizer(a[k], b[k], k); ret[k] = typeof v === "undefined" ? a[k] : v; diff --git a/src/types.ts b/src/types.ts index afb319c..f42b47b 100644 --- a/src/types.ts +++ b/src/types.ts @@ -11,5 +11,5 @@ export enum CustomizeRule { Match = "match", Append = "append", Prepend = "prepend", - Replace = "replace" + Replace = "replace", } diff --git a/test/customize.test.ts b/test/customize.test.ts index a0fc364..cc89eca 100644 --- a/test/customize.test.ts +++ b/test/customize.test.ts @@ -2,16 +2,16 @@ import assert from "assert"; import { customizeArray, customizeObject, - mergeWithCustomize + mergeWithCustomize, } from "../resolve"; import customizeTests from "../helpers/customize-tests"; import { CustomizeRule } from "../src/types"; -describe("Merge strategy", function() { - const merge = rules => +describe("Merge strategy", function () { + const merge = (rules) => mergeWithCustomize({ customizeArray: customizeArray(rules), - customizeObject: customizeObject(rules) + customizeObject: customizeObject(rules), }); customizeTests(merge); @@ -19,17 +19,17 @@ describe("Merge strategy", function() { }); function mergeStrategySpecificTests(merge) { - it("should work with nested arrays and prepend", function() { + it("should work with nested arrays and prepend", function () { const a = { module: { loaders: [ { test: /.jsx?$/, loaders: ["babel"], - exclude: /node_modules/ - } - ] - } + exclude: /node_modules/, + }, + ], + }, }; const b = { module: { @@ -37,10 +37,10 @@ function mergeStrategySpecificTests(merge) { { test: /.jsx?$/, loaders: ["react-hot"], - exclude: /node_modules/ - } - ] - } + exclude: /node_modules/, + }, + ], + }, }; const result = { module: { @@ -48,49 +48,49 @@ function mergeStrategySpecificTests(merge) { { test: /.jsx?$/, loaders: ["react-hot"], - exclude: /node_modules/ + exclude: /node_modules/, }, { test: /.jsx?$/, loaders: ["babel"], - exclude: /node_modules/ - } - ] - } + exclude: /node_modules/, + }, + ], + }, }; assert.deepStrictEqual( merge({ - "module.loaders": CustomizeRule.Prepend + "module.loaders": CustomizeRule.Prepend, })(a, b), result ); }); - it("should work with array wildcards", function() { + it("should work with array wildcards", function () { const a = { entry: { main: ["./src\\config\\main.ts"], polyfills: ["./src\\config\\polyfills.ts"], - styles: ["./src\\assets\\styles\\styles.sass"] - } + styles: ["./src\\assets\\styles\\styles.sass"], + }, }; const b = { entry: { - main: ["./src\\config\\main.playground.ts"] - } + main: ["./src\\config\\main.playground.ts"], + }, }; const result = { entry: { main: ["./src\\config\\main.playground.ts"], polyfills: ["./src\\config\\polyfills.ts"], - styles: ["./src\\assets\\styles\\styles.sass"] - } + styles: ["./src\\assets\\styles\\styles.sass"], + }, }; assert.deepStrictEqual( merge({ - "entry.*": CustomizeRule.Replace + "entry.*": CustomizeRule.Replace, })(a, b), result ); diff --git a/test/merge-with-customize.test.ts b/test/merge-with-customize.test.ts index 6fc88e2..fec4f2c 100644 --- a/test/merge-with-customize.test.ts +++ b/test/merge-with-customize.test.ts @@ -2,124 +2,124 @@ import assert from "assert"; import webpack from "webpack"; import { mergeWithCustomize } from "../resolve"; -describe("Merge", function() { +describe("Merge", function () { customizeMergeTests(mergeWithCustomize); }); function customizeMergeTests(merge) { - it("should allow overriding array behavior", function() { + it("should allow overriding array behavior", function () { const first = { - entry: ["a"] + entry: ["a"], }; const second = { - entry: ["b"] + entry: ["b"], }; assert.deepStrictEqual( merge({ customizeArray(a) { return a; - } + }, })(first, second), first ); }); - it("should pass key to array customizer", function() { + it("should pass key to array customizer", function () { let receivedKey; const first = { - entry: ["a"] + entry: ["a"], }; const second = { - entry: ["b"] + entry: ["b"], }; const result = merge({ customizeArray(a, _, key) { receivedKey = key; return a; - } + }, })(first, second); assert.strictEqual(receivedKey, "entry"); assert.deepStrictEqual(result, first); }); - it("should allow overriding object behavior", function() { + it("should allow overriding object behavior", function () { const first = { entry: { - a: "foo" - } + a: "foo", + }, }; const second = { entry: { - a: "bar" - } + a: "bar", + }, }; assert.deepStrictEqual( merge({ customizeObject(a) { return a; - } + }, })(first, second), first ); }); - it("should pass key to object customizer", function() { + it("should pass key to object customizer", function () { let receivedKey; const first = { entry: { - a: "foo" - } + a: "foo", + }, }; const second = { entry: { - a: "bar" - } + a: "bar", + }, }; const result = merge({ customizeObject(a, _, key) { receivedKey = key; return a; - } + }, })(first, second); assert.strictEqual(receivedKey, "entry"); assert.deepStrictEqual(result, first); }); - it("should customize plugins", function() { + it("should customize plugins", function () { let receivedKey; const config1 = { plugins: [ new webpack.DefinePlugin({ "process.env": { - NODE_ENV: JSON.stringify("development") - } + NODE_ENV: JSON.stringify("development"), + }, }), - new webpack.HotModuleReplacementPlugin() - ] + new webpack.HotModuleReplacementPlugin(), + ], }; const config2 = { plugins: [ new webpack.DefinePlugin({ - __CLIENT__: true + __CLIENT__: true, }), new webpack.IgnorePlugin({ resourceRegExp: /^\.\/locale$/, - contextRegExp: /moment$/ + contextRegExp: /moment$/, }), - new webpack.HotModuleReplacementPlugin() - ] + new webpack.HotModuleReplacementPlugin(), + ], }; merge({ customizeArray(_, __, key) { receivedKey = key; - } + }, })(config1, config2); assert.strictEqual(receivedKey, "plugins"); diff --git a/test/merge-with-rules.test.ts b/test/merge-with-rules.test.ts index 2722edf..fc9d754 100644 --- a/test/merge-with-rules.test.ts +++ b/test/merge-with-rules.test.ts @@ -2,36 +2,36 @@ import assert from "assert"; import { mergeWithRules } from "../resolve"; import { CustomizeRule } from "../src/types"; -describe("Merge with rules", function() { - it("should replace with nested notation", function() { +describe("Merge with rules", function () { + it("should replace with nested notation", function () { const base = { entry: "demo", module: { rules: [ { test: /\.scss$/, - loaders: ["css-loader"] + loaders: ["css-loader"], }, { test: /\.css$/, - loaders: ["style-loader"] - } - ] - } + loaders: ["style-loader"], + }, + ], + }, }; const development = { module: { rules: [ { test: /\.scss$/, - loaders: ["style-loader"] + loaders: ["style-loader"], }, { test: /\.less$/, - loaders: ["css-loader"] - } - ] - } + loaders: ["css-loader"], + }, + ], + }, }; const result = { entry: "demo", @@ -39,18 +39,18 @@ describe("Merge with rules", function() { rules: [ { test: /\.scss$/, - loaders: ["style-loader"] + loaders: ["style-loader"], }, { test: /\.css$/, - loaders: ["style-loader"] + loaders: ["style-loader"], }, { test: /\.less$/, - loaders: ["css-loader"] - } - ] - } + loaders: ["css-loader"], + }, + ], + }, }; assert.deepStrictEqual( @@ -58,44 +58,44 @@ describe("Merge with rules", function() { module: { rules: { test: CustomizeRule.Match, - loaders: CustomizeRule.Replace - } - } + loaders: CustomizeRule.Replace, + }, + }, })(base, development), result ); }); - it("should append with nested notation", function() { + it("should append with nested notation", function () { const base = { module: { rules: [ { test: /\.scss$/, - loaders: ["css-loader"] - } - ] - } + loaders: ["css-loader"], + }, + ], + }, }; const development = { module: { rules: [ { test: /\.scss$/, - loaders: ["style-loader"] - } - ] - } + loaders: ["style-loader"], + }, + ], + }, }; const result = { module: { rules: [ { test: /\.scss$/, - loaders: ["css-loader", "style-loader"] - } - ] - } + loaders: ["css-loader", "style-loader"], + }, + ], + }, }; assert.deepStrictEqual( @@ -103,44 +103,44 @@ describe("Merge with rules", function() { module: { rules: { test: CustomizeRule.Match, - loaders: CustomizeRule.Append - } - } + loaders: CustomizeRule.Append, + }, + }, })(base, development), result ); }); - it("should prepend with nested notation", function() { + it("should prepend with nested notation", function () { const base = { module: { rules: [ { test: /\.scss$/, - loaders: ["css-loader"] - } - ] - } + loaders: ["css-loader"], + }, + ], + }, }; const development = { module: { rules: [ { test: /\.scss$/, - loaders: ["style-loader"] - } - ] - } + loaders: ["style-loader"], + }, + ], + }, }; const result = { module: { rules: [ { test: /\.scss$/, - loaders: ["style-loader", "css-loader"] - } - ] - } + loaders: ["style-loader", "css-loader"], + }, + ], + }, }; assert.deepStrictEqual( @@ -148,24 +148,24 @@ describe("Merge with rules", function() { module: { rules: { test: CustomizeRule.Match, - loaders: CustomizeRule.Prepend - } - } + loaders: CustomizeRule.Prepend, + }, + }, })(base, development), result ); }); - it("should merge #146", function() { + it("should merge #146", function () { const a = { module: { rules: [ { test: /\.css$/, - use: [{ loader: "style-loader" }, { loader: "sass-loader" }] - } - ] - } + use: [{ loader: "style-loader" }, { loader: "sass-loader" }], + }, + ], + }, }; const b = { module: { @@ -176,13 +176,13 @@ describe("Merge with rules", function() { { loader: "style-loader", options: { - modules: true - } - } - ] - } - ] - } + modules: true, + }, + }, + ], + }, + ], + }, }; const result = { module: { @@ -193,14 +193,14 @@ describe("Merge with rules", function() { { loader: "style-loader", options: { - modules: true - } + modules: true, + }, }, - { loader: "sass-loader" } - ] - } - ] - } + { loader: "sass-loader" }, + ], + }, + ], + }, }; assert.deepStrictEqual( @@ -210,16 +210,16 @@ describe("Merge with rules", function() { test: CustomizeRule.Match, use: { loader: CustomizeRule.Match, - options: CustomizeRule.Replace - } - } - } + options: CustomizeRule.Replace, + }, + }, + }, })(a, b), result ); }); - it("should merge #149", function() { + it("should merge #149", function () { const base = { module: { rules: [ @@ -227,15 +227,15 @@ describe("Merge with rules", function() { test: /\.scss$/, loaders: [ { - loader: "css-loader" + loader: "css-loader", }, { - loader: "resolve-url-loader" - } - ] - } - ] - } + loader: "resolve-url-loader", + }, + ], + }, + ], + }, }; const development = { module: { @@ -246,13 +246,13 @@ describe("Merge with rules", function() { { loader: "css-loader", options: { - sourceMap: true - } - } - ] - } - ] - } + sourceMap: true, + }, + }, + ], + }, + ], + }, }; const result = { module: { @@ -263,16 +263,16 @@ describe("Merge with rules", function() { { loader: "css-loader", options: { - sourceMap: true - } + sourceMap: true, + }, }, { - loader: "resolve-url-loader" - } - ] - } - ] - } + loader: "resolve-url-loader", + }, + ], + }, + ], + }, }; assert.deepStrictEqual( @@ -282,46 +282,46 @@ describe("Merge with rules", function() { test: CustomizeRule.Match, loaders: { loader: CustomizeRule.Match, - options: CustomizeRule.Replace - } - } - } + options: CustomizeRule.Replace, + }, + }, + }, })(base, development), result ); }); - it("should merge #157", function() { + it("should merge #157", function () { const base = { entry: "demo", module: { rules: [ { test: /\.scss$/, - loaders: ["css-loader"] + loaders: ["css-loader"], }, { test: /\.css$/, - loaders: ["style-loader"] - } - ] + loaders: ["style-loader"], + }, + ], }, - plugins: [{ name: "StylelintPlugin" }] + plugins: [{ name: "StylelintPlugin" }], }; const development = { module: { rules: [ { test: /\.scss$/, - loaders: ["style-loader"] + loaders: ["style-loader"], }, { test: /\.less$/, - loaders: ["css-loader"] - } - ] + loaders: ["css-loader"], + }, + ], }, - plugins: [{ name: "MiniCssExtractPlugin" }] + plugins: [{ name: "MiniCssExtractPlugin" }], }; const result = { entry: "demo", @@ -329,19 +329,19 @@ describe("Merge with rules", function() { rules: [ { test: /\.scss$/, - loaders: ["style-loader"] + loaders: ["style-loader"], }, { test: /\.css$/, - loaders: ["style-loader"] + loaders: ["style-loader"], }, { test: /\.less$/, - loaders: ["css-loader"] - } - ] + loaders: ["css-loader"], + }, + ], }, - plugins: [{ name: "StylelintPlugin" }, { name: "MiniCssExtractPlugin" }] + plugins: [{ name: "StylelintPlugin" }, { name: "MiniCssExtractPlugin" }], }; assert.deepStrictEqual( @@ -349,118 +349,118 @@ describe("Merge with rules", function() { module: { rules: { test: CustomizeRule.Match, - loaders: CustomizeRule.Replace - } - } + loaders: CustomizeRule.Replace, + }, + }, })(base, development), result ); }); - it("should merge with a parser loader", function() { + it("should merge with a parser loader", function () { const defaultConfig = { module: { rules: [ { parser: { - system: false - } + system: false, + }, }, { test: /\.(js|ts)x?$/, exclude: /node_modules/, use: [ { - loader: "babel-loader" - } - ] + loader: "babel-loader", + }, + ], }, { test: /\.css$/i, include: [/node_modules/, /src/], use: [ { - loader: "style-loader" + loader: "style-loader", }, { loader: "css-loader", options: { - modules: false - } - } - ] - } - ] - } + modules: false, + }, + }, + ], + }, + ], + }, }; const localConfig = { module: { rules: [ { test: /\.html$/i, - use: [{ loader: "html-loader" }] + use: [{ loader: "html-loader" }], }, { test: /\.css$/i, use: [ { - loader: "style-loader" + loader: "style-loader", }, { loader: "css-loader", options: { - importLoaders: 1 - } + importLoaders: 1, + }, }, { - loader: "postcss-loader" - } - ] - } - ] - } + loader: "postcss-loader", + }, + ], + }, + ], + }, }; const result = { module: { rules: [ { parser: { - system: false - } + system: false, + }, }, { test: /\.(js|ts)x?$/, exclude: /node_modules/, use: [ { - loader: "babel-loader" - } - ] + loader: "babel-loader", + }, + ], }, { test: /\.css$/i, include: [/node_modules/, /src/], use: [ { - loader: "style-loader" + loader: "style-loader", }, { loader: "css-loader", options: { - importLoaders: 1 - } + importLoaders: 1, + }, }, { - loader: "postcss-loader" - } - ] + loader: "postcss-loader", + }, + ], }, { test: /\.html$/i, - use: [{ loader: "html-loader" }] - } - ] - } + use: [{ loader: "html-loader" }], + }, + ], + }, }; assert.deepStrictEqual( @@ -470,27 +470,27 @@ describe("Merge with rules", function() { test: CustomizeRule.Match, use: { loader: CustomizeRule.Match, - options: CustomizeRule.Replace - } - } - } + options: CustomizeRule.Replace, + }, + }, + }, })(defaultConfig, localConfig), result ); }); - it("should merge without rule (#151)", function() { + it("should merge without rule (#151)", function () { const module = { rules: { test: CustomizeRule.Match, use: { loader: CustomizeRule.Match, - options: CustomizeRule.Replace - } - } + options: CustomizeRule.Replace, + }, + }, }; const _mergeWithoutRule = mergeWithRules({ - module + module, }); const config = { resolve: { extensions: [".js"] } }; diff --git a/test/merge.test.ts b/test/merge.test.ts index 5538680..8cd3c47 100644 --- a/test/merge.test.ts +++ b/test/merge.test.ts @@ -3,63 +3,63 @@ import merge, { merge as defaultMerge } from "../resolve"; import mergeTests from "../helpers/merge-tests"; import loadersKeys from "../helpers/loaders-keys"; -describe("Merge", function() { +describe("Merge", function () { normalMergeTests(merge); mergeTests(merge); - it("should export default merge", function() { + it("should export default merge", function () { assert.strictEqual(merge, defaultMerge); }); }); function normalMergeTests(merge) { - loadersKeys.forEach(function(loadersKey) { + loadersKeys.forEach(function (loadersKey) { normalMergeTest(merge, loadersKey); }); } function normalMergeTest(merge, loadersKey) { - it("should throw with an empty configuration", function() { + it("should throw with an empty configuration", function () { assert.throws(() => merge(), { name: "TypeError", - message: "Merging undefined is not supported" + message: "Merging undefined is not supported", }); }); - it("should throw with undefined 1/4", function() { + it("should throw with undefined 1/4", function () { assert.throws(() => merge(undefined), { name: "TypeError", - message: "Merging undefined is not supported" + message: "Merging undefined is not supported", }); }); - it("should throw with undefined 2/4", function() { + it("should throw with undefined 2/4", function () { assert.throws(() => merge([undefined]), { name: "TypeError", - message: "Merging undefined is not supported" + message: "Merging undefined is not supported", }); }); - it("should throw with undefined 2/4", function() { + it("should throw with undefined 2/4", function () { const result = { devServer: null }; assert.throws( () => merge( { - devServer: { base: true } + devServer: { base: true }, }, undefined, result ), { name: "TypeError", - message: "Merging undefined is not supported" + message: "Merging undefined is not supported", } ); }); - it("should throw with undefined 3/4", function() { + it("should throw with undefined 3/4", function () { const result = { devServer: null }; assert.throws( @@ -67,28 +67,28 @@ function normalMergeTest(merge, loadersKey) { merge( undefined, { - devServer: { base: true } + devServer: { base: true }, }, result ), { name: "TypeError", - message: "Merging undefined is not supported" + message: "Merging undefined is not supported", } ); }); - it("should work with an empty array", function() { + it("should work with an empty array", function () { assert.deepStrictEqual(merge([]), {}); }); - it("should override with null (#144)", function() { + it("should override with null (#144)", function () { const result = { devServer: null }; assert.deepStrictEqual( merge( { - devServer: { base: true } + devServer: { base: true }, }, result ), @@ -96,11 +96,11 @@ function normalMergeTest(merge, loadersKey) { ); }); - it("should allow merging optimization config to itself (#145)", function() { + it("should allow merging optimization config to itself (#145)", function () { const config = { optimization: { runtimeChunk: { - name: "runtime" + name: "runtime", }, splitChunks: { @@ -112,191 +112,194 @@ function normalMergeTest(merge, loadersKey) { name: "clientApplication", test: /applications\/client/, chunks: "all", - enforce: true - } - } - } - } + enforce: true, + }, + }, + }, + }, }; assert.deepStrictEqual(merge(config, config), config); }); - it("should error on promise", function() { + it("should error on promise", function () { const a = { - module: {} + module: {}, }; assert.throws(() => merge(Promise.resolve(a), Promise.resolve(a)), { name: "TypeError", - message: "Promises are not supported" + message: "Promises are not supported", }); }); - it("should error on promises inside an array", function() { + it("should error on promises inside an array", function () { const a = { - module: {} + module: {}, }; assert.throws(() => merge([Promise.resolve(a), Promise.resolve(a)]), { name: "TypeError", - message: "Promises are not supported" + message: "Promises are not supported", }); }); - it("should append recursive structures with " + loadersKey, function() { + it("should append recursive structures with " + loadersKey, function () { const a = { - module: {} + module: {}, }; a.module[loadersKey] = [ { test: /\.js$/, - loader: "a" + loader: "a", }, { test: /\.jade$/, - loader: "a" - } + loader: "a", + }, ]; const b = { - module: {} + module: {}, }; b.module[loadersKey] = [ { test: /\.css$/, - loader: "b" + loader: "b", }, { test: /\.sass$/, - loader: "b" - } + loader: "b", + }, ]; const result = { - module: {} + module: {}, }; result.module[loadersKey] = [ { test: /\.js$/, - loader: "a" + loader: "a", }, { test: /\.jade$/, - loader: "a" + loader: "a", }, { test: /\.css$/, - loader: "b" + loader: "b", }, { test: /\.sass$/, - loader: "b" - } + loader: "b", + }, ]; assert.deepStrictEqual(merge(a, b), result); }); - it("should not override loader string values with " + loadersKey, function() { - const a = {}; - a[loadersKey] = [ - { - test: /\.js$/, - loader: "a" - } - ]; - const b = {}; - b[loadersKey] = [ - { - test: /\.js$/, - loader: "b" - }, - { - test: /\.css$/, - loader: "b" - } - ]; - const result = {}; - result[loadersKey] = [ - { - test: /\.js$/, - loader: "a" - }, - { - test: /\.js$/, - loader: "b" - }, - { - test: /\.css$/, - loader: "b" - } - ]; + it( + "should not override loader string values with " + loadersKey, + function () { + const a = {}; + a[loadersKey] = [ + { + test: /\.js$/, + loader: "a", + }, + ]; + const b = {}; + b[loadersKey] = [ + { + test: /\.js$/, + loader: "b", + }, + { + test: /\.css$/, + loader: "b", + }, + ]; + const result = {}; + result[loadersKey] = [ + { + test: /\.js$/, + loader: "a", + }, + { + test: /\.js$/, + loader: "b", + }, + { + test: /\.css$/, + loader: "b", + }, + ]; - assert.deepStrictEqual(merge(a, b), result); - }); + assert.deepStrictEqual(merge(a, b), result); + } + ); - it("should not append loaders with " + loadersKey, function() { + it("should not append loaders with " + loadersKey, function () { const a = {}; a[loadersKey] = [ { test: /\.js$/, - loaders: ["a"] - } + loaders: ["a"], + }, ]; const b = {}; b[loadersKey] = [ { test: /\.js$/, - loaders: ["b"] + loaders: ["b"], }, { test: /\.css$/, - loader: "b" - } + loader: "b", + }, ]; const result = {}; result[loadersKey] = [ { test: /\.js$/, - loaders: ["a"] + loaders: ["a"], }, { test: /\.js$/, - loaders: ["b"] + loaders: ["b"], }, { test: /\.css$/, - loader: "b" - } + loader: "b", + }, ]; assert.deepStrictEqual(merge(a, b), result); }); - it("should duplicate loaders with " + loadersKey, function() { + it("should duplicate loaders with " + loadersKey, function () { const a = {}; a[loadersKey] = [ { test: /\.js$/, - loaders: ["a"] - } + loaders: ["a"], + }, ]; const b = {}; b[loadersKey] = [ { test: /\.js$/, - loaders: ["a", "b"] - } + loaders: ["a", "b"], + }, ]; const result = {}; result[loadersKey] = [ { test: /\.js$/, - loaders: ["a"] + loaders: ["a"], }, { test: /\.js$/, - loaders: ["a", "b"] - } + loaders: ["a", "b"], + }, ]; assert.deepStrictEqual(merge(a, b), result); @@ -304,42 +307,42 @@ function normalMergeTest(merge, loadersKey) { it( "should not override query options for the same loader with " + loadersKey, - function() { + function () { const a = {}; a[loadersKey] = [ { test: /\.js$/, - loaders: ["a?1"] - } + loaders: ["a?1"], + }, ]; const b = {}; b[loadersKey] = [ { test: /\.js$/, - loaders: ["a?2", "b"] - } + loaders: ["a?2", "b"], + }, ]; const c = {}; c[loadersKey] = [ { test: /\.js$/, - loaders: ["a", "b?3"] - } + loaders: ["a", "b?3"], + }, ]; const result = {}; result[loadersKey] = [ { test: /\.js$/, - loaders: ["a?1"] + loaders: ["a?1"], }, { test: /\.js$/, - loaders: ["a?2", "b"] + loaders: ["a?2", "b"], }, { test: /\.js$/, - loaders: ["a", "b?3"] - } + loaders: ["a", "b?3"], + }, ]; assert.deepStrictEqual(merge(a, b, c), result); @@ -348,13 +351,13 @@ function normalMergeTest(merge, loadersKey) { it( "should not allow overriding with an empty array in " + loadersKey, - function() { + function () { const a = {}; a[loadersKey] = [ { test: /\.js$/, - loaders: ["a?1"] - } + loaders: ["a?1"], + }, ]; const b = {}; b[loadersKey] = []; diff --git a/test/unique.test.ts b/test/unique.test.ts index b152512..80c0284 100644 --- a/test/unique.test.ts +++ b/test/unique.test.ts @@ -2,79 +2,79 @@ import assert from "assert"; import webpack from "webpack"; import { mergeWithCustomize, unique } from "../resolve"; -describe("Unique", function() { - it("should allow unique definitions", function() { +describe("Unique", function () { + it("should allow unique definitions", function () { const output = mergeWithCustomize({ customizeArray: unique( "plugins", ["HotModuleReplacementPlugin"], - plugin => plugin.constructor && plugin.constructor.name - ) + (plugin) => plugin.constructor && plugin.constructor.name + ), })( { - plugins: [new webpack.HotModuleReplacementPlugin()] + plugins: [new webpack.HotModuleReplacementPlugin()], }, { - plugins: [new webpack.HotModuleReplacementPlugin()] + plugins: [new webpack.HotModuleReplacementPlugin()], } ); const expected = { - plugins: [new webpack.HotModuleReplacementPlugin()] + plugins: [new webpack.HotModuleReplacementPlugin()], }; assert.deepStrictEqual(output, expected); }); - it("should pick the last plugin (#119)", function() { + it("should pick the last plugin (#119)", function () { const output = mergeWithCustomize({ customizeArray: unique( "plugins", ["DefinePlugin"], - plugin => plugin.constructor && plugin.constructor.name - ) + (plugin) => plugin.constructor && plugin.constructor.name + ), })( { plugins: [ new webpack.DefinePlugin({ - a: "a" - }) - ] + a: "a", + }), + ], }, { plugins: [ new webpack.DefinePlugin({ - b: "b" - }) - ] + b: "b", + }), + ], } ); const expected = { plugins: [ new webpack.DefinePlugin({ - b: "b" - }) - ] + b: "b", + }), + ], }; assert.deepStrictEqual(output, expected); }); - it("should not lose any plugins", function() { + it("should not lose any plugins", function () { const output = mergeWithCustomize({ customizeArray: unique( "plugins", ["HotModuleReplacementPlugin"], - plugin => plugin.constructor && plugin.constructor.name - ) + (plugin) => plugin.constructor && plugin.constructor.name + ), })( { plugins: [ new webpack.HotModuleReplacementPlugin(), - new webpack.DefinePlugin({}) - ] + new webpack.DefinePlugin({}), + ], }, { - plugins: [new webpack.HotModuleReplacementPlugin()] + plugins: [new webpack.HotModuleReplacementPlugin()], } ); // The HMR plugin is picked from the last one due to @@ -82,37 +82,37 @@ describe("Unique", function() { const expected = { plugins: [ new webpack.DefinePlugin({}), - new webpack.HotModuleReplacementPlugin() - ] + new webpack.HotModuleReplacementPlugin(), + ], }; assert.deepStrictEqual(output, expected); }); - it("should check only against named plugins (#125)", function() { + it("should check only against named plugins (#125)", function () { const output = mergeWithCustomize({ customizeArray: unique( "plugins", ["DefinePlugin"], - plugin => plugin.constructor && plugin.constructor.name - ) + (plugin) => plugin.constructor && plugin.constructor.name + ), })( { plugins: [ new webpack.HotModuleReplacementPlugin(), - new webpack.DefinePlugin({}) - ] + new webpack.DefinePlugin({}), + ], }, { - plugins: [new webpack.HotModuleReplacementPlugin()] + plugins: [new webpack.HotModuleReplacementPlugin()], } ); const expected = { plugins: [ new webpack.HotModuleReplacementPlugin(), new webpack.DefinePlugin({}), - new webpack.HotModuleReplacementPlugin() - ] + new webpack.HotModuleReplacementPlugin(), + ], }; assert.deepStrictEqual(output, expected);