Home / File/ ReactCompiler.ts — react Source File

ReactCompiler.ts — react Source File

Architecture documentation for ReactCompiler.ts, a typescript file in the react codebase. 4 imports, 3 dependents.

File typescript BabelCompiler Validation 4 imports 3 dependents 9 functions

Entity Profile

Dependency Diagram

graph LR
  40190dd7_cea0_7135_9d7e_df5f2d3454b7["ReactCompiler.ts"]
  0e801e17_9dc9_7a83_ce0f_d28b56e090f5["RunReactCompiler.ts"]
  40190dd7_cea0_7135_9d7e_df5f2d3454b7 --> 0e801e17_9dc9_7a83_ce0f_d28b56e090f5
  52e3d8d7_abf4_7343_1f98_3f701ec04082["types"]
  40190dd7_cea0_7135_9d7e_df5f2d3454b7 --> 52e3d8d7_abf4_7343_1f98_3f701ec04082
  33e3aca7_66ee_ce27_72ad_b6d7fb17e06c["babel-plugin-react-compiler"]
  40190dd7_cea0_7135_9d7e_df5f2d3454b7 --> 33e3aca7_66ee_ce27_72ad_b6d7fb17e06c
  e023ae51_0bf7_c8b1_0545_8e7304e4bb72["eslint"]
  40190dd7_cea0_7135_9d7e_df5f2d3454b7 --> e023ae51_0bf7_c8b1_0545_8e7304e4bb72
  f23046a7_8ff6_6e84_73a1_6ab58cc3ee68["ReactCompilerRuleFlow-test.ts"]
  f23046a7_8ff6_6e84_73a1_6ab58cc3ee68 --> 40190dd7_cea0_7135_9d7e_df5f2d3454b7
  535f7dd0_5717_e2e5_217a_3f4a26b4e54f["ReactCompilerRuleTypescript-test.ts"]
  535f7dd0_5717_e2e5_217a_3f4a26b4e54f --> 40190dd7_cea0_7135_9d7e_df5f2d3454b7
  b4590b6e_50d1_c664_5047_3e6e187f6b97["index.ts"]
  b4590b6e_50d1_c664_5047_3e6e187f6b97 --> 40190dd7_cea0_7135_9d7e_df5f2d3454b7
  style 40190dd7_cea0_7135_9d7e_df5f2d3454b7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
/* eslint-disable no-for-of-loops/no-for-of-loops */

import type {SourceLocation as BabelSourceLocation} from '@babel/types';
import {
  type CompilerDiagnosticOptions,
  type CompilerErrorDetailOptions,
  CompilerSuggestionOperation,
  LintRules,
  type LintRule,
  ErrorSeverity,
  LintRulePreset,
} from 'babel-plugin-react-compiler';
import {type Linter, type Rule} from 'eslint';
import runReactCompiler, {RunCacheEntry} from './RunReactCompiler';

function assertExhaustive(_: never, errorMsg: string): never {
  throw new Error(errorMsg);
}

function makeSuggestions(
  detail: CompilerErrorDetailOptions | CompilerDiagnosticOptions,
): Array<Rule.SuggestionReportDescriptor> {
  const suggest: Array<Rule.SuggestionReportDescriptor> = [];
  if (Array.isArray(detail.suggestions)) {
    for (const suggestion of detail.suggestions) {
      switch (suggestion.op) {
        case CompilerSuggestionOperation.InsertBefore:
          suggest.push({
            desc: suggestion.description,
            fix(fixer) {
              return fixer.insertTextBeforeRange(
                suggestion.range,
                suggestion.text,
              );
            },
          });
          break;
        case CompilerSuggestionOperation.InsertAfter:
          suggest.push({
            desc: suggestion.description,
            fix(fixer) {
              return fixer.insertTextAfterRange(
                suggestion.range,
                suggestion.text,
              );
            },
          });
          break;
        case CompilerSuggestionOperation.Replace:
          suggest.push({
            desc: suggestion.description,
            fix(fixer) {
              return fixer.replaceTextRange(suggestion.range, suggestion.text);
            },
// ... (149 more lines)

Domain

Subdomains

Types

Dependencies

Frequently Asked Questions

What does ReactCompiler.ts do?
ReactCompiler.ts is a source file in the react codebase, written in typescript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in ReactCompiler.ts?
ReactCompiler.ts defines 9 function(s): allRules, assertExhaustive, getReactCompilerResult, hasFlowSuppression, makeRule, makeSuggestions, mapErrorSeverityToESlint, recommendedLatestRules, recommendedRules.
What does ReactCompiler.ts depend on?
ReactCompiler.ts imports 4 module(s): RunReactCompiler.ts, babel-plugin-react-compiler, eslint, types.
What files import ReactCompiler.ts?
ReactCompiler.ts is imported by 3 file(s): ReactCompilerRuleFlow-test.ts, ReactCompilerRuleTypescript-test.ts, index.ts.
Where is ReactCompiler.ts in the architecture?
ReactCompiler.ts is located at packages/eslint-plugin-react-hooks/src/shared/ReactCompiler.ts (domain: BabelCompiler, subdomain: Validation, directory: packages/eslint-plugin-react-hooks/src/shared).

Analyze Your Own Codebase

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

Try Supermodel Free