ReactCompilerRuleTypescript-test.ts — react Source File
Architecture documentation for ReactCompilerRuleTypescript-test.ts, a typescript file in the react codebase. 4 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR d018a273_4188_8c38_a8a8_a65b8c0dad2c["ReactCompilerRuleTypescript-test.ts"] 799656f0_feaf_2c82_77fc_4a08283ea146["shared-utils.ts"] d018a273_4188_8c38_a8a8_a65b8c0dad2c --> 799656f0_feaf_2c82_77fc_4a08283ea146 bcb39791_1cb0_7829_c904_92eb71e485d0["CompilerTestCases"] d018a273_4188_8c38_a8a8_a65b8c0dad2c --> bcb39791_1cb0_7829_c904_92eb71e485d0 f9d93ee9_a1c8_932c_1dae_abe7839e287e["normalizeIndent"] d018a273_4188_8c38_a8a8_a65b8c0dad2c --> f9d93ee9_a1c8_932c_1dae_abe7839e287e e023ae51_0bf7_c8b1_0545_8e7304e4bb72["eslint"] d018a273_4188_8c38_a8a8_a65b8c0dad2c --> e023ae51_0bf7_c8b1_0545_8e7304e4bb72 style d018a273_4188_8c38_a8a8_a65b8c0dad2c 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 {
CompilerTestCases,
normalizeIndent,
TestRecommendedRules,
} from './shared-utils';
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} />;
}
`,
},
],
invalid: [
{
name: 'Mutating useState value',
filename: 'test.tsx',
code: `
import { useState } from 'react';
function Component(props) {
// typescript syntax that hermes-parser doesn't understand yet
const x: \`foo\${1}\` = 'foo1';
const [state, setState] = useState({a: 0});
state.a = 1;
return <div>{props.foo}</div>;
}
`,
errors: [
{
message: /Modifying a value returned from 'useState\(\)'/,
line: 7,
},
],
},
],
};
const eslintTester = new RuleTester({
// @ts-ignore[2353] - outdated types
parser: require.resolve('@typescript-eslint/parser'),
});
eslintTester.run('react-compiler', TestRecommendedRules, tests);
Domain
Dependencies
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.
What does ReactCompilerRuleTypescript-test.ts depend on?
ReactCompilerRuleTypescript-test.ts imports 4 module(s): CompilerTestCases, eslint, normalizeIndent, shared-utils.ts.
Where is ReactCompilerRuleTypescript-test.ts in the architecture?
ReactCompilerRuleTypescript-test.ts is located at compiler/packages/eslint-plugin-react-compiler/__tests__/ReactCompilerRuleTypescript-test.ts (domain: BabelCompiler, directory: compiler/packages/eslint-plugin-react-compiler/__tests__).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free