Skip to content
Prev Previous commit
Next Next commit
Fix syntax errors introduced by commit suggestions
  • Loading branch information
ctavan committed Jan 29, 2021
commit 1fcb340bf90420fe057f679130eebb5a300d91cd
7 changes: 5 additions & 2 deletions lib/internal/modules/esm/module_job.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function extractExample(file, lineNumber) {
const imports = ArrayPrototypeMap(
ArrayPrototypeFilter(
node.node.specifiers,
(specifier) => specifier.type === 'ImportSpecifier')
(specifier) => (specifier.type === 'ImportSpecifier'),
),
(specifier) => {
const statement =
Expand All @@ -81,7 +81,10 @@ function extractExample(file, lineNumber) {

const boilerplate = `const { } = ${defaultImport};`;
const destructuringAssignment = totalLength > 80 - boilerplate.length ?
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My line splitting logic is pretty "simplistic"… Any idea on how to do this better?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we do anything similar elsewhere? a nice to have would be checking the terminal width, rather than assuming 80.

`\n${ArrayPrototypeJoin(ArrayPrototypeMap(imports, (i) => ` ${i}`), ',\n')}\n` :
`\n${ArrayPrototypeJoin(
ArrayPrototypeMap(imports, (i) => ` ${i}`),
',\n',
)}\n` :
` ${imports.join(joinString)} `;

return `\n\nimport ${defaultImport} from '${node.node.source.value}';\n` +
Expand Down