ESLintRulesOfHooks-test.js — react Source File
Architecture documentation for ESLintRulesOfHooks-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['rules-of-hooks'];
/**
* 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,
// ...
// }
// ***************************************************
const allTests = {
valid: [
{
code: normalizeIndent`
// Valid because components can use hooks.
function ComponentWithHook() {
useHook();
}
`,
},
{
syntax: 'flow',
code: normalizeIndent`
// Component syntax
component Button() {
useHook();
return <div>Button!</div>;
}
`,
},
{
syntax: 'flow',
code: normalizeIndent`
// ... (2226 more lines)
Domain
Subdomains
Functions
Source
Frequently Asked Questions
What does ESLintRulesOfHooks-test.js do?
ESLintRulesOfHooks-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 ESLintRulesOfHooks-test.js?
ESLintRulesOfHooks-test.js defines 14 function(s): asyncComponentHookError, classError, conditionalError, filteredTests, flowTests, functionError, genericError, loopError, normalizeIndent, predicate, and 4 more.
Where is ESLintRulesOfHooks-test.js in the architecture?
ESLintRulesOfHooks-test.js is located at packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-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