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

Code before:

            if (typeof importSource === "string") {
                memo[path].push({});
            } else {
                memo[path].push({
                    message: importSource.message,
                    importNames: importSource.importNames,
                    allowImportNames: importSource.allowImportNames
                });
            }
            return memo;
        }, Object.create(null));

        // Handle patterns too, either as strings or groups
        let restrictedPatterns = (isPathAndPatternsObject ? options[0].patterns : []) || [];

        // standardize to array of objects if we have an array of strings
        if (restrictedPatterns.length > 0 && typeof restrictedPatterns[0] === "string") {
            restrictedPatterns = [{ group: restrictedPatterns }];
        }

        // relative paths are supported for this rule
        const restrictedPatternGroups = restrictedPatterns.map(
            ({ group, regex, message, caseSensitive, importNames, importNamePattern, allowImportNames, allowImportNamePattern }) => (
                {
                    matcher: ignore({ allowRelativePaths: true, ignorecase: !caseSensitive }).add(group),
                    ...(regex ? { regexMatcher: new RegExp(regex, caseSensitive ? "u" : "iu") } : {}),
                    customMessage: message,
                    importNames,
                    importNamePattern,
                    allowImportNames,
                    allowImportNamePattern
                }
            )
        );

        // if no imports are restricted we don't need to check
        if (Object.keys(restrictedPaths).length === 0 && restrictedPatternGroups.length === 0) {
            return {};
        }

        /**
         * Report a restricted path.
         * @param {string} importSource path of the import
         * @param {Map<string,Object[]>} importNames Map of import names that are being imported
         * @param {node} node representing the restricted path reference
         * @returns {void}
         * @private
         */
        function checkRestrictedPathAndReport(importSource, importNames, node) {
            if (!Object.hasOwn(groupedRestrictedPaths, importSource)) {

Review comment (security):
```suggestion
                    ...(group ? { matcher: ignore({ allowRelativePaths: true, ignorecase: !caseSensitive }).add(group) } : {}),
```

Since the `group` property is now not mandatory, it might make sense to create `matcher` conditionally, the same as with `regexMatcher`.

Code after:
            if (typeof importSource === "string") {
                memo[path].push({});
            } else {
                memo[path].push({
                    message: importSource.message,
                    importNames: importSource.importNames,
                    allowImportNames: importSource.allowImportNames
                });
            }
            return memo;
        }, Object.create(null));

        // Handle patterns too, either as strings or groups
        let restrictedPatterns = (isPathAndPatternsObject ? options[0].patterns : []) || [];

        // standardize to array of objects if we have an array of strings
        if (restrictedPatterns.length > 0 && typeof restrictedPatterns[0] === "string") {
            restrictedPatterns = [{ group: restrictedPatterns }];
        }

        // relative paths are supported for this rule
        const restrictedPatternGroups = restrictedPatterns.map(
            ({ group, regex, message, caseSensitive, importNames, importNamePattern, allowImportNames, allowImportNamePattern }) => (
                {
                    ...(group ? { matcher: ignore({ allowRelativePaths: true, ignorecase: !caseSensitive }).add(group) } : {}),
                    ...(typeof regex === "string" ? { regexMatcher: new RegExp(regex, caseSensitive ? "u" : "iu") } : {}),
                    customMessage: message,
                    importNames,
                    importNamePattern,
                    allowImportNames,
                    allowImportNamePattern
                }
            )
        );

        // if no imports are restricted we don't need to check
        if (Object.keys(restrictedPaths).length === 0 && restrictedPatternGroups.length === 0) {
            return {};
        }

        /**
         * Report a restricted path.
         * @param {string} importSource path of the import
         * @param {Map<string,Object[]>} importNames Map of import names that are being imported
         * @param {node} node representing the restricted path reference
         * @returns {void}
         * @private
         */
        function checkRestrictedPathAndReport(importSource, importNames, node) {
            if (!Object.hasOwn(groupedRestrictedPaths, importSource)) {
                return;