Home / File/ ESLintRuleExhaustiveDeps-test.js — react Source File

ESLintRuleExhaustiveDeps-test.js — react Source File

Architecture documentation for ESLintRuleExhaustiveDeps-test.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.
 *
 * @jest-environment node
 */

'use strict';

const ESLintTesterV7 = require('eslint-v7').RuleTester;
const ESLintTesterV9 = require('eslint-v9').RuleTester;
const ReactHooksESLintPlugin = require('eslint-plugin-react-hooks');
const ReactHooksESLintRule =
  ReactHooksESLintPlugin.default.rules['exhaustive-deps'];

/**
 * A string template tag that removes padding from the left side of multi-line strings
 * @param {Array} strings array of code strings (only one expected)
 */
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');
}

// ***************************************************
// For easier local testing, you can add to any case:
// {
//   skip: true,
//   --or--
//   only: true,
//   ...
// }
// ***************************************************

// Tests that are valid/invalid across all parsers
const tests = {
  valid: [
    {
      code: normalizeIndent`
        function MyComponent() {
          const local = {};
          useEffect(() => {
            console.log(local);
          });
        }
      `,
    },
    {
      code: normalizeIndent`
        function MyComponent() {
          useEffect(() => {
            const local = {};
            console.log(local);
          }, []);
        }
      `,
    },
// ... (8722 more lines)

Domain

Subdomains

Frequently Asked Questions

What does ESLintRuleExhaustiveDeps-test.js do?
ESLintRuleExhaustiveDeps-test.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in ESLintRuleExhaustiveDeps-test.js?
ESLintRuleExhaustiveDeps-test.js defines 2 function(s): normalizeIndent, predicate.
Where is ESLintRuleExhaustiveDeps-test.js in the architecture?
ESLintRuleExhaustiveDeps-test.js is located at packages/eslint-plugin-react-hooks/__tests__/ESLintRuleExhaustiveDeps-test.js (domain: BabelCompiler, subdomain: Validation, directory: packages/eslint-plugin-react-hooks/__tests__).

Analyze Your Own Codebase

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

Try Supermodel Free