function checkRegex(node, pattern, flags) {
			let regExpAST;

			try {
				regExpAST = parser.parsePattern(pattern, 0, pattern.length, {
					unicode: flags.includes("u"),
					unicodeSets: flags.includes("v"),
				});
			} catch {
				// Ignore regular expressions with syntax errors
				return;
			}

			visitRegExpAST(regExpAST, {
				onBackreferenceEnter(bref) {
					const groups = [bref.resolved].flat(),
						brefPath = getPathToRoot(bref);

					const problems = groups.map(group => {
						const groupPath = getPathToRoot(group);

						if (brefPath.includes(group)) {
							// group is bref's ancestor => bref is nested ('nested reference') => group hasn't matched yet when bref starts to match.
							return {
								messageId: "nested",
								group,
							};
						}

						// Start from the root to find the lowest common ancestor.
						let i = brefPath.length - 1,
							j = groupPath.length - 1;

						do {
							i--;
							j--;
						} while (brefPath[i] === groupPath[j]);

						const indexOfLowestCommonAncestor = j + 1,
							groupCut = groupPath.slice(
								0,
								indexOfLowestCommonAncestor,
							),
							commonPath = groupPath.slice(
								indexOfLowestCommonAncestor,
							),
							lowestCommonLookaround =
								commonPath.find(isLookaround),
							isMatchingBackward =
								lowestCommonLookaround &&
								lowestCommonLookaround.kind === "lookbehind";

						if (groupCut.at(-1).type === "Alternative") {
							// group's and bref's ancestor nodes below the lowest common ancestor are sibling alternatives => they're disjunctive.
							return {
								messageId: "disjunctive",
								group,
							};
						}
						if (!isMatchingBackward && bref.end <= group.start) {
							// bref is left, group is right ('forward reference') => group hasn't matched yet when bref starts to match.
							return {
								messageId: "forward",
								group,
							};
						}
						if (isMatchingBackward && group.end <= bref.start) {
							// the opposite of the previous when the regex is matching backward in a lookbehind context.
							return {
								messageId: "backward",
								group,
							};
						}
						if (groupCut.some(isNegativeLookaround)) {
							// group is in a negative lookaround which isn't bref's ancestor => group has already failed when bref starts to match.
							return {
								messageId: "intoNegativeLookaround",
								group,
							};
						}

						return null;
					});

					if (
						problems.length === 0 ||
						problems.some(problem => !problem)
					) {
						// If there are no problems or no problems with any group then do not report it.
						return;
					}

					let problemsToReport;

					// Gets problems that appear in the same disjunction.
					const problemsInSameDisjunction = problems.filter(
						problem => problem.messageId !== "disjunctive",
					);

					if (problemsInSameDisjunction.length) {
						// Only report problems that appear in the same disjunction.
						problemsToReport = problemsInSameDisjunction;
					} else {
						// If all groups appear in different disjunctions, report it.
						problemsToReport = problems;
					}

					const [{ messageId, group }, ...other] = problemsToReport;
					let otherGroups = "";

					if (other.length === 1) {
						otherGroups = " and another group";
					} else if (other.length > 1) {
						otherGroups = ` and other ${other.length} groups`;
					}
					context.report({
						node,
						messageId,
						data: {
							bref: bref.raw,
							group: group.raw,
							otherGroups,
						},
					});
				},
			});
		}
Checks and reports useless backreferences in the given regular expression.
@param {ASTNode} node Node that represents regular expression. A regex literal or RegExp constructor call.
@param {string} pattern Regular expression pattern.
@param {string} flags Regular expression flags.
@returns {void}