Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,921 changes: 915 additions & 1,006 deletions package-lock.json

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,34 +57,34 @@
"schema-utils": "^4.3.0"
},
"devDependencies": {
"@babel/cli": "^7.26.4",
"@babel/core": "^7.26.7",
"@babel/preset-env": "^7.26.7",
"@commitlint/cli": "^19.7.1",
"@commitlint/config-conventional": "^19.7.1",
"@babel/cli": "^7.27.0",
"@babel/core": "^7.26.10",
"@babel/preset-env": "^7.26.9",
"@commitlint/cli": "^19.8.0",
"@commitlint/config-conventional": "^19.8.0",
"@types/fs-extra": "^11.0.4",
"@types/micromatch": "^4.0.9",
"@types/node": "^22.13.1",
"@types/node": "^22.14.0",
"@types/normalize-path": "^3.0.2",
"@types/webpack": "^5.28.5",
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
"babel-jest": "^29.7.0",
"chokidar": "^4.0.3",
"cross-env": "^7.0.3",
"cspell": "^8.17.3",
"cspell": "^8.18.1",
"del": "^8.0.0",
"del-cli": "^6.0.0",
"eslint": "^9.19.0",
"eslint-config-prettier": "^10.0.1",
"eslint": "^9.24.0",
"eslint-config-prettier": "^10.1.2",
"fs-extra": "^11.3.0",
"husky": "^9.1.7",
"jest": "^29.7.0",
"lint-staged": "^15.4.3",
"lint-staged": "^15.5.0",
"npm-run-all": "^4.1.5",
"prettier": "^3.4.2",
"prettier": "^3.5.3",
"standard-version": "^9.5.0",
"typescript": "^5.7.3",
"webpack": "^5.97.1"
"typescript": "^5.8.3",
"webpack": "^5.99.5"
},
"keywords": [
"eslint",
Expand Down
51 changes: 28 additions & 23 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,29 +150,34 @@ class ESLintWebpackPlugin {
});

// await and interpret results
compilation.hooks.additionalAssets.tapPromise(this.key, processResults);

async function processResults() {
const { errors, warnings, generateReportAsset } = await report();

if (warnings && !options.failOnWarning) {
// @ts-ignore
compilation.warnings.push(warnings);
} else if (warnings) {
// @ts-ignore
compilation.errors.push(warnings);
}

if (errors && !options.failOnError) {
// @ts-ignore
compilation.warnings.push(errors);
} else if (errors) {
// @ts-ignore
compilation.errors.push(errors);
}

if (generateReportAsset) await generateReportAsset(compilation);
}
compilation.hooks.additionalAssets.tapAsync(
this.key,
async function (callback) {
const { errors, warnings, generateReportAsset } = await report();

if (warnings) {
// @ts-ignore
compilation.warnings.push(warnings);
}

if (errors) {
// @ts-ignore
compilation.errors.push(errors);
}

if (generateReportAsset) {
await generateReportAsset(compilation);
}

if (warnings && options.failOnWarning) {
callback(warnings);
} else if (errors && options.failOnError) {
callback(errors);
} else {
callback();
}
},
);
});
}

Expand Down
9 changes: 4 additions & 5 deletions test/fail-on-error.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,20 @@ describe('fail on error', () => {
it('should emits errors', async () => {
const compiler = pack('error', { failOnError: true });

const stats = await compiler.runAsync();
expect(stats.hasErrors()).toBe(true);
await expect(compiler.runAsync()).rejects.toThrow('error');
});

it('should emit warnings when disabled', async () => {
const compiler = pack('error', { failOnError: false });

const stats = await compiler.runAsync();
expect(stats.hasErrors()).toBe(false);
expect(stats.hasWarnings()).toBe(true);
expect(stats.hasErrors()).toBe(true);
});

it('should correctly identifies a success', async () => {
const compiler = pack('good', { failOnError: true });

await compiler.runAsync();
const stats = await compiler.runAsync();
expect(stats.hasErrors()).toBe(false);
});
});
3 changes: 1 addition & 2 deletions test/fail-on-warning.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ describe('fail on warning', () => {
it('should emits errors', async () => {
const compiler = pack('warn', { failOnWarning: true });

const stats = await compiler.runAsync();
expect(stats.hasErrors()).toBe(true);
await expect(compiler.runAsync()).rejects.toThrow('warning');
});

it('should correctly identifies a success', async () => {
Expand Down
3 changes: 1 addition & 2 deletions test/lint-dirty-modules-only.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ describe('lint dirty modules only', () => {
expect(stats.hasErrors()).toBe(true);
const { errors } = stats.compilation;
expect(errors.length).toBe(1);
const [{ message }] = errors;
expect(message).toEqual(expect.stringMatching('no-unused-vars'));
expect(stats.compilation.errors[0].message).toEqual(expect.stringMatching('no-unused-vars'));
done();
}
});
Expand Down
8 changes: 2 additions & 6 deletions test/multiple-instances.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ describe('multiple instances', () => {
},
);

const stats = await compiler.runAsync();
expect(stats.hasWarnings()).toBe(false);
expect(stats.hasErrors()).toBe(true);
await expect(compiler.runAsync()).rejects.toThrow();
});

it('should fail on second instance', async () => {
Expand All @@ -73,8 +71,6 @@ describe('multiple instances', () => {
},
);

const stats = await compiler.runAsync();
expect(stats.hasWarnings()).toBe(false);
expect(stats.hasErrors()).toBe(true);
await expect(compiler.runAsync()).rejects.toThrow();
});
});
1 change: 1 addition & 0 deletions test/utils/conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default (entry, pluginConf = {}, webpackConf = {}) => {
ignore: false,
// TODO: update tests to run both states: test.each([[{threads: false}], [{threads: true}]])('it should...', async ({threads}) => {...})
threads: true,
failOnError: false,
...pluginConf,
}),
],
Expand Down