Lint the workflow parser package
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import {TemplateSchema} from ".";
|
||||
import {DEFINITION, BOOLEAN} from "../template-constants";
|
||||
import {MappingToken, LiteralToken} from "../tokens";
|
||||
import {TokenType} from "../tokens/types";
|
||||
@@ -40,5 +39,7 @@ export class BooleanDefinition extends ScalarDefinition {
|
||||
return literal.templateTokenType === TokenType.Boolean;
|
||||
}
|
||||
|
||||
public override validate(schema: TemplateSchema, name: string): void {}
|
||||
public override validate(): void {
|
||||
// no-op
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import {TemplateSchema} from "./template-schema";
|
||||
import {DEFINITION, NULL} from "../template-constants";
|
||||
import {MappingToken, LiteralToken} from "../tokens";
|
||||
import {DefinitionType} from "./definition-type";
|
||||
@@ -40,5 +39,7 @@ export class NullDefinition extends ScalarDefinition {
|
||||
return literal.templateTokenType === TokenType.Null;
|
||||
}
|
||||
|
||||
public override validate(schema: TemplateSchema, name: string): void {}
|
||||
public override validate(): void {
|
||||
// no-op
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import {TemplateSchema} from "./template-schema";
|
||||
import {DEFINITION, NUMBER} from "../template-constants";
|
||||
import {MappingToken, LiteralToken} from "../tokens";
|
||||
import {DefinitionType} from "./definition-type";
|
||||
@@ -40,5 +39,7 @@ export class NumberDefinition extends ScalarDefinition {
|
||||
return literal.templateTokenType === TokenType.Number;
|
||||
}
|
||||
|
||||
public override validate(schema: TemplateSchema, name: string): void {}
|
||||
public override validate(): void {
|
||||
// no-op
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ import {LiteralToken, MappingToken, StringToken} from "../tokens";
|
||||
import {TokenType} from "../tokens/types";
|
||||
import {DefinitionType} from "./definition-type";
|
||||
import {ScalarDefinition} from "./scalar-definition";
|
||||
import {TemplateSchema} from "./template-schema";
|
||||
|
||||
export class StringDefinition extends ScalarDefinition {
|
||||
public constant = "";
|
||||
@@ -80,7 +79,7 @@ export class StringDefinition extends ScalarDefinition {
|
||||
return false;
|
||||
}
|
||||
|
||||
public override validate(schema: TemplateSchema, name: string): void {
|
||||
public override validate(): void {
|
||||
if (this.constant && this.requireNonEmpty) {
|
||||
throw new Error(`Properties '${CONSTANT}' and '${REQUIRE_NON_EMPTY}' cannot both be set`);
|
||||
}
|
||||
|
||||
@@ -324,6 +324,7 @@ export class TemplateSchema {
|
||||
const template = readTemplate(context, TEMPLATE_SCHEMA, objectReader, undefined);
|
||||
context.errors.check();
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const mapping = template!.assertMapping(TEMPLATE_SCHEMA);
|
||||
const schema = new TemplateSchema(mapping);
|
||||
schema.validate();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-unnecessary-type-assertion */
|
||||
import {nullTrace} from "../../test-utils/null-trace";
|
||||
import {parseWorkflow} from "../../workflows/workflow-parser";
|
||||
import {StringToken} from "./string-token";
|
||||
@@ -20,13 +21,13 @@ describe("traverse", () => {
|
||||
expect(traverser.next()!.value).toEqual([undefined, root, undefined]);
|
||||
|
||||
// On
|
||||
const onResult = traverser.next()!.value!;
|
||||
const onResult = traverser.next().value!;
|
||||
expect(onResult[0]).toBe(root);
|
||||
expect(getValue(onResult[1])).toEqual("on");
|
||||
expect(onResult[2]).toBeUndefined();
|
||||
|
||||
// Push
|
||||
const pushResult = traverser.next()!.value!;
|
||||
const pushResult = traverser.next().value!;
|
||||
expect(pushResult[0]).toBe(root);
|
||||
expect(getValue(pushResult[1])).toEqual("push");
|
||||
expect(getValue(pushResult[2])).toEqual("on");
|
||||
|
||||
Reference in New Issue
Block a user