Skip to content

Commit 233c1a3

Browse files
author
Anuj Nair
committed
Fixing new eslint violations
1 parent a8b5094 commit 233c1a3

File tree

1 file changed

+14
-25
lines changed

1 file changed

+14
-25
lines changed

plugin.js

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ class CspHtmlWebpackPlugin {
4949
this.cspPluginPolicy = Object.freeze(policy);
5050

5151
// the additional options that this plugin allows
52-
this.opts = Object.freeze(
53-
Object.assign({}, defaultAdditionalOpts, additionalOpts)
54-
);
52+
this.opts = Object.freeze({ ...defaultAdditionalOpts, ...additionalOpts });
5553

5654
// valid hashes from https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src#Sources
5755
if (!['sha256', 'sha384', 'sha512'].includes(this.opts.hashingMethod)) {
@@ -73,36 +71,27 @@ class CspHtmlWebpackPlugin {
7371
mergeOptions(compilation, htmlPluginData, compileCb) {
7472
// 1. Let's create the policy we want to use for this HtmlWebpackPlugin instance
7573
// CspHtmlWebpackPlugin and HtmlWebpackPlugin policies merged
76-
const userPolicy = Object.freeze(
77-
Object.assign(
78-
{},
79-
this.cspPluginPolicy,
80-
get(htmlPluginData, 'plugin.options.cspPlugin.policy', {})
81-
)
82-
);
74+
const userPolicy = Object.freeze({
75+
...this.cspPluginPolicy,
76+
...get(htmlPluginData, 'plugin.options.cspPlugin.policy', {})
77+
});
8378

8479
// defaultPolicy and userPolicy merged
85-
this.policy = Object.freeze(Object.assign({}, defaultPolicy, userPolicy));
80+
this.policy = Object.freeze({ ...defaultPolicy, ...userPolicy });
8681

8782
// and now validate it
8883
this.validatePolicy(compilation);
8984

9085
// 2. Lets set which hashes and nonces are enabled for this HtmlWebpackPlugin instance
91-
this.hashEnabled = Object.freeze(
92-
Object.assign(
93-
{},
94-
this.opts.hashEnabled,
95-
get(htmlPluginData, 'plugin.options.cspPlugin.hashEnabled', {})
96-
)
97-
);
86+
this.hashEnabled = Object.freeze({
87+
...this.opts.hashEnabled,
88+
...get(htmlPluginData, 'plugin.options.cspPlugin.hashEnabled', {})
89+
});
9890

99-
this.nonceEnabled = Object.freeze(
100-
Object.assign(
101-
{},
102-
this.opts.nonceEnabled,
103-
get(htmlPluginData, 'plugin.options.cspPlugin.nonceEnabled', {})
104-
)
105-
);
91+
this.nonceEnabled = Object.freeze({
92+
...this.opts.nonceEnabled,
93+
...get(htmlPluginData, 'plugin.options.cspPlugin.nonceEnabled', {})
94+
});
10695

10796
return compileCb(null, htmlPluginData);
10897
}

0 commit comments

Comments
 (0)