Skip to content

Commit

Permalink
chore: lint code
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Jul 28, 2023
1 parent 5250851 commit 347c312
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 16 deletions.
25 changes: 14 additions & 11 deletions src/loader/babel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ function clumpLines(lines: string[], delimiters = [" "], separator = " ") {
while (lines.length > 0) {
const line = lines.shift();
if (
(line && !delimiters.includes(line[0]) && clumps[clumps.length - 1]) ||
containsIncompleteCodeblock(clumps[clumps.length - 1])
(line && !delimiters.includes(line[0]) && clumps.at(-1)) ||
containsIncompleteCodeblock(clumps.at(-1))
) {
clumps[clumps.length - 1] += separator + line;
} else {
Expand Down Expand Up @@ -259,15 +259,18 @@ function parseJSDocs(input: string | string[]): Schema {
if (firstTag >= 0) {
const tags = clumpLines(lines.slice(firstTag), ["@"], "\n");
// eslint-disable-next-line unicorn/no-array-reduce
const typedefs = tags.reduce((typedefs, tag) => {
const { typedef, alias } =
tag.match(/@typedef\s+{(?<typedef>[\S\s]+)} (?<alias>.*)/)?.groups ||
{};
if (typedef && alias) {
typedefs[typedef] = alias;
}
return typedefs;
}, {} as Record<string, string>);
const typedefs = tags.reduce(
(typedefs, tag) => {
const { typedef, alias } =
tag.match(/@typedef\s+{(?<typedef>[\S\s]+)} (?<alias>.*)/)?.groups ||
{};
if (typedef && alias) {
typedefs[typedef] = alias;
}
return typedefs;
},
{} as Record<string, string>
);
for (const tag of tags) {
if (tag.startsWith("@type")) {
const type = tag.match(/@type\s+{([\S\s]+)}/)?.[1];
Expand Down
2 changes: 1 addition & 1 deletion src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ async function _resolveSchema(
const schema: Schema = {
type: getType(input),
id: schemaId,
default: !ctx.ignoreDefaults ? safeInput : undefined,
default: ctx.ignoreDefaults ? undefined : safeInput,
};

normalizeSchema(schema, { ignoreDefaults: ctx.ignoreDefaults });
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,6 @@ export function getTypeDescriptor(type: string | JSType): TypeDescriptor {
return {
...(isJSType(type) ? { type } : {}),
tsType: type,
...(markdownType !== type ? { markdownType } : {}),
...(markdownType === type ? {} : { markdownType }),
};
}
18 changes: 15 additions & 3 deletions web/components/markdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,26 @@ export default defineComponent({

<style>
.markdown {
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial,
sans-serif, Apple Color Emoji, Segoe UI Emoji !important;
font-family:
-apple-system,
BlinkMacSystemFont,
Segoe UI,
Helvetica,
Arial,
sans-serif,
Apple Color Emoji,
Segoe UI Emoji !important;
color: #24292e !important;
word-wrap: break-word;
}
.markdown code {
font-family: SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
font-family:
SFMono-Regular,
Consolas,
Liberation Mono,
Menlo,
monospace;
padding: 0.2em 0.4em;
font-size: 85%;
background-color: #f6f8fa;
Expand Down

0 comments on commit 347c312

Please sign in to comment.