doc: modernize and fix code examples in modules.md#12224
doc: modernize and fix code examples in modules.md#12224vsemozhetbyt wants to merge 8 commits intonodejs:masterfrom vsemozhetbyt:modules.md
Conversation
doc/api/modules.md
Outdated
There was a problem hiding this comment.
Nit: not sure about other docs examples but this is inconsistent with core style where () is also used for a single argument.
There was a problem hiding this comment.
@lpinca There is a nuance here. I mean somethin like this advice: when we have implicite return and the function body is not in braces, omit parentheses around one argument. I've searched the https://nodejs.org/api/all.html and have found only 2 such cases, and they are better be rewritten with braces, because they do not use returned value and have side effects:
Then I've searched the core libs and have found only one fragment with omitted parentheses and dozens with them. So I shall revert this cange to conform with core.
doc/api/modules.md
Outdated
There was a problem hiding this comment.
Nit: no strong opinions here but I think the original is easier to grok.
doc/api/modules.md
Outdated
There was a problem hiding this comment.
I think it's a good opportunity to convert this identifier to camelCase.
aqrln
left a comment
There was a problem hiding this comment.
LGTM. Would be also nice to backport it to LTS branches taking into account which features are supported by those Node versions (e.g., exponentiation operator change would need to be reverted).
|
Landed in 166a156 |
* Replace `var` by `const`. * Fix semicolons. * Add missing code marks. * Unify quotes. * Comment out ellipsis. * Use object destructuring. * Use exponentiation operator. * Replace snake_case by camelCase. PR-URL: #12224 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Alexey Orlenko <[email protected]>
* Replace `var` by `const`. * Fix semicolons. * Add missing code marks. * Unify quotes. * Comment out ellipsis. * Use object destructuring. * Use exponentiation operator. * Replace snake_case by camelCase. PR-URL: nodejs#12224 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Alexey Orlenko <[email protected]>
|
@vsemozhetbyt would you be willing to make a backport PR to v6.x? |
|
@MylesBorins I shall try. |
|
If I get it right, I had only to remove the 'use exponentiation operator' part. |
* Replace `var` by `const`. * Fix semicolons. * Add missing code marks. * Unify quotes. * Comment out ellipsis. * Use object destructuring. * Replace snake_case by camelCase. Backport-PR-URL: #12500 PR-URL: #12224 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Alexey Orlenko <[email protected]>
* Replace `var` by `const`. * Fix semicolons. * Add missing code marks. * Unify quotes. * Comment out ellipsis. * Use object destructuring. * Replace snake_case by camelCase. Backport-PR-URL: #12500 PR-URL: #12224 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Alexey Orlenko <[email protected]>
* Replace `var` by `const`. * Fix semicolons. * Add missing code marks. * Unify quotes. * Comment out ellipsis. * Use object destructuring. * Replace snake_case by camelCase. Backport-PR-URL: #12500 PR-URL: #12224 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Alexey Orlenko <[email protected]>
* Replace `var` by `const`. * Fix semicolons. * Add missing code marks. * Unify quotes. * Comment out ellipsis. * Use object destructuring. * Replace snake_case by camelCase. Backport-PR-URL: nodejs/node#12500 PR-URL: nodejs/node#12224 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Alexey Orlenko <[email protected]>
Checklist
Affected core subsystem(s)
doc, modules
varbyconst.