Skip to content

Commit

Permalink
style: eslint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
schoero committed Jun 19, 2024
1 parent 77950ea commit 1808da5
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 101 deletions.
2 changes: 1 addition & 1 deletion src/compiler/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function reportCompilerDiagnostics(ctx: DefaultContext, diagnostics: read

diagnostics.filter(
diagnostic => diagnostic.category === ts.DiagnosticCategory.Error ||
diagnostic.category === ts.DiagnosticCategory.Warning
diagnostic.category === ts.DiagnosticCategory.Warning
).forEach(diagnostic => {

const color = diagnostic.category === ts.DiagnosticCategory.Error
Expand Down
14 changes: 7 additions & 7 deletions src/interpreter/ast/entities/source-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ export const createSourceFileEntity = (ctx: InterpreterContext, symbol: Symbol):
const exports = ctx.checker.getExportsOfModule(symbol)
.reduce<ExportableEntity[]>((parsedSymbols, exportedSymbol) => {

const parsedSymbol = interpretSymbol(ctx, exportedSymbol);
const parsedSymbol = interpretSymbol(ctx, exportedSymbol);

// Don't document unresolved entities
if(isExportableEntity(parsedSymbol)){
parsedSymbols.push(parsedSymbol);
}
// don't document unresolved entities
if(isExportableEntity(parsedSymbol)){
parsedSymbols.push(parsedSymbol);
}

return parsedSymbols;
return parsedSymbols;

}, []);
}, []);

const symbolId = getSymbolId(ctx, symbol);
const path = declaration.getSourceFile().fileName;
Expand Down
6 changes: 3 additions & 3 deletions src/interpreter/typeguards/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ export function isFunctionLikeType(ctx: InterpreterContext, type: Type): boolean
const { ts } = ctx.dependencies;
return isObjectType(ctx, type) &&
type.getCallSignatures().length > 0 &&
type.getConstructSignatures().length === 0 &&
type.getProperties().length === 0;
type.getConstructSignatures().length === 0 &&
type.getProperties().length === 0;
}

export function isGenericType(ctx: InterpreterContext, type: Type): type is GenericType {
Expand All @@ -114,7 +114,7 @@ export function isInstanceType(ctx: InterpreterContext, type: Type): type is Typ
const { ts } = ctx.dependencies;
return isObjectType(ctx, type) && (type.objectFlags & ts.ObjectFlags.Reference) !== 0 &&
((type.objectFlags & ts.ObjectFlags.Instantiated) !== 0 ||
(type.objectFlags & ts.ObjectFlags.InstantiationExpressionType) !== 0);
(type.objectFlags & ts.ObjectFlags.InstantiationExpressionType) !== 0);
}

export function isInterfaceType(ctx: InterpreterContext, type: Type): type is InterfaceType {
Expand Down
38 changes: 19 additions & 19 deletions src/renderer/markup/html/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,31 +140,31 @@ const htmlRenderer: HTMLRenderer = {
}, [])
.reduce<RenderOutput>((files, convertedSourceFileEntity) => {

// Reset context
ctx.nesting = 1;
ctx.indentation = 0;
// reset context
ctx.nesting = 1;
ctx.indentation = 0;

setCurrentSourceFile(ctx, convertedSourceFileEntity);
setCurrentSourceFile(ctx, convertedSourceFileEntity);

const tableOfContents = renderConfig.renderTableOfContents &&
createSectionNode("table-of-contents", convertedSourceFileEntity.tableOfContents);
const documentation = createSectionNode("documentation", ...convertedSourceFileEntity.documentation);
const tableOfContents = renderConfig.renderTableOfContents &&
createSectionNode("table-of-contents", convertedSourceFileEntity.tableOfContents);
const documentation = createSectionNode("documentation", ...convertedSourceFileEntity.documentation);

const ast = createTitleNode(
convertedSourceFileEntity.title,
convertedSourceFileEntity.titleAnchor,
tableOfContents,
documentation
);
const ast = createTitleNode(
convertedSourceFileEntity.title,
convertedSourceFileEntity.titleAnchor,
tableOfContents,
documentation
);

const renderedNewLine = renderNewLine(ctx);
const renderedContent = renderNode(ctx, ast);
const filePath = ctx.currentFile.dst;
const renderedNewLine = renderNewLine(ctx);
const renderedContent = renderNode(ctx, ast);
const filePath = ctx.currentFile.dst;

files[filePath] = `${renderedContent}${renderedNewLine}`;
return files;
files[filePath] = `${renderedContent}${renderedNewLine}`;
return files;

}, {});
}, {});

})

Expand Down
50 changes: 25 additions & 25 deletions src/renderer/markup/markdown/ast/multiline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,37 @@ export function renderMultilineArray(ctx: MarkdownRenderContext, children: ASTNo
.filter(child => child !== "")
.reduce<string[]>((acc, child) => {

const renderedNode = renderNode(ctx, child);

if(renderedNode === ""){
return acc;
}

// Remove empty line for sibling list nodes
// const renderedNodeWithoutSiblingEmptyLine = isListNode(child) &&
// index !== 0 && children[index - 1] &&
// isListNode(children[index - 1]) &&
// renderedNode.startsWith(renderedEmptyLine + renderedNewLine)
// ? renderedNode.slice(renderedEmptyLine.length)
// : renderedNode;

// Remove empty line if previously rendered node ends with an empty line and the current node starts with an empty line
const renderedNodeWithoutDoubleEmptyLines = acc.at(-1)?.endsWith(renderedNewLine + renderedEmptyLine) &&
startsWithEmptyLine(ctx, renderedNode)
? renderedNode.slice((renderedEmptyLine + renderedNewLine).length)
: renderedNode;

// Render indentation for all children except empty lines
const renderedNodeWithIndentation =
const renderedNode = renderNode(ctx, child);

if(renderedNode === ""){
return acc;
}

// remove empty line for sibling list nodes
// const renderedNodeWithoutSiblingEmptyLine = isListNode(child) &&
// index !== 0 && children[index - 1] &&
// isListNode(children[index - 1]) &&
// renderedNode.startsWith(renderedEmptyLine + renderedNewLine)
// ? renderedNode.slice(renderedEmptyLine.length)
// : renderedNode;

// Remove empty line if previously rendered node ends with an empty line and the current node starts with an empty line
const renderedNodeWithoutDoubleEmptyLines = acc.at(-1)?.endsWith(renderedNewLine + renderedEmptyLine) &&
startsWithEmptyLine(ctx, renderedNode)
? renderedNode.slice((renderedEmptyLine + renderedNewLine).length)
: renderedNode;

// render indentation for all children except empty lines
const renderedNodeWithIndentation =
startsWithEmptyLine(ctx, renderedNodeWithoutDoubleEmptyLines)
? renderedNodeWithoutDoubleEmptyLines
: renderWithIndentation(ctx, renderedNodeWithoutDoubleEmptyLines);

acc.push(renderedNodeWithIndentation);
acc.push(renderedNodeWithIndentation);

return acc;
return acc;

}, []);
}, []);

const joinedReturnValue = returnValue.join(renderedNewLine);

Expand Down
48 changes: 24 additions & 24 deletions src/renderer/markup/markdown/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,39 +148,39 @@ const markdownRenderer: MarkdownRenderer = {
}, [])
.reduce<RenderOutput>((files, convertedSourceFileEntity) => {

// Reset context
ctx.nesting = 1;
ctx.indentation = 0;
// reset context
ctx.nesting = 1;
ctx.indentation = 0;

setCurrentSourceFile(ctx, convertedSourceFileEntity);
setCurrentSourceFile(ctx, convertedSourceFileEntity);

const tableOfContents = renderConfig.renderTableOfContents &&
createSectionNode("table-of-contents", convertedSourceFileEntity.tableOfContents);
const documentation = createSectionNode("documentation", ...convertedSourceFileEntity.documentation);
const tableOfContents = renderConfig.renderTableOfContents &&
createSectionNode("table-of-contents", convertedSourceFileEntity.tableOfContents);
const documentation = createSectionNode("documentation", ...convertedSourceFileEntity.documentation);

const ast = createTitleNode(
convertedSourceFileEntity.title,
convertedSourceFileEntity.titleAnchor,
tableOfContents,
documentation
);
const ast = createTitleNode(
convertedSourceFileEntity.title,
convertedSourceFileEntity.titleAnchor,
tableOfContents,
documentation
);

const renderedContent = renderNode(ctx, ast);
const renderedContent = renderNode(ctx, ast);

const renderedContendWithoutTrailingEmptyLines = renderedContent.endsWith(renderedNewLine + renderedEmptyLine)
? renderedContent.slice(0, -(renderedNewLine.length + renderedEmptyLine.length))
: renderedContent;
const renderedContendWithoutTrailingEmptyLines = renderedContent.endsWith(renderedNewLine + renderedEmptyLine)
? renderedContent.slice(0, -(renderedNewLine.length + renderedEmptyLine.length))
: renderedContent;

const renderedContentWithTrailingNewLine = renderedContendWithoutTrailingEmptyLines.endsWith(renderedNewLine)
? renderedContendWithoutTrailingEmptyLines
: `${renderedContendWithoutTrailingEmptyLines}${renderedNewLine}`;
const renderedContentWithTrailingNewLine = renderedContendWithoutTrailingEmptyLines.endsWith(renderedNewLine)
? renderedContendWithoutTrailingEmptyLines
: `${renderedContendWithoutTrailingEmptyLines}${renderedNewLine}`;

const filePath = ctx.currentFile.dst;
const filePath = ctx.currentFile.dst;

files[filePath] = renderedContentWithTrailingNewLine;
return files;
files[filePath] = renderedContentWithTrailingNewLine;
return files;

}, {});
}, {});

})

Expand Down
14 changes: 7 additions & 7 deletions src/renderer/markup/utils/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ export function spaceBetween(...nodes: ASTNode[]) {
return nodes
.filter(node => !!node)
.reduce<ASTNode[]>((acc, node, index) => {
if(index > 0){
acc.push(" ", node);
} else {
acc.push(node);
}
return acc;
}, []);
if(index > 0){
acc.push(" ", node);
} else {
acc.push(node);
}
return acc;
}, []);
}
24 changes: 12 additions & 12 deletions src/utils/exclude.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@ export function isExcluded(path: string, name: string = "*", excludedPaths: Inte
const excludedFromName = normalizedExcludedNames
.reduce<boolean | undefined>((excludedFromPreviousName, excludedName) => {

const nameIsInverted = (excludedName.match(/^!+/) ?? [""])[0].length % 2 !== 0;
const nameWithoutInverts = excludedName.replace(/^!+/, "");

if(nameWithoutInverts === "*"){
return true;
} else if(nameWithoutInverts === name){
return !nameIsInverted;
} else {
return excludedFromPreviousName;
}

}, undefined);
const nameIsInverted = (excludedName.match(/^!+/) ?? [""])[0].length % 2 !== 0;
const nameWithoutInverts = excludedName.replace(/^!+/, "");

if(nameWithoutInverts === "*"){
return true;
} else if(nameWithoutInverts === name){
return !nameIsInverted;
} else {
return excludedFromPreviousName;
}

}, undefined);

if(excludedFromName === undefined){
return excludedFromPreviousFile;
Expand Down
6 changes: 3 additions & 3 deletions src/utils/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export function sortKeys(_: string, value: any) {
return Object.keys(value)
.sort()
.reduce<{ [key: string]: any; }>((sorted, key) => {
sorted[key] = value[key];
return sorted;
}, {});
sorted[key] = value[key];
return sorted;
}, {});

}

0 comments on commit 1808da5

Please sign in to comment.