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/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 (