diff --git a/packages/apidom-converter/.eslintrc b/packages/apidom-converter/.eslintrc new file mode 100644 index 0000000000..86a24bfc5c --- /dev/null +++ b/packages/apidom-converter/.eslintrc @@ -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 + } + ] + } +} diff --git a/packages/apidom-converter/package.json b/packages/apidom-converter/package.json index 2f10edbbb7..042a8386cc 100644 --- a/packages/apidom-converter/package.json +++ b/packages/apidom-converter/package.json @@ -24,8 +24,8 @@ "lint": "eslint ./", "lint:fix": "eslint ./ --fix", "clean": "rimraf --glob 'src/**/*.mjs' 'src/**/*.cjs' 'test/**/*.mjs' ./dist ./types", - "typescript:check-types": "tsc --noEmit", - "typescript:declaration": "tsc -p declaration.tsconfig.json && rollup -c config/rollup/types.dist.js", + "typescript:check-types": "tsc --noEmit && tsc -p ./test/tsconfig.json --noEmit", + "typescript:declaration": "tsc -p tsconfig.declaration.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", "test:update-snapshots": "cross-env UPDATE_SNAPSHOT=1 mocha", "prepack": "copyfiles -u 3 ../../LICENSES/* LICENSES && copyfiles -u 2 ../../NOTICE .", diff --git a/packages/apidom-converter/src/errors/UnmatchedConvertStrategyError.ts b/packages/apidom-converter/src/errors/UnmatchedConvertStrategyError.ts index 42da39de7e..73f914a4cb 100644 --- a/packages/apidom-converter/src/errors/UnmatchedConvertStrategyError.ts +++ b/packages/apidom-converter/src/errors/UnmatchedConvertStrategyError.ts @@ -1,4 +1,4 @@ -import ConvertError from './ConvertError'; +import ConvertError from './ConvertError.ts'; class UnmatchedConvertStrategyError extends ConvertError {} diff --git a/packages/apidom-converter/src/index.ts b/packages/apidom-converter/src/index.ts index 6aca95733d..c3100111ef 100644 --- a/packages/apidom-converter/src/index.ts +++ b/packages/apidom-converter/src/index.ts @@ -1,9 +1,9 @@ import { ParseResultElement } from '@swagger-api/apidom-core'; import { mergeOptions, bundle, File } from '@swagger-api/apidom-reference'; -import defaultOptions, { ConverterOptions } from './options'; -import ConvertError from './errors/ConvertError'; -import UnmatchedConvertStrategyError from './errors/UnmatchedConvertStrategyError'; +import defaultOptions, { ConverterOptions } from './options/index.ts'; +import ConvertError from './errors/ConvertError.ts'; +import UnmatchedConvertStrategyError from './errors/UnmatchedConvertStrategyError.ts'; export { ConvertError, UnmatchedConvertStrategyError }; diff --git a/packages/apidom-converter/src/options/index.ts b/packages/apidom-converter/src/options/index.ts index 1ba7bff4eb..b1d7bce303 100644 --- a/packages/apidom-converter/src/options/index.ts +++ b/packages/apidom-converter/src/options/index.ts @@ -1,7 +1,7 @@ import { options as referenceOptions } from '@swagger-api/apidom-reference'; -import ConvertStrategy from '../strategies/ConvertStrategy'; -import OpenAPI31ToOpenAPI30ConvertStrategy from '../strategies/openapi-3-1-to-openapi-3-0-3'; +import ConvertStrategy from '../strategies/ConvertStrategy.ts'; +import OpenAPI31ToOpenAPI30ConvertStrategy from '../strategies/openapi-3-1-to-openapi-3-0-3/index.ts'; type ReferenceOptions = typeof referenceOptions; diff --git a/packages/apidom-converter/src/strategies/ConvertStrategy.ts b/packages/apidom-converter/src/strategies/ConvertStrategy.ts index cc3f5d062b..15bcf29494 100644 --- a/packages/apidom-converter/src/strategies/ConvertStrategy.ts +++ b/packages/apidom-converter/src/strategies/ConvertStrategy.ts @@ -1,7 +1,7 @@ import { ParseResultElement } from '@swagger-api/apidom-core'; import { File } from '@swagger-api/apidom-reference'; -import type { ConverterOptions } from '../options'; +import type { ConverterOptions } from '../options/index.ts'; export interface ConvertStrategyOptions { readonly name: string; diff --git a/packages/apidom-converter/src/strategies/openapi-3-1-to-openapi-3-0-3/index.ts b/packages/apidom-converter/src/strategies/openapi-3-1-to-openapi-3-0-3/index.ts index 88cc8e988c..55f9ae7995 100644 --- a/packages/apidom-converter/src/strategies/openapi-3-1-to-openapi-3-0-3/index.ts +++ b/packages/apidom-converter/src/strategies/openapi-3-1-to-openapi-3-0-3/index.ts @@ -16,17 +16,17 @@ import { } from '@swagger-api/apidom-core'; import { File } from '@swagger-api/apidom-reference'; -import ConvertStrategy from '../ConvertStrategy'; -import openAPIVersionRefractorPlugin from './refractor-plugins/openapi-version'; -import webhooksRefractorPlugin from './refractor-plugins/webhooks'; -import securitySchemeTypeRefractorPlugin from './refractor-plugins/security-scheme-type'; -import securityRequirementsEmptyRolesRefractorPlugin from './refractor-plugins/security-requirements-empty-roles'; -import type { ConverterOptions } from '../../options'; -import createToolbox from './toolbox'; -import infoSummaryRefractorPlugin from './refractor-plugins/info-summary'; -import licenseIdentifierRefractorPlugin from './refractor-plugins/license-identifier'; -import referenceDescriptionRefractorPlugin from './refractor-plugins/reference-description'; -import referenceSummaryRefractorPlugin from './refractor-plugins/reference-summary'; +import ConvertStrategy from '../ConvertStrategy.ts'; +import openAPIVersionRefractorPlugin from './refractor-plugins/openapi-version.ts'; +import webhooksRefractorPlugin from './refractor-plugins/webhooks.ts'; +import securitySchemeTypeRefractorPlugin from './refractor-plugins/security-scheme-type.ts'; +import securityRequirementsEmptyRolesRefractorPlugin from './refractor-plugins/security-requirements-empty-roles.ts'; +import type { ConverterOptions } from '../../options/index.ts'; +import createToolbox from './toolbox.ts'; +import infoSummaryRefractorPlugin from './refractor-plugins/info-summary.ts'; +import licenseIdentifierRefractorPlugin from './refractor-plugins/license-identifier.ts'; +import referenceDescriptionRefractorPlugin from './refractor-plugins/reference-description.ts'; +import referenceSummaryRefractorPlugin from './refractor-plugins/reference-summary.ts'; const dispatchPluginsAsync = dispatchPlugins[Symbol.for('nodejs.util.promisify.custom')]; diff --git a/packages/apidom-converter/src/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/security-requirements-empty-roles.ts b/packages/apidom-converter/src/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/security-requirements-empty-roles.ts index 6179946c1f..4c08737b1e 100644 --- a/packages/apidom-converter/src/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/security-requirements-empty-roles.ts +++ b/packages/apidom-converter/src/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/security-requirements-empty-roles.ts @@ -7,7 +7,7 @@ import { } from '@swagger-api/apidom-ns-openapi-3-1'; import { AnnotationElement, toValue, isObjectElement, Element } from '@swagger-api/apidom-core'; -import type { Toolbox } from '../toolbox'; +import type { Toolbox } from '../toolbox.ts'; type SecurityRequirementsArrayPluginOptions = { annotations: AnnotationElement[]; diff --git a/packages/apidom-converter/src/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/security-scheme-type.ts b/packages/apidom-converter/src/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/security-scheme-type.ts index 748be986f4..15e37f6bea 100644 --- a/packages/apidom-converter/src/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/security-scheme-type.ts +++ b/packages/apidom-converter/src/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/security-scheme-type.ts @@ -18,7 +18,7 @@ import { } from '@swagger-api/apidom-core'; import { dereferenceApiDOM, ReferenceSet, Reference, url } from '@swagger-api/apidom-reference'; -import type { Toolbox } from '../toolbox'; +import type { Toolbox } from '../toolbox.ts'; type SecuritySchemeTypePluginOptions = { annotations: AnnotationElement[]; diff --git a/packages/apidom-converter/test/index.ts b/packages/apidom-converter/test/index.ts index aa81aee34d..5d67345686 100644 --- a/packages/apidom-converter/test/index.ts +++ b/packages/apidom-converter/test/index.ts @@ -6,7 +6,7 @@ import { mediaTypes as openAPI30MediaTypes } from '@swagger-api/apidom-parser-ad import { mediaTypes as openAPI31MediaTypes } from '@swagger-api/apidom-parser-adapter-openapi-json-3-1'; import { parse } from '@swagger-api/apidom-reference'; -import convert, { convertApiDOM, ConvertError } from '../src'; +import convert, { convertApiDOM, ConvertError } from '../src/index.ts'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); diff --git a/packages/apidom-converter/test/mocha-bootstrap.ts b/packages/apidom-converter/test/mocha-bootstrap.ts index be1b7cffba..c68e716960 100644 --- a/packages/apidom-converter/test/mocha-bootstrap.ts +++ b/packages/apidom-converter/test/mocha-bootstrap.ts @@ -4,9 +4,9 @@ import * as chai from 'chai'; import { jestSnapshotPlugin, addSerializer } from 'mocha-chai-jest-snapshot'; // @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'; chai.use(jestSnapshotPlugin()); addSerializer(jestApiDOMSerializer); diff --git a/packages/apidom-converter/test/strategies/openapi-3-1-to-openapi-3-0-3/index.ts b/packages/apidom-converter/test/strategies/openapi-3-1-to-openapi-3-0-3/index.ts index 06532978e2..2915db70f4 100644 --- a/packages/apidom-converter/test/strategies/openapi-3-1-to-openapi-3-0-3/index.ts +++ b/packages/apidom-converter/test/strategies/openapi-3-1-to-openapi-3-0-3/index.ts @@ -13,7 +13,7 @@ import { import { mediaTypes as openAPI31MediaTypes } from '@swagger-api/apidom-parser-adapter-openapi-json-3-1'; import { mediaTypes as openAPI30MediaTypes } from '@swagger-api/apidom-parser-adapter-openapi-json-3-0'; -import convert from '../../../src'; +import convert from '../../../src/index.ts'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); diff --git a/packages/apidom-converter/test/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/info-summary/index.ts b/packages/apidom-converter/test/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/info-summary/index.ts index a8c863ae0b..81f718f2f8 100644 --- a/packages/apidom-converter/test/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/info-summary/index.ts +++ b/packages/apidom-converter/test/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/info-summary/index.ts @@ -10,7 +10,7 @@ import { includesClasses, } from '@swagger-api/apidom-core'; -import convert from '../../../../../src'; +import convert from '../../../../../src/index.ts'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); diff --git a/packages/apidom-converter/test/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/license-identifier/index.ts b/packages/apidom-converter/test/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/license-identifier/index.ts index 3031e58b74..af93141fc8 100644 --- a/packages/apidom-converter/test/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/license-identifier/index.ts +++ b/packages/apidom-converter/test/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/license-identifier/index.ts @@ -10,7 +10,7 @@ import { includesClasses, } from '@swagger-api/apidom-core'; -import convert from '../../../../../src'; +import convert from '../../../../../src/index.ts'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); diff --git a/packages/apidom-converter/test/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/openapi-version/index.ts b/packages/apidom-converter/test/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/openapi-version/index.ts index 4602c31c3f..81e0d90f30 100644 --- a/packages/apidom-converter/test/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/openapi-version/index.ts +++ b/packages/apidom-converter/test/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/openapi-version/index.ts @@ -5,7 +5,7 @@ import { mediaTypes as openAPI31MediaTypes } from '@swagger-api/apidom-parser-ad import { mediaTypes as openAPI30MediaTypes } from '@swagger-api/apidom-parser-adapter-openapi-json-3-0'; import { toJSON } from '@swagger-api/apidom-core'; -import convert from '../../../../../src'; +import convert from '../../../../../src/index.ts'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); diff --git a/packages/apidom-converter/test/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/reference-description/index.ts b/packages/apidom-converter/test/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/reference-description/index.ts index 7d79597e5a..774481027d 100644 --- a/packages/apidom-converter/test/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/reference-description/index.ts +++ b/packages/apidom-converter/test/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/reference-description/index.ts @@ -10,7 +10,7 @@ import { includesClasses, } from '@swagger-api/apidom-core'; -import convert from '../../../../../src'; +import convert from '../../../../../src/index.ts'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); diff --git a/packages/apidom-converter/test/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/reference-summary/index.ts b/packages/apidom-converter/test/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/reference-summary/index.ts index 605f46dc4a..612f2fef64 100644 --- a/packages/apidom-converter/test/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/reference-summary/index.ts +++ b/packages/apidom-converter/test/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/reference-summary/index.ts @@ -10,7 +10,7 @@ import { includesClasses, } from '@swagger-api/apidom-core'; -import convert from '../../../../../src'; +import convert from '../../../../../src/index.ts'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); diff --git a/packages/apidom-converter/test/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/security-requirements-empty-roles/index.ts b/packages/apidom-converter/test/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/security-requirements-empty-roles/index.ts index 5a58906ab8..2018ee45e8 100644 --- a/packages/apidom-converter/test/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/security-requirements-empty-roles/index.ts +++ b/packages/apidom-converter/test/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/security-requirements-empty-roles/index.ts @@ -5,7 +5,7 @@ import { mediaTypes as openAPI30MediaTypes } from '@swagger-api/apidom-parser-ad import { AnnotationElement, includesClasses, toJSON, toValue } from '@swagger-api/apidom-core'; import { assert, expect } from 'chai'; -import convert from '../../../../../src'; +import convert from '../../../../../src/index.ts'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); diff --git a/packages/apidom-converter/test/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/security-scheme-type/index.ts b/packages/apidom-converter/test/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/security-scheme-type/index.ts index 43002c0dac..e9770c5606 100644 --- a/packages/apidom-converter/test/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/security-scheme-type/index.ts +++ b/packages/apidom-converter/test/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/security-scheme-type/index.ts @@ -5,7 +5,7 @@ import { mediaTypes as openAPI30MediaTypes } from '@swagger-api/apidom-parser-ad import { AnnotationElement, includesClasses, toJSON, toValue } from '@swagger-api/apidom-core'; import { assert, expect } from 'chai'; -import convert from '../../../../../src'; +import convert from '../../../../../src/index.ts'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); diff --git a/packages/apidom-converter/test/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/webhooks/index.ts b/packages/apidom-converter/test/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/webhooks/index.ts index 67309cead1..ed4812f275 100644 --- a/packages/apidom-converter/test/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/webhooks/index.ts +++ b/packages/apidom-converter/test/strategies/openapi-3-1-to-openapi-3-0-3/refractor-plugins/webhooks/index.ts @@ -10,7 +10,7 @@ import { includesClasses, } from '@swagger-api/apidom-core'; -import convert from '../../../../../src'; +import convert from '../../../../../src/index.ts'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); diff --git a/packages/apidom-converter/test/tsconfig.json b/packages/apidom-converter/test/tsconfig.json new file mode 100644 index 0000000000..405aae2d2f --- /dev/null +++ b/packages/apidom-converter/test/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "module": "esnext", + "moduleResolution": "node" + }, + "include": [ + "." + ] +} diff --git a/packages/apidom-converter/declaration.tsconfig.json b/packages/apidom-converter/tsconfig.declaration.json similarity index 82% rename from packages/apidom-converter/declaration.tsconfig.json rename to packages/apidom-converter/tsconfig.declaration.json index 5697fa3e89..82d128fa80 100644 --- a/packages/apidom-converter/declaration.tsconfig.json +++ b/packages/apidom-converter/tsconfig.declaration.json @@ -1,8 +1,5 @@ { "extends": "./tsconfig.json", - "exclude": [ - "test/**/*" - ], "compilerOptions": { "declaration": true, "declarationDir": "types", diff --git a/packages/apidom-converter/tsconfig.json b/packages/apidom-converter/tsconfig.json index 4081635a03..501a41d3f2 100644 --- a/packages/apidom-converter/tsconfig.json +++ b/packages/apidom-converter/tsconfig.json @@ -1,7 +1,11 @@ { "extends": "../../tsconfig.json", + "compilerOptions": { + "module": "nodenext", + "moduleResolution": "nodenext", + "allowImportingTsExtensions": true + }, "include": [ - "src/**/*", - "test/**/*" + "src/**/*" ] }