Skip to content

Commit e5bb5ce

Browse files
authored
chore: update @ionic/prettier-config (#32)
1 parent edc8cdb commit e5bb5ce

13 files changed

+150
-273
lines changed

package-lock.json

+13-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
},
4242
"devDependencies": {
4343
"@capacitor/cli": "^3.0.1",
44-
"@ionic/prettier-config": "^1.0.1",
44+
"@ionic/prettier-config": "^2.0.0",
4545
"@stencil/core": "^2.6.0",
4646
"@types/github-slugger": "^1.3.0",
4747
"@types/jest": "^26.0.23",

src/cli.ts

+4-8
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,13 @@ export async function run(config: { cwd: string; args: string[] }) {
2424

2525
try {
2626
if (!args.api) {
27-
throw new Error(
28-
`Please provide the primary interface name using the "--api" arg`,
29-
);
27+
throw new Error(`Please provide the primary interface name using the "--api" arg`);
3028
}
3129

3230
const tsconfigPath = getTsconfigPath(config.cwd, args.project);
3331
if (!tsconfigPath) {
3432
throw new Error(
35-
`Unable to find project's tsconfig.json file. Use the "--project" arg to specify the exact path.`,
33+
`Unable to find project's tsconfig.json file. Use the "--project" arg to specify the exact path.`
3634
);
3735
}
3836

@@ -42,9 +40,7 @@ export async function run(config: { cwd: string; args: string[] }) {
4240
};
4341

4442
if (!args['output-json'] && !args['output-readme']) {
45-
throw new Error(
46-
`Please provide an output path with either "--output-readme" or "--output-json" args, or both.`,
47-
);
43+
throw new Error(`Please provide an output path with either "--output-readme" or "--output-json" args, or both.`);
4844
}
4945

5046
if (args['output-json']) {
@@ -74,7 +70,7 @@ function getTsconfigPath(cwd: string, cliTsConfigPath: string) {
7470
if (cliTsConfigPath) {
7571
return normalizePath(cwd, cliTsConfigPath);
7672
}
77-
return ts.findConfigFile(cwd, f => fs.existsSync(f));
73+
return ts.findConfigFile(cwd, (f) => fs.existsSync(f));
7874
}
7975

8076
function logOutput(outputPath: string | undefined) {

src/formatting.ts

+6-13
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,7 @@ export function formatType(data: DocsData, c: string | undefined) {
1515
tokens.shift();
1616
} else {
1717
for (let i = tokens.length - 1; i >= 0; i--) {
18-
if (
19-
tokens[i] === 'undefined' &&
20-
tokens[i - 1] === ' ' &&
21-
tokens[i - 2] === '|' &&
22-
tokens[i - 3] === ' '
23-
) {
18+
if (tokens[i] === 'undefined' && tokens[i - 1] === ' ' && tokens[i - 2] === '|' && tokens[i - 3] === ' ') {
2419
tokens.splice(i - 3, 4);
2520
i = i - 4;
2621
}
@@ -92,25 +87,23 @@ export function formatMethodSignatureForSlug(m: DocsInterfaceMethod) {
9287

9388
function linkToken(data: DocsData, token: string) {
9489
const t = token.replace(/`/g, '');
95-
const i = data.interfaces.find(i => {
90+
const i = data.interfaces.find((i) => {
9691
return (
9792
i.name === t ||
98-
i.methods.some(m => i.name + '.' + m.name === t) ||
99-
i.properties.some(p => i.name + '.' + p.name === t)
93+
i.methods.some((m) => i.name + '.' + m.name === t) ||
94+
i.properties.some((p) => i.name + '.' + p.name === t)
10095
);
10196
});
10297
if (i) {
10398
return `<a href="#${i.slug}">${token}</a>`;
10499
}
105100

106-
const ta = data.typeAliases.find(ta => ta.name === t);
101+
const ta = data.typeAliases.find((ta) => ta.name === t);
107102
if (ta) {
108103
return `<a href="#${ta.slug}">${token}</a>`;
109104
}
110105

111-
const e = data.enums.find(
112-
e => e.name === t || e.members.some(m => e.name + '.' + m.name === t),
113-
);
106+
const e = data.enums.find((e) => e.name === t || e.members.some((m) => e.name + '.' + m.name === t));
114107
if (e) {
115108
return `<a href="#${e.slug}">${token}</a>`;
116109
}

src/index.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
export { generate } from './generate';
2-
export {
3-
outputJson,
4-
outputReadme,
5-
replaceMarkdownPlaceholders,
6-
} from './output';
2+
export { outputJson, outputReadme, replaceMarkdownPlaceholders } from './output';
73
export { parse } from './parse';
84
export { run } from './cli';
95
export * from './types';

src/markdown.ts

+11-15
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export class MarkdownTable {
88
addRow(data: string[], isHeader = false) {
99
const colData: ColumnData[] = [];
1010

11-
data.forEach(text => {
11+
data.forEach((text) => {
1212
const col: ColumnData = {
1313
text: escapeMarkdownTableColumn(text),
1414
width: text.length,
@@ -36,11 +36,7 @@ export class MarkdownTable {
3636
const row = this.rows[r];
3737
if (row && !row.isHeader) {
3838
const column = row.columns[c];
39-
if (
40-
column &&
41-
typeof column.text === 'string' &&
42-
column.text.trim().length > 0
43-
) {
39+
if (column && typeof column.text === 'string' && column.text.trim().length > 0) {
4440
isEmptyColumn = false;
4541
break;
4642
}
@@ -80,15 +76,15 @@ const createTable = (rows: RowData[]) => {
8076
normalizeColumCount(rows);
8177
normalizeColumnWidth(rows);
8278

83-
const th = rows.find(r => r.isHeader);
79+
const th = rows.find((r) => r.isHeader);
8480
if (th) {
8581
const headerRow = createRow(th);
8682
content.push(headerRow);
8783
content.push(createBorder(th));
8884
}
8985

90-
const tds = rows.filter(r => !r.isHeader);
91-
tds.forEach(td => {
86+
const tds = rows.filter((r) => !r.isHeader);
87+
tds.forEach((td) => {
9288
content.push(createRow(td));
9389
});
9490

@@ -101,7 +97,7 @@ const createBorder = (th: RowData) => {
10197
isHeader: false,
10298
};
10399

104-
th.columns.forEach(c => {
100+
th.columns.forEach((c) => {
105101
const borderCol: ColumnData = {
106102
text: '',
107103
width: c.width,
@@ -118,7 +114,7 @@ const createBorder = (th: RowData) => {
118114
const createRow = (row: RowData) => {
119115
const content: string[] = ['| '];
120116

121-
row.columns.forEach(c => {
117+
row.columns.forEach((c) => {
122118
content.push(c.text);
123119
content.push(' | ');
124120
});
@@ -129,13 +125,13 @@ const createRow = (row: RowData) => {
129125
const normalizeColumCount = (rows: RowData[]) => {
130126
let columnCount = 0;
131127

132-
rows.forEach(r => {
128+
rows.forEach((r) => {
133129
if (r.columns.length > columnCount) {
134130
columnCount = r.columns.length;
135131
}
136132
});
137133

138-
rows.forEach(r => {
134+
rows.forEach((r) => {
139135
while (r.columns.length < columnCount) {
140136
r.columns.push({
141137
text: ``,
@@ -151,14 +147,14 @@ const normalizeColumnWidth = (rows: RowData[]) => {
151147
for (let columnIndex = 0; columnIndex < columnCount; columnIndex++) {
152148
let longestText = 0;
153149

154-
rows.forEach(r => {
150+
rows.forEach((r) => {
155151
const col = r.columns[columnIndex];
156152
if (col.text.length > longestText) {
157153
longestText = col.text.length;
158154
}
159155
});
160156

161-
rows.forEach(r => {
157+
rows.forEach((r) => {
162158
const col = r.columns[columnIndex];
163159
col.width = longestText;
164160
while (col.text.length < longestText) {

0 commit comments

Comments
 (0)