Home / Function/ getFormat() — react Function Reference

getFormat() — react Function Reference

Architecture documentation for the getFormat() function in index.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  6ecf6f88_354a_bb25_822b_39a3f1fc89bb["getFormat()"]
  10e2ef43_1ceb_8344_7ea3_0dd6c0816e16["index.js"]
  6ecf6f88_354a_bb25_822b_39a3f1fc89bb -->|defined in| 10e2ef43_1ceb_8344_7ea3_0dd6c0816e16
  06fd1e36_aaba_e022_c78f_11c4209292b9["lintEverything()"]
  06fd1e36_aaba_e022_c78f_11c4209292b9 -->|calls| 6ecf6f88_354a_bb25_822b_39a3f1fc89bb
  style 6ecf6f88_354a_bb25_822b_39a3f1fc89bb fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

scripts/rollup/validate/index.js lines 12–53

function getFormat(filepath) {
  if (filepath.includes('facebook')) {
    if (filepath.includes('shims')) {
      // We don't currently lint these shims. We rely on the downstream Facebook
      // repo to transform them.
      // TODO: Should we lint them?
      return null;
    }
    return 'fb';
  }
  if (filepath.includes('react-native')) {
    if (filepath.includes('shims')) {
      // We don't currently lint these shims. We rely on the downstream Facebook
      // repo to transform them.
      // TODO: Should we lint them?
      return null;
    }
    return 'rn';
  }
  if (filepath.includes('cjs')) {
    if (
      filepath.includes('react-server-dom-webpack-plugin') ||
      filepath.includes('react-server-dom-webpack-node-register') ||
      filepath.includes('react-suspense-test-utils')
    ) {
      return 'cjs2015';
    }
    return 'cjs';
  }
  if (filepath.includes('esm')) {
    return 'esm';
  }
  if (
    filepath.includes('oss-experimental') ||
    filepath.includes('oss-stable')
  ) {
    // If a file in one of the open source channels doesn't match an earlier,
    // more specific rule, then assume it's CommonJS.
    return 'cjs';
  }
  throw new Error('Could not find matching lint format for file: ' + filepath);
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does getFormat() do?
getFormat() is a function in the react codebase, defined in scripts/rollup/validate/index.js.
Where is getFormat() defined?
getFormat() is defined in scripts/rollup/validate/index.js at line 12.
What calls getFormat()?
getFormat() is called by 1 function(s): lintEverything.

Analyze Your Own Codebase

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

Try Supermodel Free