Skip to content

Commit 283169a

Browse files
committed
refactor(es6) upgrade NoErrorsPlugin to ES6 class
1 parent de9323f commit 283169a

1 file changed

Lines changed: 20 additions & 17 deletions

File tree

‎lib/NoErrorsPlugin.js‎

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,28 @@
22
MIT License http://www.opensource.org/licenses/mit-license.php
33
Author Tobias Koppers @sokra
44
*/
5-
function NoErrorsPlugin() {}
5+
"use strict";
66

7-
var deprecationReported = false;
7+
let deprecationReported = false;
88

9-
module.exports = NoErrorsPlugin;
10-
NoErrorsPlugin.prototype.apply = function(compiler) {
11-
compiler.plugin("should-emit", function(compilation) {
12-
if(!deprecationReported) {
13-
compilation.warnings.push("webpack: Using NoErrorsPlugin is deprecated.\n" +
14-
"Use NoEmitOnErrorsPlugin instead.\n");
15-
deprecationReported = true;
16-
}
17-
if(compilation.errors.length > 0)
18-
return false;
19-
});
20-
compiler.plugin("compilation", function(compilation) {
21-
compilation.plugin("should-record", function() {
9+
class NoErrorsPlugin {
10+
apply(compiler) {
11+
compiler.plugin("should-emit", (compilation) => {
12+
if(!deprecationReported) {
13+
compilation.warnings.push("webpack: Using NoErrorsPlugin is deprecated.\n" +
14+
"Use NoEmitOnErrorsPlugin instead.\n");
15+
deprecationReported = true;
16+
}
2217
if(compilation.errors.length > 0)
2318
return false;
2419
});
25-
});
26-
};
20+
compiler.plugin("compilation", (compilation) => {
21+
compilation.plugin("should-record", () => {
22+
if(compilation.errors.length > 0)
23+
return false;
24+
});
25+
});
26+
}
27+
}
28+
29+
module.exports = NoErrorsPlugin;

0 commit comments

Comments
 (0)