Skip to content

Commit

Permalink
Make undefined checks more explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
georg-schwarz committed Jan 17, 2024
1 parent 492e876 commit 5c479d9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ function checkHasPipeline(
context: ValidationContext,
): void {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (blockType.pipes?.length === 0) {
if (blockType.pipes === undefined) {
return;
}

if (blockType.pipes.length === 0) {
context.accept(
'error',
`Composite blocktypes must define one pipeline '${blockType.name}'`,
Expand All @@ -48,7 +52,11 @@ function checkExactlyOnePipeline(
context: ValidationContext,
): void {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (blockType.pipes?.length > 1) {
if (blockType.pipes === undefined) {
return;
}

if (blockType.pipes.length > 1) {
blockType.pipes.forEach((pipe) => {
context.accept(
'error',
Expand Down Expand Up @@ -87,7 +95,7 @@ function doCheckDefinedBlockIsUsed(
context: ValidationContext,
): void {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!BlockTypeWrapper.canBeWrapped(block?.type)) {
if (block.type === undefined || !BlockTypeWrapper.canBeWrapped(block.type)) {
return;
}
const pipes = pipelineWrapper.astNode.pipes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ function doCheckDefinedBlockIsUsed(
context: ValidationContext,
): void {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!BlockTypeWrapper.canBeWrapped(block?.type)) {
if (block.type === undefined || !BlockTypeWrapper.canBeWrapped(block.type)) {
return;
}
const blockType = new BlockTypeWrapper(block.type);
Expand Down

0 comments on commit 5c479d9

Please sign in to comment.