diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5de11dda6d6b0..8f9c2636b4d79 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -51,9 +51,9 @@ jobs: run: echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%" - name: Git Checkout - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - - uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 + - uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 with: path: ${{ github.workspace }}/apps/site/.next/cache key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }} diff --git a/.github/workflows/chromatic.yml b/.github/workflows/chromatic.yml index dd64b0ba60721..848f9a30383be 100644 --- a/.github/workflows/chromatic.yml +++ b/.github/workflows/chromatic.yml @@ -59,7 +59,7 @@ jobs: egress-policy: audit - name: Git Checkout - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: # Provides the Pull Request commit SHA or the GitHub merge group ref ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.ref }} @@ -82,10 +82,8 @@ jobs: - name: Start Visual Regression Tests (Chromatic) # This assigns the Environment Deployment for Storybook - # This action must be manually updated to the latest commit from - # https://github.com/chromaui/action id: chromatic-deploy - uses: chromaui/action@4d8ebd13658d795114f8051e25c28d66f14886c6 # v13.1.2 + uses: chromaui/action@d0795df816d05c4a89c80295303970fddd247cce # v13.1.4 with: workingDir: packages/ui-components buildScriptName: storybook:build diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 8478f5720fde0..450ac5dd3f628 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -46,7 +46,7 @@ jobs: egress-policy: audit - name: Checkout repository - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index 24ba07cfcf1cd..9abb4c5576be3 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -31,7 +31,7 @@ jobs: egress-policy: audit - name: Git Checkout - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - name: Review Dependencies - uses: actions/dependency-review-action@da24556b548a50705dd671f47852072ea4c105d9 # v4.7.1 + uses: actions/dependency-review-action@595b5aeba73380359d98a5e087f648dbb0edce1b # v4.7.3 diff --git a/.github/workflows/find-inactive-collaborators.yml b/.github/workflows/find-inactive-collaborators.yml index 906ad58fee9dd..2f2e1d494e1c6 100644 --- a/.github/workflows/find-inactive-collaborators.yml +++ b/.github/workflows/find-inactive-collaborators.yml @@ -21,7 +21,7 @@ jobs: with: egress-policy: audit - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - name: Report inactive collaborators id: inactive diff --git a/.github/workflows/lighthouse.yml b/.github/workflows/lighthouse.yml index e2809821cc7dc..87110aea99e08 100644 --- a/.github/workflows/lighthouse.yml +++ b/.github/workflows/lighthouse.yml @@ -70,7 +70,7 @@ jobs: egress-policy: audit - name: Git Checkout - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: # Provides the Pull Request commit SHA or the GitHub merge group ref ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.ref }} diff --git a/.github/workflows/lint-and-tests.yml b/.github/workflows/lint-and-tests.yml index 01b311dbcb12b..685ad1f209696 100644 --- a/.github/workflows/lint-and-tests.yml +++ b/.github/workflows/lint-and-tests.yml @@ -48,10 +48,10 @@ jobs: egress-policy: audit - name: Git Checkout - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - name: Restore Lint Cache - uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 + uses: actions/cache/restore@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 with: path: | .turbo/cache @@ -101,7 +101,7 @@ jobs: (github.event_name == 'pull_request' && startsWith(github.event.pull_request.head.ref, 'dependabot/') == false && github.event.pull_request.head.ref != 'chore/crowdin') - uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 + uses: actions/cache/save@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 with: path: | .turbo/cache @@ -121,7 +121,7 @@ jobs: egress-policy: audit - name: Git Checkout - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - name: Set up pnpm uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 @@ -143,7 +143,7 @@ jobs: - name: Upload test coverage to Codecov if: ${{ !cancelled() && github.event_name != 'merge_group' }} - uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3 + uses: codecov/codecov-action@fdcc8476540edceab3de004e990f80d881c6cc00 # v5.5.0 with: files: ./apps/site/lcov.info,./packages/*/lcov.info diff --git a/.github/workflows/playwright-cloudflare-open-next.yml b/.github/workflows/playwright-cloudflare-open-next.yml index 746aecb149e61..7b5f0830bbb5b 100644 --- a/.github/workflows/playwright-cloudflare-open-next.yml +++ b/.github/workflows/playwright-cloudflare-open-next.yml @@ -34,7 +34,7 @@ jobs: egress-policy: audit - name: Git Checkout - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: fetch-depth: 2 @@ -58,7 +58,7 @@ jobs: - name: Cache Playwright browsers id: playwright-cache - uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 + uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 with: path: ~/.cache/ms-playwright key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }} diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index d143cc7d45cb4..49539885f83d3 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -60,7 +60,7 @@ jobs: egress-policy: audit - name: Git Checkout - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: fetch-depth: 2 @@ -84,7 +84,7 @@ jobs: - name: Cache Playwright browsers id: playwright-cache - uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 + uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 with: path: ~/.cache/ms-playwright key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }} diff --git a/.github/workflows/publish-packages.yml b/.github/workflows/publish-packages.yml index 05471fdf28f56..b349a68176607 100644 --- a/.github/workflows/publish-packages.yml +++ b/.github/workflows/publish-packages.yml @@ -60,7 +60,7 @@ jobs: echo "✅ Commit is verified and trusted." - name: Checkout repository - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: fetch-depth: 2 # Need at least 2 commits to detect changes between commits @@ -108,7 +108,7 @@ jobs: egress-policy: audit - name: Checkout repository - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - name: Set up pnpm uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index 97dacbe6d149f..ef8e4c889d64c 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -37,7 +37,7 @@ jobs: egress-policy: audit - name: Git Checkout - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false diff --git a/.github/workflows/sync-orama.yml b/.github/workflows/sync-orama.yml index 4814e7af56856..4efa07ce2e905 100644 --- a/.github/workflows/sync-orama.yml +++ b/.github/workflows/sync-orama.yml @@ -33,7 +33,7 @@ jobs: steps: - name: Git Checkout - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.ref }} diff --git a/.github/workflows/translations-sync.yml b/.github/workflows/translations-sync.yml index e8f62615e23f8..bd858569dd428 100644 --- a/.github/workflows/translations-sync.yml +++ b/.github/workflows/translations-sync.yml @@ -31,13 +31,13 @@ jobs: egress-policy: audit - name: Checkout - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: token: ${{ secrets.CROWDIN_GITHUB_BOT_TOKEN }} # see all the options at https://github.com/crowdin/github-action - name: Crowdin PR - uses: crowdin/github-action@9fd07c1c5b36b15f082d1d860dc399f16f849bd7 # v2.9.0 + uses: crowdin/github-action@9787f4fcb6a8450929673f1e8db841e8a5c35a2f # v2.10.0 with: # do not upload anything - this is a one-way operation download upload_sources: false @@ -71,14 +71,14 @@ jobs: egress-policy: audit - name: Git Checkout - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: ref: ${{ env.BRANCH_NAME }} token: ${{ secrets.CROWDIN_GITHUB_BOT_TOKEN }} fetch-depth: 2 - name: Restore Lint Cache - uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 + uses: actions/cache/restore@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 with: path: | apps/site/.eslintmdcache @@ -129,7 +129,7 @@ jobs: branch: ${{ env.BRANCH_NAME }} - name: Save Lint Cache - uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 + uses: actions/cache/save@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 with: path: | apps/site/.eslintmdcache diff --git a/.github/workflows/translations-upload.yml b/.github/workflows/translations-upload.yml index 5f1ffc4b2f5cf..c30320723d7fd 100644 --- a/.github/workflows/translations-upload.yml +++ b/.github/workflows/translations-upload.yml @@ -23,11 +23,11 @@ jobs: egress-policy: audit - name: Checkout - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 # see all the options at https://github.com/crowdin/github-action - name: crowdin action - uses: crowdin/github-action@9fd07c1c5b36b15f082d1d860dc399f16f849bd7 # v2.9.0 + uses: crowdin/github-action@9787f4fcb6a8450929673f1e8db841e8a5c35a2f # v2.10.0 with: # only upload sources, ensuring this is a one-way operation upload_sources: true diff --git a/apps/site/components/Downloads/Release/ReleaseCodeBox.tsx b/apps/site/components/Downloads/Release/ReleaseCodeBox.tsx index 0c31225248be6..645b428affe18 100644 --- a/apps/site/components/Downloads/Release/ReleaseCodeBox.tsx +++ b/apps/site/components/Downloads/Release/ReleaseCodeBox.tsx @@ -16,6 +16,7 @@ import { ReleaseContext, ReleasesContext, } from '#site/providers/releaseProvider'; +import type { DownloadSnippet } from '#site/types/download'; import type { ReleaseContextType } from '#site/types/release'; import { INSTALL_METHODS } from '#site/util/download'; @@ -26,80 +27,109 @@ import { INSTALL_METHODS } from '#site/util/download'; // by Shiki to render the highlighted syntax. Hence XSS attacks or JavaScript injections are not possible. const interpreter = createSval({}, 'script'); -const parseSnippet = (s: string, releaseContext: ReleaseContextType) => { - // Adds the release context to the interpreter context +/** + * Parses a snippet string using the interpreter with the given release context + */ +const parseSnippet = (snippet: string, releaseContext: ReleaseContextType) => { interpreter.import({ props: releaseContext }); - - // Evaluates the JavaScript code applying the release context to the code - interpreter.run(`exports.content = \`${s}\``); - - // Sets the parsed raw string to be used by the JSX CodeBox - return String(interpreter.exports.content); + interpreter.run(`exports.content = \`${snippet}\``); + return interpreter.exports.content; }; -const ReleaseCodeBox: FC = () => { - const { snippets } = useContext(ReleasesContext); +/** + * Custom hook to handle snippet processing logic + */ +const useSnippetProcessor = ( + snippets: Array, + context: ReleaseContextType +) => { + return useMemo(() => { + // Find relevant snippets + const installMethodSnippet = snippets.find( + ({ name }) => name === context.installMethod.toLowerCase() + ); - const { installMethod, os, packageManager, release } = - useContext(ReleaseContext); + const packageManagerSnippet = snippets.find( + ({ name }) => name === context.packageManager.toLowerCase() + ); - const t = useTranslations(); + // Only process if both snippets are available + if (!installMethodSnippet || !packageManagerSnippet) { + return ''; + } - // Retrieves the current platform (Dropdown Item) based on the selected platform value - const currentPlatform = useMemo( - () => INSTALL_METHODS.find(({ value }) => value === installMethod), - [installMethod] - ); + const verifyNodeSnippet = snippets.find(({ name }) => name === 'node'); + + const installCorepackSnippet = + context.packageManager !== 'NPM' && + // Corepack is no longer distributed with Node.js v25 + context.release.major >= 25 && + snippets.find(({ name }) => name === 'corepack'); + + // Combine and parse snippets + const parsedContent = parseSnippet( + [ + installMethodSnippet, + verifyNodeSnippet, + installCorepackSnippet, + packageManagerSnippet, + ] + .filter(Boolean) + .map(snippet => (snippet as DownloadSnippet).content) + .join('\n'), + context + ); - // Parses the snippets based on the selected platform, package manager, and release context - const parsedSnippets = useMemo(() => { - // Retrieves a snippet for the given Installation Method (aka Platform) - const installMethodSnippet = snippets.find( - ({ name }) => name === installMethod.toLowerCase() + // Convert to HTML using Shiki's highlighter + // This is faster than JSX rendering as it avoids React runtime overhead + return highlightToHtml( + parsedContent, + context.os === 'WIN' ? 'ps1' : 'bash' ); + }, [snippets, context]); +}; - // Retrieves a snippet for the given Package Manager to be bundled with the Platform snippet - const packageManagerSnippet = snippets.find( - ({ name }) => name === packageManager.toLowerCase() +/** + * Custom hook to get current platform information + */ +const usePlatformInfo = (installMethod: string) => { + return useMemo(() => { + const platform = INSTALL_METHODS.find( + ({ value }) => value === installMethod ); - // Prevents numerous recalculations of `sval` and `Shiki` when not necessary - // As we only want to parse the snippets when both the Platform and Package Manager snippets are available - if (installMethodSnippet && packageManagerSnippet) { - const content = parseSnippet( - // Bundles the Platform and Package Manager snippets - `${installMethodSnippet.content}\n${packageManagerSnippet.content}`, - // Passes a partial state of only the things we need to the parser - { release, os } as ReleaseContextType - ); - - // We use Shikis's `hast-util-to-html` to convert the highlighted code into plain HTML (Pretty much using Rehype) - // This is actually faster than using `hast-util-to-jsx-runtime` and then rendering the JSX - // As it requires React's runtime to interpolate and build these components dynamically - // Which also leads to a lot o GC being emitted. (Tested via Profiling) - return highlightToHtml(content, os === 'WIN' ? 'ps1' : 'bash'); - } + // Provide defaults for destructuring + return { + label: platform?.label || '', + url: platform?.url || '', + info: platform?.info || 'layouts.download.codeBox.platformInfo.default', + recommended: platform?.recommended || false, + exists: !!platform, + }; + }, [installMethod]); +}; - return ''; - // Only change to these specific properties which are relevant for the re-rendering of the CodeBox - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [release.versionWithPrefix, installMethod, os, packageManager]); +/** + * ReleaseCodeBox component displays installation instructions based on platform and context + */ +const ReleaseCodeBox: FC = () => { + const { snippets } = useContext(ReleasesContext); + const context = useContext(ReleaseContext); + const t = useTranslations(); - // Determines the code language based on the OS - const displayName = os === 'WIN' ? 'PowerShell' : 'Bash'; + // Process platform information + const platformInfo = usePlatformInfo(context.installMethod); - // Determines if the code box should render the skeleton loader - const renderSkeleton = os === 'LOADING' || installMethod === ''; + // Process snippets + const parsedSnippets = useSnippetProcessor(snippets, context); - // Defines fallbacks for the currentPlatform object - const { - label = '', - url = '', - info = 'layouts.download.codeBox.platformInfo.default', - } = currentPlatform ?? {}; + // UI state calculations + const displayLanguage = context.os === 'WIN' ? 'PowerShell' : 'Bash'; + const isLoading = context.os === 'LOADING' || context.installMethod === ''; return (
+ {/* NoScript warning */} - + {/* Release status alert */} + - {!currentPlatform || currentPlatform.recommended || ( + {/* Community platform notice */} + {platformInfo.exists && !platformInfo.recommended && ( { )} - - + {/* Code display with skeleton loading */} + + + {/* Platform info footer */} - - {t(info, { platform: label })}{' '} + + {t(platformInfo.info, { platform: platformInfo.label })}{' '} {t.rich('layouts.download.codeBox.externalSupportInfo', { - platform: label, + platform: platformInfo.label, link: text => ( - + {text} ), diff --git a/apps/site/pages/en/learn/asynchronous-work/asynchronous-flow-control.md b/apps/site/pages/en/learn/asynchronous-work/asynchronous-flow-control.md index 50e3ee8f1ed7c..71a792a72cd0d 100644 --- a/apps/site/pages/en/learn/asynchronous-work/asynchronous-flow-control.md +++ b/apps/site/pages/en/learn/asynchronous-work/asynchronous-flow-control.md @@ -98,7 +98,10 @@ function getSong() { } function singSong(_song) { - if (!_song) throw new Error("song is '' empty, FEED ME A SONG!"); + if (!_song) { + throw new Error("song is '' empty, FEED ME A SONG!"); + } + console.log(_song); } @@ -128,7 +131,10 @@ function getSong() { } function singSong(_song) { - if (!_song) throw new Error("song is '' empty, FEED ME A SONG!"); + if (!_song) { + throw new Error("song is '' empty, FEED ME A SONG!"); + } + console.log(_song); } @@ -161,7 +167,10 @@ function executeFunctionWithArgs(operation, callback) { } function serialProcedure(operation) { - if (!operation) process.exit(0); // finished + if (!operation) { + process.exit(0); // finished + } + executeFunctionWithArgs(operation, function (result) { // continue AFTER callback serialProcedure(operations.shift()); @@ -195,12 +204,20 @@ function dispatch(recipient, callback) { function sendOneMillionEmailsOnly() { getListOfTenMillionGreatEmails(function (err, bigList) { - if (err) throw err; + if (err) { + throw err; + } function serial(recipient) { - if (!recipient || successCount >= 1000000) return final(); + if (!recipient || successCount >= 1000000) { + return final(); + } + dispatch(recipient, function (_err) { - if (!_err) successCount += 1; + if (!_err) { + successCount += 1; + } + serial(bigList.pop()); }); } @@ -241,9 +258,10 @@ function dispatch(recipient, callback) { function final(result) { console.log(`Result: ${result.count} attempts \ & ${result.success} succeeded emails`); - if (result.failed.length) + if (result.failed.length) { console.log(`Failed to send to: \ \n${result.failed.join('\n')}\n`); + } } recipients.forEach(function (recipient) { diff --git a/apps/site/pages/en/learn/asynchronous-work/dont-block-the-event-loop.md b/apps/site/pages/en/learn/asynchronous-work/dont-block-the-event-loop.md index 12a93f01d5652..63ffef92cec98 100644 --- a/apps/site/pages/en/learn/asynchronous-work/dont-block-the-event-loop.md +++ b/apps/site/pages/en/learn/asynchronous-work/dont-block-the-event-loop.md @@ -318,7 +318,10 @@ For a simple example, suppose you want to compute the average of the numbers `1` Example 1: Un-partitioned average, costs `O(n)` ```js -for (let i = 0; i < n; i++) sum += i; +for (let i = 0; i < n; i++) { + sum += i; +} + const avg = sum / n; console.log('avg: ' + avg); ``` diff --git a/apps/site/pages/en/learn/asynchronous-work/event-loop-timers-and-nexttick.md b/apps/site/pages/en/learn/asynchronous-work/event-loop-timers-and-nexttick.md index 966d6ca1607a9..43aa7ebca34d2 100644 --- a/apps/site/pages/en/learn/asynchronous-work/event-loop-timers-and-nexttick.md +++ b/apps/site/pages/en/learn/asynchronous-work/event-loop-timers-and-nexttick.md @@ -310,11 +310,12 @@ it doesn't have to be. Take this code snippet for example: ```js function apiCall(arg, callback) { - if (typeof arg !== 'string') + if (typeof arg !== 'string') { return process.nextTick( callback, new TypeError('argument should be string') ); + } } ``` diff --git a/apps/site/pages/en/learn/asynchronous-work/overview-of-blocking-vs-non-blocking.md b/apps/site/pages/en/learn/asynchronous-work/overview-of-blocking-vs-non-blocking.md index b4df68edf80f5..e516cd6f8f3c8 100644 --- a/apps/site/pages/en/learn/asynchronous-work/overview-of-blocking-vs-non-blocking.md +++ b/apps/site/pages/en/learn/asynchronous-work/overview-of-blocking-vs-non-blocking.md @@ -51,7 +51,9 @@ And here is an equivalent **asynchronous** example: const fs = require('node:fs'); fs.readFile('/file.md', (err, data) => { - if (err) throw err; + if (err) { + throw err; + } }); ``` @@ -78,7 +80,10 @@ And here is a similar, but not equivalent asynchronous example: const fs = require('node:fs'); fs.readFile('/file.md', (err, data) => { - if (err) throw err; + if (err) { + throw err; + } + console.log(data); }); moreWork(); // will run before console.log @@ -117,7 +122,10 @@ at an example: const fs = require('node:fs'); fs.readFile('/file.md', (err, data) => { - if (err) throw err; + if (err) { + throw err; + } + console.log(data); }); fs.unlinkSync('/file.md'); @@ -132,10 +140,16 @@ execute in the correct order is: const fs = require('node:fs'); fs.readFile('/file.md', (readFileErr, data) => { - if (readFileErr) throw readFileErr; + if (readFileErr) { + throw readFileErr; + } + console.log(data); + fs.unlink('/file.md', unlinkErr => { - if (unlinkErr) throw unlinkErr; + if (unlinkErr) { + throw unlinkErr; + } }); }); ``` diff --git a/apps/site/pages/en/learn/manipulating-files/working-with-file-descriptors-in-nodejs.md b/apps/site/pages/en/learn/manipulating-files/working-with-file-descriptors-in-nodejs.md index 6692046947251..9b934dc686917 100644 --- a/apps/site/pages/en/learn/manipulating-files/working-with-file-descriptors-in-nodejs.md +++ b/apps/site/pages/en/learn/manipulating-files/working-with-file-descriptors-in-nodejs.md @@ -77,7 +77,9 @@ async function example() { console.log(filehandle.fd); console.log(await filehandle.readFile({ encoding: 'utf8' })); } finally { - if (filehandle) await filehandle.close(); + if (filehandle) { + await filehandle.close(); + } } } example(); @@ -92,7 +94,9 @@ try { console.log(filehandle.fd); console.log(await filehandle.readFile({ encoding: 'utf8' })); } finally { - if (filehandle) await filehandle.close(); + if (filehandle) { + await filehandle.close(); + } } ``` diff --git a/apps/site/pages/en/learn/modules/backpressuring-in-streams.md b/apps/site/pages/en/learn/modules/backpressuring-in-streams.md index 4ad78d6d0ebdd..f8992c8437036 100644 --- a/apps/site/pages/en/learn/modules/backpressuring-in-streams.md +++ b/apps/site/pages/en/learn/modules/backpressuring-in-streams.md @@ -658,15 +658,23 @@ However, when we want to use a [`Writable`][] directly, we must respect the // there is a great chance multiple callbacks will be called. class MyWritable extends Writable { _write(chunk, encoding, callback) { - if (chunk.toString().indexOf('a') >= 0) callback(); - else if (chunk.toString().indexOf('b') >= 0) callback(); + if (chunk.toString().indexOf('a') >= 0) { + callback(); + } else if (chunk.toString().indexOf('b') >= 0) { + callback(); + } callback(); } } // The proper way to write this would be: -if (chunk.contains('a')) return callback(); -if (chunk.contains('b')) return callback(); +if (chunk.contains('a')) { + return callback(); +} + +if (chunk.contains('b')) { + return callback(); +} callback(); ``` diff --git a/apps/site/pages/en/learn/test-runner/mocking.md b/apps/site/pages/en/learn/test-runner/mocking.md index fc7fc1c8b645d..1ce756866e546 100644 --- a/apps/site/pages/en/learn/test-runner/mocking.md +++ b/apps/site/pages/en/learn/test-runner/mocking.md @@ -91,7 +91,9 @@ import { db } from 'db'; export function read(key, all = false) { validate(key, val); - if (all) return db.getAll(key); + if (all) { + return db.getAll(key); + } return db.getOne(key); } diff --git a/apps/site/pages/en/learn/typescript/introduction.md b/apps/site/pages/en/learn/typescript/introduction.md index 5ba39d8f04c3b..4c9739e8efaa9 100644 --- a/apps/site/pages/en/learn/typescript/introduction.md +++ b/apps/site/pages/en/learn/typescript/introduction.md @@ -75,7 +75,9 @@ import * as fs from 'fs'; fs.readFile('example.txt', 'foo', (err, data) => { // ^^^ Argument of type '"foo"' is not assignable to parameter of type … - if (err) throw err; + if (err) { + throw err; + } console.log(data); }); ``` diff --git a/apps/site/snippets/en/download/brew.bash b/apps/site/snippets/en/download/brew.bash index 5e9920102fa4f..96c16ac6bd083 100644 --- a/apps/site/snippets/en/download/brew.bash +++ b/apps/site/snippets/en/download/brew.bash @@ -3,6 +3,3 @@ curl -o- https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh | ba # Download and install Node.js: brew install node@${props.release.major} - -# Verify the Node.js version: -node -v # Should print "${props.release.versionWithPrefix}". diff --git a/apps/site/snippets/en/download/choco.bash b/apps/site/snippets/en/download/choco.bash index 8a79968b2ed64..95c3d5750a7b6 100644 --- a/apps/site/snippets/en/download/choco.bash +++ b/apps/site/snippets/en/download/choco.bash @@ -3,6 +3,3 @@ powershell -c "irm https://community.chocolatey.org/install.ps1|iex" # Download and install Node.js: choco install nodejs --version="${props.release.version}" - -# Verify the Node.js version: -node -v # Should print "${props.release.versionWithPrefix}". diff --git a/apps/site/snippets/en/download/corepack.bash b/apps/site/snippets/en/download/corepack.bash new file mode 100644 index 0000000000000..5dfe35d3cd17a --- /dev/null +++ b/apps/site/snippets/en/download/corepack.bash @@ -0,0 +1,2 @@ +# Install Corepack: +npm install -g corepack diff --git a/apps/site/snippets/en/download/devbox.bash b/apps/site/snippets/en/download/devbox.bash index 791e40fb4c71c..d536761f0fc8e 100644 --- a/apps/site/snippets/en/download/devbox.bash +++ b/apps/site/snippets/en/download/devbox.bash @@ -9,6 +9,3 @@ devbox add node@${props.release.major} # Open a Devbox shell devbox shell - -# Verify the Node.js version: -node -v # Should print "${props.release.versionWithPrefix}". diff --git a/apps/site/snippets/en/download/docker.bash b/apps/site/snippets/en/download/docker.bash index 9be099e1d7373..bee8df5c03ae1 100644 --- a/apps/site/snippets/en/download/docker.bash +++ b/apps/site/snippets/en/download/docker.bash @@ -6,6 +6,3 @@ docker pull node:${props.release.major}-${props.release.major >= 4 ? 'alpine' : # Create a Node.js container and start a Shell session: docker run -it --rm --entrypoint sh node:${props.release.major}-${props.release.major >= 4 ? 'alpine' : 'slim'} - -# Verify the Node.js version: -node -v # Should print "${props.release.versionWithPrefix}". diff --git a/apps/site/snippets/en/download/fnm.bash b/apps/site/snippets/en/download/fnm.bash index 5692c0b633f25..063ca3e6aec66 100644 --- a/apps/site/snippets/en/download/fnm.bash +++ b/apps/site/snippets/en/download/fnm.bash @@ -6,6 +6,3 @@ ${props.os === 'WIN' ? # Download and install Node.js: fnm install ${props.release.major} - -# Verify the Node.js version: -node -v # Should print "${props.release.versionWithPrefix}". diff --git a/apps/site/snippets/en/download/n.bash b/apps/site/snippets/en/download/n.bash index 4ced5d55f7bcd..6de7abe3d79bb 100644 --- a/apps/site/snippets/en/download/n.bash +++ b/apps/site/snippets/en/download/n.bash @@ -3,6 +3,3 @@ curl -fsSL https://raw.githubusercontent.com/mklement0/n-install/stable/bin/n-in # Node.js already installs during n-install, but you can also install it manually: # n install ${props.release.major} - -# Verify the Node.js version: -node -v # Should print "${props.release.versionWithPrefix}". diff --git a/apps/site/snippets/en/download/node.bash b/apps/site/snippets/en/download/node.bash new file mode 100644 index 0000000000000..9a8e88e27bb54 --- /dev/null +++ b/apps/site/snippets/en/download/node.bash @@ -0,0 +1,2 @@ +# Verify the Node.js version: +node -v # Should print "${props.release.versionWithPrefix}". diff --git a/apps/site/snippets/en/download/volta.bash b/apps/site/snippets/en/download/volta.bash index b1978fe00a511..fa3427b0c28fe 100644 --- a/apps/site/snippets/en/download/volta.bash +++ b/apps/site/snippets/en/download/volta.bash @@ -6,6 +6,3 @@ ${props.os === 'WIN' ? # Download and install Node.js: volta install node@${props.release.major} - -# Verify the Node.js version: -node -v # Should print "${props.release.versionWithPrefix}". diff --git a/apps/site/util/download/constants.json b/apps/site/util/download/constants.json index 02694b9bcfe0b..d0f2cb70c3589 100644 --- a/apps/site/util/download/constants.json +++ b/apps/site/util/download/constants.json @@ -69,7 +69,7 @@ "label": "ARMv7", "value": "armv7l", "compatibility": { - "semver": [">= 4.0.0"] + "semver": [">= 4.0.0", "< 24.0.0"] } }, { diff --git a/apps/site/util/download/index.tsx b/apps/site/util/download/index.tsx index bca51484cc93a..ad70b522a4474 100644 --- a/apps/site/util/download/index.tsx +++ b/apps/site/util/download/index.tsx @@ -59,7 +59,7 @@ export const parseCompat = < compatibility.installMethod.includes(installMethod), !compatibility.platform || compatibility.platform.includes(platform), !compatibility.semver || - compatibility.semver.some(semver => satisfies(version, semver)), + compatibility.semver.every(semver => satisfies(version, semver)), !compatibility.releases || compatibility.releases.includes(release.status), ]; diff --git a/docs/code-style.md b/docs/code-style.md index f608e55e3c3a0..9edd501c53691 100644 --- a/docs/code-style.md +++ b/docs/code-style.md @@ -129,7 +129,9 @@ type MyComponentProps = { }; const MyComponent: FC = ({ title, isVisible = true }) => { - if (!isVisible) return null; + if (!isVisible) { + return null; + } return (
diff --git a/eslint.config.js b/eslint.config.js index 561dd687ab75b..722a00ffc8cfe 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -79,6 +79,7 @@ export default tseslint.config( ], 'object-shorthand': 'error', + curly: ['error', 'all'], }, } ); diff --git a/packages/remark-lint/src/rules/hashed-self-reference.mjs b/packages/remark-lint/src/rules/hashed-self-reference.mjs index 789c41cab3dd4..e00964ac5355c 100644 --- a/packages/remark-lint/src/rules/hashed-self-reference.mjs +++ b/packages/remark-lint/src/rules/hashed-self-reference.mjs @@ -27,7 +27,9 @@ const hashedSelfReference = (tree, vfile) => { for (const node of getLinksRecursively(tree)) { const { url } = node; - if (!url || url[0] === '#') continue; + if (!url || url[0] === '#') { + continue; + } const targetURL = new URL(url, currentFileURL); diff --git a/packages/remark-lint/src/rules/yaml/ordered-yaml-keys.mjs b/packages/remark-lint/src/rules/yaml/ordered-yaml-keys.mjs index 9126a4b0959df..6160bd5aecd48 100644 --- a/packages/remark-lint/src/rules/yaml/ordered-yaml-keys.mjs +++ b/packages/remark-lint/src/rules/yaml/ordered-yaml-keys.mjs @@ -26,7 +26,9 @@ export default function orderedYamlKeys( validKeys = DEFAULT_VALID_KEYS, prefix = '' ) { - if (!yaml || typeof yaml !== 'object' || Array.isArray(yaml)) return; + if (!yaml || typeof yaml !== 'object' || Array.isArray(yaml)) { + return; + } const keys = Object.keys(yaml); diff --git a/packages/ui-components/src/Common/AvatarGroup/Avatar/index.tsx b/packages/ui-components/src/Common/AvatarGroup/Avatar/index.tsx index 46f0ac699c4f0..e0704405527e8 100644 --- a/packages/ui-components/src/Common/AvatarGroup/Avatar/index.tsx +++ b/packages/ui-components/src/Common/AvatarGroup/Avatar/index.tsx @@ -34,7 +34,10 @@ const Avatar = forwardRef< }, ref ) => { - if (!url) Component = 'div'; + if (!url) { + Component = 'div'; + } + return (