8,921 matches across 25 files for func main lang:JavaScript
snippet_mode: grep · sorted by relevance
8'use strict';
9
10▶// NOTE: Extracted from https://github.com/facebook/react/blob/main/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js
11
12/**
· · ·
13 * A string template tag that removes padding from the left side of multi-line strings
14 */
15▶function normalizeIndent(strings) {
16 const codeLines = strings[0].split('\n');
17 const leftPadding = codeLines[1].match(/\s+/)[0];
· · ·
24 code: normalizeIndent`
25 // Valid because components can use hooks.
26▶ function ComponentWithHook() {
27 useHook();
28 }
· · ·
32 code: normalizeIndent`
33 // Valid because components can use hooks.
34▶ function createComponentWithHook() {
35 return function ComponentWithHook() {
36 useHook();
· · ·
35▶ return function ComponentWithHook() {
36 useHook();
37 };
+ 89 more matches in this file
6 */
7
8▶module.exports = function makeE2EConfig(displayName, useForget) {
9 return {
10 displayName,
· · ·
15 // ignore snapshots from the opposite forget configuration
16 useForget ? '.*\\.no-forget\\.snap$' : '.*\\.with-forget\\.snap$',
17▶ // ignore snapshots from the main project
18 '.*\\.ts\\.snap$',
19 ],
4// Currently invalid because it violates the convention and removes the "taint"
5// from a hook. We *could* make it valid to avoid some false positives but let's
6▶// ensure that we don't break the "renderItem" and "normalFunctionWithConditionalHook"
7// cases which must remain invalid.
8function normalFunctionWithHook() {
· · ·
7▶// cases which must remain invalid.
8function normalFunctionWithHook() {
9 useHookInsideNormalFunction();
· · ·
8▶function normalFunctionWithHook() {
9 useHookInsideNormalFunction();
10}
· · ·
9▶ useHookInsideNormalFunction();
10}
11
9 * Debug HIR printer for the Rust port testing infrastructure.
10 *
11▶ * Custom printer that walks the HIRFunction structure and prints every field
12 * of every identifier, instruction, terminal, and block. Also includes
13 * outlined functions (from FunctionExpression instruction values).
· · ·
13▶ * outlined functions (from FunctionExpression instruction values).
14 *
15 * This does NOT delegate to printFunctionWithOutlined() — it is a standalone
· · ·
15▶ * This does NOT delegate to printFunctionWithOutlined() — it is a standalone
16 * walker that produces a detailed, deterministic representation suitable for
17 * cross-compiler comparison between the TS and Rust implementations.
· · ·
18 *
19▶ * @param {Function} _printFunctionWithOutlined - Unused (kept for API compat)
20 * @param {object} hirFunction - The HIRFunction to print
21 * @returns {string} The debug representation
· · ·
20▶ * @param {object} hirFunction - The HIRFunction to print
21 * @returns {string} The debug representation
22 */
+ 45 more matches in this file
7
8/**
9▶ * Debug ReactiveFunction printer for the Rust port testing infrastructure.
10 *
11 * Custom printer that walks the ReactiveFunction tree structure and prints
· · ·
11▶ * Custom printer that walks the ReactiveFunction tree structure and prints
12 * every field of every scope, instruction, terminal, and reactive value node.
13 *
· · ·
14▶ * This does NOT delegate to printReactiveFunctionWithOutlined() — it is a
15 * standalone walker that produces a detailed, deterministic representation
16 * suitable for cross-compiler comparison between the TS and Rust implementations.
· · ·
17 *
18▶ * @param {Function} _printReactiveFunctionWithOutlined - Unused (kept for API compat)
19 * @param {object} reactiveFunction - The ReactiveFunction to print
20 * @returns {string} The debug representation
· · ·
19▶ * @param {object} reactiveFunction - The ReactiveFunction to print
20 * @returns {string} The debug representation
21 */
+ 47 more matches in this file
30 * Parse command line arguments
31 */
32▶function parseArgs() {
33 const argv = yargs(hideBin(process.argv))
34 .usage('Usage: $0 <flag-name>')
· · ·
54 * Enable a feature flag in Environment.ts by changing default(false) to default(true)
55 */
56▶function enableFlagInEnvironment(flagName) {
57 console.log(`\nEnabling flag "${flagName}" in Environment.ts...`);
58
· · ·
106 * Helper to escape regex special characters
107 */
108▶function escapeRegex(string) {
109 return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
110}
· · ·
113 * Run yarn snap and capture output
114 */
115▶function runTests() {
116 console.log('\nRunning test suite (yarn snap)...');
117
· · ·
133 * Parse failing test names from test output
134 */
135▶function parseFailingTests(output) {
136 const failingTests = [];
137
+ 7 more matches in this file
41 * the command only report what it would have done, instead of actually publishing to npm.
42 */
43▶async function main() {
44 const argv = yargs(process.argv.slice(2))
45 .option('packages', {
· · ·
90 const currBranchName = await execHelper('git rev-parse --abbrev-ref HEAD');
91 const isPristine = (await execHelper('git status --porcelain')) === '';
92▶ if (currBranchName !== 'main' || isPristine === false) {
93 throw new Error(
94 'This script must be run from the `main` branch with no uncommitted changes'
· · ·
94▶ 'This script must be run from the `main` branch with no uncommitted changes'
95 );
96 }
· · ·
36};
37
38▶function formatCommitMessage(str) {
39 let formattedStr = '';
40 let line = '';
· · ·
63}
64
65▶function filterMsg(response) {
66 const {body, title} = response;
67
· · ·
100}
101
102▶function parsePullRequestNumber(text) {
103 if (!text) {
104 return null;
· · ·
122}
123
124▶async function main() {
125 const data = fs.readFileSync(0, 'utf-8');
126 const pr = parsePullRequestNumber(data);
· · ·
59});
60
61▶function kbs(bytes) {
62 return kilobyteFormatter.format(bytes / 1000);
63}
· · ·
70});
71
72▶function change(decimal) {
73 if (decimal === Infinity) {
74 return 'New file';
· · ·
87 | ---- | --- | ---- | ------- | -------- | --------- | ------------ |`;
88
89▶function row(result, baseSha, headSha) {
90 const diffViewUrl = `https://react-builds.vercel.app/commits/${headSha}/files/${result.path}?compare=${baseSha}`;
91 const rowArr = [
· · ·
101}
102
103▶(async function () {
104 // Use git locally to grab the commit which represents the place
105 // where the branches differ
· · ·
107 const upstreamRepo = danger.github.pr.base.repo.full_name;
108 if (upstreamRepo !== 'react/react') {
109▶ // Exit unless we're running in the main repo
110 return;
111 }
+ 1 more matches in this file
11
12// Convenience wrapper to organize API features in DevTools.
13▶function Feature({children, label, version}) {
14 return (
15 <div className="Feature">
· · ·
33}
34
35▶// https://github.com/facebook/react/blob/main/CHANGELOG.md
36switch (major) {
37 case 16:
· · ·
38 switch (minor) {
39 case 7:
40▶ if (typeof React.useState === 'function') {
41 // Hooks
42 function Hooks() {
· · ·
42▶ function Hooks() {
43 const [count, setCount] = React.useState(0);
44 const incrementCount = React.useCallback(
· · ·
61 case 6:
62 // memo
63▶ function LabelComponent({label}) {
64 return <label>{label}</label>;
65 }
+ 8 more matches in this file
9const {Fragment, useRef, useState} = React;
10
11▶function GetClientRectsTextOnly() {
12 return (
13 <TestCase title="getClientRects - Text Only">
· · ·
30}
31
32▶function GetClientRectsMixed() {
33 return (
34 <TestCase title="getClientRects - Mixed Content">
· · ·
71}
72
73▶function FocusTextOnlyNoop() {
74 const fragmentRef = useRef(null);
75 const [message, setMessage] = useState('');
· · ·
118}
119
120▶function ScrollIntoViewTextOnly() {
121 const fragmentRef = useRef(null);
122 const [message, setMessage] = useState('');
· · ·
171}
172
173▶function ScrollIntoViewMixed() {
174 const fragmentRef = useRef(null);
175 const [message, setMessage] = useState('');
+ 8 more matches in this file
1const React = window.React;
2
3▶export default function Home() {
4 return (
5 <main className="container">
· · ·
5▶ <main className="container">
6 <h1>DOM Test Fixtures</h1>
7 <p>
· · ·
87 <p>
88 These services provide access to all browsers we test, however they
89▶ cost money. There is no obligation to pay for them. Maintainers have
90 access to a BrowserStack subscription; feel free to contact a
91 maintainer or mention browsers where extra testing is required.
· · ·
91▶ maintainer or mention browsers where extra testing is required.
92 </p>
93 </section>
· · ·
114 </section>
115 </section>
116▶ </main>
117 );
118}
7const React = window.React;
8
9▶function NumberInputs() {
10 return (
11 <FixtureSet
· · ·
30 <b>Notes:</b> Modern Chrome and Safari {'<='} 6 clear trailing
31 decimals on blur. React makes this concession so that the value
32▶ attribute remains in sync with the value property.
33 </p>
34 </TestCase>
· · ·
108 <TestCase
109 title="Inserting decimals precision"
110▶ description="Inserting '.' in to '300' maintains the trailing zeroes">
111 <TestCase.Steps>
112 <li>Type "300"</li>
15// In a real setup, you'd read it from webpack build stats.
16let assets = {
17▶ 'main.js': '/main.js',
18 'main.css': '/main.css',
19};
· · ·
18▶ 'main.css': '/main.css',
19};
20
· · ·
21▶function HtmlWritable(options) {
22 Writable.call(this, options);
23 this.chunks = [];
· · ·
26
27HtmlWritable.prototype = Object.create(Writable.prototype);
28▶HtmlWritable.prototype.getHtml = function getHtml() {
29 return this.html;
30};
· · ·
31▶HtmlWritable.prototype._write = function _write(chunk, encoding, callback) {
32 this.chunks.push(chunk);
33 callback();
+ 3 more matches in this file
14// In a real setup, you'd read it from webpack build stats.
15let assets = {
16▶ 'main.js': '/main.js',
17 'main.css': '/main.css',
18};
· · ·
17▶ 'main.css': '/main.css',
18};
19
· · ·
20▶module.exports = function render(url, res) {
21 // The new wiring is a bit more involved.
22 res.socket.on('error', error => {
· · ·
26 let didFinish = false;
27 const {pipe, abort} = renderToPipeableStream(<App assets={assets} />, {
28▶ bootstrapScripts: [assets['main.js']],
29 onAllReady() {
30 // Full completion.
15// In a real setup, you'd read it from webpack build stats.
16let assets = {
17▶ 'main.js': '/main.js',
18 'main.css': '/main.css',
19};
· · ·
18▶ 'main.css': '/main.css',
19};
20
· · ·
21let textEncoder = new TextEncoder();
22
23▶module.exports = function render(url, res) {
24 let payload =
25 '<!DOCTYPE html>' +
· · ·
26 renderToString(<App assets={assets} />) +
27▶ '<script src="/main.js" async=""></script>';
28 let arr = textEncoder.encode(payload);
29
31app.get(
32 '/',
33▶ handleErrors(async function (req, res) {
34 await waitForWebpack();
35 renderToStream(req.url, res);
· · ·
38app.get(
39 '/string',
40▶ handleErrors(async function (req, res) {
41 await waitForWebpack();
42 renderToString(req.url, res);
· · ·
45app.get(
46 '/stream',
47▶ handleErrors(async function (req, res) {
48 await waitForWebpack();
49 renderToStream(req.url, res);
· · ·
52app.get(
53 '/buffer',
54▶ handleErrors(async function (req, res) {
55 await waitForWebpack();
56 renderToBuffer(req.url, res);
· · ·
64 console.log(`Listening at ${PORT}...`);
65 })
66▶ .on('error', function (error) {
67 if (error.syscall !== 'listen') {
68 throw error;
+ 4 more matches in this file
7 */
8
9▶export default function Html({assets, children, title}) {
10 return (
11 <html lang="en">
· · ·
14 <meta name="viewport" content="width=device-width, initial-scale=1" />
15 <link rel="shortcut icon" href="favicon.ico" />
16▶ <link rel="stylesheet" href={assets['main.css']} />
17 <title>{title}</title>
18 </head>
24// ---------------------------------------------------------------------------
25
26▶function build() {
27 const config = require('./webpack.config');
28 return new Promise(function (resolve, reject) {
· · ·
28▶ return new Promise(function (resolve, reject) {
29 webpack(config, function (err, stats) {
30 if (err) {
· · ·
29▶ webpack(config, function (err, stats) {
30 if (err) {
31 reject(err);
· · ·
51const PORT = 3001;
52
53▶async function main() {
54 console.log('Building RSC bundle...\n');
55 await build();
· · ·
64 const AppAsync = require('./src/AppAsync.js').default;
65
66▶ function pipeStreamToRes(stream, res) {
67 if (typeof stream.pipe === 'function') {
68 // Node Readable stream
+ 26 more matches in this file
22// ---------------------------------------------------------------------------
23
24▶function build() {
25 const config = require('./webpack.config');
26 return new Promise(function (resolve, reject) {
· · ·
26▶ return new Promise(function (resolve, reject) {
27 webpack(config, function (err, stats) {
28 if (err) {
· · ·
27▶ webpack(config, function (err, stats) {
28 if (err) {
29 reject(err);
· · ·
56const {printGrid} = require('./print-helpers');
57
58▶function renderFizzNode(AppComponent, itemCount) {
59 return nodeStreamToString(renderFizzNodeStream(AppComponent, itemCount));
60}
· · ·
61
62▶function renderFizzEdge(AppComponent, itemCount) {
63 return renderFizzEdgeStream(AppComponent, itemCount).then(webStreamToString);
64}
+ 24 more matches in this file
8// ---------------------------------------------------------------------------
9
10▶function renderFizzNode(AppComponent, itemCount) {
11 const React = require('react');
12 const {renderToPipeableStream} = require('react-dom/server');
· · ·
33// ---------------------------------------------------------------------------
34
35▶function renderFizzEdge(AppComponent, itemCount) {
36 const React = require('react');
37 const {renderToReadableStream} = require('react-dom/server');
· · ·
46// ---------------------------------------------------------------------------
47
48▶function renderFlightFizzNode(
49 renderRSCNode,
50 AppComponent,
· · ·
75 trunk.pipe(forInline);
76
77▶ forInline.on('data', function (chunk) {
78 flightScripts +=
79 '<script>(self.__FLIGHT_DATA||=[]).push(' +
· · ·
90
91 let cachedResult;
92▶ function Root() {
93 if (!cachedResult) {
94 cachedResult = createFromNodeStream(flightStream, ssrManifest);
+ 21 more matches in this file
5import {generateProducts, generateActivities, generateStats} from './data';
6
7▶export default function Dashboard({itemCount}) {
8 const products = generateProducts(itemCount);
9 const activities = generateActivities(Math.min(itemCount, 50));
· · ·
11
12 return (
13▶ <main className="dashboard">
14 <div className="dashboard-header">
15 <h1>Dashboard Overview</h1>
· · ·
20 <StatsGrid stats={stats} />
21 <div className="dashboard-grid">
22▶ <div className="dashboard-main">
23 <ProductTable products={products} />
24 </div>
· · ·
28 </div>
29 </div>
30▶ </main>
31 );
32}
9import {generateProducts, generateActivities, generateStats} from './data';
10
11▶function fetchData(generator, ...args) {
12 return new Promise(resolve => {
13 setTimeout(() => resolve(generator(...args)), 1);
· · ·
15}
16
17▶function fetchDelayed(value, delayMs) {
18 return new Promise(resolve => {
19 setTimeout(() => resolve(value), delayMs);
· · ·
21}
22
23▶async function AsyncStatsSection() {
24 const stats = await fetchData(generateStats);
25 return <StatsGrid stats={stats} />;
· · ·
36];
37
38▶async function AsyncProductRow({product, delay}) {
39 const resolved = await fetchDelayed(product, delay);
40 return <TableRow product={resolved} columns={productColumns} />;
· · ·
41}
42
43▶async function AsyncProductSection({itemCount}) {
44 const products = await fetchData(generateProducts, itemCount);
45 return (
+ 7 more matches in this file
29const {WebpackManifestPlugin} = require('webpack-manifest-plugin');
30
31▶function createEnvironmentHash(env) {
32 const hash = createHash('md5');
33 hash.update(JSON.stringify(env));
· · ·
79// This is the production and development configuration.
80// It is focused on developer experience, fast rebuilds, and a minimal bundle.
81▶module.exports = function (webpackEnv) {
82 const isEnvDevelopment = webpackEnv === 'development';
83 const isEnvProduction = webpackEnv === 'production';
· · ·
96 const shouldUseReactRefresh = env.raw.FAST_REFRESH;
97
98▶ // common function to get style loaders
99 const getStyleLoaders = (cssOptions, preProcessor) => {
100 const loaders = [
· · ·
204 // Add /* filename */ comments to generated require()s in the output.
205 pathinfo: isEnvDevelopment,
206▶ // There will be one main bundle, and one file per asynchronous chunk.
207 // In development, it does not produce real files.
208 filename: isEnvProduction
· · ·
572 new webpack.DefinePlugin(env.stringified),
573 // Experimental hot reloading for React .
574▶ // https://github.com/facebook/react/tree/main/packages/react-refresh
575 isEnvDevelopment &&
576 shouldUseReactRefresh &&
+ 2 more matches in this file