Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default tseslint.config(
"simple-import-sort": eslintPluginSimpleImportSort,
},
rules: {
"object-shorthand": "error",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-explicit-any": "off",
Expand Down
8 changes: 4 additions & 4 deletions src/factories/alias.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { type Alias, type Content, type Position } from "../types.js";
import { createCommentAttachable } from "./comment-attachable.js";
import { createNode } from "./node.js";

export function createAlias(
position: Position,
content: Content,
value: string,
): Alias {
return {
...createNode("alias", position),
...createCommentAttachable(),
type: "alias",
position,
leadingComments: [],
trailingComment: null,
...content,
value,
};
Expand Down
4 changes: 2 additions & 2 deletions src/factories/anchor.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { type Anchor, type Position } from "../types.js";
import { createNode } from "./node.js";

export function createAnchor(position: Position, value: string): Anchor {
return {
...createNode("anchor", position),
type: "anchor",
position,
value,
};
}
7 changes: 3 additions & 4 deletions src/factories/block-value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import {
type Content,
type Position,
} from "../types.ts";
import { createLeadingCommentAttachable } from "./leading-comment-attachable.ts";
import { createNode } from "./node.ts";

export function createBlockValue(
position: Position,
Expand All @@ -16,8 +14,9 @@ export function createBlockValue(
indicatorComment: null | Comment,
): BlockValue {
return {
...createNode("blockValue", position),
...createLeadingCommentAttachable(),
type: "blockValue",
position,
leadingComments: [],
...content,
chomping,
indent,
Expand Down
10 changes: 0 additions & 10 deletions src/factories/comment-attachable.ts

This file was deleted.

9 changes: 0 additions & 9 deletions src/factories/comment.ts

This file was deleted.

8 changes: 4 additions & 4 deletions src/factories/directive.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { type Directive, type Position } from "../types.ts";
import { createCommentAttachable } from "./comment-attachable.ts";
import { createNode } from "./node.ts";

export function createDirective(
position: Position,
name: string,
parameters: string[],
): Directive {
return {
...createNode("directive", position),
...createCommentAttachable(),
type: "directive",
position,
leadingComments: [],
trailingComment: null,
name,
parameters,
};
Expand Down
7 changes: 3 additions & 4 deletions src/factories/document-body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@ import {
type DocumentBody,
type Position,
} from "../types.ts";
import { createEndCommentAttachable } from "./end-comment-attachable.ts";
import { createNode } from "./node.ts";

export function createDocumentBody(
position: Position,
content: null | ContentNode,
endComments: Comment[],
): DocumentBody {
return {
...createNode("documentBody", position),
...createEndCommentAttachable(endComments),
type: "documentBody",
position,
endComments,
children: !content ? [] : [content],
};
}
10 changes: 4 additions & 6 deletions src/factories/document-head.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import {
type DocumentHead,
type Position,
} from "../types.ts";
import { createEndCommentAttachable } from "./end-comment-attachable.ts";
import { createNode } from "./node.ts";
import { createTrailingCommentAttachable } from "./trailing-comment-attachable.ts";

export function createDocumentHead(
position: Position,
Expand All @@ -15,9 +12,10 @@ export function createDocumentHead(
trailingComment: null | Comment,
): DocumentHead {
return {
...createNode("documentHead", position),
...createEndCommentAttachable(endComments),
...createTrailingCommentAttachable(trailingComment),
type: "documentHead",
position,
endComments,
trailingComment,
children,
};
}
7 changes: 3 additions & 4 deletions src/factories/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import {
type DocumentHead,
type Position,
} from "../types.ts";
import { createNode } from "./node.ts";
import { createTrailingCommentAttachable } from "./trailing-comment-attachable.ts";

export function createDocument(
position: Position,
Expand All @@ -17,8 +15,9 @@ export function createDocument(
trailingComment: null | Comment,
): Document {
return {
...createNode("document", position),
...createTrailingCommentAttachable(trailingComment),
type: "document",
position,
trailingComment,
directivesEndMarker,
documentEndMarker,
children: [head, body],
Expand Down
9 changes: 0 additions & 9 deletions src/factories/end-comment-attachable.ts

This file was deleted.

12 changes: 6 additions & 6 deletions src/factories/flow-collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ import {
type FlowSequenceItem,
type Position,
} from "../types.ts";
import { createCommentAttachable } from "./comment-attachable.ts";
import { createEndCommentAttachable } from "./end-comment-attachable.ts";
import { createNode } from "./node.ts";

export function createFlowCollection<
T extends FlowMappingItem | FlowSequenceItem,
>(position: Position, content: Content, children: T[]) {
return {
...createNode("flowCollection", position),
...createCommentAttachable(),
...createEndCommentAttachable(),
type: "flowCollection",
position,

leadingComments: [],
trailingComment: null,
endComments: [],
...content,
children,
};
Expand Down
7 changes: 3 additions & 4 deletions src/factories/flow-mapping-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@ import {
type MappingValue,
type Position,
} from "../types.ts";
import { createLeadingCommentAttachable } from "./leading-comment-attachable.ts";
import { createNode } from "./node.ts";

export function createFlowMappingItem(
position: Position,
key: MappingKey,
value: MappingValue,
): FlowMappingItem {
return {
...createNode("flowMappingItem", position),
...createLeadingCommentAttachable(),
type: "flowMappingItem",
position,
leadingComments: [],
children: [key, value],
};
}
4 changes: 2 additions & 2 deletions src/factories/flow-sequence-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import {
type FlowSequenceItem,
type Position,
} from "../types.ts";
import { createNode } from "./node.ts";

export function createFlowSequenceItem(
position: Position,
content: ContentNode,
): FlowSequenceItem {
return {
...createNode("flowSequenceItem", position),
type: "flowSequenceItem",
position,
children: [content],
};
}
7 changes: 0 additions & 7 deletions src/factories/leading-comment-attachable.ts

This file was deleted.

7 changes: 3 additions & 4 deletions src/factories/mapping-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@ import {
type MappingValue,
type Position,
} from "../types.ts";
import { createLeadingCommentAttachable } from "./leading-comment-attachable.ts";
import { createNode } from "./node.ts";

export function createMappingItem(
position: Position,
key: MappingKey,
value: MappingValue,
): MappingItem {
return {
...createNode("mappingItem", position),
...createLeadingCommentAttachable(),
type: "mappingItem",
position,
leadingComments: [],
children: [key, value],
};
}
10 changes: 4 additions & 6 deletions src/factories/mapping-key.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { type ContentNode, type MappingKey, type Position } from "../types.ts";
import { createEndCommentAttachable } from "./end-comment-attachable.ts";
import { createNode } from "./node.ts";
import { createTrailingCommentAttachable } from "./trailing-comment-attachable.ts";

export function createMappingKey(
position: Position,
content: null | ContentNode,
): MappingKey {
return {
...createNode("mappingKey", position),
...createTrailingCommentAttachable(),
...createEndCommentAttachable(),
type: "mappingKey",
position,
trailingComment: null,
endComments: [],
children: !content ? [] : [content],
};
}
12 changes: 6 additions & 6 deletions src/factories/mapping-value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import {
type MappingValue,
type Position,
} from "../types.ts";
import { createCommentAttachable } from "./comment-attachable.ts";
import { createEndCommentAttachable } from "./end-comment-attachable.ts";
import { createNode } from "./node.ts";

export function createMappingValue(
position: Position,
content: null | ContentNode,
): MappingValue {
return {
...createNode("mappingValue", position),
...createCommentAttachable(),
...createEndCommentAttachable(),
type: "mappingValue",
position,

leadingComments: [],
trailingComment: null,
endComments: [],
children: !content ? [] : [content],
};
}
7 changes: 3 additions & 4 deletions src/factories/mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@ import {
type MappingItem,
type Position,
} from "../types.ts";
import { createLeadingCommentAttachable } from "./leading-comment-attachable.ts";
import { createNode } from "./node.ts";

export function createMapping(
position: Position,
content: Content,
children: MappingItem[],
): Mapping {
return {
...createNode("mapping", position),
...createLeadingCommentAttachable(),
type: "mapping",
position,
leadingComments: [],
...content,
children,
};
Expand Down
5 changes: 0 additions & 5 deletions src/factories/node.ts

This file was deleted.

8 changes: 4 additions & 4 deletions src/factories/plain.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { type Content, type Plain, type Position } from "../types.ts";
import { createCommentAttachable } from "./comment-attachable.ts";
import { createNode } from "./node.ts";

export function createPlain(
position: Position,
content: Content,
value: string,
): Plain {
return {
...createNode("plain", position),
...createCommentAttachable(),
type: "plain",
position,
leadingComments: [],
trailingComment: null,
...content,
value,
};
Expand Down
8 changes: 4 additions & 4 deletions src/factories/quote-value.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { type Content, type Position, type QuoteValue } from "../types.ts";
import { createCommentAttachable } from "./comment-attachable.ts";
import { createNode } from "./node.ts";

export function createQuoteValue(
position: Position,
content: Content,
value: string,
): QuoteValue {
return {
...createNode("quoteValue", position),
type: "quoteValue",
position,
...content,
...createCommentAttachable(),
leadingComments: [],
trailingComment: null,
value,
};
}
Loading
Loading