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