Skip to content

Commit

Permalink
build(parser-adapter-yaml-1-2): use nodenext for TypeScript modules
Browse files Browse the repository at this point in the history
Refs #4385
  • Loading branch information
glowcloud committed Nov 7, 2024
1 parent 47c8c46 commit 8dc9d57
Show file tree
Hide file tree
Showing 37 changed files with 89 additions and 42 deletions.
22 changes: 22 additions & 0 deletions packages/apidom-parser-adapter-yaml-1-2/.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
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"allowImportingTsExtensions": true
},
"include": [
"test/**/*"
]
}
11 changes: 11 additions & 0 deletions packages/apidom-parser-adapter-yaml-1-2/check-types.tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"module": "nodenext",
"moduleResolution": "nodenext",
"allowImportingTsExtensions": true
},
"include": [
"src/**/*"
]
}
2 changes: 1 addition & 1 deletion packages/apidom-parser-adapter-yaml-1-2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"lint": "eslint ./",
"lint:fix": "eslint ./ --fix",
"clean": "rimraf --glob 'src/**/*.mjs' 'src/**/*.cjs' 'test/**/*.mjs' ./dist ./types",
"typescript:check-types": "tsc --noEmit",
"typescript:check-types": "tsc -p check-types.tsconfig.json --noEmit && tsc -p check-types-test.tsconfig.json --noEmit",
"typescript:declaration": "tsc -p declaration.tsconfig.json && rollup -c config/rollup/types.dist.js",
"test": "npm run build:es && cross-env BABEL_ENV=es babel test --out-dir test --extensions '.ts' --out-file-extension '.mjs' --root-mode 'upward' && cross-env NODE_ENV=test mocha",
"perf": "cross-env BABEL_ENV=es babel ./test/perf/index.ts --out-file ./test/perf/index.mjs --root-mode 'upward' && cross-env NODE_ENV=test node ./test/perf/index.mjs",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ParseResultElement } from '@swagger-api/apidom-core';

import lexicalAnalysis from './lexical-analysis/browser';
import syntacticAnalysis from './syntactic-analysis/indirect/index';
import lexicalAnalysis from './lexical-analysis/browser.ts';
import syntacticAnalysis from './syntactic-analysis/indirect/index.ts';

export { mediaTypes, namespace } from './adapter';
export { mediaTypes, namespace } from './adapter.ts';
export { lexicalAnalysis, syntacticAnalysis };

export const detect = async (source: string): Promise<boolean> => {
Expand Down
6 changes: 3 additions & 3 deletions packages/apidom-parser-adapter-yaml-1-2/src/adapter-node.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ParseResultElement } from '@swagger-api/apidom-core';

import lexicalAnalysis from './lexical-analysis/node';
import syntacticAnalysis from './syntactic-analysis/indirect/index';
import lexicalAnalysis from './lexical-analysis/node.ts';
import syntacticAnalysis from './syntactic-analysis/indirect/index.ts';

export { mediaTypes, namespace } from './adapter';
export { mediaTypes, namespace } from './adapter.ts';
export { lexicalAnalysis, syntacticAnalysis };

export const detect = async (source: string): Promise<boolean> => {
Expand Down
2 changes: 1 addition & 1 deletion packages/apidom-parser-adapter-yaml-1-2/src/adapter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createNamespace } from '@swagger-api/apidom-core';

export { default as mediaTypes } from './media-types';
export { default as mediaTypes } from './media-types.ts';

export const namespace = createNamespace();
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import './browser-patch';
import './browser-patch.ts';

import Parser, { Tree } from 'web-tree-sitter';
import { ApiDOMError } from '@swagger-api/apidom-error';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TreeCursor as NodeTreeCursor } from 'tree-sitter';
import { TreeCursor as WebTreeCursor } from 'web-tree-sitter';

import TreeCursorSyntaxNode from './TreeCursorSyntaxNode';
import TreeCursorSyntaxNode from './TreeCursorSyntaxNode.ts';

class TreeCursorIterator {
protected readonly cursor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { Tree as WebTree } from 'web-tree-sitter';
import { ParseResultElement } from '@swagger-api/apidom-core';
import { visit, YamlJsonSchema as JsonSchema, YamlReferenceManager } from '@swagger-api/apidom-ast';

import CstVisitor, { keyMap as cstKeyMap, isNode as isCstNode } from './visitors/CstVisitor';
import CstVisitor, { keyMap as cstKeyMap, isNode as isCstNode } from './visitors/CstVisitor.ts';
import YamlAstVisitor, {
keyMap as astKeyMap,
isNode as isAstNode,
getNodeType as getAstNodeType,
} from './visitors/YamlAstVisitor';
import TreeCursorIterator from '../TreeCursorIterator';
} from './visitors/YamlAstVisitor.ts';
import TreeCursorIterator from '../TreeCursorIterator.ts';

type Tree = WebTree | NodeTree;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
YamlTag,
} from '@swagger-api/apidom-ast';

import TreeCursorSyntaxNode from '../../TreeCursorSyntaxNode';
import TreeCursorSyntaxNode from '../../TreeCursorSyntaxNode.ts';

export const keyMap = {
stream: ['children'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
isStringElement,
} from '@swagger-api/apidom-core';

import * as adapter from '../src/adapter-browser';
import * as adapter from '../src/adapter-browser.ts';

const __dirname = path.dirname(fileURLToPath(import.meta.url));
const spec = fs.readFileSync(path.join(__dirname, 'fixtures', 'sample-data.yaml')).toString();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assert } from 'chai';
import { includesClasses, toValue, SourceMapElement } from '@swagger-api/apidom-core';

import * as adapter from '../../../../../src/adapter-node';
import * as adapter from '../../../../../src/adapter-node.ts';

const setupEmptyElement = async () => {
const yamlSource = '!str &anchor : value';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { assert } from 'chai';
import dedent from 'dedent';
import { includesClasses, toValue, SourceMapElement } from '@swagger-api/apidom-core';

import * as adapter from '../../../../../src/adapter-node';
import * as adapter from '../../../../../src/adapter-node.ts';

const setupMemberElement = async (): Promise<any> => {
const yamlSource = dedent`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assert } from 'chai';
import { includesClasses, toValue, SourceMapElement } from '@swagger-api/apidom-core';

import * as adapter from '../../../../../src/adapter-node';
import * as adapter from '../../../../../src/adapter-node.ts';

const setupMemberElement = async (): Promise<any> => {
const yamlSource = '!str &anchor : !str &anchor';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assert } from 'chai';
import { includesClasses, toValue, SourceMapElement } from '@swagger-api/apidom-core';

import * as adapter from '../../../../../src/adapter-node';
import * as adapter from '../../../../../src/adapter-node.ts';

const setupMemberElement = async (): Promise<any> => {
const yamlSource = ':';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assert } from 'chai';
import { includesClasses, toValue, SourceMapElement } from '@swagger-api/apidom-core';

import * as adapter from '../../../../../src/adapter-node';
import * as adapter from '../../../../../src/adapter-node.ts';

const setupEmptyElement = async () => {
const yamlSource = ': value';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assert } from 'chai';
import { includesClasses, toValue, SourceMapElement } from '@swagger-api/apidom-core';

import * as adapter from '../../../../../src/adapter-node';
import * as adapter from '../../../../../src/adapter-node.ts';

const setupEmptyElement = async () => {
const yamlSource = 'key: !str &anchor';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assert } from 'chai';
import { includesClasses, toValue, SourceMapElement } from '@swagger-api/apidom-core';

import * as adapter from '../../../../../src/adapter-node';
import * as adapter from '../../../../../src/adapter-node.ts';

const setupEmptyElement = async () => {
const yamlSource = 'key:';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assert } from 'chai';
import { includesClasses, toValue, SourceMapElement } from '@swagger-api/apidom-core';

import * as adapter from '../../../../../src/adapter-node';
import * as adapter from '../../../../../src/adapter-node.ts';

const setupEmptyElement = async () => {
const yamlSource = '{!str &anchor : value}';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assert } from 'chai';
import { includesClasses, toValue, SourceMapElement } from '@swagger-api/apidom-core';

import * as adapter from '../../../../../src/adapter-node';
import * as adapter from '../../../../../src/adapter-node.ts';

const setupMemberElement = async (): Promise<any> => {
const yamlSource = '{ key: value, ? }';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assert } from 'chai';
import { includesClasses, toValue, SourceMapElement } from '@swagger-api/apidom-core';

import * as adapter from '../../../../../src/adapter-node';
import * as adapter from '../../../../../src/adapter-node.ts';

const setupMemberElement = async (): Promise<any> => {
const yamlSource = '{!str &anchor : !str &anchor}';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assert } from 'chai';
import { includesClasses, toValue, SourceMapElement } from '@swagger-api/apidom-core';

import * as adapter from '../../../../../src/adapter-node';
import * as adapter from '../../../../../src/adapter-node.ts';

const setupMemberElement = async (): Promise<any> => {
const yamlSource = '{:}';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assert } from 'chai';
import { includesClasses, toValue, SourceMapElement } from '@swagger-api/apidom-core';

import * as adapter from '../../../../../src/adapter-node';
import * as adapter from '../../../../../src/adapter-node.ts';

const setupEmptyElement = async () => {
const yamlSource = '{: value}';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assert } from 'chai';
import { includesClasses, toValue, SourceMapElement } from '@swagger-api/apidom-core';

import * as adapter from '../../../../../src/adapter-node';
import * as adapter from '../../../../../src/adapter-node.ts';

const setupEmptyElement = async () => {
const yamlSource = '{key: !str &anchor}';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assert } from 'chai';
import { includesClasses, toValue, SourceMapElement } from '@swagger-api/apidom-core';

import * as adapter from '../../../../../src/adapter-node';
import * as adapter from '../../../../../src/adapter-node.ts';

const setupEmptyElement = async () => {
const yamlSource = '{key:}';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assert } from 'chai';
import { includesClasses, toValue, SourceMapElement } from '@swagger-api/apidom-core';

import * as adapter from '../../../../../src/adapter-node';
import * as adapter from '../../../../../src/adapter-node.ts';

const setupMemberElement = async (): Promise<any> => {
const yamlSource = '!str &anchor';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assert } from 'chai';
import { includesClasses, toValue, SourceMapElement } from '@swagger-api/apidom-core';

import * as adapter from '../../../../../src/adapter-node';
import * as adapter from '../../../../../src/adapter-node.ts';

const setupEmptyElement = async () => {
const yamlSource = '-';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assert } from 'chai';
import { includesClasses, toValue, SourceMapElement } from '@swagger-api/apidom-core';

import * as adapter from '../../../../../src/adapter-node';
import * as adapter from '../../../../../src/adapter-node.ts';

const setupEmptyElement = async () => {
const yamlSource = '[!string &anchor]';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
isStringElement,
} from '@swagger-api/apidom-core';

import * as adapter from '../../src/adapter-node';
import * as adapter from '../../src/adapter-node.ts';

const __dirname = path.dirname(fileURLToPath(import.meta.url));
const spec = fs.readFileSync(path.join(__dirname, '..', 'fixtures', 'sample-data.yaml')).toString();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assert } from 'chai';
import ApiDOMParser from '@swagger-api/apidom-parser';

import * as jsonAdapter from '../src/adapter-node';
import * as jsonAdapter from '../src/adapter-node.ts';

describe('given adapter is used in parser', function () {
const parser = new ApiDOMParser().use(jsonAdapter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { jestSnapshotPlugin, addSerializer } from 'mocha-chai-jest-snapshot';
import jsdomGlobal from 'jsdom-global';

// @ts-ignore
import * as jestApiDOMSerializer from '../../../scripts/jest-serializer-apidom';
import * as jestApiDOMSerializer from '../../../scripts/jest-serializer-apidom.mjs';
// @ts-ignore
import * as jestStringSerializer from '../../../scripts/jest-serializer-string';
import * as jestStringSerializer from '../../../scripts/jest-serializer-string.mjs';

/**
* Configure snapshot testing.
Expand Down
4 changes: 2 additions & 2 deletions packages/apidom-parser-adapter-yaml-1-2/test/perf/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Benchmark from 'benchmark';
import type { Event } from 'benchmark';

import parseSyntacticAnalysisIndirectBench from './parse-syntactic-analysis-indirect';
import lexicalAnalysisBench from './lexical-analysis';
import parseSyntacticAnalysisIndirectBench from './parse-syntactic-analysis-indirect.ts';
import lexicalAnalysisBench from './lexical-analysis.ts';

const suite = new Benchmark.Suite();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { fileURLToPath } from 'node:url';
import Benchmark from 'benchmark';
import type { Event, Deferred } from 'benchmark';

import analyze from '../../src/lexical-analysis/node';
import analyze from '../../src/lexical-analysis/node.ts';

const __dirname = path.dirname(fileURLToPath(import.meta.url));
const fixturePath = path.join(__dirname, 'fixtures/data.yaml');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { fileURLToPath } from 'node:url';
import Benchmark from 'benchmark';
import type { Event, Deferred } from 'benchmark';

import { parse as parseSyntacticAnalysisIndirect } from '../../src/adapter-node';
import { parse as parseSyntacticAnalysisIndirect } from '../../src/adapter-node.ts';

const __dirname = path.dirname(fileURLToPath(import.meta.url));
const fixturePath = path.join(__dirname, 'fixtures/data.yaml');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from 'chai';

import { lexicalAnalysis } from '../../src/adapter-node';
import TreeCursorIterator from '../../src/syntactic-analysis/TreeCursorIterator';
import { lexicalAnalysis } from '../../src/adapter-node.ts';
import TreeCursorIterator from '../../src/syntactic-analysis/TreeCursorIterator.ts';

describe('syntactic-analysis', function () {
context('TreeCursorIterator', function () {
Expand Down
5 changes: 5 additions & 0 deletions packages/apidom-parser-adapter-yaml-1-2/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"module": "nodenext",
"moduleResolution": "nodenext",
"allowImportingTsExtensions": true
},
"include": [
"src/**/*",
"test/**/*"
Expand Down

0 comments on commit 8dc9d57

Please sign in to comment.