mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2025-12-18 04:06:19 +00:00
refactor: adjust to stricter eslint rules
This commit is contained in:
24
src/cli.ts
24
src/cli.ts
@@ -187,16 +187,16 @@ commander
|
||||
unexpected = unexpected || errorsPerFile[file].some(error => !error.expected);
|
||||
}
|
||||
|
||||
if (typeof relativeReportPath !== 'undefined') {
|
||||
if (relativeReportPath !== undefined) {
|
||||
const reportPath = path.resolve(relativeReportPath);
|
||||
await writeReport(reportPath, errorsPerFile);
|
||||
}
|
||||
|
||||
if (!unexpected) {
|
||||
Logger.ok('Successfully finished validation.');
|
||||
} else {
|
||||
if (unexpected) {
|
||||
await Logger.error('Unexpected errors occurred during validation');
|
||||
process.exit(1);
|
||||
} else {
|
||||
Logger.ok('Successfully finished validation.');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -219,17 +219,17 @@ commander
|
||||
.option('--outputFileName <fileName>', 'Defines the filename of the output')
|
||||
.action(async (relativeSourcePath, plantumlServer, options) => {
|
||||
const plantUmlConfig: UMLConfig = {
|
||||
definitions: typeof options.definitions !== 'undefined' ? options.definitions : [],
|
||||
showAssociations: typeof options.showAssociations !== 'undefined' ? options.showAssociations : false,
|
||||
showEnumValues: typeof options.showEnumValues !== 'undefined' ? options.showEnumValues : false,
|
||||
showInheritance: typeof options.showInheritance !== 'undefined' ? options.showInheritance : false,
|
||||
definitions: options.definitions === undefined ? [] : options.definitions,
|
||||
showAssociations: options.showAssociations === undefined ? false : options.showAssociations,
|
||||
showEnumValues: options.showEnumValues === undefined ? false : options.showEnumValues,
|
||||
showInheritance: options.showInheritance === undefined ? false : options.showInheritance,
|
||||
showInheritedProperties:
|
||||
typeof options.showInheritedProperties !== 'undefined' ? options.showInheritedProperties : false,
|
||||
options.showInheritedProperties === undefined ? false : options.showInheritedProperties,
|
||||
showOptionalProperties:
|
||||
typeof options.showOptionalProperties !== 'undefined' ? options.showOptionalProperties : false,
|
||||
showProperties: typeof options.showProperties !== 'undefined' ? options.showProperties : false,
|
||||
options.showOptionalProperties === undefined ? false : options.showOptionalProperties,
|
||||
showProperties: options.showProperties === undefined ? false : options.showProperties,
|
||||
};
|
||||
if (typeof options.outputFileName !== 'undefined') {
|
||||
if (options.outputFileName !== undefined) {
|
||||
plantUmlConfig.outputFileName = options.outputFileName;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ export function extractComment(node: ts.Node): LightweightComment | undefined {
|
||||
);
|
||||
const comment = jsDocument?.comment?.split('\n\n');
|
||||
|
||||
return typeof jsDocument === 'undefined'
|
||||
return jsDocument === undefined
|
||||
? undefined
|
||||
: cleanupEmpty({
|
||||
shortSummary: first(comment),
|
||||
@@ -109,11 +109,11 @@ export function getModifiers(text: string, kind: string): string[] {
|
||||
|
||||
/** @internal */
|
||||
export function resolvePropertyName(name?: PropertyName): string | undefined {
|
||||
return typeof name !== 'undefined'
|
||||
? isComputedPropertyName(name)
|
||||
? 'UNSUPPORTED_IDENTIFIER_TYPE'
|
||||
: name.getText()
|
||||
: undefined;
|
||||
return name === undefined
|
||||
? undefined
|
||||
: isComputedPropertyName(name)
|
||||
? 'UNSUPPORTED_IDENTIFIER_TYPE'
|
||||
: name.getText();
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
@@ -124,7 +124,7 @@ export function resolveTypeName(type?: TypeNode): string | undefined {
|
||||
|
||||
/** @internal */
|
||||
export function isArrayLikeType(typeNode?: TypeNode): typeNode is ArrayTypeNode | TypeReferenceNode {
|
||||
return typeof typeNode !== 'undefined' && (isArrayTypeNode(typeNode) || isArrayReference(typeNode));
|
||||
return typeNode !== undefined && (isArrayTypeNode(typeNode) || isArrayReference(typeNode));
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
|
||||
@@ -190,9 +190,9 @@ class LightweightDefinitionBuilder {
|
||||
type: this.lightweightTypeAtNode(property),
|
||||
properties: this.collectProperties((property.type as TypeLiteralNode)?.members),
|
||||
optional: isPropertyDeclaration(property)
|
||||
? typeof property.questionToken !== 'undefined'
|
||||
? true
|
||||
: undefined
|
||||
? property.questionToken === undefined
|
||||
? undefined
|
||||
: true
|
||||
: undefined,
|
||||
}),
|
||||
),
|
||||
@@ -220,9 +220,8 @@ class LightweightDefinitionBuilder {
|
||||
|
||||
return out;
|
||||
}
|
||||
const isReference =
|
||||
typeof typeNode !== 'undefined' && isTypeReferenceNode(typeNode) && !isEnumLiteralType(type);
|
||||
const isTypeLiteral = typeof typeNode !== 'undefined' && isTypeLiteralNode(typeNode);
|
||||
const isReference = typeNode !== undefined && isTypeReferenceNode(typeNode) && !isEnumLiteralType(type);
|
||||
const isTypeLiteral = typeNode !== undefined && isTypeLiteralNode(typeNode);
|
||||
// @ts-expect-error intrinsic name & value exist
|
||||
const intrinsicName = (type.intrinsicName ?? type.value) as string | undefined;
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ export class LightweightProjectWithIndex {
|
||||
*/
|
||||
async instantiateDefinitionByName<T>(name: string, findCompiledModule = true): Promise<T | undefined> {
|
||||
const fsPath = this.index[name];
|
||||
if (typeof fsPath === 'undefined') {
|
||||
if (fsPath === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ async function packTypeDefinitions(): Promise<void> {
|
||||
});
|
||||
|
||||
// add list of already imported objects for module
|
||||
if (typeof imports[module] === 'undefined') {
|
||||
if (imports[module] === undefined) {
|
||||
imports[module] = [];
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ async function packJavaScriptFiles(): Promise<void> {
|
||||
|
||||
// replace lines with internal requires
|
||||
if (match !== null) {
|
||||
if (typeof match[6] === 'undefined') {
|
||||
if (match[6] === undefined) {
|
||||
match[6] = match[8];
|
||||
}
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ export async function createDiagramFromString(
|
||||
*/
|
||||
function getReferenceTypes(type: LightweightType): string[] {
|
||||
const types: string[] = [];
|
||||
if (typeof type.referenceName !== 'undefined') {
|
||||
if (type.referenceName !== undefined) {
|
||||
types.push(type.referenceName);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import {SchemaWithDefinitions} from '../types/schema';
|
||||
* Guard for if a JSON schema is in fact a schema with definitions
|
||||
*/
|
||||
export function isSchemaWithDefinitions(schema: JSONSchema): schema is SchemaWithDefinitions {
|
||||
return typeof schema.definitions !== 'undefined';
|
||||
return schema.definitions !== undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -89,7 +89,7 @@ export class Validator {
|
||||
* @param schema Name of schema to validate instance against or the schema itself
|
||||
*/
|
||||
public validate(instance: unknown, schema?: string | Schema): ValidationResult {
|
||||
if (typeof schema === 'undefined') {
|
||||
if (schema === undefined) {
|
||||
if (isThingWithType(instance)) {
|
||||
// schema name can be inferred from type string
|
||||
const schemaSuffix = (instance as {type: string}).type
|
||||
|
||||
Reference in New Issue
Block a user