Skip to content

Commit edc8cdb

Browse files
authored
chore: Include prettier scripts (#31)
1 parent b40a7c8 commit edc8cdb

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

package.json

+7-4
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,17 @@
1616
"main": "dist/index.js",
1717
"types": "dist/index.d.ts",
1818
"scripts": {
19-
"clean": "rimraf -rf dist",
2019
"build": "npm run clean && tsc",
21-
"watch": "tsc -w",
20+
"clean": "rimraf -rf dist",
21+
"fmt": "npm run prettier -- --write",
22+
"lint": "npm run prettier -- --check",
23+
"prettier": "prettier \"**/*.ts\"",
2224
"release": "np --no-2fa",
23-
"version": "npm run build",
2425
"test": "jest",
2526
"test.watch": "jest --watchAll",
26-
"test.output": "node bin/docgen --project src/test/fixtures/tsconfig.json --api HapticsPlugin --output-readme src/test/README.md --output-json src/test/docs.json"
27+
"test.output": "node bin/docgen --project src/test/fixtures/tsconfig.json --api HapticsPlugin --output-readme src/test/README.md --output-json src/test/docs.json",
28+
"version": "npm run build",
29+
"watch": "tsc -w"
2730
},
2831
"license": "MIT",
2932
"files": [

src/parse.ts

+12-7
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,20 @@ export function parse(opts: DocsParseOptions) {
5151
* Add methods of import(many is used in `extends`)
5252
*/
5353
const allImportObject = interfaces
54-
.filter(i => apiInterface?.importObject.includes(i.name) && i.name !== api)
54+
.filter(
55+
i => apiInterface?.importObject.includes(i.name) && i.name !== api,
56+
)
5557
.map(i => i.importObject);
5658

57-
const otherMethod = interfaces
58-
.filter(i => [...new Set(allImportObject.flat())].includes(i.name))
59-
.map(d => d.methods)|| null;
59+
const otherMethod =
60+
interfaces
61+
.filter(i => [...new Set(allImportObject.flat())].includes(i.name))
62+
.map(d => d.methods) || null;
6063

6164
if (apiInterface !== null && otherMethod && otherMethod.length > 0) {
62-
apiInterface.methods = [...new Set(apiInterface?.methods.concat(otherMethod.flat(1)))];
65+
apiInterface.methods = [
66+
...new Set(apiInterface?.methods.concat(otherMethod.flat(1))),
67+
];
6368
}
6469

6570
const data: DocsData = {
@@ -189,7 +194,7 @@ function getInterface(
189194
const docs = symbol ? serializeSymbol(typeChecker, symbol) : null;
190195

191196
// @ts-ignore
192-
const importObject = node.parent?.locals?.keys() || []
197+
const importObject = node.parent?.locals?.keys() || [];
193198

194199
const i: DocsInterface = {
195200
name: interfaceName,
@@ -198,7 +203,7 @@ function getInterface(
198203
tags: docs?.tags || [],
199204
methods,
200205
properties,
201-
importObject: [...importObject].filter((d: string) => d !== interfaceName)
206+
importObject: [...importObject].filter((d: string) => d !== interfaceName),
202207
};
203208

204209
return i;

src/test/parse.spec.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ describe('parse', () => {
66
tsconfigPath: path.join(__dirname, 'fixtures', 'tsconfig.json'),
77
});
88

9-
const { api, interfaces, enums, typeAliases, pluginConfigs } = apiFinder(
10-
'HapticsPlugin',
11-
);
9+
const { api, interfaces, enums, typeAliases, pluginConfigs } =
10+
apiFinder('HapticsPlugin');
1211

1312
it('api', () => {
1413
expect(api.name).toBe(`HapticsPlugin`);

0 commit comments

Comments
 (0)