8,921 matches across 25 files for func main lang:JavaScript lang:JavaScript lang:JavaScript lang:JavaScript
snippet_mode: grep · sorted by relevance
compiler/packages/babel-plugin-react-compiler/scripts/eslint-plugin-react-hooks-test-cases.js JAVASCRIPT 94 matches · showing 5 view file →
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 */
15function 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
compiler/packages/babel-plugin-react-compiler/scripts/jest/makeE2EConfig.js JAVASCRIPT 2 matches view file →
6 */
7
8module.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 ],
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/rules-of-hooks/todo.invalid.invalid-rules-of-hooks-c59788ef5676.js JAVASCRIPT 4 matches view file →
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();
· · ·
8function normalFunctionWithHook() {
9 useHookInsideNormalFunction();
10}
· · ·
9 useHookInsideNormalFunction();
10}
11
compiler/packages/react-forgive/scripts/build.mjs JAVASCRIPT 2 matches view file →
28 .parse();
29
30async function main() {
31 if (argv.w) {
32 const serverCtx = await esbuild.context(Server.config);
· · ·
56}
57
58main();
59
compiler/scripts/debug-print-hir.mjs JAVASCRIPT 50 matches · showing 5 view file →
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
compiler/scripts/debug-print-reactive.mjs JAVASCRIPT 52 matches · showing 5 view 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
compiler/scripts/enable-feature-flag.js JAVASCRIPT 12 matches · showing 5 view file →
30 * Parse command line arguments
31 */
32function 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 */
56function enableFlagInEnvironment(flagName) {
57 console.log(`\nEnabling flag "${flagName}" in Environment.ts...`);
58
· · ·
106 * Helper to escape regex special characters
107 */
108function escapeRegex(string) {
109 return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
110}
· · ·
113 * Run yarn snap and capture output
114 */
115function runTests() {
116 console.log('\nRunning test suite (yarn snap)...');
117
· · ·
133 * Parse failing test names from test output
134 */
135function parseFailingTests(output) {
136 const failingTests = [];
137
+ 7 more matches in this file
compiler/scripts/release/publish.js JAVASCRIPT 4 matches view file →
41 * the command only report what it would have done, instead of actually publishing to npm.
42 */
43async 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 }
· · ·
235}
236
237main();
238
compiler/scripts/update-commit-message.js JAVASCRIPT 5 matches view file →
36};
37
38function formatCommitMessage(str) {
39 let formattedStr = '';
40 let line = '';
· · ·
63}
64
65function filterMsg(response) {
66 const {body, title} = response;
67
· · ·
100}
101
102function parsePullRequestNumber(text) {
103 if (!text) {
104 return null;
· · ·
122}
123
124async function main() {
125 const data = fs.readFileSync(0, 'utf-8');
126 const pr = parsePullRequestNumber(data);
· · ·
145}
146
147main();
148
dangerfile.js JAVASCRIPT 6 matches · showing 5 view file →
59});
60
61function kbs(bytes) {
62 return kilobyteFormatter.format(bytes / 1000);
63}
· · ·
70});
71
72function change(decimal) {
73 if (decimal === Infinity) {
74 return 'New file';
· · ·
87 | ---- | --- | ---- | ------- | -------- | --------- | ------------ |`;
88
89function 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
fixtures/devtools/regression/shared.js JAVASCRIPT 13 matches · showing 5 view file →
11
12// Convenience wrapper to organize API features in DevTools.
13function 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
fixtures/dom/src/components/fixtures/fragment-refs/TextNodesCase.js JAVASCRIPT 13 matches · showing 5 view file →
9const {Fragment, useRef, useState} = React;
10
11function GetClientRectsTextOnly() {
12 return (
13 <TestCase title="getClientRects - Text Only">
· · ·
30}
31
32function GetClientRectsMixed() {
33 return (
34 <TestCase title="getClientRects - Mixed Content">
· · ·
71}
72
73function FocusTextOnlyNoop() {
74 const fragmentRef = useRef(null);
75 const [message, setMessage] = useState('');
· · ·
118}
119
120function ScrollIntoViewTextOnly() {
121 const fragmentRef = useRef(null);
122 const [message, setMessage] = useState('');
· · ·
171}
172
173function ScrollIntoViewMixed() {
174 const fragmentRef = useRef(null);
175 const [message, setMessage] = useState('');
+ 8 more matches in this file
fixtures/dom/src/components/fixtures/home.js JAVASCRIPT 5 matches view file →
1const React = window.React;
2
3export 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}
fixtures/dom/src/components/fixtures/number-inputs/index.js JAVASCRIPT 3 matches view file →
7const React = window.React;
8
9function 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>
fixtures/fizz/server/render-to-buffer.js JAVASCRIPT 8 matches · showing 5 view file →
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
· · ·
21function HtmlWritable(options) {
22 Writable.call(this, options);
23 this.chunks = [];
· · ·
26
27HtmlWritable.prototype = Object.create(Writable.prototype);
28HtmlWritable.prototype.getHtml = function getHtml() {
29 return this.html;
30};
· · ·
31HtmlWritable.prototype._write = function _write(chunk, encoding, callback) {
32 this.chunks.push(chunk);
33 callback();
+ 3 more matches in this file
fixtures/fizz/server/render-to-stream.js JAVASCRIPT 4 matches view 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
· · ·
20module.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.
fixtures/fizz/server/render-to-string.js JAVASCRIPT 4 matches view file →
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
23module.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
fixtures/fizz/server/server.js JAVASCRIPT 9 matches · showing 5 view file →
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
fixtures/fizz/src/Html.js JAVASCRIPT 2 matches view file →
7 */
8
9export 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>
fixtures/flight-ssr-bench/bench-server.js JAVASCRIPT 31 matches · showing 5 view file →
24// ---------------------------------------------------------------------------
25
26function 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
53async 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
fixtures/flight-ssr-bench/bench.js JAVASCRIPT 29 matches · showing 5 view file →
22// ---------------------------------------------------------------------------
23
24function 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
58function renderFizzNode(AppComponent, itemCount) {
59 return nodeStreamToString(renderFizzNodeStream(AppComponent, itemCount));
60}
· · ·
61
62function renderFizzEdge(AppComponent, itemCount) {
63 return renderFizzEdgeStream(AppComponent, itemCount).then(webStreamToString);
64}
+ 24 more matches in this file
fixtures/flight-ssr-bench/render-helpers.js JAVASCRIPT 26 matches · showing 5 view file →
8// ---------------------------------------------------------------------------
9
10function renderFizzNode(AppComponent, itemCount) {
11 const React = require('react');
12 const {renderToPipeableStream} = require('react-dom/server');
· · ·
33// ---------------------------------------------------------------------------
34
35function renderFizzEdge(AppComponent, itemCount) {
36 const React = require('react');
37 const {renderToReadableStream} = require('react-dom/server');
· · ·
46// ---------------------------------------------------------------------------
47
48function 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
fixtures/flight-ssr-bench/src/components/Dashboard.js JAVASCRIPT 4 matches view file →
5import {generateProducts, generateActivities, generateStats} from './data';
6
7export 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}
fixtures/flight-ssr-bench/src/components/DashboardAsync.js JAVASCRIPT 12 matches · showing 5 view file →
9import {generateProducts, generateActivities, generateStats} from './data';
10
11function fetchData(generator, ...args) {
12 return new Promise(resolve => {
13 setTimeout(() => resolve(generator(...args)), 1);
· · ·
15}
16
17function fetchDelayed(value, delayMs) {
18 return new Promise(resolve => {
19 setTimeout(() => resolve(value), delayMs);
· · ·
21}
22
23async function AsyncStatsSection() {
24 const stats = await fetchData(generateStats);
25 return <StatsGrid stats={stats} />;
· · ·
36];
37
38async function AsyncProductRow({product, delay}) {
39 const resolved = await fetchDelayed(product, delay);
40 return <TableRow product={resolved} columns={productColumns} />;
· · ·
41}
42
43async function AsyncProductSection({itemCount}) {
44 const products = await fetchData(generateProducts, itemCount);
45 return (
+ 7 more matches in this file
fixtures/flight/config/webpack.config.js JAVASCRIPT 7 matches · showing 5 view file →
29const {WebpackManifestPlugin} = require('webpack-manifest-plugin');
30
31function 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.
81module.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
Search syntax
auth loginboth terms (AND is implicit)
auth OR logineither term
NOT path:vendorexclude matches
"exact phrase"quoted exact match
/func\s+Test/regex
handler~1fuzzy (Levenshtein 1)
file:*_test.gofilename glob
path:pkg/auth/**full path glob
lang:golanguage filter

Search any public repo from your terminal

This page calls POST /api/v1/code_search. Same tool, available over MCP for Claude/Cursor/Copilot.