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

Code before:

/**
 * Throws an error if the given options are not cloneable.
 * @param {ESLintOptions} options The options to check.
 * @returns {void}
 * @throws {TypeError} If the options are not cloneable.
 */
function validateOptionCloneability(options) {
	try {
		structuredClone(options);
		return;
	} catch {
		// continue
	}
	const uncloneableOptionKeys = Object.keys(options)
		.filter(key => {
			try {
				structuredClone(options[key]);
			} catch {
				return true;
			}
			return false;
		})
		.sort();
	const error = new TypeError(
		`The ${uncloneableOptionKeys.length === 1 ? "option" : "options"} ${new Intl.ListFormat("en-US").format(uncloneableOptionKeys.map(key => `"${key}"`))} cannot be cloned. When concurrency is enabled, all options must be cloneable values--such as primitives, plain objects, or arrays. Remove uncloneable options or use an options module.`,
	);
	error.code = "ESLINT_UNCLONEABLE_OPTIONS";
	throw error;
}

//-----------------------------------------------------------------------------
// Main API
//-----------------------------------------------------------------------------

/**
 * Primary Node.js API for ESLint.
 */
class ESLint {
	/**
	 * The type of configuration used by this class.
	 * @type {string}
	 */
	static configType = "flat";

	/**
	 * The loader to use for finding config files.
	 * @type {ConfigLoader}
	 */
	#configLoader;


Review comment (refactor):
The double-dash makes it a bit difficult to read and isn't how we typically format error messages. I also think we can simplify this message and make it clearer.

```suggestion
		`The ${uncloneableOptionKeys.length === 1 ? "option" : "options"} ${new Intl.ListFormat("en-US").format(uncloneableOptionKeys.map(key => `"${key}"`))} cannot be cloned. When concurrency is enabled, all options must be cloneable values (JSON values). Remove uncloneable options or use an options module.`,
```

Code after:
		}),
	);
	return results;
}

/**
 * Throws an error if the given options are not cloneable.
 * @param {ESLintOptions} options The options to check.
 * @returns {void}
 * @throws {TypeError} If the options are not cloneable.
 */
function validateOptionCloneability(options) {
	try {
		structuredClone(options);
		return;
	} catch {
		// continue
	}
	const uncloneableOptionKeys = Object.keys(options)
		.filter(key => {
			try {
				structuredClone(options[key]);
			} catch {
				return true;
			}
			return false;
		})
		.sort();
	const error = new TypeError(
		`The ${uncloneableOptionKeys.length === 1 ? "option" : "options"} ${new Intl.ListFormat("en-US").format(uncloneableOptionKeys.map(key => `"${key}"`))} cannot be cloned. When concurrency is enabled, all options must be cloneable values (JSON values). Remove uncloneable options or use an options module.`,
	);
	error.code = "ESLINT_UNCLONEABLE_OPTIONS";
	throw error;
}

//-----------------------------------------------------------------------------
// Main API
//-----------------------------------------------------------------------------

/**
 * Primary Node.js API for ESLint.
 */
class ESLint {
	/**
	 * The type of configuration used by this class.
	 * @type {string}
	 */
	static configType = "flat";

	/**
	 * The loader to use for finding config files.