Home / Function/ validateRestrictedImports() — react Function Reference

validateRestrictedImports() — react Function Reference

Architecture documentation for the validateRestrictedImports() function in Imports.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  67757659_3cd9_ac9a_4dd3_4c5ae8672636["validateRestrictedImports()"]
  2a7e50cd_6171_085d_277c_6ced6ddd7148["Imports.ts"]
  67757659_3cd9_ac9a_4dd3_4c5ae8672636 -->|defined in| 2a7e50cd_6171_085d_277c_6ced6ddd7148
  1c9af54b_10e9_8985_e772_1f517e46c560["compileProgram()"]
  1c9af54b_10e9_8985_e772_1f517e46c560 -->|calls| 67757659_3cd9_ac9a_4dd3_4c5ae8672636
  073c81a5_c389_d108_5b8f_4d6dc6eece83["push()"]
  67757659_3cd9_ac9a_4dd3_4c5ae8672636 -->|calls| 073c81a5_c389_d108_5b8f_4d6dc6eece83
  6d8385f7_ca89_0968_e79e_ed2e1aa846c9["hasAnyErrors()"]
  67757659_3cd9_ac9a_4dd3_4c5ae8672636 -->|calls| 6d8385f7_ca89_0968_e79e_ed2e1aa846c9
  style 67757659_3cd9_ac9a_4dd3_4c5ae8672636 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Imports.ts lines 25–54

export function validateRestrictedImports(
  path: NodePath<t.Program>,
  {validateBlocklistedImports}: EnvironmentConfig,
): CompilerError | null {
  if (
    validateBlocklistedImports == null ||
    validateBlocklistedImports.length === 0
  ) {
    return null;
  }
  const error = new CompilerError();
  const restrictedImports = new Set(validateBlocklistedImports);
  path.traverse({
    ImportDeclaration(importDeclPath) {
      if (restrictedImports.has(importDeclPath.node.source.value)) {
        error.push({
          category: ErrorCategory.Todo,
          reason: 'Bailing out due to blocklisted import',
          description: `Import from module ${importDeclPath.node.source.value}`,
          loc: importDeclPath.node.loc ?? null,
        });
      }
    },
  });
  if (error.hasAnyErrors()) {
    return error;
  } else {
    return null;
  }
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does validateRestrictedImports() do?
validateRestrictedImports() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Imports.ts.
Where is validateRestrictedImports() defined?
validateRestrictedImports() is defined in compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Imports.ts at line 25.
What does validateRestrictedImports() call?
validateRestrictedImports() calls 2 function(s): hasAnyErrors, push.
What calls validateRestrictedImports()?
validateRestrictedImports() 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