ReactCompilerRuleTypescript-test.ts — react Source File
Architecture documentation for ReactCompilerRuleTypescript-test.ts, a typescript file in the react codebase. 3 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 535f7dd0_5717_e2e5_217a_3f4a26b4e54f["ReactCompilerRuleTypescript-test.ts"] 40190dd7_cea0_7135_9d7e_df5f2d3454b7["ReactCompiler.ts"] 535f7dd0_5717_e2e5_217a_3f4a26b4e54f --> 40190dd7_cea0_7135_9d7e_df5f2d3454b7 dc45eeec_7cda_3dde_2446_228b95f1d232["allRules"] 535f7dd0_5717_e2e5_217a_3f4a26b4e54f --> dc45eeec_7cda_3dde_2446_228b95f1d232 e023ae51_0bf7_c8b1_0545_8e7304e4bb72["eslint"] 535f7dd0_5717_e2e5_217a_3f4a26b4e54f --> e023ae51_0bf7_c8b1_0545_8e7304e4bb72 style 535f7dd0_5717_e2e5_217a_3f4a26b4e54f fill:#6366f1,stroke:#818cf8,color:#fff
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.
*/
import {RuleTester} from 'eslint';
import {allRules} from '../src/shared/ReactCompiler';
const ESLintTesterV8 = require('eslint-v8').RuleTester;
/**
* 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: TemplateStringsArray): string {
const codeLines = strings[0]?.split('\n') ?? [];
const leftPadding = codeLines[1]?.match(/\s+/)![0] ?? '';
return codeLines.map(line => line.slice(leftPadding.length)).join('\n');
}
type CompilerTestCases = {
valid: RuleTester.ValidTestCase[];
invalid: RuleTester.InvalidTestCase[];
};
const tests: CompilerTestCases = {
valid: [
{
name: 'Basic example',
filename: 'test.tsx',
code: normalizeIndent`
function Button(props) {
return null;
}
`,
},
{
name: 'Repro for hooks as normal values',
filename: 'test.tsx',
code: normalizeIndent`
function Button(props) {
const scrollview = React.useRef<ScrollView>(null);
return <Button thing={scrollview} />;
}
`,
},
// ===========================================
// Tests for mayContainReactCode heuristic
// Files that should be SKIPPED (no React-like function names)
// These contain code that WOULD trigger errors if compiled,
// but since the heuristic skips them, no errors are reported.
// ===========================================
{
name: '[Heuristic] Skips files with only lowercase utility functions',
filename: 'utils.ts',
// This mutates an argument, which would be flagged in a component/hook,
// but this file is skipped because there are no React-like function names
code: normalizeIndent`
// ... (142 more lines)
Domain
Subdomains
Functions
Types
Dependencies
- ReactCompiler.ts
- allRules
- eslint
Source
Frequently Asked Questions
What does ReactCompilerRuleTypescript-test.ts do?
ReactCompilerRuleTypescript-test.ts is a source file in the react codebase, written in typescript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in ReactCompilerRuleTypescript-test.ts?
ReactCompilerRuleTypescript-test.ts defines 1 function(s): normalizeIndent.
What does ReactCompilerRuleTypescript-test.ts depend on?
ReactCompilerRuleTypescript-test.ts imports 3 module(s): ReactCompiler.ts, allRules, eslint.
Where is ReactCompilerRuleTypescript-test.ts in the architecture?
ReactCompilerRuleTypescript-test.ts is located at packages/eslint-plugin-react-hooks/__tests__/ReactCompilerRuleTypescript-test.ts (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