diff --git a/packages/community-cli-plugin/src/commands/bundle/__mocks__/sign.js b/packages/community-cli-plugin/src/commands/bundle/__mocks__/sign.js index beaaaf9dff0..3281fe40b32 100644 --- a/packages/community-cli-plugin/src/commands/bundle/__mocks__/sign.js +++ b/packages/community-cli-plugin/src/commands/bundle/__mocks__/sign.js @@ -4,10 +4,11 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * + * @flow strict-local * @format */ -function sign(source) { +function sign(source: string): string { return source; } diff --git a/packages/react-native-bots/code-analysis-bot.js b/packages/react-native-bots/code-analysis-bot.js index 68724c34f5c..258e6879824 100644 --- a/packages/react-native-bots/code-analysis-bot.js +++ b/packages/react-native-bots/code-analysis-bot.js @@ -5,6 +5,7 @@ * LICENSE file in the root directory of this source tree. * * @format + * @noflow */ 'use strict'; diff --git a/packages/react-native-bots/dangerfile.js b/packages/react-native-bots/dangerfile.js index 8323a9b6902..ddec0bdbc60 100644 --- a/packages/react-native-bots/dangerfile.js +++ b/packages/react-native-bots/dangerfile.js @@ -5,9 +5,11 @@ * LICENSE file in the root directory of this source tree. * * @format + * @noflow */ 'use strict'; + const {danger, fail, warn} = require('danger'); const body = danger.github.pr.body?.toLowerCase() ?? ''; diff --git a/packages/react-native-codegen-typescript-test/scripts/build.js b/packages/react-native-codegen-typescript-test/scripts/build.js index 8148f26408d..ebc4998611a 100644 --- a/packages/react-native-codegen-typescript-test/scripts/build.js +++ b/packages/react-native-codegen-typescript-test/scripts/build.js @@ -6,6 +6,7 @@ * * @format * @lint-ignore-every LICENSELINT + * @noflow */ const fs = require('fs'); diff --git a/packages/react-native-codegen/scripts/build.js b/packages/react-native-codegen/scripts/build.js index 8277a90987e..80e24ac1234 100644 --- a/packages/react-native-codegen/scripts/build.js +++ b/packages/react-native-codegen/scripts/build.js @@ -5,6 +5,7 @@ * LICENSE file in the root directory of this source tree. * * @format + * @noflow */ /** diff --git a/packages/react-native-popup-menu-android/react-native.config.js b/packages/react-native-popup-menu-android/react-native.config.js index a23cfdb6674..5301f495f7d 100644 --- a/packages/react-native-popup-menu-android/react-native.config.js +++ b/packages/react-native-popup-menu-android/react-native.config.js @@ -5,6 +5,7 @@ * LICENSE file in the root directory of this source tree. * * @format + * @noflow */ module.exports = { diff --git a/packages/react-native-popup-menu-android/scripts/prepublish-popup-menu-android.js b/packages/react-native-popup-menu-android/scripts/prepublish-popup-menu-android.js index 97e9551e2b3..a6cf3f07c60 100644 --- a/packages/react-native-popup-menu-android/scripts/prepublish-popup-menu-android.js +++ b/packages/react-native-popup-menu-android/scripts/prepublish-popup-menu-android.js @@ -5,6 +5,7 @@ * LICENSE file in the root directory of this source tree. * * @format + * @noflow */ /* diff --git a/packages/react-native-test-library/babel.config.js b/packages/react-native-test-library/babel.config.js index 489b9c61277..87d86f0b5a5 100644 --- a/packages/react-native-test-library/babel.config.js +++ b/packages/react-native-test-library/babel.config.js @@ -5,6 +5,7 @@ * LICENSE file in the root directory of this source tree. * * @format + * @noflow */ module.exports = { diff --git a/packages/react-native-test-library/react-native.config.js b/packages/react-native-test-library/react-native.config.js index a23cfdb6674..5301f495f7d 100644 --- a/packages/react-native-test-library/react-native.config.js +++ b/packages/react-native-test-library/react-native.config.js @@ -5,6 +5,7 @@ * LICENSE file in the root directory of this source tree. * * @format + * @noflow */ module.exports = { diff --git a/packages/rn-tester/metro.config.js b/packages/rn-tester/metro.config.js index 4057964bfa8..e0ca2bc8d6b 100644 --- a/packages/rn-tester/metro.config.js +++ b/packages/rn-tester/metro.config.js @@ -5,6 +5,7 @@ * LICENSE file in the root directory of this source tree. * * @format + * @noflow */ 'use strict'; diff --git a/packages/rn-tester/react-native.config.js b/packages/rn-tester/react-native.config.js index db5c45ff4bf..1cfe5e432d4 100644 --- a/packages/rn-tester/react-native.config.js +++ b/packages/rn-tester/react-native.config.js @@ -5,6 +5,7 @@ * LICENSE file in the root directory of this source tree. * * @format + * @noflow */ 'use strict'; diff --git a/scripts/clean-gha-cache.js b/scripts/clean-gha-cache.js index 3ca884e6649..8e85ba75c8a 100644 --- a/scripts/clean-gha-cache.js +++ b/scripts/clean-gha-cache.js @@ -3,11 +3,14 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. + * + * @format + * @noflow */ const {execSync} = require('node:child_process'); -const CACHE_LIMIT = (10 * 1024 ** 3) * 0.9; +const CACHE_LIMIT = 10 * 1024 ** 3 * 0.9; // Doing this to capture node-modules- and the pre-existing node-cache--yarn- entries const NODE_CACHE_KEY = 'node-'; const NODE_CACHE_KEY_FULL = 'node-modules-'; @@ -15,14 +18,16 @@ const NODE_CACHE_KEY_FULL = 'node-modules-'; function cleanData(rawStr) { const now = new Date(); const json = JSON.parse(rawStr); - return json - .map(raw => ({ - ...raw, - createdAt: now - new Date(raw.createdAt), - msSinceLastAccessed: now - new Date(raw.lastAccessedAt), - })) - // Order: oldest last access time first - .sort((a, b) => b.msSinceLastAccessed - a.msSinceLastAccessed); + return ( + json + .map(raw => ({ + ...raw, + createdAt: now - new Date(raw.createdAt), + msSinceLastAccessed: now - new Date(raw.lastAccessedAt), + })) + // Order: oldest last access time first + .sort((a, b) => b.msSinceLastAccessed - a.msSinceLastAccessed) + ); } const mb = bytes => (bytes / 1024 ** 2).toFixed(2) + 'MB'; @@ -37,7 +42,7 @@ function cacheToString(entry) { function cleanCache(cmd) { try { const msg = execSync(cmd, 'utf8'); - return (msg.trim().length > 0) ? msg.trim() : '🪓'; + return msg.trim().length > 0 ? msg.trim() : '🪓'; } catch (e) { // There can be race conditions between github cache cleanups and this script. if (/Could not find a cache matching/.test(e.message)) { @@ -48,10 +53,12 @@ function cleanCache(cmd) { } function main() { - const cacheUsage = cleanData(execSync( - 'gh cache list --sort last_accessed_at --json id,key,createdAt,lastAccessedAt,sizeInBytes --limit 1000', - 'utf8' - )); + const cacheUsage = cleanData( + execSync( + 'gh cache list --sort last_accessed_at --json id,key,createdAt,lastAccessedAt,sizeInBytes --limit 1000', + 'utf8', + ), + ); let total = 0; let remove = []; @@ -60,25 +67,38 @@ function main() { // Be aggressive with node cache entries. Ignore entries < 1MB and only keep most // recently created entry. const nodeCacheUsage = cacheUsage - .filter(({key, sizeInBytes}) => - // I've observed some noisy entries, ignore anything that isn't > 1MB - key.startsWith(NODE_CACHE_KEY) && sizeInBytes > 1024 * 1024 + .filter( + ({key, sizeInBytes}) => + // I've observed some noisy entries, ignore anything that isn't > 1MB + key.startsWith(NODE_CACHE_KEY) && sizeInBytes > 1024 * 1024, ) .sort((a, b) => b.createdAt - a.createdAt); // Find the oldest version of node-modules-*. It's still possible that we have legacy node-yarn-* // entries if there are commits on branches of RN < 0.75-stable, so guard for this: - const idx = nodeCacheUsage.findLastIndex(({key}) => key.startsWith(NODE_CACHE_KEY_FULL)); - const keeping = ((idx === -1) ? nodeCacheUsage : nodeCacheUsage.splice(idx, 1)).pop(); + const idx = nodeCacheUsage.findLastIndex(({key}) => + key.startsWith(NODE_CACHE_KEY_FULL), + ); + const keeping = ( + idx === -1 ? nodeCacheUsage : nodeCacheUsage.splice(idx, 1) + ).pop(); - console.log('TASK: clean up old node_modules cache entries.', keeping ? `\nkeeping ${cacheToString(keeping)}` : ' Skipping, no cache entries.'); + console.log( + 'TASK: clean up old node_modules cache entries.', + keeping + ? `\nkeeping ${cacheToString(keeping)}` + : ' Skipping, no cache entries.', + ); for (const entry of nodeCacheUsage) { - console.warn(`removing ${cacheToString(entry)}`); - cleaned += entry.sizeInBytes; - remove.push(entry.id); + console.warn(`removing ${cacheToString(entry)}`); + cleaned += entry.sizeInBytes; + remove.push(entry.id); } // Cleanup everything else - console.log('TASK: clean up everything else that takes us over our threshold: ' + mb(CACHE_LIMIT)); + console.log( + 'TASK: clean up everything else that takes us over our threshold: ' + + mb(CACHE_LIMIT), + ); for (let i = cacheUsage.length - 1; i > 0; i--) { const cache = cacheUsage[i]; total += cache.sizeInBytes; @@ -89,12 +109,18 @@ function main() { cleaned += cache.sizeInBytes; remove.push(cache.id); } else { - console.warn(`skip ${cacheUsage.length - i} ${mb(cache.sizeInBytes)} ${hrs(cache.msSinceLastAccessed)}`); + console.warn( + `skip ${cacheUsage.length - i} ${mb(cache.sizeInBytes)} ${hrs(cache.msSinceLastAccessed)}`, + ); } } - console.warn(`Identifed ${remove.length} cache keys for removal, reducing cache from ${mb(total)} -> ${mb(total - cleaned)}`); + console.warn( + `Identifed ${remove.length} cache keys for removal, reducing cache from ${mb(total)} -> ${mb(total - cleaned)}`, + ); - const cleanup = remove.map(id => `gh cache delete ${id} --repo facebook/react-native`); + const cleanup = remove.map( + id => `gh cache delete ${id} --repo facebook/react-native`, + ); for (const cmd of cleanup) { if (dryRun) { console.warn(`Skip: ${cmd}`); diff --git a/scripts/e2e/utils/retry.js b/scripts/e2e/utils/retry.js index d5df037b7cf..e2f1e6146fe 100644 --- a/scripts/e2e/utils/retry.js +++ b/scripts/e2e/utils/retry.js @@ -5,6 +5,7 @@ * LICENSE file in the root directory of this source tree. * * @format + * @noflow */ const {spawnSync} = require('child_process'); diff --git a/scripts/lint-java.js b/scripts/lint-java.js index 105e4cc0680..d532503af19 100644 --- a/scripts/lint-java.js +++ b/scripts/lint-java.js @@ -5,6 +5,7 @@ * LICENSE file in the root directory of this source tree. * * @format + * @noflow */ 'use strict'; diff --git a/scripts/monorepo/print/index.js b/scripts/monorepo/print/index.js index 4783c5c02f3..e5035e9c97e 100644 --- a/scripts/monorepo/print/index.js +++ b/scripts/monorepo/print/index.js @@ -5,6 +5,7 @@ * LICENSE file in the root directory of this source tree. * * @format + * @noflow */ const {getVersionsBySpec} = require('../../npm-utils'); diff --git a/scripts/run-ci-javascript-tests.js b/scripts/run-ci-javascript-tests.js index ab690e45dee..fa5668af7cc 100644 --- a/scripts/run-ci-javascript-tests.js +++ b/scripts/run-ci-javascript-tests.js @@ -5,6 +5,7 @@ * LICENSE file in the root directory of this source tree. * * @format + * @noflow */ 'use strict';