Repository: eslint/eslint
File: tests/lib/eslint/eslint.js (JavaScript)

Code before:
			}, /The compact formatter is no longer part of core ESLint\. Install it manually with `npm install -D eslint-formatter-compact`/u);
		});

		it("should not throw the special message for removed formatters when loading an external module that fails", async () => {
			const engine = new ESLint({
				cwd: getFixturePath("cli-engine"),
			});

			await assert.rejects(async () => {
				await engine.loadFormatter("table-external");
			}, /There was a problem loading formatter/u);

			// Ensure it doesn't contain the "no longer part of core" message
			await assert.rejects(
				async () => {
					await engine.loadFormatter("table-external");
				},
				error => {
					assert.ok(
						!error.message.includes(
							"no longer part of core ESLint",
						),
					);
					return true;
				},
			);
		});
	});

	describe("getErrorResults()", () => {
		it("should report 5 error messages when looking for errors only", async () => {
			process.chdir(originalDir);
			const engine = new ESLint({
				overrideConfigFile: true,
				overrideConfig: {
					rules: {
						quotes: "error",
						"no-var": "error",
						"eol-last": "error",
						"no-unused-vars": "error",
					},
				},
			});
			const results = await engine.lintText("var foo = 'bar';");
			const errorResults = ESLint.getErrorResults(results);

			assert.strictEqual(
				errorResults[0].messages.length,
				4,
				"messages.length is wrong",
			);

Review comment (suggestion):
```suggestion
			// Ensure it doesn't contain the "no longer part of core" message
			await assert.rejects(
				async () => {
					await engine.loadFormatter("table-external");
				},
				error => {
					assert.ok(
						error.message.includes(
							"There was a problem loading formatter",
						) &&
							!error.message.includes(
								"no longer part of core ESLint",
							),
						`Unexpected error message: ${error.message}`,
					);
					return true;
				},
			);
```

I think we can merge these two checks into one since they're both running the same code and checking the error message.

Code after:
			}, /The compact formatter is no longer part of core ESLint\. Install it manually with `npm install -D eslint-formatter-compact`/u);
		});

		it("should not throw the special message for removed formatters when loading an external module that fails", async () => {
			const engine = new ESLint({
				cwd: getFixturePath("cli-engine"),
			});

			// Ensure it doesn't contain the "no longer part of core" message
			await assert.rejects(
				async () => {
					await engine.loadFormatter("table-external");
				},
				error => {
					assert.ok(
						error.message.includes(
							"There was a problem loading formatter",
						) &&
							!error.message.includes(
								"no longer part of core ESLint",
							),
						`Unexpected error message: ${error.message}`,
					);
					return true;
				},
			);
		});

		it("should throw if a removed formatter from node_modules throws on loading", async () => {
			const engine = new ESLint({
				cwd: getFixturePath("cli-engine"),
			});

			await assert.rejects(async () => {
				await engine.loadFormatter("checkstyle");
			}, /There was a problem loading formatter.*Error: Formatter loading failed/su);
		});
	});

	describe("getErrorResults()", () => {
		it("should report 5 error messages when looking for errors only", async () => {
			process.chdir(originalDir);
			const engine = new ESLint({
				overrideConfigFile: true,
				overrideConfig: {
					rules: {
						quotes: "error",
						"no-var": "error",
						"eol-last": "error",
						"no-unused-vars": "error",
					},