Repository: eslint/eslint
File: lib/rules/no-restricted-properties.js (JavaScript)

Code before:
			const propertyName = option.property;

			if (typeof objectName === "undefined") {
				globallyRestrictedProperties.set(propertyName, {
					allowObjects: option.allowObjects,
					message: option.message,
				});
			} else if (typeof propertyName === "undefined") {
				globallyRestrictedObjects.set(objectName, {
					message: option.message,
				});
			} else {
				if (!restrictedProperties.has(objectName)) {
					restrictedProperties.set(objectName, new Map());
				}

				restrictedProperties.get(objectName).set(propertyName, {
					message: option.message,
				});
			}
		});

		/**
		 * Checks if an object name is in the allowed objects list.
		 * @param {string} objectName The name of the object to check
		 * @param {string[]} allowObjects The list of objects to allow
		 * @returns {boolean} True if the object is allowed, false otherwise
		 */
		function isAllowedObject(objectName, allowObjects) {
			if (!allowObjects) {
				return false;
			}

			return allowObjects.includes(objectName);
		}

		/**
		 * Checks to see whether a property access is restricted, and reports it if so.
		 * @param {ASTNode} node The node to report
		 * @param {string} objectName The name of the object
		 * @param {string} propertyName The name of the property
		 * @returns {undefined}
		 */
		function checkPropertyAccess(node, objectName, propertyName) {
			if (propertyName === null) {
				return;
			}
			const matchedObject = restrictedProperties.get(objectName);
			const matchedObjectProperty = matchedObject
				? matchedObject.get(propertyName)
				: globallyRestrictedObjects.get(objectName);

Review comment (suggestion):
```suggestion
		 * @param {string[]} [allowObjects] The list of objects to allow
```

As it can be undefined.

Code after:
			const propertyName = option.property;

			if (typeof objectName === "undefined") {
				globallyRestrictedProperties.set(propertyName, {
					allowObjects: option.allowObjects,
					message: option.message,
				});
			} else if (typeof propertyName === "undefined") {
				globallyRestrictedObjects.set(objectName, {
					message: option.message,
				});
			} else {
				if (!restrictedProperties.has(objectName)) {
					restrictedProperties.set(objectName, new Map());
				}

				restrictedProperties.get(objectName).set(propertyName, {
					message: option.message,
				});
			}
		});

		/**
		 * Checks if an object name is in the allowed objects list.
		 * @param {string} objectName The name of the object to check
		 * @param {string[]} [allowObjects] The list of objects to allow
		 * @returns {boolean} True if the object is allowed, false otherwise
		 */
		function isAllowedObject(objectName, allowObjects) {
			if (!allowObjects) {
				return false;
			}

			return allowObjects.includes(objectName);
		}

		/**
		 * Checks to see whether a property access is restricted, and reports it if so.
		 * @param {ASTNode} node The node to report
		 * @param {string} objectName The name of the object
		 * @param {string} propertyName The name of the property
		 * @returns {undefined}
		 */
		function checkPropertyAccess(node, objectName, propertyName) {
			if (propertyName === null) {
				return;
			}
			const matchedObject = restrictedProperties.get(objectName);
			const matchedObjectProperty = matchedObject
				? matchedObject.get(propertyName)
				: globallyRestrictedObjects.get(objectName);