Home / File/ eslint-plugin-react-hooks-test-cases.js — react Source File

eslint-plugin-react-hooks-test-cases.js — react Source File

Architecture documentation for eslint-plugin-react-hooks-test-cases.js, a javascript file in the react codebase.

Entity Profile

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.
 */

'use strict';

// NOTE: Extracted from https://github.com/facebook/react/blob/main/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js

/**
 * A string template tag that removes padding from the left side of multi-line strings
 */
function normalizeIndent(strings) {
  const codeLines = strings[0].split('\n');
  const leftPadding = codeLines[1].match(/\s+/)[0];
  return codeLines.map(line => line.slice(leftPadding.length)).join('\n');
}

module.exports.tests = {
  valid: [
    {
      code: normalizeIndent`
        // Valid because components can use hooks.
        function ComponentWithHook() {
          useHook();
        }
      `,
    },
    {
      code: normalizeIndent`
        // Valid because components can use hooks.
        function createComponentWithHook() {
          return function ComponentWithHook() {
            useHook();
          };
        }
      `,
    },
    {
      code: normalizeIndent`
        // Valid because hooks can use hooks.
        function useHookWithHook() {
          useHook();
        }
      `,
    },
    {
      code: normalizeIndent`
        // Valid because hooks can use hooks.
        function createHook() {
          return function useHookWithHook() {
            useHook();
          }
        }
      `,
    },
    {
      code: normalizeIndent`
// ... (926 more lines)

Subdomains

Functions

Frequently Asked Questions

What does eslint-plugin-react-hooks-test-cases.js do?
eslint-plugin-react-hooks-test-cases.js is a source file in the react codebase, written in javascript. It belongs to the TestingUtilities domain, E2E subdomain.
What functions are defined in eslint-plugin-react-hooks-test-cases.js?
eslint-plugin-react-hooks-test-cases.js defines 1 function(s): normalizeIndent.
Where is eslint-plugin-react-hooks-test-cases.js in the architecture?
eslint-plugin-react-hooks-test-cases.js is located at compiler/packages/babel-plugin-react-compiler/scripts/eslint-plugin-react-hooks-test-cases.js (domain: TestingUtilities, subdomain: E2E, directory: compiler/packages/babel-plugin-react-compiler/scripts).

Analyze Your Own Codebase

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

Try Supermodel Free