Skip to content

Commit d8ffdd4

Browse files
authored
fix: do not exit process on rule crash (#19436)
* test: rule crash should not exit process * update `@humanwhocodes/retry`
1 parent dab5478 commit d8ffdd4

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
"@eslint/plugin-kit": "^0.2.5",
109109
"@humanfs/node": "^0.16.6",
110110
"@humanwhocodes/module-importer": "^1.0.1",
111-
"@humanwhocodes/retry": "^0.4.1",
111+
"@humanwhocodes/retry": "^0.4.2",
112112
"@types/estree": "^1.0.6",
113113
"@types/json-schema": "^7.0.15",
114114
"ajv": "^6.12.4",

tests/lib/eslint/eslint.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6158,6 +6158,54 @@ describe("ESLint", () => {
61586158
assert.strictEqual(createCallCount, 1);
61596159
});
61606160

6161+
// https://github.com/eslint/eslint/issues/19243
6162+
it("should not exit the process unexpectedly after a rule crashes", async () => {
6163+
const cwd = getFixturePath();
6164+
6165+
/*
6166+
* Mocha attaches `unhandledRejection` event handlers to the current process.
6167+
* To test without global handlers, we must launch a new process.
6168+
*/
6169+
const teardown = createCustomTeardown({
6170+
cwd,
6171+
files: {
6172+
"test.js": `
6173+
const { ESLint } = require(${JSON.stringify(require.resolve("eslint"))});
6174+
6175+
const eslint = new ESLint({
6176+
flags: ${JSON.stringify(flags)},
6177+
overrideConfigFile: true,
6178+
plugins: {
6179+
boom: {
6180+
rules: {
6181+
boom: {
6182+
create: () => ({
6183+
"*"() {
6184+
throw "Boom!";
6185+
},
6186+
}),
6187+
}
6188+
}
6189+
}
6190+
},
6191+
baseConfig: {
6192+
rules: {
6193+
"boom/boom": "error"
6194+
}
6195+
}
6196+
});
6197+
6198+
eslint.lintFiles("passing.js").catch(() => { });
6199+
`
6200+
}
6201+
});
6202+
6203+
await teardown.prepare();
6204+
const execFile = util.promisify(require("node:child_process").execFile);
6205+
6206+
await execFile(process.execPath, ["test.js"], { cwd });
6207+
});
6208+
61616209
describe("Error while globbing", () => {
61626210

61636211
it("should throw an error with a glob pattern if an invalid config was provided", async () => {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy