Skip to content

Commit def99b0

Browse files
fix!: use compiler.options.mode to set the default value of failOnError (#296)
* fix!: use `compiler.options.mode` to set the default value of `failOnError` * test: update option `failOnError`
1 parent 42de4fe commit def99b0

File tree

4 files changed

+7
-2
lines changed

4 files changed

+7
-2
lines changed

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class ESLintWebpackPlugin {
3434
// Generate key for each compilation,
3535
// this differentiates one from the other when being cached.
3636
this.key = compiler.name || `${this.key}_${(compilerId += 1)}`;
37+
this.options.failOnError ??= compiler.options.mode !== "development";
3738

3839
const excludedFiles = parseFiles(
3940
this.options.exclude || [],

src/options.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ function getOptions(pluginOptions) {
5252
extensions: "js",
5353
emitError: true,
5454
emitWarning: true,
55-
failOnError: true,
5655
resourceQueryExclude: [],
5756
...pluginOptions,
5857
...(pluginOptions.quiet ? { emitError: true, emitWarning: false } : {}),

test/multiple-instances.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ describe("multiple instances", () => {
1010
{
1111
plugins: [
1212
new ESLintPlugin({
13+
failOnError: true,
1314
overrideConfigFile: join(
1415
__dirname,
1516
"./config-for-tests/eslint.config.mjs",
@@ -18,6 +19,7 @@ describe("multiple instances", () => {
1819
exclude: "error.js",
1920
}),
2021
new ESLintPlugin({
22+
failOnError: true,
2123
overrideConfigFile: join(
2224
__dirname,
2325
"./config-for-tests/eslint.config.mjs",
@@ -41,6 +43,7 @@ describe("multiple instances", () => {
4143
{
4244
plugins: [
4345
new ESLintPlugin({
46+
failOnError: true,
4447
overrideConfigFile: join(
4548
__dirname,
4649
"./config-for-tests/eslint.config.mjs",
@@ -49,6 +52,7 @@ describe("multiple instances", () => {
4952
exclude: "good.js",
5053
}),
5154
new ESLintPlugin({
55+
failOnError: true,
5256
overrideConfigFile: join(
5357
__dirname,
5458
"./config-for-tests/eslint.config.mjs",
@@ -70,6 +74,7 @@ describe("multiple instances", () => {
7074
{
7175
plugins: [
7276
new ESLintPlugin({
77+
failOnError: true,
7378
overrideConfigFile: join(
7479
__dirname,
7580
"./config-for-tests/eslint.config.mjs",
@@ -78,6 +83,7 @@ describe("multiple instances", () => {
7883
exclude: "error.js",
7984
}),
8085
new ESLintPlugin({
86+
failOnError: true,
8187
overrideConfigFile: join(
8288
__dirname,
8389
"./config-for-tests/eslint.config.mjs",

test/utils/conf.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ export default (entry, pluginConf = {}, webpackConf = {}) => {
2424
ignore: false,
2525
// TODO: update tests to run both states: test.each([[{threads: false}], [{threads: true}]])('it should...', async ({threads}) => {...})
2626
threads: true,
27-
failOnError: false,
2827
...pluginConf,
2928
}),
3029
],

0 commit comments

Comments
 (0)