Repository: eslint/eslint
File: lib/rule-tester/rule-tester.js (JavaScript)

Code before:
		hasValid,
		`Test Scenarios for rule ${ruleName} is invalid:\nCould not find any valid test scenarios\n`,
	);

	assert.ok(
		hasInvalid,
		`Test Scenarios for rule ${ruleName} is invalid:\nCould not find any invalid test scenarios\n`,
	);
}

/**
 * Asserts that the common properties of a valid/invalid test case have the correct types.
 * @param {Object} item The test case object to check.
 * @returns {void}
 */
function assertTestCommonProperties(item) {
	assert.ok(
		typeof item.code === "string",
		"Test case must specify a string value for 'code'",
	);

	// optional properties
	assert.ok(
		item.name === void 0 || typeof item.name === "string",
		`Optional test case property 'name' must be a string`,
	);
	assert.ok(
		item.only === void 0 || typeof item.only === "boolean",
		`Optional test case property 'only' must be a boolean`,
	);
	assert.ok(
		item.filename === void 0 || typeof item.filename === "string",
		`Optional test case property 'filename' must be a string`,
	);
	assert.ok(
		item.options === void 0 || Array.isArray(item.options),
		`Optional test case property 'options' must be an array`,
	);
}

/**
 * Asserts that a valid test case object is valid.
 * A valid test case must specify a string value for 'code' and must not have 'errors' or 'output' properties.
 * Optional properties are checked for correct types.
 * @param {Object} item The valid test case object to check.
 * @param {Set<string>} seenTestCases Set of serialized test cases to check for duplicates.
 * @returns {void}
 * @throws {AssertionError} If the test case is not valid.
 */
function assertValidTestCase(item, seenTestCases) {
	assertTestCommonProperties(item);

Review comment (suggestion):
```suggestion
	if (item.name) {
		assert.ok(
			typeof item.name === "string",
			"Optional test case property 'name' must be a string",
		);
	}
```

The difference would be when `name` is set to a falsy value.

Code after:
	assert.ok(
		test && typeof test === "object",
		`Test Scenarios for rule ${ruleName} : Could not find test scenario object`,
	);

	const hasValid = Array.isArray(test.valid);
	const hasInvalid = Array.isArray(test.invalid);

	assert.ok(
		hasValid,
		`Test Scenarios for rule ${ruleName} is invalid: Could not find any valid test scenarios`,
	);

	assert.ok(
		hasInvalid,
		`Test Scenarios for rule ${ruleName} is invalid: Could not find any invalid test scenarios`,
	);
}

/**
 * Asserts that the common properties of a valid/invalid test case have the correct types.
 * @param {Object} item The test case object to check.
 * @returns {void}
 */
function assertTestCommonProperties(item) {
	assert.ok(
		typeof item.code === "string",
		"Test case must specify a string value for 'code'",
	);

	// optional properties
	if (item.name) {
		assert.ok(
			typeof item.name === "string",
			"Optional test case property 'name' must be a string",
		);
	}
	if (hasOwnProperty(item, "only")) {
		assert.ok(
			typeof item.only === "boolean",
			"Optional test case property 'only' must be a boolean",
		);
	}
	if (hasOwnProperty(item, "filename")) {
		assert.ok(
			typeof item.filename === "string",
			"Optional test case property 'filename' must be a string",
		);
	}
	if (hasOwnProperty(item, "options")) {
		assert.ok(