HEX
Server: nginx/1.18.0
System: Linux test-ipsremont 5.4.0-214-generic #234-Ubuntu SMP Fri Mar 14 23:50:27 UTC 2025 x86_64
User: ips (1000)
PHP: 8.0.30
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/ai-notam/node_modules/eslint-rule-composer/lib/rule-composer.js
'use strict';

/**
 * Translates a multi-argument context.report() call into a single object argument call
 * @param {...*} arguments A list of arguments passed to `context.report`
 * @returns {MessageDescriptor} A normalized object containing report information
 */
function normalizeMultiArgReportCall() {
  // If there is one argument, it is considered to be a new-style call already.
  if (arguments.length === 1) {
    return arguments[0];
  }

  // If the second argument is a string, the arguments are interpreted as [node, message, data, fix].
  if (typeof arguments[1] === 'string') {
    return {
      node: arguments[0],
      message: arguments[1],
      data: arguments[2],
      fix: arguments[3],
    };
  }

  // Otherwise, the arguments are interpreted as [node, loc, message, data, fix].
  return {
    node: arguments[0],
    loc: arguments[1],
    message: arguments[2],
    data: arguments[3],
    fix: arguments[4],
  };
}

/**
 * Normalizes a MessageDescriptor to always have a `loc` with `start` and `end` properties
 * @param {MessageDescriptor} descriptor A descriptor for the report from a rule.
 * @returns {{start: Location, end: (Location|null)}} An updated location that infers the `start` and `end` properties
 * from the `node` of the original descriptor, or infers the `start` from the `loc` of the original descriptor.
 */
function normalizeReportLoc(descriptor) {
  if (descriptor.loc) {
    if (descriptor.loc.start) {
      return descriptor.loc;
    }
    return { start: descriptor.loc, end: null };
  }
  return descriptor.node.loc;
}


/**
 * Interpolates data placeholders in report messages
 * @param {MessageDescriptor} descriptor The report message descriptor.
 * @param {Object} messageIds Message IDs from rule metadata
 * @returns {{message: string, data: Object}} The interpolated message and data for the descriptor
 */
function normalizeMessagePlaceholders(descriptor, messageIds) {
  const message = typeof descriptor.messageId === 'string' ? messageIds[descriptor.messageId] : descriptor.message;
  if (!descriptor.data) {
    return {
      message,
      data: typeof descriptor.messageId === 'string' ? {} : null,
    };
  }

  const normalizedData = Object.create(null);
  const interpolatedMessage = message.replace(/\{\{\s*([^{}]+?)\s*\}\}/g, (fullMatch, term) => {
    if (term in descriptor.data) {
      normalizedData[term] = descriptor.data[term];
      return descriptor.data[term];
    }

    return fullMatch;
  });

  return {
    message: interpolatedMessage,
    data: Object.freeze(normalizedData),
  };
}

function getRuleMeta(rule) {
  return typeof rule === 'object' && rule.meta && typeof rule.meta === 'object'
    ? rule.meta
    : {};
}

function getMessageIds(rule) {
  const meta = getRuleMeta(rule);
  return meta.messages && typeof rule.meta.messages === 'object'
    ? meta.messages
    : {};
}

function getReportNormalizer(rule) {
  const messageIds = getMessageIds(rule);

  return function normalizeReport() {
    const descriptor = normalizeMultiArgReportCall.apply(null, arguments)