Skip to content

Commit 90d5d3f

Browse files
committed
feat(api): expose pre-configured Prettier format
1 parent 4f210fc commit 90d5d3f

File tree

5 files changed

+24
-0
lines changed

5 files changed

+24
-0
lines changed

api.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './dist/api'

api.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('./dist/api')

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
}
2828
},
2929
"files": [
30+
"api",
31+
"api.js",
32+
"api.d.ts",
3033
"dist",
3134
"babel.js",
3235
"commitlint.js",

src/api/format.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/** @typedef {import('prettier').Options} Options */
2+
3+
const prettier = require('prettier')
4+
const config = require('../config/prettierrc')
5+
6+
/**
7+
*
8+
* @param {string} source
9+
* @param {Options} options
10+
*
11+
* @returns {string} Formatted source
12+
*/
13+
const format = (source, options) =>
14+
prettier.format(source, {...config, ...options})
15+
16+
module.exports = format

src/api/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
format: require('./format'),
3+
}

0 commit comments

Comments
 (0)