Skip to content

Commit

Permalink
build(ast): use nodenext for TypeScript modules
Browse files Browse the repository at this point in the history
Refs #4385
  • Loading branch information
glowcloud committed Nov 5, 2024
1 parent da406b3 commit 58bbb7c
Show file tree
Hide file tree
Showing 52 changed files with 211 additions and 184 deletions.
22 changes: 22 additions & 0 deletions packages/apidom-ast/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"settings": {
"import/resolver": {
"typescript": {
"project": ["./tsconfig.json"]
}
}
},
"rules": {
"import/extensions": [
"error",
"always",
{
"ts": "always",
"tsx": "always",
"js": "always",
"jsx": "never",
"ignorePackages": true
}
]
}
}
4 changes: 2 additions & 2 deletions packages/apidom-ast/src/Error.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Node from './Node';
import type { NodeOptions } from './Node';
import Node from './Node.ts';
import type { NodeOptions } from './Node.ts';

export interface ErrorOptions extends NodeOptions {
readonly value?: unknown;
Expand Down
4 changes: 2 additions & 2 deletions packages/apidom-ast/src/Literal.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Node from './Node';
import type { NodeOptions } from './Node';
import Node from './Node.ts';
import type { NodeOptions } from './Node.ts';

export interface LiteralOptions extends NodeOptions {
readonly value?: unknown;
Expand Down
2 changes: 1 addition & 1 deletion packages/apidom-ast/src/Node.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Position from './Position';
import Position from './Position.ts';

export interface NodeOptions {
readonly children?: unknown[];
Expand Down
2 changes: 1 addition & 1 deletion packages/apidom-ast/src/ParseResult.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { head } from 'ramda';

import Node from './Node';
import Node from './Node.ts';

class ParseResult extends Node {
public static readonly type: string = 'parseResult';
Expand Down
90 changes: 45 additions & 45 deletions packages/apidom-ast/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// JSON AST related exports
export { default as JsonNode } from './json/nodes/JsonNode';
export { default as JsonDocument } from './json/nodes/JsonDocument';
export { default as JsonObject } from './json/nodes/JsonObject';
export { default as JsonProperty } from './json/nodes/JsonProperty';
export { default as JsonArray } from './json/nodes/JsonArray';
export { default as JsonValue } from './json/nodes/JsonValue';
export { default as JsonKey } from './json/nodes/JsonKey';
export { default as JsonString } from './json/nodes/JsonString';
export { default as JsonStringContent } from './json/nodes/JsonStringContent';
export { default as JsonEscapeSequence } from './json/nodes/JsonEscapeSequence';
export { default as JsonNumber } from './json/nodes/JsonNumber';
export { default as JsonTrue } from './json/nodes/JsonTrue';
export { default as JsonFalse } from './json/nodes/JsonFalse';
export { default as JsonNull } from './json/nodes/JsonNull';
export { default as JsonNode } from './json/nodes/JsonNode.ts';
export { default as JsonDocument } from './json/nodes/JsonDocument.ts';
export { default as JsonObject } from './json/nodes/JsonObject.ts';
export { default as JsonProperty } from './json/nodes/JsonProperty.ts';
export { default as JsonArray } from './json/nodes/JsonArray.ts';
export { default as JsonValue } from './json/nodes/JsonValue.ts';
export { default as JsonKey } from './json/nodes/JsonKey.ts';
export { default as JsonString } from './json/nodes/JsonString.ts';
export { default as JsonStringContent } from './json/nodes/JsonStringContent.ts';
export { default as JsonEscapeSequence } from './json/nodes/JsonEscapeSequence.ts';
export { default as JsonNumber } from './json/nodes/JsonNumber.ts';
export { default as JsonTrue } from './json/nodes/JsonTrue.ts';
export { default as JsonFalse } from './json/nodes/JsonFalse.ts';
export { default as JsonNull } from './json/nodes/JsonNull.ts';
export {
isDocument as isJsonDocument,
isFalse as isJsonFalse,
Expand All @@ -26,25 +26,25 @@ export {
isObject as isJsonObject,
isString as isJsonString,
isTrue as isJsonTrue,
} from './json/nodes/predicates';
} from './json/nodes/predicates.ts';
// YAML AST related exports
export { default as YamlAlias } from './yaml/nodes/YamlAlias';
export { default as YamlCollection } from './yaml/nodes/YamlCollection';
export { default as YamlComment } from './yaml/nodes/YamlComment';
export { default as YamlDirective } from './yaml/nodes/YamlDirective';
export { default as YamlDocument } from './yaml/nodes/YamlDocument';
export { default as YamlKeyValuePair } from './yaml/nodes/YamlKeyValuePair';
export { default as YamlMapping } from './yaml/nodes/YamlMapping';
export { default as YamlNode } from './yaml/nodes/YamlNode';
export { default as YamlScalar } from './yaml/nodes/YamlScalar';
export { default as YamlSequence } from './yaml/nodes/YamlSequence';
export { default as YamlStream } from './yaml/nodes/YamlStream';
export { default as YamlTag, YamlNodeKind } from './yaml/nodes/YamlTag';
export { default as YamlAnchor } from './yaml/nodes/YamlAnchor';
export { YamlStyle, YamlStyleGroup } from './yaml/nodes/YamlStyle';
export { default as YamlFailsafeSchema } from './yaml/schemas/failsafe/index';
export { default as YamlJsonSchema } from './yaml/schemas/json/index';
export { default as YamlReferenceManager } from './yaml/anchors-aliases/ReferenceManager';
export { default as YamlAlias } from './yaml/nodes/YamlAlias.ts';
export { default as YamlCollection } from './yaml/nodes/YamlCollection.ts';
export { default as YamlComment } from './yaml/nodes/YamlComment.ts';
export { default as YamlDirective } from './yaml/nodes/YamlDirective.ts';
export { default as YamlDocument } from './yaml/nodes/YamlDocument.ts';
export { default as YamlKeyValuePair } from './yaml/nodes/YamlKeyValuePair.ts';
export { default as YamlMapping } from './yaml/nodes/YamlMapping.ts';
export { default as YamlNode } from './yaml/nodes/YamlNode.ts';
export { default as YamlScalar } from './yaml/nodes/YamlScalar.ts';
export { default as YamlSequence } from './yaml/nodes/YamlSequence.ts';
export { default as YamlStream } from './yaml/nodes/YamlStream.ts';
export { default as YamlTag, YamlNodeKind } from './yaml/nodes/YamlTag.ts';
export { default as YamlAnchor } from './yaml/nodes/YamlAnchor.ts';
export { YamlStyle, YamlStyleGroup } from './yaml/nodes/YamlStyle.ts';
export { default as YamlFailsafeSchema } from './yaml/schemas/failsafe/index.ts';
export { default as YamlJsonSchema } from './yaml/schemas/json/index.ts';
export { default as YamlReferenceManager } from './yaml/anchors-aliases/ReferenceManager.ts';
export {
isAlias as isYamlAlias,
isAnchor as isYamlAnchor,
Expand All @@ -57,18 +57,18 @@ export {
isSequence as isYamlSequence,
isStream as isYamlStream,
isTag as isYamlTag,
} from './yaml/nodes/predicates';
export { default as YamlError } from './yaml/errors/YamlError';
export { default as YamlReferenceError } from './yaml/errors/YamlReferenceError';
export { default as YamlSchemaError } from './yaml/errors/YamlSchemaError';
export { default as YamlTagError } from './yaml/errors/YamlTagError';
export type { YamlTagErrorOptions } from './yaml/errors/YamlTagError';
} from './yaml/nodes/predicates.ts';
export { default as YamlError } from './yaml/errors/YamlError.ts';
export { default as YamlReferenceError } from './yaml/errors/YamlReferenceError.ts';
export { default as YamlSchemaError } from './yaml/errors/YamlSchemaError.ts';
export { default as YamlTagError } from './yaml/errors/YamlTagError.ts';
export type { YamlTagErrorOptions } from './yaml/errors/YamlTagError.ts';
// generic AST related exports
export { default as Literal } from './Literal';
export { Point, default as Position } from './Position';
export { default as Error } from './Error';
export { default as ParseResult } from './ParseResult';
export { isParseResult, isLiteral, isPoint, isPosition } from './predicates';
export { default as Literal } from './Literal.ts';
export { Point, default as Position } from './Position.ts';
export { default as Error } from './Error.ts';
export { default as ParseResult } from './ParseResult.ts';
export { isParseResult, isLiteral, isPoint, isPosition } from './predicates.ts';
// AST traversal related exports
export {
BREAK,
Expand All @@ -78,5 +78,5 @@ export {
getNodeType,
isNode,
cloneNode,
} from './traversal/visitor';
export type { MergeAllSync, MergeAllAsync } from './traversal/visitor';
} from './traversal/visitor.ts';
export type { MergeAllSync, MergeAllAsync } from './traversal/visitor.ts';
4 changes: 2 additions & 2 deletions packages/apidom-ast/src/json/nodes/JsonArray.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import JsonNode from './JsonNode';
import { isFalse, isTrue, isNull, isNumber, isString, isArray, isObject } from './predicates';
import JsonNode from './JsonNode.ts';
import { isFalse, isTrue, isNull, isNumber, isString, isArray, isObject } from './predicates.ts';

class JsonArray extends JsonNode {
public static readonly type = 'array';
Expand Down
2 changes: 1 addition & 1 deletion packages/apidom-ast/src/json/nodes/JsonDocument.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { head } from 'ramda';

import JsonNode from './JsonNode';
import JsonNode from './JsonNode.ts';

class JsonDocument extends JsonNode {
public static readonly type = 'document';
Expand Down
2 changes: 1 addition & 1 deletion packages/apidom-ast/src/json/nodes/JsonEscapeSequence.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import JsonValue from './JsonValue';
import JsonValue from './JsonValue.ts';

class JsonEscapeSequence extends JsonValue {
public static readonly type = 'escapeSequence';
Expand Down
2 changes: 1 addition & 1 deletion packages/apidom-ast/src/json/nodes/JsonFalse.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import JsonValue from './JsonValue';
import JsonValue from './JsonValue.ts';

class JsonFalse extends JsonValue {
public static readonly type = 'false';
Expand Down
2 changes: 1 addition & 1 deletion packages/apidom-ast/src/json/nodes/JsonKey.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import JsonString from './JsonString';
import JsonString from './JsonString.ts';

class JsonKey extends JsonString {
public static readonly type = 'key';
Expand Down
2 changes: 1 addition & 1 deletion packages/apidom-ast/src/json/nodes/JsonNode.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Node from '../../Node';
import Node from '../../Node.ts';

class JsonNode extends Node {}

Expand Down
2 changes: 1 addition & 1 deletion packages/apidom-ast/src/json/nodes/JsonNull.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import JsonValue from './JsonValue';
import JsonValue from './JsonValue.ts';

class JsonNull extends JsonValue {
public static readonly type = 'null';
Expand Down
2 changes: 1 addition & 1 deletion packages/apidom-ast/src/json/nodes/JsonNumber.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import JsonValue from './JsonValue';
import JsonValue from './JsonValue.ts';

class JsonNumber extends JsonValue {
public static readonly type = 'number';
Expand Down
6 changes: 3 additions & 3 deletions packages/apidom-ast/src/json/nodes/JsonObject.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import JsonNode from './JsonNode';
import { isProperty } from './predicates';
import type JsonProperty from './JsonProperty';
import JsonNode from './JsonNode.ts';
import { isProperty } from './predicates.ts';
import type JsonProperty from './JsonProperty.ts';

class JsonObject extends JsonNode {
public static readonly type = 'object';
Expand Down
20 changes: 10 additions & 10 deletions packages/apidom-ast/src/json/nodes/JsonProperty.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import JsonNode from './JsonNode';
import JsonKey from './JsonKey';
import JsonNode from './JsonNode.ts';
import JsonKey from './JsonKey.ts';
import {
isArray,
isFalse,
Expand All @@ -9,14 +9,14 @@ import {
isObject,
isString,
isTrue,
} from './predicates';
import type JsonString from './JsonString';
import type JsonFalse from './JsonFalse';
import type JsonTrue from './JsonTrue';
import type JsonNull from './JsonNull';
import type JsonNumber from './JsonNumber';
import type JsonArray from './JsonArray';
import type JsonObject from './JsonObject';
} from './predicates.ts';
import type JsonString from './JsonString.ts';
import type JsonFalse from './JsonFalse.ts';
import type JsonTrue from './JsonTrue.ts';
import type JsonNull from './JsonNull.ts';
import type JsonNumber from './JsonNumber.ts';
import type JsonArray from './JsonArray.ts';
import type JsonObject from './JsonObject.ts';

type JsonValue = JsonFalse | JsonTrue | JsonNull | JsonNumber | JsonString | JsonArray | JsonObject;

Expand Down
8 changes: 4 additions & 4 deletions packages/apidom-ast/src/json/nodes/JsonString.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import JsonNode from './JsonNode';
import JsonStringContent from './JsonStringContent';
import JsonEscapeSequence from './JsonEscapeSequence';
import { isEscapeSequence, isStringContent } from './predicates';
import JsonNode from './JsonNode.ts';
import JsonStringContent from './JsonStringContent.ts';
import JsonEscapeSequence from './JsonEscapeSequence.ts';
import { isEscapeSequence, isStringContent } from './predicates.ts';

type JsonStringLike = JsonStringContent | JsonEscapeSequence;

Expand Down
2 changes: 1 addition & 1 deletion packages/apidom-ast/src/json/nodes/JsonStringContent.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import JsonValue from './JsonValue';
import JsonValue from './JsonValue.ts';

class JsonStringContent extends JsonValue {
public static readonly type = 'stringContent';
Expand Down
2 changes: 1 addition & 1 deletion packages/apidom-ast/src/json/nodes/JsonTrue.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import JsonValue from './JsonValue';
import JsonValue from './JsonValue.ts';

class JsonTrue extends JsonValue {
public static readonly type = 'true';
Expand Down
4 changes: 2 additions & 2 deletions packages/apidom-ast/src/json/nodes/JsonValue.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import JsonNode from './JsonNode';
import type { NodeOptions } from '../../Node';
import JsonNode from './JsonNode.ts';
import type { NodeOptions } from '../../Node.ts';

export interface JsonValueOptions extends NodeOptions {
value: string;
Expand Down
26 changes: 13 additions & 13 deletions packages/apidom-ast/src/json/nodes/predicates.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { isNodeType } from '../../predicates';
import type JsonDocument from './JsonDocument';
import type JsonString from './JsonString';
import type JsonFalse from './JsonFalse';
import type JsonTrue from './JsonTrue';
import type JsonNull from './JsonNull';
import type JsonNumber from './JsonNumber';
import type JsonArray from './JsonArray';
import type JsonObject from './JsonObject';
import type JsonStringContent from './JsonStringContent';
import type JsonEscapeSequence from './JsonEscapeSequence';
import type JsonProperty from './JsonProperty';
import type JsonKey from './JsonKey';
import { isNodeType } from '../../predicates.ts';
import type JsonDocument from './JsonDocument.ts';
import type JsonString from './JsonString.ts';
import type JsonFalse from './JsonFalse.ts';
import type JsonTrue from './JsonTrue.ts';
import type JsonNull from './JsonNull.ts';
import type JsonNumber from './JsonNumber.ts';
import type JsonArray from './JsonArray.ts';
import type JsonObject from './JsonObject.ts';
import type JsonStringContent from './JsonStringContent.ts';
import type JsonEscapeSequence from './JsonEscapeSequence.ts';
import type JsonProperty from './JsonProperty.ts';
import type JsonKey from './JsonKey.ts';

export const isDocument = (node: unknown): node is JsonDocument => isNodeType('document', node);

Expand Down
6 changes: 3 additions & 3 deletions packages/apidom-ast/src/predicates.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type Literal from './Literal';
import Position, { Point } from './Position';
import ParseResult from './ParseResult';
import type Literal from './Literal.ts';
import Position, { Point } from './Position.ts';
import ParseResult from './ParseResult.ts';

export const isNodeType = (type: string, node: unknown): boolean =>
node != null && typeof node === 'object' && 'type' in node && node.type === type;
Expand Down
12 changes: 6 additions & 6 deletions packages/apidom-ast/src/yaml/anchors-aliases/ReferenceManager.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import YamlAlias from '../nodes/YamlAlias';
import YamlNode from '../nodes/YamlNode';
import YamlScalar from '../nodes/YamlScalar';
import YamlReferenceError from '../errors/YamlReferenceError';
import { isAnchor } from '../nodes/predicates';
import { YamlStyle, YamlStyleGroup } from '../nodes/YamlStyle';
import YamlAlias from '../nodes/YamlAlias.ts';
import YamlNode from '../nodes/YamlNode.ts';
import YamlScalar from '../nodes/YamlScalar.ts';
import YamlReferenceError from '../errors/YamlReferenceError.ts';
import { isAnchor } from '../nodes/predicates.ts';
import { YamlStyle, YamlStyleGroup } from '../nodes/YamlStyle.ts';

/* eslint-disable class-methods-use-this */
class ReferenceManager {
Expand Down
2 changes: 1 addition & 1 deletion packages/apidom-ast/src/yaml/errors/YamlReferenceError.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import YamlError from './YamlError';
import YamlError from './YamlError.ts';

class YamlReferenceError extends YamlError {}

Expand Down
2 changes: 1 addition & 1 deletion packages/apidom-ast/src/yaml/errors/YamlSchemaError.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import YamlError from './YamlError';
import YamlError from './YamlError.ts';

class YamlSchemaError extends YamlError {}

Expand Down
6 changes: 3 additions & 3 deletions packages/apidom-ast/src/yaml/errors/YamlTagError.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { ApiDOMErrorOptions } from '@swagger-api/apidom-error';

import YamlSchemaError from './YamlSchemaError';
import Position from '../../Position';
import Node from '../../Node';
import YamlSchemaError from './YamlSchemaError.ts';
import Position from '../../Position.ts';
import Node from '../../Node.ts';

export interface YamlTagErrorOptions<T extends Node = Node> extends ApiDOMErrorOptions {
readonly specificTagName: string;
Expand Down
4 changes: 2 additions & 2 deletions packages/apidom-ast/src/yaml/nodes/YamlAlias.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Node from '../../Node';
import type { NodeOptions } from '../../Node';
import Node from '../../Node.ts';
import type { NodeOptions } from '../../Node.ts';

export interface YamlAliasOptions extends NodeOptions {
readonly content: string;
Expand Down
4 changes: 2 additions & 2 deletions packages/apidom-ast/src/yaml/nodes/YamlAnchor.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Node from '../../Node';
import type { NodeOptions } from '../../Node';
import Node from '../../Node.ts';
import type { NodeOptions } from '../../Node.ts';

export interface YamlAnchorOptions extends NodeOptions {
readonly name: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/apidom-ast/src/yaml/nodes/YamlCollection.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import YamlNode from './YamlNode';
import YamlNode from './YamlNode.ts';

class YamlCollection extends YamlNode {}

Expand Down
Loading

0 comments on commit 58bbb7c

Please sign in to comment.