Home / Function/ findProgramSuppressions() — react Function Reference

findProgramSuppressions() — react Function Reference

Architecture documentation for the findProgramSuppressions() function in Suppression.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  6a20a35f_9061_eb10_3e52_2cce36820b84["findProgramSuppressions()"]
  f3160d78_61c2_0ad9_2d19_6daf9a63b386["Suppression.ts"]
  6a20a35f_9061_eb10_3e52_2cce36820b84 -->|defined in| f3160d78_61c2_0ad9_2d19_6daf9a63b386
  1c9af54b_10e9_8985_e772_1f517e46c560["compileProgram()"]
  1c9af54b_10e9_8985_e772_1f517e46c560 -->|calls| 6a20a35f_9061_eb10_3e52_2cce36820b84
  073c81a5_c389_d108_5b8f_4d6dc6eece83["push()"]
  6a20a35f_9061_eb10_3e52_2cce36820b84 -->|calls| 073c81a5_c389_d108_5b8f_4d6dc6eece83
  style 6a20a35f_9061_eb10_3e52_2cce36820b84 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Suppression.ts lines 79–159

export function findProgramSuppressions(
  programComments: Array<t.Comment>,
  ruleNames: Array<string> | null,
  flowSuppressions: boolean,
): Array<SuppressionRange> {
  const suppressionRanges: Array<SuppressionRange> = [];
  let disableComment: t.Comment | null = null;
  let enableComment: t.Comment | null = null;
  let source: SuppressionSource | null = null;

  let disableNextLinePattern: RegExp | null = null;
  let disablePattern: RegExp | null = null;
  let enablePattern: RegExp | null = null;
  if (ruleNames != null && ruleNames.length !== 0) {
    const rulePattern = `(${ruleNames.join('|')})`;
    disableNextLinePattern = new RegExp(
      `eslint-disable-next-line ${rulePattern}`,
    );
    disablePattern = new RegExp(`eslint-disable ${rulePattern}`);
    enablePattern = new RegExp(`eslint-enable ${rulePattern}`);
  }

  const flowSuppressionPattern = new RegExp(
    '\\$(FlowFixMe\\w*|FlowExpectedError|FlowIssue)\\[react\\-rule',
  );

  for (const comment of programComments) {
    if (comment.start == null || comment.end == null) {
      continue;
    }

    if (
      /*
       * If we're already within a CommentBlock, we should not restart the range prematurely for a
       * CommentLine within the block.
       */
      disableComment == null &&
      disableNextLinePattern != null &&
      disableNextLinePattern.test(comment.value)
    ) {
      disableComment = comment;
      enableComment = comment;
      source = 'Eslint';
    }

    if (
      flowSuppressions &&
      disableComment == null &&
      flowSuppressionPattern.test(comment.value)
    ) {
      disableComment = comment;
      enableComment = comment;
      source = 'Flow';
    }

    if (disablePattern != null && disablePattern.test(comment.value)) {
      disableComment = comment;
      source = 'Eslint';
    }

    if (
      enablePattern != null &&
      enablePattern.test(comment.value) &&
      source === 'Eslint'
    ) {
      enableComment = comment;
    }

    if (disableComment != null && source != null) {
      suppressionRanges.push({
        disableComment: disableComment,
        enableComment: enableComment,
        source,
      });
      disableComment = null;
      enableComment = null;
      source = null;
    }
  }
  return suppressionRanges;
}

Domain

Subdomains

Calls

Called By

Frequently Asked Questions

What does findProgramSuppressions() do?
findProgramSuppressions() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Suppression.ts.
Where is findProgramSuppressions() defined?
findProgramSuppressions() is defined in compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Suppression.ts at line 79.
What does findProgramSuppressions() call?
findProgramSuppressions() calls 1 function(s): push.
What calls findProgramSuppressions()?
findProgramSuppressions() is called by 1 function(s): compileProgram.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free