Skip to content

Commit

Permalink
Add JSDoc based types
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Aug 4, 2021
1 parent 85d6f71 commit f03fa4e
Show file tree
Hide file tree
Showing 6 changed files with 302 additions and 146 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.DS_Store
*.log
coverage/
node_modules/
.DS_Store
*.d.ts
*.log
yarn.lock
20 changes: 14 additions & 6 deletions formatters.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
/**
* @typedef {import('remark-contributors').FormatterObjects} FormatterObjects
*/

/**
* @type {FormatterObjects}
*/
export const defaultFormatters = {
email: {exclude: true},
commits: {exclude: true},
social: {
label: 'Social',
format(value) {
const object = /** @type {{url: string, text: string}|undefined} */ (
value
)

// Shouldn’t happen, but let’s keep it here just to be sure.
/* c8 ignore next 3 */
if (!value) {
if (!object) {
return ''
}

return {
type: 'link',
url: value.url,
url: object.url,
children: [
{
type: 'strong',
children: [{type: 'text', value: value.text}]
}
{type: 'strong', children: [{type: 'text', value: object.text}]}
]
}
}
Expand Down
Loading

0 comments on commit f03fa4e

Please sign in to comment.