diff --git a/__tests__/commands.test.ts b/__tests__/commands.test.ts index ad83820ea..38b1557f0 100644 --- a/__tests__/commands.test.ts +++ b/__tests__/commands.test.ts @@ -1,16 +1,16 @@ -import { readdirSync, statSync, existsSync } from 'fs'; +import { readdirSync, statSync, existsSync } from 'node:fs'; import { join, relative } from 'path'; -//@ts-ignore -import { toMatchSpecificSnapshot } from './specific-snapshot'; +// @ts-ignore +import { toMatchSpecificSnapshot } from './specific-snapshot.cjs'; import { getCommandOutput, getEntrypoints, callSerializer, getParams, cleanupOutput, -} from './helpers'; -import * as fs from 'fs'; -import { spawnSync } from 'child_process'; +} from './helpers.js'; +import * as fs from 'node:fs'; +import { spawnSync } from 'node:child_process'; expect.extend({ toMatchExtendedSpecificSnapshot(received, snapshotFile) { diff --git a/__tests__/helpers.ts b/__tests__/helpers.ts index 0de06c5cd..6e3bd69b7 100644 --- a/__tests__/helpers.ts +++ b/__tests__/helpers.ts @@ -1,8 +1,8 @@ import { readFileSync } from 'fs'; import { join } from 'path'; -import { parseYaml } from '../packages/core/src/utils'; // not able to import from @redocly/openapi-core -//@ts-ignore -import { addSerializer } from './specific-snapshot'; +import { parseYaml } from '../packages/core/src/utils.js'; // not able to import from @redocly/openapi-core +// @ts-ignore +import { addSerializer } from './specific-snapshot.cjs'; import { spawnSync } from 'child_process'; type CLICommands = @@ -61,3 +61,59 @@ export function cleanupOutput(message: string) { const cwdRegexp = new RegExp(process.cwd(), 'g'); return message.replace(cwdRegexp, '.'); } + +// --------------------------------------------- + +// const { readFileSync } = require('fs'); +// const { join } = require('path'); +// import { parseYaml } from '../packages/core/src/utils.js'; // not able to import from @redocly/openapi-core +// import { addSerializer } from './specific-snapshot.cjs'; +// import { spawnSync } from 'child_process'; + +// function getParams(indexEntryPoint, command, args) { +// return ['--transpile-only', indexEntryPoint, command, ...args]; +// } + +// function getEntrypoints(folderPath) { +// const redoclyYamlFile = readFileSync(join(folderPath, 'redocly.yaml'), 'utf8'); +// const redoclyYaml = parseYaml(redoclyYamlFile); +// return Object.keys(redoclyYaml.apis); +// } + +// function getCommandOutput(params, folderPath) { +// const result = spawnSync('ts-node', params, { +// cwd: folderPath, +// env: { +// ...process.env, +// NODE_ENV: 'test', +// NO_COLOR: 'TRUE', +// }, +// }); +// const out = result.stdout.toString('utf-8'); +// const err = result.stderr.toString('utf-8'); +// return `${out}\n${err}`; +// } + +// function cleanUpVersion(str) { +// return str.replace(/"version":\s(\".*\")*/g, '"version": ""'); +// } + +// function callSerializer() { +// addSerializer({ +// test: (val) => typeof val === 'string', +// print: (v) => cleanUpVersion(v), +// }); +// } + +// function cleanupOutput(message) { +// const cwdRegexp = new RegExp(process.cwd(), 'g'); +// return message.replace(cwdRegexp, '.'); +// } + +// module.exports = { +// getParams, +// getEntrypoints, +// getCommandOutput, +// callSerializer, +// cleanupOutput, +// }; diff --git a/__tests__/specific-snapshot.js b/__tests__/specific-snapshot.cjs similarity index 100% rename from __tests__/specific-snapshot.js rename to __tests__/specific-snapshot.cjs diff --git a/__tests__/webpack-bundle.test.ts b/__tests__/webpack-bundle.test.ts index ea11508df..b65a7eba2 100644 --- a/__tests__/webpack-bundle.test.ts +++ b/__tests__/webpack-bundle.test.ts @@ -1,8 +1,8 @@ import { readFileSync } from 'fs'; import { join } from 'path'; -import { getCommandOutput, getEntrypoints, callSerializer, getParams } from './helpers'; -//@ts-ignore -import { toMatchSpecificSnapshot, addSerializer } from './specific-snapshot'; +import { getCommandOutput, getEntrypoints, callSerializer, getParams } from './helpers.js'; +// @ts-ignore +import { toMatchSpecificSnapshot, addSerializer } from './specific-snapshot.cjs'; expect.extend({ toMatchExtendedSpecificSnapshot(received, snapshotFile) { diff --git a/jest.config.js b/jest.config.ts similarity index 67% rename from jest.config.js rename to jest.config.ts index bd4408430..e6d886af3 100644 --- a/jest.config.js +++ b/jest.config.ts @@ -1,7 +1,10 @@ -module.exports = { +import type { JestConfigWithTsJest } from 'ts-jest'; + +const jestConfig: JestConfigWithTsJest = { clearMocks: true, restoreMocks: true, - preset: 'ts-jest', + preset: 'ts-jest/presets/default-esm', + extensionsToTreatAsEsm: ['.ts'], testEnvironment: 'node', collectCoverageFrom: [ 'packages/*/src/**/*.ts', @@ -23,11 +26,14 @@ module.exports = { functions: 60, lines: 60, }, - }, - testMatch: ['**/__tests__/**/*.test.ts', '**/*.test.ts'], - globals: { - 'ts-jest': { - diagnostics: false, + global: { + statements: 70, + branches: 70, + functions: 70, + lines: 70, }, }, + testMatch: ['**/__tests__/**/*.test.ts', '**/*.test.ts'], }; + +export default jestConfig; diff --git a/package-lock.json b/package-lock.json index bcc0a357d..d141249a9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36,8 +36,8 @@ "webpack-cli": "^4.10.0" }, "engines": { - "node": ">=15.0.0", - "npm": ">=7.0.0" + "node": ">=18", + "npm": ">=10" } }, "node_modules/@ampproject/remapping": { @@ -13791,8 +13791,8 @@ "typescript": "5.5.3" }, "engines": { - "node": ">=14.19.0", - "npm": ">=7.0.0" + "node": ">=18", + "npm": ">=10" } }, "packages/cli/node_modules/form-data": { @@ -13837,8 +13837,8 @@ "typescript": "5.5.3" }, "engines": { - "node": ">=14.19.0", - "npm": ">=7.0.0" + "node": ">=18", + "npm": ">=10" } }, "packages/core/node_modules/agent-base": { diff --git a/package.json b/package.json index 8d71944b1..21b30b6fe 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,12 @@ { "name": "@redocly/cli", "version": "1.0.0", + "type": "module", "description": "", "private": true, "engines": { - "node": ">=15.0.0", - "npm": ">=7.0.0" + "node": ">=18", + "npm": ">=10" }, "engineStrict": true, "scripts": { @@ -17,6 +18,7 @@ "coverage:core": "npm run jest -- --roots packages/core/src --coverage", "typecheck": "tsc --noEmit --skipLibCheck", "e2e": "npm run webpack-bundle -- --mode=none && REDOCLY_TELEMETRY=off jest --roots=./__tests__/", + "e2e2": "node --experimental-vm-modules node_modules/jest/bin/jest.js --roots=./__tests__/", "prettier": " npx prettier --write \"**/*.{ts,js,yaml,yml,json,md}\"", "prettier:check": "npx prettier --check \"**/*.{ts,js,yaml,yml,json,md}\"", "eslint": "eslint packages/**", @@ -25,6 +27,7 @@ "compile": "tsc -b tsconfig.build.json", "prepare": "npm run compile", "cli": "ts-node packages/cli/src/index.ts", + "cli2": "ts-node packages/cli/lib/index.js", "lint": "npm run cli lint resources/pets.yaml -- --format stylish", "bundle": "npm run cli bundle resources/pets.yaml", "stats": "npm run cli stats resources/pets.yaml", diff --git a/packages/cli/bin/cli.js b/packages/cli/bin/cli.js index 4bd2d67c1..227810f0d 100755 --- a/packages/cli/bin/cli.js +++ b/packages/cli/bin/cli.js @@ -1,3 +1,3 @@ #!/usr/bin/env node -require('../lib/index'); +import '../lib/index.js'; diff --git a/packages/cli/package.json b/packages/cli/package.json index d16e2bd98..ce1fea8c4 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,15 +1,16 @@ { "name": "@redocly/cli", "version": "1.19.0", + "type": "module", "description": "", "license": "MIT", "bin": { - "openapi": "bin/cli.js", - "redocly": "bin/cli.js" + "openapi": "./bin/cli.js", + "redocly": "./bin/cli.js" }, "engines": { - "node": ">=14.19.0", - "npm": ">=7.0.0" + "node": ">=18", + "npm": ">=10" }, "engineStrict": true, "scripts": { diff --git a/packages/cli/src/__mocks__/@redocly/openapi-core.ts b/packages/cli/src/__mocks__/@redocly/openapi-core.ts index a77f64939..dbbbf21ff 100644 --- a/packages/cli/src/__mocks__/@redocly/openapi-core.ts +++ b/packages/cli/src/__mocks__/@redocly/openapi-core.ts @@ -1,5 +1,5 @@ -import { ConfigFixture } from './../../__tests__/fixtures/config'; -import { firstDocument, secondDocument, thirdDocument } from '../documents'; +import { ConfigFixture } from './../../__tests__/fixtures/config.js'; +import { firstDocument, secondDocument, thirdDocument } from '../documents.js'; import type { Document } from '@redocly/openapi-core'; diff --git a/packages/cli/src/__tests__/commands/build-docs.test.ts b/packages/cli/src/__tests__/commands/build-docs.test.ts index 37438b6eb..5a2be0efe 100644 --- a/packages/cli/src/__tests__/commands/build-docs.test.ts +++ b/packages/cli/src/__tests__/commands/build-docs.test.ts @@ -1,9 +1,9 @@ import { createStore, loadAndBundleSpec } from 'redoc'; import { renderToString } from 'react-dom/server'; -import { handlerBuildCommand } from '../../commands/build-docs'; -import { BuildDocsArgv } from '../../commands/build-docs/types'; -import { getPageHTML } from '../../commands/build-docs/utils'; -import { getFallbackApisOrExit } from '../../utils/miscellaneous'; +import { handlerBuildCommand } from '../../commands/build-docs/index.js'; +import { BuildDocsArgv } from '../../commands/build-docs/types.js'; +import { getPageHTML } from '../../commands/build-docs/utils.js'; +import { getFallbackApisOrExit } from '../../utils/miscellaneous.js'; jest.mock('redoc'); jest.mock('fs'); diff --git a/packages/cli/src/__tests__/commands/bundle.test.ts b/packages/cli/src/__tests__/commands/bundle.test.ts index 9b82af2f8..6ceebd32d 100644 --- a/packages/cli/src/__tests__/commands/bundle.test.ts +++ b/packages/cli/src/__tests__/commands/bundle.test.ts @@ -1,8 +1,8 @@ import { bundle, getTotals, getMergedConfig } from '@redocly/openapi-core'; -import { BundleOptions, handleBundle } from '../../commands/bundle'; -import { handleError } from '../../utils/miscellaneous'; -import { commandWrapper } from '../../wrapper'; +import { BundleOptions, handleBundle } from '../../commands/bundle.js'; +import { handleError } from '../../utils/miscellaneous.js'; +import { commandWrapper } from '../../wrapper.js'; import SpyInstance = jest.SpyInstance; import { Arguments } from 'yargs'; diff --git a/packages/cli/src/__tests__/commands/join.test.ts b/packages/cli/src/__tests__/commands/join.test.ts index 8980be4cc..51b20b061 100644 --- a/packages/cli/src/__tests__/commands/join.test.ts +++ b/packages/cli/src/__tests__/commands/join.test.ts @@ -1,9 +1,9 @@ import { yellow } from 'colorette'; import { detectSpec } from '@redocly/openapi-core'; -import { handleJoin } from '../../commands/join'; -import { exitWithError, writeToFileByExtension } from '../../utils/miscellaneous'; -import { loadConfig } from '../../__mocks__/@redocly/openapi-core'; -import { ConfigFixture } from '../fixtures/config'; +import { handleJoin } from '../../commands/join.js'; +import { exitWithError, writeToFileByExtension } from '../../utils/miscellaneous.js'; +import { loadConfig } from '../../__mocks__/@redocly/openapi-core.js'; +import { ConfigFixture } from '../fixtures/config.js'; jest.mock('../../utils/miscellaneous'); diff --git a/packages/cli/src/__tests__/commands/lint.test.ts b/packages/cli/src/__tests__/commands/lint.test.ts index cf76c6b83..f0c850ef4 100644 --- a/packages/cli/src/__tests__/commands/lint.test.ts +++ b/packages/cli/src/__tests__/commands/lint.test.ts @@ -1,4 +1,4 @@ -import { handleLint, LintOptions } from '../../commands/lint'; +import { handleLint, LintOptions } from '../../commands/lint.js'; import { getMergedConfig, lint, @@ -14,10 +14,10 @@ import { exitWithError, loadConfigAndHandleErrors, checkIfRulesetExist, -} from '../../utils/miscellaneous'; -import { ConfigFixture } from '../fixtures/config'; +} from '../../utils/miscellaneous.js'; +import { ConfigFixture } from '../fixtures/config.js'; import { performance } from 'perf_hooks'; -import { commandWrapper } from '../../wrapper'; +import { commandWrapper } from '../../wrapper.js'; import { Arguments } from 'yargs'; import { blue } from 'colorette'; diff --git a/packages/cli/src/__tests__/commands/push-region.test.ts b/packages/cli/src/__tests__/commands/push-region.test.ts index a0e4bb188..6ac069d88 100644 --- a/packages/cli/src/__tests__/commands/push-region.test.ts +++ b/packages/cli/src/__tests__/commands/push-region.test.ts @@ -1,7 +1,7 @@ import { getMergedConfig } from '@redocly/openapi-core'; -import { handlePush } from '../../commands/push'; -import { promptClientToken } from '../../commands/login'; -import { ConfigFixture } from '../fixtures/config'; +import { handlePush } from '../../commands/push.js'; +import { promptClientToken } from '../../commands/login.js'; +import { ConfigFixture } from '../fixtures/config.js'; jest.mock('fs'); jest.mock('node-fetch', () => ({ diff --git a/packages/cli/src/__tests__/commands/push.test.ts b/packages/cli/src/__tests__/commands/push.test.ts index 2fe8c36d6..8bfbb8c1d 100644 --- a/packages/cli/src/__tests__/commands/push.test.ts +++ b/packages/cli/src/__tests__/commands/push.test.ts @@ -1,8 +1,8 @@ import * as fs from 'fs'; import { Config, getMergedConfig } from '@redocly/openapi-core'; -import { exitWithError } from '../../utils/miscellaneous'; -import { getApiRoot, getDestinationProps, handlePush, transformPush } from '../../commands/push'; -import { ConfigFixture } from '../fixtures/config'; +import { exitWithError } from '../../utils/miscellaneous.js'; +import { getApiRoot, getDestinationProps, handlePush, transformPush } from '../../commands/push.js'; +import { ConfigFixture } from '../fixtures/config.js'; import { yellow } from 'colorette'; jest.mock('fs'); diff --git a/packages/cli/src/__tests__/fetch-with-timeout.test.ts b/packages/cli/src/__tests__/fetch-with-timeout.test.ts index e3db223d2..68bfaed60 100644 --- a/packages/cli/src/__tests__/fetch-with-timeout.test.ts +++ b/packages/cli/src/__tests__/fetch-with-timeout.test.ts @@ -1,5 +1,5 @@ import AbortController from 'abort-controller'; -import fetchWithTimeout from '../utils/fetch-with-timeout'; +import fetchWithTimeout from '../utils/fetch-with-timeout.js'; import nodeFetch from 'node-fetch'; jest.mock('node-fetch'); @@ -17,6 +17,7 @@ describe('fetchWithTimeout', () => { await fetchWithTimeout('url'); expect(global.setTimeout).toHaveBeenCalledTimes(1); + // @ts-ignore FIXME: expect(nodeFetch).toHaveBeenCalledWith('url', { signal: new AbortController().signal }); expect(global.clearTimeout).toHaveBeenCalledTimes(1); }); diff --git a/packages/cli/src/__tests__/spinner.test.ts b/packages/cli/src/__tests__/spinner.test.ts index 3b8be2fa2..987ea0aea 100644 --- a/packages/cli/src/__tests__/spinner.test.ts +++ b/packages/cli/src/__tests__/spinner.test.ts @@ -1,4 +1,4 @@ -import { Spinner } from '../utils/spinner'; +import { Spinner } from '../utils/spinner.js'; import * as process from 'process'; jest.useFakeTimers(); diff --git a/packages/cli/src/__tests__/utils.test.ts b/packages/cli/src/__tests__/utils.test.ts index e29f24960..b14ed868d 100644 --- a/packages/cli/src/__tests__/utils.test.ts +++ b/packages/cli/src/__tests__/utils.test.ts @@ -14,7 +14,7 @@ import { cleanRawInput, getAndValidateFileExtension, writeToFileByExtension, -} from '../utils/miscellaneous'; +} from '../utils/miscellaneous.js'; import { ResolvedApi, Totals, diff --git a/packages/cli/src/__tests__/wrapper.test.ts b/packages/cli/src/__tests__/wrapper.test.ts index e1f857798..a1f2644a9 100644 --- a/packages/cli/src/__tests__/wrapper.test.ts +++ b/packages/cli/src/__tests__/wrapper.test.ts @@ -1,9 +1,9 @@ -import { loadConfigAndHandleErrors, sendTelemetry } from '../utils/miscellaneous'; +import { loadConfigAndHandleErrors, sendTelemetry } from '../utils/miscellaneous.js'; import * as process from 'process'; -import { commandWrapper } from '../wrapper'; -import { handleLint } from '../commands/lint'; +import { commandWrapper } from '../wrapper.js'; +import { handleLint } from '../commands/lint.js'; import { Arguments } from 'yargs'; -import { handlePush, PushOptions } from '../commands/push'; +import { handlePush, PushOptions } from '../commands/push.js'; import { detectSpec } from '@redocly/openapi-core'; jest.mock('node-fetch'); diff --git a/packages/cli/src/cms/api/__tests__/api-keys.test.ts b/packages/cli/src/cms/api/__tests__/api-keys.test.ts index 36169e120..15324aba1 100644 --- a/packages/cli/src/cms/api/__tests__/api-keys.test.ts +++ b/packages/cli/src/cms/api/__tests__/api-keys.test.ts @@ -1,4 +1,4 @@ -import { getApiKeys } from '../api-keys'; +import { getApiKeys } from '../api-keys.js'; import * as fs from 'fs'; describe('getApiKeys()', () => { diff --git a/packages/cli/src/cms/api/__tests__/api.client.test.ts b/packages/cli/src/cms/api/__tests__/api.client.test.ts index cb7a2c13e..6e5ab8efc 100644 --- a/packages/cli/src/cms/api/__tests__/api.client.test.ts +++ b/packages/cli/src/cms/api/__tests__/api.client.test.ts @@ -1,7 +1,9 @@ -import fetch, { Response } from 'node-fetch'; -import * as FormData from 'form-data'; +import _fetch, { Response } from 'node-fetch'; +import FormData from 'form-data'; -import { ReuniteApiClient, PushPayload } from '../api-client'; +import { ReuniteApiClient, PushPayload } from '../api-client.js'; + +const fetch = _fetch.default; jest.mock('node-fetch', () => ({ default: jest.fn(), diff --git a/packages/cli/src/cms/api/__tests__/domains.test.ts b/packages/cli/src/cms/api/__tests__/domains.test.ts index 261b1e7f7..90039ed4f 100644 --- a/packages/cli/src/cms/api/__tests__/domains.test.ts +++ b/packages/cli/src/cms/api/__tests__/domains.test.ts @@ -1,4 +1,4 @@ -import { getDomain } from '../domains'; +import { getDomain } from '../domains.js'; describe('getDomain()', () => { it('should return the domain from environment variable', () => { diff --git a/packages/cli/src/cms/api/api-client.ts b/packages/cli/src/cms/api/api-client.ts index 3a5183dbf..ee74ebae4 100644 --- a/packages/cli/src/cms/api/api-client.ts +++ b/packages/cli/src/cms/api/api-client.ts @@ -1,7 +1,7 @@ -import fetch from 'node-fetch'; -import * as FormData from 'form-data'; +import _fetch from 'node-fetch'; +import FormData from 'form-data'; import { getProxyAgent } from '@redocly/openapi-core'; -import fetchWithTimeout from '../../utils/fetch-with-timeout'; +import fetchWithTimeout from '../../utils/fetch-with-timeout.js'; import type { Response } from 'node-fetch'; import type { ReadStream } from 'fs'; @@ -10,7 +10,9 @@ import type { ProjectSourceResponse, PushResponse, UpsertRemoteResponse, -} from './types'; +} from './types.js'; + +const fetch = _fetch.default; class RemotesApiClient { constructor(private readonly domain: string, private readonly apiKey: string) {} diff --git a/packages/cli/src/cms/api/api-keys.ts b/packages/cli/src/cms/api/api-keys.ts index 79bf77621..864453191 100644 --- a/packages/cli/src/cms/api/api-keys.ts +++ b/packages/cli/src/cms/api/api-keys.ts @@ -1,8 +1,7 @@ import { resolve } from 'path'; import { homedir } from 'os'; import { existsSync, readFileSync } from 'fs'; -import { isNotEmptyObject } from '@redocly/openapi-core/lib/utils'; -import { TOKEN_FILENAME } from '@redocly/openapi-core/lib/redocly'; +import { isNotEmptyObject, TOKEN_FILENAME } from '@redocly/openapi-core'; function readCredentialsFile(credentialsPath: string) { return existsSync(credentialsPath) ? JSON.parse(readFileSync(credentialsPath, 'utf-8')) : {}; diff --git a/packages/cli/src/cms/api/index.ts b/packages/cli/src/cms/api/index.ts index a21875a36..f4c29f90f 100644 --- a/packages/cli/src/cms/api/index.ts +++ b/packages/cli/src/cms/api/index.ts @@ -1,3 +1,3 @@ -export * from './api-client'; -export * from './domains'; -export * from './api-keys'; +export * from './api-client.js'; +export * from './domains.js'; +export * from './api-keys.js'; diff --git a/packages/cli/src/cms/commands/__tests__/push-status.test.ts b/packages/cli/src/cms/commands/__tests__/push-status.test.ts index 8bcd4cfa0..6dff825ee 100644 --- a/packages/cli/src/cms/commands/__tests__/push-status.test.ts +++ b/packages/cli/src/cms/commands/__tests__/push-status.test.ts @@ -1,5 +1,5 @@ -import { handlePushStatus } from '../push-status'; -import { PushResponse } from '../../api/types'; +import { handlePushStatus } from '../push-status.js'; +import { PushResponse } from '../../api/types.js'; const remotes = { getPush: jest.fn(), diff --git a/packages/cli/src/cms/commands/__tests__/push.test.ts b/packages/cli/src/cms/commands/__tests__/push.test.ts index 2ac0845d2..52db03769 100644 --- a/packages/cli/src/cms/commands/__tests__/push.test.ts +++ b/packages/cli/src/cms/commands/__tests__/push.test.ts @@ -1,7 +1,7 @@ import * as fs from 'fs'; import * as path from 'path'; -import { handlePush } from '../push'; -import { ReuniteApiClient } from '../../api'; +import { handlePush } from '../push.js'; +import { ReuniteApiClient } from '../../api/index.js'; const remotes = { push: jest.fn(), diff --git a/packages/cli/src/cms/commands/__tests__/utils.test.ts b/packages/cli/src/cms/commands/__tests__/utils.test.ts index 482e02e11..fb2f1e298 100644 --- a/packages/cli/src/cms/commands/__tests__/utils.test.ts +++ b/packages/cli/src/cms/commands/__tests__/utils.test.ts @@ -1,4 +1,4 @@ -import { retryUntilConditionMet } from '../utils'; +import { retryUntilConditionMet } from '../utils.js'; jest.mock('@redocly/openapi-core', () => ({ pause: jest.requireActual('@redocly/openapi-core').pause, diff --git a/packages/cli/src/cms/commands/push-status.ts b/packages/cli/src/cms/commands/push-status.ts index 428957d9c..55370f996 100644 --- a/packages/cli/src/cms/commands/push-status.ts +++ b/packages/cli/src/cms/commands/push-status.ts @@ -1,19 +1,19 @@ import * as colors from 'colorette'; -import { exitWithError, printExecutionTime } from '../../utils/miscellaneous'; -import { Spinner } from '../../utils/spinner'; -import { DeploymentError } from '../utils'; -import { ReuniteApiClient, getApiKeys, getDomain } from '../api'; -import { capitalize } from '../../utils/js-utils'; -import { retryUntilConditionMet } from './utils'; +import { exitWithError, printExecutionTime } from '../../utils/miscellaneous.js'; +import { Spinner } from '../../utils/spinner.js'; +import { DeploymentError } from '../utils.js'; +import { ReuniteApiClient, getApiKeys, getDomain } from '../api/index.js'; +import { capitalize } from '../../utils/js-utils.js'; +import { retryUntilConditionMet } from './utils.js'; import type { OutputFormat } from '@redocly/openapi-core'; -import type { CommandArgs } from '../../wrapper'; +import type { CommandArgs } from '../../wrapper.js'; import type { DeploymentStatus, DeploymentStatusResponse, PushResponse, ScorecardItem, -} from '../api/types'; +} from '../api/types.js'; const RETRY_INTERVAL_MS = 5000; // 5 sec diff --git a/packages/cli/src/cms/commands/push.ts b/packages/cli/src/cms/commands/push.ts index a3b43ee60..d1c7b4b82 100644 --- a/packages/cli/src/cms/commands/push.ts +++ b/packages/cli/src/cms/commands/push.ts @@ -7,12 +7,12 @@ import { HandledError, pluralize, printExecutionTime, -} from '../../utils/miscellaneous'; -import { handlePushStatus } from './push-status'; -import { ReuniteApiClient, getDomain, getApiKeys } from '../api'; +} from '../../utils/miscellaneous.js'; +import { handlePushStatus } from './push-status.js'; +import { ReuniteApiClient, getDomain, getApiKeys } from '../api/index.js'; import type { OutputFormat } from '@redocly/openapi-core'; -import type { CommandArgs } from '../../wrapper'; +import type { CommandArgs } from '../../wrapper.js'; export type PushOptions = { apis?: string[]; diff --git a/packages/cli/src/commands/build-docs/index.ts b/packages/cli/src/commands/build-docs/index.ts index 69977bef3..6f85e7b3d 100644 --- a/packages/cli/src/commands/build-docs/index.ts +++ b/packages/cli/src/commands/build-docs/index.ts @@ -1,13 +1,17 @@ -import { loadAndBundleSpec } from 'redoc'; +import redoc from 'redoc'; import { dirname, resolve } from 'path'; import { writeFileSync, mkdirSync } from 'fs'; import { performance } from 'perf_hooks'; import { getMergedConfig, isAbsoluteUrl } from '@redocly/openapi-core'; -import { getObjectOrJSON, getPageHTML } from './utils'; -import { exitWithError, getExecutionTime, getFallbackApisOrExit } from '../../utils/miscellaneous'; +import { getObjectOrJSON, getPageHTML } from './utils.js'; +import { + exitWithError, + getExecutionTime, + getFallbackApisOrExit, +} from '../../utils/miscellaneous.js'; -import type { BuildDocsArgv } from './types'; -import type { CommandArgs } from '../../wrapper'; +import type { BuildDocsArgv } from './types.js'; +import type { CommandArgs } from '../../wrapper.js'; export const handlerBuildCommand = async ({ argv, @@ -33,8 +37,9 @@ export const handlerBuildCommand = async ({ try { const elapsed = getExecutionTime(startedAt); - - const api = await loadAndBundleSpec(isAbsoluteUrl(pathToApi) ? pathToApi : resolve(pathToApi)); + const api = await redoc.loadAndBundleSpec( + isAbsoluteUrl(pathToApi) ? pathToApi : resolve(pathToApi) + ); collectSpecData?.(api); const pageHTML = await getPageHTML( api, diff --git a/packages/cli/src/commands/build-docs/utils.ts b/packages/cli/src/commands/build-docs/utils.ts index 1fcc04411..93b9184db 100644 --- a/packages/cli/src/commands/build-docs/utils.ts +++ b/packages/cli/src/commands/build-docs/utils.ts @@ -1,16 +1,16 @@ import { createElement } from 'react'; -import { createStore, Redoc } from 'redoc'; +import redoc from 'redoc'; import { renderToString } from 'react-dom/server'; import { ServerStyleSheet } from 'styled-components'; -import { compile } from 'handlebars'; +import handlebars from 'handlebars'; import { dirname, join, resolve } from 'path'; import { existsSync, lstatSync, readFileSync } from 'fs'; import { red } from 'colorette'; import { isAbsoluteUrl } from '@redocly/openapi-core'; -import { exitWithError } from '../../utils/miscellaneous'; +import { exitWithError } from '../../utils/miscellaneous.js'; import type { Config } from '@redocly/openapi-core'; -import type { BuildDocsOptions } from './types'; +import type { BuildDocsOptions } from './types.js'; export function getObjectOrJSON( openapiOptions: string | Record, @@ -63,10 +63,10 @@ export async function getPageHTML( process.stderr.write('Prerendering docs\n'); const apiUrl = redocOptions.specUrl || (isAbsoluteUrl(pathToApi) ? pathToApi : undefined); - const store = await createStore(api, apiUrl, redocOptions); + const store = await redoc.createStore(api, apiUrl, redocOptions); const sheet = new ServerStyleSheet(); - const html = renderToString(sheet.collectStyles(createElement(Redoc, { store }))); + const html = renderToString(sheet.collectStyles(createElement(redoc.Redoc, { store }))); const state = await store.toJS(); const css = sheet.getStyleTags(); @@ -75,7 +75,7 @@ export async function getPageHTML( : redocOptions?.htmlTemplate ? resolve(configPath ? dirname(configPath) : '', redocOptions.htmlTemplate) : join(__dirname, './template.hbs'); - const template = compile(readFileSync(templateFileName).toString()); + const template = handlebars.compile(readFileSync(templateFileName).toString()); return template({ redocHTML: `
${html || ''}
diff --git a/packages/cli/src/commands/bundle.ts b/packages/cli/src/commands/bundle.ts index ee32d7289..303db92e9 100644 --- a/packages/cli/src/commands/bundle.ts +++ b/packages/cli/src/commands/bundle.ts @@ -12,10 +12,10 @@ import { saveBundle, sortTopLevelKeysForOas, checkForDeprecatedOptions, -} from '../utils/miscellaneous'; +} from '../utils/miscellaneous.js'; -import type { OutputExtensions, Skips, Totals } from '../types'; -import type { CommandArgs } from '../wrapper'; +import type { OutputExtensions, Skips, Totals } from '../types.js'; +import type { CommandArgs } from '../wrapper.js'; export type BundleOptions = { apis?: string[]; diff --git a/packages/cli/src/commands/join.ts b/packages/cli/src/commands/join.ts index 043091933..65474413a 100644 --- a/packages/cli/src/commands/join.ts +++ b/packages/cli/src/commands/join.ts @@ -9,8 +9,8 @@ import { detectSpec, bundleDocument, isRef, + dequal, } from '@redocly/openapi-core'; -import { dequal } from '@redocly/openapi-core/lib/utils'; import { getFallbackApisOrExit, printExecutionTime, @@ -18,10 +18,10 @@ import { sortTopLevelKeysForOas, getAndValidateFileExtension, writeToFileByExtension, -} from '../utils/miscellaneous'; -import { isObject, isString, keysOf } from '../utils/js-utils'; -import { COMPONENTS, OPENAPI3_METHOD } from './split/types'; -import { crawl, startsWithComponents } from './split'; +} from '../utils/miscellaneous.js'; +import { isObject, isString, keysOf } from '../utils/js-utils.js'; +import { COMPONENTS, OPENAPI3_METHOD } from './split/types.js'; +import { crawl, startsWithComponents } from './split/index.js'; import type { Oas3Definition, @@ -29,15 +29,13 @@ import type { Oas3Tag, Referenced, RuleSeverity, -} from '@redocly/openapi-core'; -import type { BundleResult } from '@redocly/openapi-core/lib/bundle'; -import type { + BundleResult, Oas3Parameter, Oas3PathItem, Oas3Server, Oas3_1Definition, -} from '@redocly/openapi-core/lib/typings/openapi'; -import type { CommandArgs } from '../wrapper'; +} from '@redocly/openapi-core'; +import type { CommandArgs } from '../wrapper.js'; const Tags = 'tags'; const xTagGroups = 'x-tagGroups'; diff --git a/packages/cli/src/commands/lint.ts b/packages/cli/src/commands/lint.ts index 8030b9a01..1ae0871fb 100644 --- a/packages/cli/src/commands/lint.ts +++ b/packages/cli/src/commands/lint.ts @@ -6,8 +6,8 @@ import { getTotals, lint, lintConfig, + ConfigValidationError, } from '@redocly/openapi-core'; -import { ConfigValidationError } from '@redocly/openapi-core/lib/config'; import { checkIfRulesetExist, exitWithError, @@ -19,14 +19,18 @@ import { printConfigLintTotals, printLintTotals, printUnusedWarnings, -} from '../utils/miscellaneous'; -import { getCommandNameFromArgs } from '../utils/getCommandNameFromArgs'; +} from '../utils/miscellaneous.js'; +import { getCommandNameFromArgs } from '../utils/getCommandNameFromArgs.js'; import type { Arguments } from 'yargs'; -import type { OutputFormat, ProblemSeverity, RuleSeverity } from '@redocly/openapi-core'; -import type { RawConfigProcessor } from '@redocly/openapi-core/lib/config'; -import type { CommandOptions, Skips, Totals } from '../types'; -import type { CommandArgs } from '../wrapper'; +import type { + OutputFormat, + ProblemSeverity, + RawConfigProcessor, + RuleSeverity, +} from '@redocly/openapi-core'; +import type { CommandOptions, Skips, Totals } from '../types.js'; +import type { CommandArgs } from '../wrapper.js'; export type LintOptions = { apis?: string[]; diff --git a/packages/cli/src/commands/login.ts b/packages/cli/src/commands/login.ts index d0934b3de..c4e212076 100644 --- a/packages/cli/src/commands/login.ts +++ b/packages/cli/src/commands/login.ts @@ -1,8 +1,8 @@ import { blue, green, gray } from 'colorette'; import { RedoclyClient } from '@redocly/openapi-core'; -import { promptUser } from '../utils/miscellaneous'; +import { promptUser } from '../utils/miscellaneous.js'; -import type { CommandArgs } from '../wrapper'; +import type { CommandArgs } from '../wrapper.js'; import type { Region } from '@redocly/openapi-core'; export function promptClientToken(domain: string) { diff --git a/packages/cli/src/commands/preview-docs/index.ts b/packages/cli/src/commands/preview-docs/index.ts index c075dd88e..8ed780bac 100644 --- a/packages/cli/src/commands/preview-docs/index.ts +++ b/packages/cli/src/commands/preview-docs/index.ts @@ -5,11 +5,11 @@ import { getFallbackApisOrExit, handleError, loadConfigAndHandleErrors, -} from '../../utils/miscellaneous'; -import startPreviewServer from './preview-server/preview-server'; +} from '../../utils/miscellaneous.js'; +import startPreviewServer from './preview-server/preview-server.js'; -import type { Skips } from '../../types'; -import type { CommandArgs } from '../../wrapper'; +import type { Skips } from '../../types.js'; +import type { CommandArgs } from '../../wrapper.js'; export type PreviewDocsOptions = { port: number; diff --git a/packages/cli/src/commands/preview-docs/preview-server/preview-server.ts b/packages/cli/src/commands/preview-docs/preview-server/preview-server.ts index e3c093499..e01030a7c 100644 --- a/packages/cli/src/commands/preview-docs/preview-server/preview-server.ts +++ b/packages/cli/src/commands/preview-docs/preview-server/preview-server.ts @@ -1,10 +1,10 @@ -import { compile } from 'handlebars'; +import handlebars from 'handlebars'; import * as colorette from 'colorette'; import { getPort } from 'get-port-please'; import { readFileSync, promises as fsPromises } from 'fs'; import * as path from 'path'; -import { startHttpServer, startWsServer, respondWithGzip, mimeTypes } from './server'; -import { isSubdir } from '../../../utils/miscellaneous'; +import { startHttpServer, startWsServer, respondWithGzip, mimeTypes } from './server.js'; +import { isSubdir } from '../../../utils/miscellaneous.js'; import type { IncomingMessage } from 'http'; @@ -22,7 +22,7 @@ function getPageHTML( .replace(/{?{{redocHead}}}?/, '{{{redocHead}}}') .replace('{{redocBody}}', '{{{redocHTML}}}'); - const template = compile(templateSrc); + const template = handlebars.compile(templateSrc); return template({ redocHead: ` diff --git a/packages/cli/src/commands/preview-docs/preview-server/server.ts b/packages/cli/src/commands/preview-docs/preview-server/server.ts index 38ffacdfa..c74e119ba 100644 --- a/packages/cli/src/commands/preview-docs/preview-server/server.ts +++ b/packages/cli/src/commands/preview-docs/preview-server/server.ts @@ -1,10 +1,10 @@ import * as http from 'http'; import * as zlib from 'zlib'; +// @ts-ignore FIXME: fix types +import SocketServer from 'simple-websocket/server.js'; import type { ReadStream } from 'fs'; -const SocketServer = require('simple-websocket/server.js'); - export const mimeTypes = { '.html': 'text/html', '.js': 'text/javascript', diff --git a/packages/cli/src/commands/preview-project/constants.ts b/packages/cli/src/commands/preview-project/constants.ts index 24f2db8b8..358aeb32a 100644 --- a/packages/cli/src/commands/preview-project/constants.ts +++ b/packages/cli/src/commands/preview-project/constants.ts @@ -1,4 +1,4 @@ -import type { Product } from './types'; +import type { Product } from './types.js'; export const PRODUCT_PACKAGES = { realm: '@redocly/realm', diff --git a/packages/cli/src/commands/preview-project/index.ts b/packages/cli/src/commands/preview-project/index.ts index cc32bf639..7ea9a693c 100644 --- a/packages/cli/src/commands/preview-project/index.ts +++ b/packages/cli/src/commands/preview-project/index.ts @@ -1,10 +1,10 @@ import path = require('path'); import { existsSync, readFileSync } from 'fs'; import { spawn } from 'child_process'; -import { PRODUCT_NAMES, PRODUCT_PACKAGES } from './constants'; +import { PRODUCT_NAMES, PRODUCT_PACKAGES } from './constants.js'; -import type { PreviewProjectOptions, Product } from './types'; -import type { CommandArgs } from '../../wrapper'; +import type { PreviewProjectOptions, Product } from './types.js'; +import type { CommandArgs } from '../../wrapper.js'; export const previewProject = async ({ argv }: CommandArgs) => { const { plan, port } = argv; diff --git a/packages/cli/src/commands/preview-project/types.ts b/packages/cli/src/commands/preview-project/types.ts index b561b0d39..5be80be47 100644 --- a/packages/cli/src/commands/preview-project/types.ts +++ b/packages/cli/src/commands/preview-project/types.ts @@ -1,4 +1,4 @@ -import type { PRODUCT_PACKAGES, PRODUCT_PLANS } from './constants'; +import type { PRODUCT_PACKAGES, PRODUCT_PLANS } from './constants.js'; export type Product = keyof typeof PRODUCT_PACKAGES; export type ProductPlan = typeof PRODUCT_PLANS[number]; diff --git a/packages/cli/src/commands/push.ts b/packages/cli/src/commands/push.ts index ea98a257f..84d0850fc 100644 --- a/packages/cli/src/commands/push.ts +++ b/packages/cli/src/commands/push.ts @@ -1,6 +1,6 @@ import * as fs from 'fs'; import * as path from 'path'; -import fetch from 'node-fetch'; +import _fetch from 'node-fetch'; import { performance } from 'perf_hooks'; import { yellow, green, blue, red } from 'colorette'; import { createHash } from 'crypto'; @@ -19,12 +19,14 @@ import { getFallbackApisOrExit, dumpBundle, pluralize, -} from '../utils/miscellaneous'; -import { promptClientToken } from './login'; -import { handlePush as handleCMSPush } from '../cms/commands/push'; +} from '../utils/miscellaneous.js'; +import { promptClientToken } from './login.js'; +import { handlePush as handleCMSPush } from '../cms/commands/push.js'; import type { Config, BundleOutputFormat, Region } from '@redocly/openapi-core'; -import type { CommandArgs } from '../wrapper'; +import type { CommandArgs } from '../wrapper.js'; + +const fetch = _fetch.default; const DEFAULT_VERSION = 'latest'; diff --git a/packages/cli/src/commands/split/__tests__/index.test.ts b/packages/cli/src/commands/split/__tests__/index.test.ts index 88ff15340..69e1cfada 100644 --- a/packages/cli/src/commands/split/__tests__/index.test.ts +++ b/packages/cli/src/commands/split/__tests__/index.test.ts @@ -1,9 +1,9 @@ -import { iteratePathItems, handleSplit } from '../index'; +import { iteratePathItems, handleSplit } from '../index.js'; import * as path from 'path'; import * as openapiCore from '@redocly/openapi-core'; -import { ComponentsFiles } from '../types'; +import { ComponentsFiles } from '../types.js'; import { blue, green } from 'colorette'; -import { loadConfigAndHandleErrors } from '../../../utils/__mocks__/miscellaneous'; +import { loadConfigAndHandleErrors } from '../../../utils/__mocks__/miscellaneous.js'; import type { Config } from '@redocly/openapi-core'; diff --git a/packages/cli/src/commands/split/index.ts b/packages/cli/src/commands/split/index.ts index 49ea5749b..45faf1853 100644 --- a/packages/cli/src/commands/split/index.ts +++ b/packages/cli/src/commands/split/index.ts @@ -1,7 +1,6 @@ import { red, blue, yellow, green } from 'colorette'; import * as fs from 'fs'; -import { parseYaml, slash, isRef, isTruthy } from '@redocly/openapi-core'; -import { dequal } from '@redocly/openapi-core/lib/utils'; +import { parseYaml, slash, isRef, isTruthy, dequal } from '@redocly/openapi-core'; import * as path from 'path'; import { performance } from 'perf_hooks'; import { @@ -13,14 +12,14 @@ import { langToExt, writeToFileByExtension, getAndValidateFileExtension, -} from '../../utils/miscellaneous'; -import { isObject, isEmptyObject } from '../../utils/js-utils'; +} from '../../utils/miscellaneous.js'; +import { isObject, isEmptyObject } from '../../utils/js-utils.js'; import { OPENAPI3_COMPONENT, COMPONENTS, OPENAPI3_METHOD_NAMES, OPENAPI3_COMPONENT_NAMES, -} from './types'; +} from './types.js'; import type { OasRef } from '@redocly/openapi-core'; import type { @@ -35,8 +34,8 @@ import type { RefObject, Oas3PathItem, Referenced, -} from './types'; -import type { CommandArgs } from '../../wrapper'; +} from './types.js'; +import type { CommandArgs } from '../../wrapper.js'; export type SplitOptions = { api: string; diff --git a/packages/cli/src/commands/stats.ts b/packages/cli/src/commands/stats.ts index 4022ed28a..2204c2d81 100755 --- a/packages/cli/src/commands/stats.ts +++ b/packages/cli/src/commands/stats.ts @@ -11,9 +11,9 @@ import { Stats, bundle, } from '@redocly/openapi-core'; -import { getFallbackApisOrExit, printExecutionTime } from '../utils/miscellaneous'; +import { getFallbackApisOrExit, printExecutionTime } from '../utils/miscellaneous.js'; -import type { CommandArgs } from '../wrapper'; +import type { CommandArgs } from '../wrapper.js'; import type { StatsAccumulator, StatsName, diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index 0a95b428c..5d2242da4 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -1,41 +1,39 @@ #!/usr/bin/env node -import './utils/assert-node-version'; -import * as yargs from 'yargs'; +import './utils/assert-node-version.js'; +import makeYargs from 'yargs'; import * as colors from 'colorette'; import { RedoclyClient } from '@redocly/openapi-core'; -import { outputExtensions, regionChoices } from './types'; -import { previewDocs } from './commands/preview-docs'; -import { handleStats } from './commands/stats'; -import { handleSplit } from './commands/split'; -import { handleJoin } from './commands/join'; -import { handlePushStatus } from './cms/commands/push-status'; -import { handleLint } from './commands/lint'; -import { handleBundle } from './commands/bundle'; -import { handleLogin } from './commands/login'; -import { handlerBuildCommand } from './commands/build-docs'; +import { outputExtensions, regionChoices } from './types.js'; +import { previewDocs } from './commands/preview-docs/index.js'; +import { handleStats } from './commands/stats.js'; +import { handleSplit } from './commands/split/index.js'; +import { handleJoin } from './commands/join.js'; +import { handlePushStatus } from './cms/commands/push-status.js'; +import { handleLint } from './commands/lint.js'; +import { handleBundle } from './commands/bundle.js'; +import { handleLogin } from './commands/login.js'; +import { handlerBuildCommand } from './commands/build-docs/index.js'; import { cacheLatestVersion, notifyUpdateCliVersion, version, -} from './utils/update-version-notifier'; -import { commandWrapper } from './wrapper'; -import { previewProject } from './commands/preview-project'; -import { PRODUCT_PLANS } from './commands/preview-project/constants'; -import { commonPushHandler } from './commands/push'; +} from './utils/update-version-notifier.js'; +import { commandWrapper } from './wrapper.js'; +import { previewProject } from './commands/preview-project/index.js'; +import { PRODUCT_PLANS } from './commands/preview-project/constants.js'; +import { commonPushHandler } from './commands/push.js'; import type { Arguments } from 'yargs'; import type { OutputFormat, RuleSeverity } from '@redocly/openapi-core'; -import type { BuildDocsArgv } from './commands/build-docs/types'; -import type { PushStatusOptions } from './cms/commands/push-status'; -import type { PushArguments } from './types'; - -if (!('replaceAll' in String.prototype)) { - require('core-js/actual/string/replace-all'); -} +import type { BuildDocsArgv } from './commands/build-docs/types.js'; +import type { PushStatusOptions } from './cms/commands/push-status.js'; +import type { PushArguments } from './types.js'; cacheLatestVersion(); +const yargs = makeYargs(process.argv.slice(2)); + yargs .version('version', 'Show version number.', version) .help('help', 'Show help.') @@ -761,7 +759,8 @@ yargs }), async (argv) => { process.env.REDOCLY_CLI_COMMAND = 'build-docs'; - commandWrapper(handlerBuildCommand)(argv as Arguments); + // FIXME: this fails. use local redoc? + // commandWrapper(handlerBuildCommand)(argv as Arguments); } ) .completion('completion', 'Generate autocomplete script for `redocly` command.') diff --git a/packages/cli/src/types.ts b/packages/cli/src/types.ts index bce718cc7..c65f56848 100644 --- a/packages/cli/src/types.ts +++ b/packages/cli/src/types.ts @@ -1,17 +1,17 @@ import type { BundleOutputFormat, Region, Config } from '@redocly/openapi-core'; import type { ArgumentsCamelCase } from 'yargs'; -import type { LintOptions } from './commands/lint'; -import type { BundleOptions } from './commands/bundle'; -import type { JoinOptions } from './commands/join'; -import type { LoginOptions } from './commands/login'; -import type { PushOptions } from './commands/push'; -import type { StatsOptions } from './commands/stats'; -import type { SplitOptions } from './commands/split'; -import type { PreviewDocsOptions } from './commands/preview-docs'; -import type { BuildDocsArgv } from './commands/build-docs/types'; -import type { PushOptions as CMSPushOptions } from './cms/commands/push'; -import type { PushStatusOptions } from './cms/commands/push-status'; -import type { PreviewProjectOptions } from './commands/preview-project/types'; +import type { LintOptions } from './commands/lint.js'; +import type { BundleOptions } from './commands/bundle.js'; +import type { JoinOptions } from './commands/join.js'; +import type { LoginOptions } from './commands/login.js'; +import type { PushOptions } from './commands/push.js'; +import type { StatsOptions } from './commands/stats.js'; +import type { SplitOptions } from './commands/split/index.js'; +import type { PreviewDocsOptions } from './commands/preview-docs/index.js'; +import type { BuildDocsArgv } from './commands/build-docs/types.js'; +import type { PushOptions as CMSPushOptions } from './cms/commands/push.js'; +import type { PushStatusOptions } from './cms/commands/push-status.js'; +import type { PreviewProjectOptions } from './commands/preview-project/types.js'; export type Totals = { errors: number; diff --git a/packages/cli/src/utils/__mocks__/miscellaneous.ts b/packages/cli/src/utils/__mocks__/miscellaneous.ts index 1298db942..7007c53e8 100644 --- a/packages/cli/src/utils/__mocks__/miscellaneous.ts +++ b/packages/cli/src/utils/__mocks__/miscellaneous.ts @@ -1,4 +1,4 @@ -import { ConfigFixture } from '../../__tests__/fixtures/config'; +import { ConfigFixture } from '../../__tests__/fixtures/config.js'; export const getFallbackApisOrExit = jest.fn((entrypoints) => entrypoints.map((path: string) => ({ path })) diff --git a/packages/cli/src/utils/assert-node-version.ts b/packages/cli/src/utils/assert-node-version.ts index c259e82ea..1fba7ae0e 100644 --- a/packages/cli/src/utils/assert-node-version.ts +++ b/packages/cli/src/utils/assert-node-version.ts @@ -2,10 +2,13 @@ import * as semver from 'semver'; import * as path from 'path'; import * as process from 'process'; import { yellow } from 'colorette'; +import fs from 'fs'; + +const __dirname = import.meta.dirname; try { - const { engines } = require(path.join(__dirname, '../package.json')); - const version = engines.node; + const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, '../../package.json'), 'utf-8')); + const version = pkg.engines.node; if (!semver.satisfies(process.version, version)) { process.stderr.write( diff --git a/packages/cli/src/utils/fetch-with-timeout.ts b/packages/cli/src/utils/fetch-with-timeout.ts index 82bd29b3c..24003a09a 100644 --- a/packages/cli/src/utils/fetch-with-timeout.ts +++ b/packages/cli/src/utils/fetch-with-timeout.ts @@ -1,11 +1,13 @@ -import nodeFetch from 'node-fetch'; +import _fetch from 'node-fetch'; import AbortController from 'abort-controller'; import { getProxyAgent } from '@redocly/openapi-core'; +const nodeFetch = _fetch.default; const TIMEOUT = 3000; export default async (url: string, options = {}) => { try { + // @ts-ignore FIXME: fix types const controller = new AbortController(); const timeout = setTimeout(() => { controller.abort(); diff --git a/packages/cli/src/utils/miscellaneous.ts b/packages/cli/src/utils/miscellaneous.ts index 9b5970703..5118fe457 100644 --- a/packages/cli/src/utils/miscellaneous.ts +++ b/packages/cli/src/utils/miscellaneous.ts @@ -1,8 +1,8 @@ -import * as pluralizeOne from 'pluralize'; +import pluralizeOne from 'pluralize'; import { basename, dirname, extname, join, resolve, relative, isAbsolute } from 'path'; import { blue, gray, green, red, yellow } from 'colorette'; import { performance } from 'perf_hooks'; -import * as glob from 'glob'; +import glob from 'glob'; import * as fs from 'fs'; import * as readline from 'readline'; import { Writable } from 'stream'; @@ -16,14 +16,15 @@ import { isAbsoluteUrl, loadConfig, RedoclyClient, + isEmptyObject, + isPlainObject, + ConfigValidationError, } from '@redocly/openapi-core'; -import { isEmptyObject, isPlainObject } from '@redocly/openapi-core/lib/utils'; -import { ConfigValidationError } from '@redocly/openapi-core/lib/config'; -import { deprecatedRefDocsSchema } from '@redocly/config/lib/reference-docs-config-schema'; -import { outputExtensions } from '../types'; -import { version } from './update-version-notifier'; -import { DESTINATION_REGEX } from '../commands/push'; -import fetch from './fetch-with-timeout'; +import { deprecatedRefDocsSchema } from '@redocly/config/lib/reference-docs-config-schema.js'; +import { outputExtensions } from '../types.js'; +import { version } from './update-version-notifier.js'; +import { DESTINATION_REGEX } from '../commands/push.js'; +import fetch from './fetch-with-timeout.js'; import type { Arguments } from 'yargs'; import type { @@ -34,9 +35,9 @@ import type { Config, Oas3Definition, Oas2Definition, + RawConfigProcessor, } from '@redocly/openapi-core'; -import type { RawConfigProcessor } from '@redocly/openapi-core/lib/config'; -import type { Totals, Entrypoint, ConfigApis, CommandOptions, OutputExtensions } from '../types'; +import type { Totals, Entrypoint, ConfigApis, CommandOptions, OutputExtensions } from '../types.js'; export async function getFallbackApisOrExit( argsApis: string[] | undefined, diff --git a/packages/cli/src/utils/update-version-notifier.ts b/packages/cli/src/utils/update-version-notifier.ts index 8adff2237..aa0f8b731 100644 --- a/packages/cli/src/utils/update-version-notifier.ts +++ b/packages/cli/src/utils/update-version-notifier.ts @@ -2,11 +2,15 @@ import { tmpdir } from 'os'; import { join } from 'path'; import { existsSync, writeFileSync, readFileSync, statSync } from 'fs'; import { compare } from 'semver'; -import fetch from './fetch-with-timeout'; +import fetch from './fetch-with-timeout.js'; import { cyan, green, yellow } from 'colorette'; -import { cleanColors } from './miscellaneous'; +import { cleanColors } from './miscellaneous.js'; -export const { version, name } = require('../../package.json'); +const __dirname = import.meta.dirname; + +const pkg = JSON.parse(readFileSync(join(__dirname, '../../package.json'), 'utf-8')); +export const version = pkg?.version; +export const name = pkg?.name; const VERSION_CACHE_FILE = 'redocly-cli-version'; const SPACE_TO_BORDER = 4; diff --git a/packages/cli/src/wrapper.ts b/packages/cli/src/wrapper.ts index df27a1167..1d5375d57 100644 --- a/packages/cli/src/wrapper.ts +++ b/packages/cli/src/wrapper.ts @@ -1,14 +1,12 @@ -import { detectSpec, doesYamlFileExist } from '@redocly/openapi-core'; -import { isPlainObject } from '@redocly/openapi-core/lib/utils'; -import { version } from './utils/update-version-notifier'; -import { exitWithError, loadConfigAndHandleErrors, sendTelemetry } from './utils/miscellaneous'; -import { lintConfigCallback } from './commands/lint'; +import { detectSpec, doesYamlFileExist, isPlainObject } from '@redocly/openapi-core'; +import { version } from './utils/update-version-notifier.js'; +import { exitWithError, loadConfigAndHandleErrors, sendTelemetry } from './utils/miscellaneous.js'; +import { lintConfigCallback } from './commands/lint.js'; import type { Arguments } from 'yargs'; -import type { Config, Region } from '@redocly/openapi-core'; -import type { CollectFn } from '@redocly/openapi-core/lib/utils'; -import type { ExitCode } from './utils/miscellaneous'; -import type { CommandOptions } from './types'; +import type { Config, Region, CollectFn } from '@redocly/openapi-core'; +import type { ExitCode } from './utils/miscellaneous.js'; +import type { CommandOptions } from './types.js'; export type CommandArgs = { argv: T; diff --git a/packages/core/__tests__/utils.ts b/packages/core/__tests__/utils.ts index 9f51bfb3e..3d5a0c79e 100644 --- a/packages/core/__tests__/utils.ts +++ b/packages/core/__tests__/utils.ts @@ -1,10 +1,10 @@ import * as path from 'path'; -import { Document, Source, NormalizedProblem, parseYaml, stringifyYaml } from '../src'; -import { StyleguideConfig, resolveStyleguideConfig, resolvePlugins } from '../src/config'; -import { Oas3RuleSet } from '../src/oas-types'; +import { Document, Source, NormalizedProblem, parseYaml, stringifyYaml } from '../src/index.js'; +import { StyleguideConfig, resolveStyleguideConfig, resolvePlugins } from '../src/config/index.js'; +import { Oas3RuleSet } from '../src/oas-types.js'; -import type { RuleConfig, Plugin, DecoratorConfig } from '../src/config'; +import type { RuleConfig, Plugin, DecoratorConfig } from '../src/config/index.js'; export function parseYamlToDocument(body: string, absoluteRef: string = ''): Document { return { diff --git a/packages/core/package.json b/packages/core/package.json index 0710f22d8..ac7861160 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,11 +1,12 @@ { "name": "@redocly/openapi-core", "version": "1.19.0", + "type": "module", "description": "", - "main": "lib/index.js", + "exports": "./lib/index.js", "engines": { - "node": ">=14.19.0", - "npm": ">=7.0.0" + "node": ">=18", + "npm": ">=10" }, "engineStrict": true, "license": "MIT", diff --git a/packages/core/src/__tests__/bundle.test.ts b/packages/core/src/__tests__/bundle.test.ts index aed9007ff..cb88dfacc 100644 --- a/packages/core/src/__tests__/bundle.test.ts +++ b/packages/core/src/__tests__/bundle.test.ts @@ -1,10 +1,16 @@ -import outdent from 'outdent'; +import { outdent } from 'outdent'; import * as path from 'path'; -import { bundleDocument, bundle, bundleFromString } from '../bundle'; -import { parseYamlToDocument, yamlSerializer, makeConfig } from '../../__tests__/utils'; -import { StyleguideConfig, Config, ResolvedConfig, createConfig, loadConfig } from '../config'; -import { BaseResolver } from '../resolve'; +import { bundleDocument, bundle, bundleFromString } from '../bundle.js'; +import { parseYamlToDocument, yamlSerializer, makeConfig } from '../../__tests__/utils.js'; +import { + StyleguideConfig, + Config, + ResolvedConfig, + createConfig, + loadConfig, +} from '../config/index.js'; +import { BaseResolver } from '../resolve.js'; const stringDocument = outdent` openapi: 3.0.0 diff --git a/packages/core/src/__tests__/codeframes.test.ts b/packages/core/src/__tests__/codeframes.test.ts index 451b9a0fb..73ab1bdb1 100644 --- a/packages/core/src/__tests__/codeframes.test.ts +++ b/packages/core/src/__tests__/codeframes.test.ts @@ -1,8 +1,8 @@ import { outdent } from 'outdent'; -import { getLineColLocation, getCodeframe } from '../format/codeframes'; -import { LocationObject } from '../walk'; -import { Source } from '../resolve'; +import { getLineColLocation, getCodeframe } from '../format/codeframes.js'; +import { LocationObject } from '../walk.js'; +import { Source } from '../resolve.js'; describe('Location', () => { it('should correctly calculate location for key', () => { diff --git a/packages/core/src/__tests__/format.test.ts b/packages/core/src/__tests__/format.test.ts index 37edca6aa..4830a1606 100644 --- a/packages/core/src/__tests__/format.test.ts +++ b/packages/core/src/__tests__/format.test.ts @@ -1,8 +1,8 @@ import { outdent } from 'outdent'; -import { formatProblems, getTotals } from '../format/format'; -import { LocationObject, NormalizedProblem } from '../walk'; -import { Source } from '../resolve'; +import { formatProblems, getTotals } from '../format/format.js'; +import { LocationObject, NormalizedProblem } from '../walk.js'; +import { Source } from '../resolve.js'; describe('format', () => { function replaceColors(log: string) { diff --git a/packages/core/src/__tests__/js-yaml.test.ts b/packages/core/src/__tests__/js-yaml.test.ts index e4411b0cf..976a16668 100644 --- a/packages/core/src/__tests__/js-yaml.test.ts +++ b/packages/core/src/__tests__/js-yaml.test.ts @@ -1,5 +1,5 @@ import { outdent } from 'outdent'; -import { parseYaml, stringifyYaml } from '../js-yaml'; +import { parseYaml, stringifyYaml } from '../js-yaml/index.js'; const yaml = ` emptyValue: diff --git a/packages/core/src/__tests__/lint.test.ts b/packages/core/src/__tests__/lint.test.ts index 4e1ca1bcd..7fcd013f4 100644 --- a/packages/core/src/__tests__/lint.test.ts +++ b/packages/core/src/__tests__/lint.test.ts @@ -1,13 +1,13 @@ import * as path from 'path'; import { outdent } from 'outdent'; -import { lintFromString, lintConfig, lintDocument, lint } from '../lint'; -import { BaseResolver } from '../resolve'; -import { createConfig, loadConfig } from '../config/load'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../__tests__/utils'; -import { detectSpec } from '../oas-types'; +import { lintFromString, lintConfig, lintDocument, lint } from '../lint.js'; +import { BaseResolver } from '../resolve.js'; +import { createConfig, loadConfig } from '../config/load.js'; +import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../__tests__/utils.js'; +import { detectSpec } from '../oas-types.js'; import { rootRedoclyConfigSchema } from '@redocly/config'; -import { createConfigTypes } from '../types/redocly-yaml'; +import { createConfigTypes } from '../types/redocly-yaml.js'; const testPortalConfig = parseYamlToDocument( outdent` diff --git a/packages/core/src/__tests__/logger-browser.test.ts b/packages/core/src/__tests__/logger-browser.test.ts index 15de710a8..fac1490da 100644 --- a/packages/core/src/__tests__/logger-browser.test.ts +++ b/packages/core/src/__tests__/logger-browser.test.ts @@ -3,7 +3,7 @@ */ import * as colorette from 'colorette'; -import { logger, colorize } from '../logger'; +import { logger, colorize } from '../logger.js'; describe('Logger in Browser', () => { it('should call "console.error"', () => { diff --git a/packages/core/src/__tests__/logger.test.ts b/packages/core/src/__tests__/logger.test.ts index ed5365d69..9dc916a1f 100644 --- a/packages/core/src/__tests__/logger.test.ts +++ b/packages/core/src/__tests__/logger.test.ts @@ -1,5 +1,5 @@ import * as colorette from 'colorette'; -import { logger, colorize } from '../logger'; +import { logger, colorize } from '../logger.js'; describe('Logger in nodejs', () => { let spyingStderr: jest.SpyInstance; diff --git a/packages/core/src/__tests__/login.test.ts b/packages/core/src/__tests__/login.test.ts index e61de9bcf..e7f8013ba 100644 --- a/packages/core/src/__tests__/login.test.ts +++ b/packages/core/src/__tests__/login.test.ts @@ -1,4 +1,4 @@ -import { RedoclyClient } from '../redocly'; +import { RedoclyClient } from '../redocly/index.js'; describe.skip('login', () => { it('should call login with setAccessTokens function', async () => { diff --git a/packages/core/src/__tests__/normalizeVisitors.test.ts b/packages/core/src/__tests__/normalizeVisitors.test.ts index cd6b9f5d7..8d0904f7c 100644 --- a/packages/core/src/__tests__/normalizeVisitors.test.ts +++ b/packages/core/src/__tests__/normalizeVisitors.test.ts @@ -4,10 +4,10 @@ import { normalizeVisitors, RuleInstanceConfig, VisitorLevelContext, -} from '../visitors'; -import { Oas3RuleSet } from '../oas-types'; -import { Oas3Types } from '../types/oas3'; -import { normalizeTypes } from '../types'; +} from '../visitors.js'; +import { Oas3RuleSet } from '../oas-types.js'; +import { Oas3Types } from '../types/oas3.js'; +import { normalizeTypes } from '../types/index.js'; describe('Normalize visitors', () => { it('should work correctly for single rule', () => { diff --git a/packages/core/src/__tests__/output-browser.test.ts b/packages/core/src/__tests__/output-browser.test.ts index 79380f9f7..5fc2a2aae 100644 --- a/packages/core/src/__tests__/output-browser.test.ts +++ b/packages/core/src/__tests__/output-browser.test.ts @@ -2,7 +2,7 @@ * @jest-environment jsdom */ -import { output } from '../output'; +import { output } from '../output.js'; describe('output', () => { it('should ignore all parsable data in browser', () => { diff --git a/packages/core/src/__tests__/output.test.ts b/packages/core/src/__tests__/output.test.ts index f080c2676..5e64c9ec0 100644 --- a/packages/core/src/__tests__/output.test.ts +++ b/packages/core/src/__tests__/output.test.ts @@ -1,4 +1,4 @@ -import { output } from '../output'; +import { output } from '../output.js'; describe('output', () => { it('should write all parsable data to stdout', () => { diff --git a/packages/core/src/__tests__/ref-utils.test.ts b/packages/core/src/__tests__/ref-utils.test.ts index 86439cd30..f3dcf5c06 100644 --- a/packages/core/src/__tests__/ref-utils.test.ts +++ b/packages/core/src/__tests__/ref-utils.test.ts @@ -1,9 +1,9 @@ -import outdent from 'outdent'; -import { parseYamlToDocument } from '../../__tests__/utils'; -import { parseRef, refBaseName } from '../ref-utils'; -import { lintDocument } from '../lint'; -import { StyleguideConfig } from '../config'; -import { BaseResolver } from '../resolve'; +import { outdent } from 'outdent'; +import { parseYamlToDocument } from '../../__tests__/utils.js'; +import { parseRef, refBaseName } from '../ref-utils.js'; +import { lintDocument } from '../lint.js'; +import { StyleguideConfig } from '../config/index.js'; +import { BaseResolver } from '../resolve.js'; describe('ref-utils', () => { it(`should unescape refs with '/'`, () => { diff --git a/packages/core/src/__tests__/resolve-http.test.ts b/packages/core/src/__tests__/resolve-http.test.ts index 0da6d9e1c..5607b0b9e 100644 --- a/packages/core/src/__tests__/resolve-http.test.ts +++ b/packages/core/src/__tests__/resolve-http.test.ts @@ -1,9 +1,9 @@ import { outdent } from 'outdent'; -import { resolveDocument, BaseResolver } from '../resolve'; -import { parseYamlToDocument } from '../../__tests__/utils'; -import { Oas3Types } from '../types/oas3'; -import { normalizeTypes } from '../types'; +import { resolveDocument, BaseResolver } from '../resolve.js'; +import { parseYamlToDocument } from '../../__tests__/utils.js'; +import { Oas3Types } from '../types/oas3.js'; +import { normalizeTypes } from '../types/index.js'; describe('Resolve http-headers', () => { it('should use matching http-headers', async () => { diff --git a/packages/core/src/__tests__/resolve.test.ts b/packages/core/src/__tests__/resolve.test.ts index ae3e79d1d..26e19fbed 100644 --- a/packages/core/src/__tests__/resolve.test.ts +++ b/packages/core/src/__tests__/resolve.test.ts @@ -1,10 +1,10 @@ import { outdent } from 'outdent'; import * as path from 'path'; -import { resolveDocument, BaseResolver, Document } from '../resolve'; -import { parseYamlToDocument } from '../../__tests__/utils'; -import { Oas3Types } from '../types/oas3'; -import { normalizeTypes } from '../types'; +import { resolveDocument, BaseResolver, Document } from '../resolve.js'; +import { parseYamlToDocument } from '../../__tests__/utils.js'; +import { Oas3Types } from '../types/oas3.js'; +import { normalizeTypes } from '../types/index.js'; import * as fs from 'fs'; describe('collect refs', () => { diff --git a/packages/core/src/__tests__/utils-browser.test.ts b/packages/core/src/__tests__/utils-browser.test.ts index eaa874b1a..3b8b0c331 100644 --- a/packages/core/src/__tests__/utils-browser.test.ts +++ b/packages/core/src/__tests__/utils-browser.test.ts @@ -2,7 +2,7 @@ * @jest-environment jsdom */ -import { isBrowser } from '../env'; +import { isBrowser } from '../env.js'; describe('isBrowser', () => { it('should be browser', () => { diff --git a/packages/core/src/__tests__/utils.test.ts b/packages/core/src/__tests__/utils.test.ts index 83b6c28c2..c3888886b 100644 --- a/packages/core/src/__tests__/utils.test.ts +++ b/packages/core/src/__tests__/utils.test.ts @@ -5,8 +5,8 @@ import { getMatchingStatusCodeRange, doesYamlFileExist, pickDefined, -} from '../utils'; -import { isBrowser } from '../env'; +} from '../utils.js'; +import { isBrowser } from '../env.js'; import * as fs from 'fs'; import * as path from 'path'; diff --git a/packages/core/src/__tests__/walk.test.ts b/packages/core/src/__tests__/walk.test.ts index 778e086f9..66908b261 100644 --- a/packages/core/src/__tests__/walk.test.ts +++ b/packages/core/src/__tests__/walk.test.ts @@ -1,17 +1,15 @@ -import outdent from 'outdent'; +import { outdent } from 'outdent'; import each from 'jest-each'; import * as path from 'path'; - -import { lintDocument } from '../lint'; - +import { lintDocument } from '../lint.js'; import { parseYamlToDocument, replaceSourceWithRef, makeConfigForRuleset, -} from '../../__tests__/utils'; -import { BaseResolver, Document } from '../resolve'; -import { listOf } from '../types'; -import { Oas3RuleSet } from '../oas-types'; +} from '../../__tests__/utils.js'; +import { BaseResolver, Document } from '../resolve.js'; +import { listOf } from '../types/index.js'; +import { Oas3RuleSet } from '../oas-types.js'; describe('walk order', () => { it('should run visitors', async () => { @@ -1391,9 +1389,11 @@ describe('context.resolve', () => { }); describe('type extensions', () => { + // @ts-ignore FIXME: fix types each([ ['3.0.0', 'oas3_0'], ['3.1.0', 'oas3_1'], + // @ts-ignore FIXME: fix types ]).it('should correctly visit OpenAPI %s extended types', async (openapi, oas) => { const calls: string[] = []; diff --git a/packages/core/src/benchmark/benches/lint-with-many-rules.bench.ts b/packages/core/src/benchmark/benches/lint-with-many-rules.bench.ts index 9e0ddea42..ed3ee2f2d 100644 --- a/packages/core/src/benchmark/benches/lint-with-many-rules.bench.ts +++ b/packages/core/src/benchmark/benches/lint-with-many-rules.bench.ts @@ -1,8 +1,8 @@ import { readFileSync } from 'fs'; import { join as pathJoin, resolve as pathResolve } from 'path'; -import { lintDocument } from '../../lint'; -import { BaseResolver } from '../../resolve'; -import { parseYamlToDocument, makeConfigForRuleset } from '../utils'; +import { lintDocument } from '../../lint.js'; +import { BaseResolver } from '../../resolve.js'; +import { parseYamlToDocument, makeConfigForRuleset } from '../utils.js'; export const name = 'Validate with 50 top-level rules'; export const count = 10; diff --git a/packages/core/src/benchmark/benches/lint-with-nested-rule.bench.ts b/packages/core/src/benchmark/benches/lint-with-nested-rule.bench.ts index 5656b4afc..571ca6ace 100644 --- a/packages/core/src/benchmark/benches/lint-with-nested-rule.bench.ts +++ b/packages/core/src/benchmark/benches/lint-with-nested-rule.bench.ts @@ -1,8 +1,8 @@ import { readFileSync } from 'fs'; import { join as pathJoin, resolve as pathResolve } from 'path'; -import { lintDocument } from '../../lint'; -import { BaseResolver } from '../../resolve'; -import { parseYamlToDocument, makeConfigForRuleset } from '../utils'; +import { lintDocument } from '../../lint.js'; +import { BaseResolver } from '../../resolve.js'; +import { parseYamlToDocument, makeConfigForRuleset } from '../utils.js'; export const name = 'Validate with single nested rule'; export const count = 10; diff --git a/packages/core/src/benchmark/benches/lint-with-no-rules.bench.ts b/packages/core/src/benchmark/benches/lint-with-no-rules.bench.ts index 624c7a4fa..6fc9ee911 100644 --- a/packages/core/src/benchmark/benches/lint-with-no-rules.bench.ts +++ b/packages/core/src/benchmark/benches/lint-with-no-rules.bench.ts @@ -1,8 +1,8 @@ import { readFileSync } from 'fs'; import { join as pathJoin, resolve as pathResolve } from 'path'; -import { lintDocument } from '../../lint'; -import { BaseResolver } from '../../resolve'; -import { parseYamlToDocument, makeConfigForRuleset } from '../utils'; +import { lintDocument } from '../../lint.js'; +import { BaseResolver } from '../../resolve.js'; +import { parseYamlToDocument, makeConfigForRuleset } from '../utils.js'; export const name = 'Validate with no rules'; export const count = 10; const rebillyDefinitionRef = pathResolve(pathJoin(__dirname, 'rebilly.yaml')); diff --git a/packages/core/src/benchmark/benches/lint-with-top-level-rule-report.bench.ts b/packages/core/src/benchmark/benches/lint-with-top-level-rule-report.bench.ts index 605c7422b..c861dcee4 100644 --- a/packages/core/src/benchmark/benches/lint-with-top-level-rule-report.bench.ts +++ b/packages/core/src/benchmark/benches/lint-with-top-level-rule-report.bench.ts @@ -1,8 +1,8 @@ import { readFileSync } from 'fs'; import { join as pathJoin, resolve as pathResolve } from 'path'; -import { lintDocument } from '../../lint'; -import { BaseResolver } from '../../resolve'; -import { parseYamlToDocument, makeConfigForRuleset } from '../utils'; +import { lintDocument } from '../../lint.js'; +import { BaseResolver } from '../../resolve.js'; +import { parseYamlToDocument, makeConfigForRuleset } from '../utils.js'; export const name = 'Validate with single top-level rule and report'; export const count = 10; diff --git a/packages/core/src/benchmark/benches/lint-with-top-level-rule.bench.ts b/packages/core/src/benchmark/benches/lint-with-top-level-rule.bench.ts index 1d0f8531a..b8b24c597 100644 --- a/packages/core/src/benchmark/benches/lint-with-top-level-rule.bench.ts +++ b/packages/core/src/benchmark/benches/lint-with-top-level-rule.bench.ts @@ -1,8 +1,8 @@ import { readFileSync } from 'fs'; import { join as pathJoin, resolve as pathResolve } from 'path'; -import { lintDocument } from '../../lint'; -import { BaseResolver } from '../../resolve'; -import { parseYamlToDocument, makeConfigForRuleset } from '../utils'; +import { lintDocument } from '../../lint.js'; +import { BaseResolver } from '../../resolve.js'; +import { parseYamlToDocument, makeConfigForRuleset } from '../utils.js'; export const name = 'Validate with single top-level rule'; export const count = 10; const rebillyDefinitionRef = pathResolve(pathJoin(__dirname, 'rebilly.yaml')); diff --git a/packages/core/src/benchmark/benches/recommended-oas3.bench.ts b/packages/core/src/benchmark/benches/recommended-oas3.bench.ts index 751c77e69..210906551 100644 --- a/packages/core/src/benchmark/benches/recommended-oas3.bench.ts +++ b/packages/core/src/benchmark/benches/recommended-oas3.bench.ts @@ -1,9 +1,9 @@ import { readFileSync } from 'fs'; import { join as pathJoin, resolve as pathResolve } from 'path'; -import { lintDocument } from '../../lint'; -import { StyleguideConfig, defaultPlugin, resolvePreset } from '../../config'; -import { BaseResolver } from '../../resolve'; -import { parseYamlToDocument } from '../utils'; +import { lintDocument } from '../../lint.js'; +import { StyleguideConfig, defaultPlugin, resolvePreset } from '../../config/index.js'; +import { BaseResolver } from '../../resolve.js'; +import { parseYamlToDocument } from '../utils.js'; export const name = 'Validate with recommended rules'; export const count = 10; diff --git a/packages/core/src/benchmark/benches/resolve-with-no-external.bench.ts b/packages/core/src/benchmark/benches/resolve-with-no-external.bench.ts index 0efde21e9..fbb60bdf4 100644 --- a/packages/core/src/benchmark/benches/resolve-with-no-external.bench.ts +++ b/packages/core/src/benchmark/benches/resolve-with-no-external.bench.ts @@ -1,9 +1,9 @@ import * as path from 'path'; import { readFileSync } from 'fs'; -import { resolveDocument, BaseResolver } from '../../resolve'; -import { parseYamlToDocument } from '../utils'; -import { Oas3Types } from '../../types/oas3'; -import { normalizeTypes } from '../../types'; +import { resolveDocument, BaseResolver } from '../../resolve.js'; +import { parseYamlToDocument } from '../utils.js'; +import { Oas3Types } from '../../types/oas3.js'; +import { normalizeTypes } from '../../types/index.js'; export const name = 'Resolve with no external refs'; export const count = 10; diff --git a/packages/core/src/benchmark/utils.ts b/packages/core/src/benchmark/utils.ts index 283da59d7..21015a253 100644 --- a/packages/core/src/benchmark/utils.ts +++ b/packages/core/src/benchmark/utils.ts @@ -1,10 +1,10 @@ -import { parseYaml } from '../js-yaml'; -import { Source } from '../resolve'; -import { StyleguideConfig, mergeExtends, resolvePlugins } from '../config'; +import { parseYaml } from '../js-yaml/index.js'; +import { Source } from '../resolve.js'; +import { StyleguideConfig, mergeExtends, resolvePlugins } from '../config/index.js'; -import type { Document } from '../resolve'; -import type { Oas3RuleSet } from '../oas-types'; -import type { RuleConfig, Plugin, ResolvedStyleguideConfig } from '../config/types'; +import type { Document } from '../resolve.js'; +import type { Oas3RuleSet } from '../oas-types.js'; +import type { RuleConfig, Plugin, ResolvedStyleguideConfig } from '../config/types.js'; export function parseYamlToDocument(body: string, absoluteRef: string = ''): Document { return { diff --git a/packages/core/src/bundle.ts b/packages/core/src/bundle.ts index be58ab1d1..3d80757b0 100755 --- a/packages/core/src/bundle.ts +++ b/packages/core/src/bundle.ts @@ -1,31 +1,31 @@ -import { BaseResolver, resolveDocument, makeRefId, makeDocumentFromString } from './resolve'; -import { normalizeVisitors } from './visitors'; -import { normalizeTypes } from './types'; -import { walkDocument } from './walk'; +import { BaseResolver, resolveDocument, makeRefId, makeDocumentFromString } from './resolve.js'; +import { normalizeVisitors } from './visitors.js'; +import { normalizeTypes } from './types/index.js'; +import { walkDocument } from './walk.js'; import { detectSpec, getTypes, getMajorSpecVersion, SpecMajorVersion, SpecVersion, -} from './oas-types'; -import { isAbsoluteUrl, isRef, refBaseName } from './ref-utils'; -import { initRules } from './config/rules'; -import { reportUnresolvedRef } from './rules/no-unresolved-refs'; -import { dequal, isPlainObject, isTruthy } from './utils'; -import { isRedoclyRegistryURL } from './redocly/domains'; -import { RemoveUnusedComponents as RemoveUnusedComponentsOas2 } from './decorators/oas2/remove-unused-components'; -import { RemoveUnusedComponents as RemoveUnusedComponentsOas3 } from './decorators/oas3/remove-unused-components'; -import { ConfigTypes } from './types/redocly-yaml'; - -import type { Location } from './ref-utils'; -import type { Oas3Visitor, Oas2Visitor } from './visitors'; -import type { NormalizedNodeType, NodeType } from './types'; -import type { WalkContext, UserContext, ResolveResult, NormalizedProblem } from './walk'; -import type { Config, StyleguideConfig } from './config'; -import type { OasRef } from './typings/openapi'; -import type { Document, ResolvedRefMap } from './resolve'; -import type { CollectFn } from './utils'; +} from './oas-types.js'; +import { isAbsoluteUrl, isRef, refBaseName } from './ref-utils.js'; +import { initRules } from './config/rules.js'; +import { reportUnresolvedRef } from './rules/no-unresolved-refs.js'; +import { dequal, isPlainObject, isTruthy } from './utils.js'; +import { isRedoclyRegistryURL } from './redocly/domains.js'; +import { RemoveUnusedComponents as RemoveUnusedComponentsOas2 } from './decorators/oas2/remove-unused-components.js'; +import { RemoveUnusedComponents as RemoveUnusedComponentsOas3 } from './decorators/oas3/remove-unused-components.js'; +import { ConfigTypes } from './types/redocly-yaml.js'; + +import type { Location } from './ref-utils.js'; +import type { Oas3Visitor, Oas2Visitor } from './visitors.js'; +import type { NormalizedNodeType, NodeType } from './types/index.js'; +import type { WalkContext, UserContext, ResolveResult, NormalizedProblem } from './walk.js'; +import type { Config, StyleguideConfig } from './config/index.js'; +import type { OasRef } from './typings/openapi.js'; +import type { Document, ResolvedRefMap } from './resolve.js'; +import type { CollectFn } from './utils.js'; export enum OasVersion { Version2 = 'oas2', diff --git a/packages/core/src/config/__tests__/config-resolvers.test.ts b/packages/core/src/config/__tests__/config-resolvers.test.ts index 6ece8a007..1f8183785 100644 --- a/packages/core/src/config/__tests__/config-resolvers.test.ts +++ b/packages/core/src/config/__tests__/config-resolvers.test.ts @@ -1,11 +1,11 @@ -import { colorize } from '../../logger'; -import { Asserts, asserts } from '../../rules/common/assertions/asserts'; -import { resolveStyleguideConfig, resolveApis, resolveConfig } from '../config-resolvers'; -import recommended from '../recommended'; +import { colorize } from '../../logger.js'; +import { Asserts, asserts } from '../../rules/common/assertions/asserts.js'; +import { resolveStyleguideConfig, resolveApis, resolveConfig } from '../config-resolvers.js'; +import recommended from '../recommended.js'; const path = require('path'); -import type { StyleguideRawConfig, RawConfig, PluginStyleguideConfig } from '../types'; +import type { StyleguideRawConfig, RawConfig, PluginStyleguideConfig } from '../types.js'; const configPath = path.join(__dirname, 'fixtures/resolve-config/redocly.yaml'); const baseStyleguideConfig: StyleguideRawConfig = { diff --git a/packages/core/src/config/__tests__/config.test.ts b/packages/core/src/config/__tests__/config.test.ts index 650787fd5..b5d49eaf8 100644 --- a/packages/core/src/config/__tests__/config.test.ts +++ b/packages/core/src/config/__tests__/config.test.ts @@ -1,13 +1,11 @@ -import { SpecVersion } from '../../oas-types'; -import { Config, StyleguideConfig } from '../config'; -import { getMergedConfig } from '../utils'; -import { doesYamlFileExist } from '../../utils'; -import { parseYaml } from '../../js-yaml'; +import { SpecVersion } from '../../oas-types.js'; +import { Config, StyleguideConfig } from '../config.js'; +import { getMergedConfig } from '../utils.js'; +import { doesYamlFileExist } from '../../utils.js'; +import { parseYaml } from '../../js-yaml/index.js'; import { readFileSync } from 'fs'; -import { ignoredFileStub } from './fixtures/ingore-file'; +import { ignoredFileStub } from './fixtures/ingore-file.js'; import * as path from 'path'; -import { NormalizedProblem } from '../../walk'; -import { Source } from '../../resolve'; jest.mock('../../utils'); jest.mock('../../js-yaml'); diff --git a/packages/core/src/config/__tests__/load.test.ts b/packages/core/src/config/__tests__/load.test.ts index 9776aba38..2a2f8e68e 100644 --- a/packages/core/src/config/__tests__/load.test.ts +++ b/packages/core/src/config/__tests__/load.test.ts @@ -1,11 +1,11 @@ -import { loadConfig, findConfig, getConfig, createConfig } from '../load'; -import { RedoclyClient } from '../../redocly'; -import { Config } from '../config'; -import { lintConfig } from '../../lint'; -import { replaceSourceWithRef } from '../../../__tests__/utils'; -import type { RuleConfig, FlatRawConfig } from './../types'; -import type { NormalizedProblem } from '../../walk'; -import { BaseResolver } from '../../resolve'; +import { loadConfig, findConfig, getConfig, createConfig } from '../load.js'; +import { RedoclyClient } from '../../redocly/index.js'; +import { Config } from '../config.js'; +import { lintConfig } from '../../lint.js'; +import { replaceSourceWithRef } from '../../../__tests__/utils.js'; +import type { RuleConfig, FlatRawConfig } from './../types.js'; +import type { NormalizedProblem } from '../../walk.js'; +import { BaseResolver } from '../../resolve.js'; const fs = require('fs'); const path = require('path'); diff --git a/packages/core/src/config/__tests__/resolve-plugins.test.ts b/packages/core/src/config/__tests__/resolve-plugins.test.ts index badbf3f9e..811db4da5 100644 --- a/packages/core/src/config/__tests__/resolve-plugins.test.ts +++ b/packages/core/src/config/__tests__/resolve-plugins.test.ts @@ -1,5 +1,5 @@ import * as path from 'path'; -import { loadConfig } from '../load'; +import { loadConfig } from '../load.js'; describe('resolving a plugin', () => { const configPath = path.join(__dirname, 'fixtures/plugin-config.yaml'); diff --git a/packages/core/src/config/__tests__/utils.test.ts b/packages/core/src/config/__tests__/utils.test.ts index cd5c6b1d1..d67414dd3 100644 --- a/packages/core/src/config/__tests__/utils.test.ts +++ b/packages/core/src/config/__tests__/utils.test.ts @@ -1,5 +1,5 @@ -import type { DeprecatedInRawConfig, RawConfig, FlatRawConfig } from '../types'; -import * as utils from '../utils'; +import type { DeprecatedInRawConfig, RawConfig, FlatRawConfig } from '../types.js'; +import * as utils from '../utils.js'; const makeTestRawConfig = ( apiStyleguideName: string, diff --git a/packages/core/src/config/all.ts b/packages/core/src/config/all.ts index 31d4e0e23..3a412b970 100644 --- a/packages/core/src/config/all.ts +++ b/packages/core/src/config/all.ts @@ -1,4 +1,4 @@ -import type { PluginStyleguideConfig } from './types'; +import type { PluginStyleguideConfig } from './types.js'; const all: PluginStyleguideConfig<'built-in'> = { rules: { diff --git a/packages/core/src/config/builtIn.ts b/packages/core/src/config/builtIn.ts index ad3975ce5..eaa1cf0e6 100644 --- a/packages/core/src/config/builtIn.ts +++ b/packages/core/src/config/builtIn.ts @@ -1,19 +1,28 @@ -import recommended from './recommended'; -import recommendedStrict from './recommended-strict'; -import all from './all'; -import minimal from './minimal'; -import { rules as oas3Rules, preprocessors as oas3Preprocessors } from '../rules/oas3'; -import { rules as oas2Rules, preprocessors as oas2Preprocessors } from '../rules/oas2'; -import { rules as async2Rules, preprocessors as async2Preprocessors } from '../rules/async2'; -import { rules as async3Rules, preprocessors as async3Preprocessors } from '../rules/async3'; -import { rules as arazzoRules, preprocessors as arazzoPreprocessors } from '../rules/arazzo'; -import { decorators as oas3Decorators } from '../decorators/oas3'; -import { decorators as oas2Decorators } from '../decorators/oas2'; -import { decorators as async2Decorators } from '../decorators/async2'; -import { decorators as async3Decorators } from '../decorators/async3'; -import { decorators as arazzoDecorators } from '../decorators/arazzo'; +import recommended from './recommended.js'; +import recommendedStrict from './recommended-strict.js'; +import all from './all.js'; +import minimal from './minimal.js'; +import { rules as oas3Rules, preprocessors as oas3Preprocessors } from '../rules/oas3/index.js'; +import { rules as oas2Rules, preprocessors as oas2Preprocessors } from '../rules/oas2/index.js'; +import { + rules as async2Rules, + preprocessors as async2Preprocessors, +} from '../rules/async2/index.js'; +import { + rules as async3Rules, + preprocessors as async3Preprocessors, +} from '../rules/async3/index.js'; +import { + rules as arazzoRules, + preprocessors as arazzoPreprocessors, +} from '../rules/arazzo/index.js'; +import { decorators as oas3Decorators } from '../decorators/oas3/index.js'; +import { decorators as oas2Decorators } from '../decorators/oas2/index.js'; +import { decorators as async2Decorators } from '../decorators/async2/index.js'; +import { decorators as async3Decorators } from '../decorators/async3/index.js'; +import { decorators as arazzoDecorators } from '../decorators/arazzo/index.js'; -import type { CustomRulesConfig, StyleguideRawConfig, Plugin } from './types'; +import type { CustomRulesConfig, StyleguideRawConfig, Plugin } from './types.js'; export const builtInConfigs: Record = { recommended, diff --git a/packages/core/src/config/config-resolvers.ts b/packages/core/src/config/config-resolvers.ts index 68f59b883..fbc30ed8c 100644 --- a/packages/core/src/config/config-resolvers.ts +++ b/packages/core/src/config/config-resolvers.ts @@ -1,8 +1,8 @@ import * as path from 'path'; -import { isAbsoluteUrl } from '../ref-utils'; -import { pickDefined, isNotString, isString, isDefined, keysOf } from '../utils'; -import { resolveDocument, BaseResolver } from '../resolve'; -import { defaultPlugin } from './builtIn'; +import { isAbsoluteUrl } from '../ref-utils.js'; +import { pickDefined, isNotString, isString, isDefined, keysOf } from '../utils.js'; +import { resolveDocument, BaseResolver } from '../resolve.js'; +import { defaultPlugin } from './builtIn.js'; import { getResolveConfig, getUniquePlugins, @@ -10,13 +10,13 @@ import { parsePresetName, prefixRules, transformConfig, -} from './utils'; -import { isBrowser } from '../env'; -import { Config } from './config'; -import { colorize, logger } from '../logger'; -import { asserts, buildAssertCustomFunction } from '../rules/common/assertions/asserts'; -import { normalizeTypes } from '../types'; -import { ConfigTypes } from '../types/redocly-yaml'; +} from './utils.js'; +import { isBrowser } from '../env.js'; +import { Config } from './config.js'; +import { colorize, logger } from '../logger.js'; +import { asserts, buildAssertCustomFunction } from '../rules/common/assertions/asserts.js'; +import { normalizeTypes } from '../types/index.js'; +import { ConfigTypes } from '../types/redocly-yaml.js'; import type { StyleguideRawConfig, @@ -27,11 +27,15 @@ import type { ResolvedStyleguideConfig, RuleConfig, DeprecatedInRawConfig, -} from './types'; -import type { Assertion, AssertionDefinition, RawAssertion } from '../rules/common/assertions'; -import type { Asserts, AssertionFn } from '../rules/common/assertions/asserts'; -import type { BundleOptions } from '../bundle'; -import type { Document, ResolvedRefMap } from '../resolve'; +} from './types.js'; +import type { + Assertion, + AssertionDefinition, + RawAssertion, +} from '../rules/common/assertions/index.js'; +import type { Asserts, AssertionFn } from '../rules/common/assertions/asserts.js'; +import type { BundleOptions } from '../bundle.js'; +import type { Document, ResolvedRefMap } from '../resolve.js'; export async function resolveConfigFileAndRefs({ configPath, diff --git a/packages/core/src/config/config.ts b/packages/core/src/config/config.ts index 780f9c6cb..b6bb1b28f 100755 --- a/packages/core/src/config/config.ts +++ b/packages/core/src/config/config.ts @@ -1,21 +1,21 @@ import * as fs from 'fs'; import * as path from 'path'; -import { parseYaml, stringifyYaml } from '../js-yaml'; -import { slash, doesYamlFileExist } from '../utils'; -import { SpecVersion, SpecMajorVersion } from '../oas-types'; -import { isBrowser } from '../env'; -import { getResolveConfig } from './utils'; -import { isAbsoluteUrl } from '../ref-utils'; - -import type { NormalizedProblem } from '../walk'; +import { parseYaml, stringifyYaml } from '../js-yaml/index.js'; +import { slash, doesYamlFileExist } from '../utils.js'; +import { SpecVersion, SpecMajorVersion } from '../oas-types.js'; +import { isBrowser } from '../env.js'; +import { getResolveConfig } from './utils.js'; +import { isAbsoluteUrl } from '../ref-utils.js'; + +import type { NormalizedProblem } from '../walk.js'; import type { Oas2RuleSet, Oas3RuleSet, Async2RuleSet, Async3RuleSet, ArazzoRuleSet, -} from '../oas-types'; -import type { NodeType } from '../types'; +} from '../oas-types.js'; +import type { NodeType } from '../types/index.js'; import type { DecoratorConfig, Plugin, @@ -29,7 +29,7 @@ import type { RuleSettings, Telemetry, ThemeRawConfig, -} from './types'; +} from './types.js'; export const IGNORE_FILE = '.redocly.lint-ignore.yaml'; const IGNORE_BANNER = diff --git a/packages/core/src/config/index.ts b/packages/core/src/config/index.ts index 6f5963eeb..8080f7b36 100644 --- a/packages/core/src/config/index.ts +++ b/packages/core/src/config/index.ts @@ -1,7 +1,7 @@ -export * from './config'; -export * from './types'; -export * from './rules'; -export * from './builtIn'; -export * from './load'; -export * from './utils'; -export * from './config-resolvers'; +export * from './config.js'; +export * from './types.js'; +export * from './rules.js'; +export * from './builtIn.js'; +export * from './load.js'; +export * from './utils.js'; +export * from './config-resolvers.js'; diff --git a/packages/core/src/config/load.ts b/packages/core/src/config/load.ts index 6f3c1294e..650a29fd9 100644 --- a/packages/core/src/config/load.ts +++ b/packages/core/src/config/load.ts @@ -1,19 +1,19 @@ import * as fs from 'fs'; import * as path from 'path'; -import { RedoclyClient } from '../redocly'; -import { isEmptyObject } from '../utils'; -import { parseYaml } from '../js-yaml'; -import { ConfigValidationError, transformConfig, deepCloneMapWithJSON } from './utils'; -import { resolveConfig, resolveConfigFileAndRefs } from './config-resolvers'; -import { bundleConfig } from '../bundle'; -import { BaseResolver } from '../resolve'; -import { isBrowser } from '../env'; -import { DOMAINS } from '../redocly/domains'; - -import type { Config } from './config'; -import type { Document, ResolvedRefMap } from '../resolve'; -import type { RegionalToken, RegionalTokenWithValidity } from '../redocly/redocly-client-types'; -import type { RawConfig, RawUniversalConfig, Region } from './types'; +import { RedoclyClient } from '../redocly/index.js'; +import { isEmptyObject } from '../utils.js'; +import { parseYaml } from '../js-yaml/index.js'; +import { ConfigValidationError, transformConfig, deepCloneMapWithJSON } from './utils.js'; +import { resolveConfig, resolveConfigFileAndRefs } from './config-resolvers.js'; +import { bundleConfig } from '../bundle.js'; +import { BaseResolver } from '../resolve.js'; +import { isBrowser } from '../env.js'; +import { DOMAINS } from '../redocly/domains.js'; + +import type { Config } from './config.js'; +import type { Document, ResolvedRefMap } from '../resolve.js'; +import type { RegionalToken, RegionalTokenWithValidity } from '../redocly/redocly-client-types.js'; +import type { RawConfig, RawUniversalConfig, Region } from './types.js'; async function addConfigMetadata({ rawConfig, diff --git a/packages/core/src/config/minimal.ts b/packages/core/src/config/minimal.ts index 16c2e2699..febdb94ae 100644 --- a/packages/core/src/config/minimal.ts +++ b/packages/core/src/config/minimal.ts @@ -1,4 +1,4 @@ -import type { PluginStyleguideConfig } from './types'; +import type { PluginStyleguideConfig } from './types.js'; const minimal: PluginStyleguideConfig<'built-in'> = { rules: { diff --git a/packages/core/src/config/recommended-strict.ts b/packages/core/src/config/recommended-strict.ts index b5482f54b..5260f27b1 100644 --- a/packages/core/src/config/recommended-strict.ts +++ b/packages/core/src/config/recommended-strict.ts @@ -1,4 +1,4 @@ -import type { PluginStyleguideConfig } from './types'; +import type { PluginStyleguideConfig } from './types.js'; const recommendedStrict: PluginStyleguideConfig<'built-in'> = { rules: { diff --git a/packages/core/src/config/recommended.ts b/packages/core/src/config/recommended.ts index df79a8665..659e3b1ba 100644 --- a/packages/core/src/config/recommended.ts +++ b/packages/core/src/config/recommended.ts @@ -1,4 +1,4 @@ -import type { PluginStyleguideConfig } from './types'; +import type { PluginStyleguideConfig } from './types.js'; const recommended: PluginStyleguideConfig<'built-in'> = { rules: { diff --git a/packages/core/src/config/rules.ts b/packages/core/src/config/rules.ts index 6ba529d9d..6ac84efff 100644 --- a/packages/core/src/config/rules.ts +++ b/packages/core/src/config/rules.ts @@ -1,4 +1,4 @@ -import { isDefined } from '../utils'; +import { isDefined } from '../utils.js'; import type { ArazzoRuleSet, @@ -7,9 +7,9 @@ import type { Oas2RuleSet, Oas3RuleSet, SpecVersion, -} from '../oas-types'; -import type { StyleguideConfig } from './config'; -import type { ProblemSeverity } from '../walk'; +} from '../oas-types.js'; +import type { StyleguideConfig } from './config.js'; +import type { ProblemSeverity } from '../walk.js'; type InitializedRule = { severity: ProblemSeverity; diff --git a/packages/core/src/config/types.ts b/packages/core/src/config/types.ts index ace6daae4..c8eff2a05 100644 --- a/packages/core/src/config/types.ts +++ b/packages/core/src/config/types.ts @@ -1,5 +1,5 @@ -import type { Location } from '../ref-utils'; -import type { ProblemSeverity, UserContext } from '../walk'; +import type { Location } from '../ref-utils.js'; +import type { ProblemSeverity, UserContext } from '../walk.js'; import type { Oas3PreprocessorsSet, SpecMajorVersion, @@ -19,9 +19,9 @@ import type { ArazzoPreprocessorsSet, ArazzoDecoratorsSet, RuleMap, -} from '../oas-types'; -import type { NodeType } from '../types'; -import type { SkipFunctionContext } from '../visitors'; +} from '../oas-types.js'; +import type { NodeType } from '../types/index.js'; +import type { SkipFunctionContext } from '../visitors.js'; import type { BuiltInAsync2RuleId, BuiltInAsync3RuleId, @@ -29,7 +29,7 @@ import type { BuiltInOAS2RuleId, BuiltInOAS3RuleId, BuiltInArazzoRuleId, -} from '../types/redocly-yaml'; +} from '../types/redocly-yaml.js'; export type RuleSeverity = ProblemSeverity | 'off'; diff --git a/packages/core/src/config/utils.ts b/packages/core/src/config/utils.ts index ed8e2f412..82e25cb9b 100644 --- a/packages/core/src/config/utils.ts +++ b/packages/core/src/config/utils.ts @@ -4,9 +4,9 @@ import { isTruthy, showErrorForDeprecatedField, showWarningForDeprecatedField, -} from '../utils'; -import { Config } from './config'; -import { logger, colorize } from '../logger'; +} from '../utils.js'; +import { Config } from './config.js'; +import { logger, colorize } from '../logger.js'; import type { Api, @@ -22,7 +22,7 @@ import type { RulesFields, StyleguideRawConfig, ThemeConfig, -} from './types'; +} from './types.js'; export function parsePresetName(presetName: string): { pluginId: string; configName: string } { if (presetName.indexOf('/') > -1) { diff --git a/packages/core/src/decorators/__tests__/filter-in.test.ts b/packages/core/src/decorators/__tests__/filter-in.test.ts index c11916643..cf2970e03 100644 --- a/packages/core/src/decorators/__tests__/filter-in.test.ts +++ b/packages/core/src/decorators/__tests__/filter-in.test.ts @@ -1,7 +1,7 @@ import { outdent } from 'outdent'; -import { bundleDocument } from '../../bundle'; -import { BaseResolver } from '../../resolve'; -import { makeConfig, parseYamlToDocument, yamlSerializer } from '../../../__tests__/utils'; +import { bundleDocument } from '../../bundle.js'; +import { BaseResolver } from '../../resolve.js'; +import { makeConfig, parseYamlToDocument, yamlSerializer } from '../../../__tests__/utils.js'; describe('oas3 filter-in', () => { expect.addSnapshotSerializer(yamlSerializer); diff --git a/packages/core/src/decorators/__tests__/filter-out.test.ts b/packages/core/src/decorators/__tests__/filter-out.test.ts index 58e529444..8c00cd16e 100644 --- a/packages/core/src/decorators/__tests__/filter-out.test.ts +++ b/packages/core/src/decorators/__tests__/filter-out.test.ts @@ -1,7 +1,7 @@ import { outdent } from 'outdent'; -import { bundleDocument } from '../../bundle'; -import { BaseResolver } from '../../resolve'; -import { makeConfig, parseYamlToDocument, yamlSerializer } from '../../../__tests__/utils'; +import { bundleDocument } from '../../bundle.js'; +import { BaseResolver } from '../../resolve.js'; +import { makeConfig, parseYamlToDocument, yamlSerializer } from '../../../__tests__/utils.js'; describe('oas3 filter-out', () => { expect.addSnapshotSerializer(yamlSerializer); diff --git a/packages/core/src/decorators/__tests__/media-type-examples-override.test.ts b/packages/core/src/decorators/__tests__/media-type-examples-override.test.ts index 91588ded4..0a6fd379e 100644 --- a/packages/core/src/decorators/__tests__/media-type-examples-override.test.ts +++ b/packages/core/src/decorators/__tests__/media-type-examples-override.test.ts @@ -1,7 +1,7 @@ -import { makeConfig, parseYamlToDocument, yamlSerializer } from '../../../__tests__/utils'; +import { makeConfig, parseYamlToDocument, yamlSerializer } from '../../../__tests__/utils.js'; import { outdent } from 'outdent'; -import { bundleDocument } from '../../bundle'; -import { BaseResolver } from '../../resolve'; +import { bundleDocument } from '../../bundle.js'; +import { BaseResolver } from '../../resolve.js'; describe('oas3 media-type-examples-override', () => { expect.addSnapshotSerializer(yamlSerializer); diff --git a/packages/core/src/decorators/__tests__/remove-x-internal.test.ts b/packages/core/src/decorators/__tests__/remove-x-internal.test.ts index 4c9f31c71..59a1012f1 100644 --- a/packages/core/src/decorators/__tests__/remove-x-internal.test.ts +++ b/packages/core/src/decorators/__tests__/remove-x-internal.test.ts @@ -1,7 +1,7 @@ import { outdent } from 'outdent'; -import { bundleDocument } from '../../bundle'; -import { BaseResolver } from '../../resolve'; -import { parseYamlToDocument, yamlSerializer, makeConfig } from '../../../__tests__/utils'; +import { bundleDocument } from '../../bundle.js'; +import { BaseResolver } from '../../resolve.js'; +import { parseYamlToDocument, yamlSerializer, makeConfig } from '../../../__tests__/utils.js'; describe('oas3 remove-x-internal', () => { expect.addSnapshotSerializer(yamlSerializer); diff --git a/packages/core/src/decorators/common/filters/filter-helper.ts b/packages/core/src/decorators/common/filters/filter-helper.ts index c193d913c..57a3b8fe6 100644 --- a/packages/core/src/decorators/common/filters/filter-helper.ts +++ b/packages/core/src/decorators/common/filters/filter-helper.ts @@ -1,7 +1,7 @@ -import { isRef } from '../../../ref-utils'; -import { isEmptyArray, isEmptyObject, isPlainObject } from '../../../utils'; +import { isRef } from '../../../ref-utils.js'; +import { isEmptyArray, isEmptyObject, isPlainObject } from '../../../utils.js'; -import type { UserContext } from '../../../walk'; +import type { UserContext } from '../../../walk.js'; export function filter(node: any, ctx: UserContext, criteria: (item: any) => boolean) { const { parent, key } = ctx; diff --git a/packages/core/src/decorators/common/filters/filter-in.ts b/packages/core/src/decorators/common/filters/filter-in.ts index 24cdaf5c8..14d10c151 100644 --- a/packages/core/src/decorators/common/filters/filter-in.ts +++ b/packages/core/src/decorators/common/filters/filter-in.ts @@ -1,6 +1,6 @@ -import { checkIfMatchByStrategy, filter } from './filter-helper'; +import { checkIfMatchByStrategy, filter } from './filter-helper.js'; -import type { Oas2Decorator, Oas3Decorator } from '../../../visitors'; +import type { Oas2Decorator, Oas3Decorator } from '../../../visitors.js'; const DEFAULT_STRATEGY = 'any'; diff --git a/packages/core/src/decorators/common/filters/filter-out.ts b/packages/core/src/decorators/common/filters/filter-out.ts index e8efd689e..0c825e04f 100644 --- a/packages/core/src/decorators/common/filters/filter-out.ts +++ b/packages/core/src/decorators/common/filters/filter-out.ts @@ -1,6 +1,6 @@ -import { checkIfMatchByStrategy, filter } from './filter-helper'; +import { checkIfMatchByStrategy, filter } from './filter-helper.js'; -import type { Oas2Decorator, Oas3Decorator } from '../../../visitors'; +import type { Oas2Decorator, Oas3Decorator } from '../../../visitors.js'; const DEFAULT_STRATEGY = 'any'; diff --git a/packages/core/src/decorators/common/info-description-override.ts b/packages/core/src/decorators/common/info-description-override.ts index fff0e4ef2..077f51f9e 100644 --- a/packages/core/src/decorators/common/info-description-override.ts +++ b/packages/core/src/decorators/common/info-description-override.ts @@ -1,7 +1,7 @@ -import { readFileAsStringSync } from '../../utils'; +import { readFileAsStringSync } from '../../utils.js'; -import type { Oas3Decorator, Oas2Decorator } from '../../visitors'; -import type { UserContext } from '../../walk'; +import type { Oas3Decorator, Oas2Decorator } from '../../visitors.js'; +import type { UserContext } from '../../walk.js'; export const InfoDescriptionOverride: Oas3Decorator | Oas2Decorator = ({ filePath }) => { return { diff --git a/packages/core/src/decorators/common/info-override.ts b/packages/core/src/decorators/common/info-override.ts index 9e3b2e2a5..6d6e1db6d 100644 --- a/packages/core/src/decorators/common/info-override.ts +++ b/packages/core/src/decorators/common/info-override.ts @@ -1,4 +1,4 @@ -import type { Oas3Decorator, Oas2Decorator } from '../../visitors'; +import type { Oas3Decorator, Oas2Decorator } from '../../visitors.js'; export const InfoOverride: Oas3Decorator | Oas2Decorator = (newInfo) => { return { diff --git a/packages/core/src/decorators/common/media-type-examples-override.ts b/packages/core/src/decorators/common/media-type-examples-override.ts index 8b8037fe3..35d56a32f 100644 --- a/packages/core/src/decorators/common/media-type-examples-override.ts +++ b/packages/core/src/decorators/common/media-type-examples-override.ts @@ -1,9 +1,9 @@ -import { yamlAndJsonSyncReader } from '../../utils'; -import { isRef } from '../../ref-utils'; +import { yamlAndJsonSyncReader } from '../../utils.js'; +import { isRef } from '../../ref-utils.js'; -import type { Oas3Decorator } from '../../visitors'; -import type { Oas3Operation, Oas3RequestBody, Oas3Response } from '../../typings/openapi'; -import type { NonUndefined, ResolveFn, UserContext } from '../../walk'; +import type { Oas3Decorator } from '../../visitors.js'; +import type { Oas3Operation, Oas3RequestBody, Oas3Response } from '../../typings/openapi.js'; +import type { NonUndefined, ResolveFn, UserContext } from '../../walk.js'; export const MediaTypeExamplesOverride: Oas3Decorator = ({ operationIds }) => { return { diff --git a/packages/core/src/decorators/common/operation-description-override.ts b/packages/core/src/decorators/common/operation-description-override.ts index c583fb4ff..9928f1ed4 100644 --- a/packages/core/src/decorators/common/operation-description-override.ts +++ b/packages/core/src/decorators/common/operation-description-override.ts @@ -1,9 +1,9 @@ -import { readFileAsStringSync } from '../../utils'; +import { readFileAsStringSync } from '../../utils.js'; -import type { Oas3Decorator, Oas2Decorator } from '../../visitors'; -import type { Oas2Operation } from '../../typings/swagger'; -import type { Oas3Operation } from '../../typings/openapi'; -import type { UserContext } from '../../walk'; +import type { Oas3Decorator, Oas2Decorator } from '../../visitors.js'; +import type { Oas2Operation } from '../../typings/swagger.js'; +import type { Oas3Operation } from '../../typings/openapi.js'; +import type { UserContext } from '../../walk.js'; export const OperationDescriptionOverride: Oas3Decorator | Oas2Decorator = ({ operationIds }) => { return { diff --git a/packages/core/src/decorators/common/registry-dependencies.ts b/packages/core/src/decorators/common/registry-dependencies.ts index abf03e516..03d5c27e2 100644 --- a/packages/core/src/decorators/common/registry-dependencies.ts +++ b/packages/core/src/decorators/common/registry-dependencies.ts @@ -1,7 +1,7 @@ -import { isRedoclyRegistryURL } from '../../redocly/domains'; +import { isRedoclyRegistryURL } from '../../redocly/domains.js'; -import type { UserContext } from '../../walk'; -import type { Oas3Decorator, Oas2Decorator } from '../../visitors'; +import type { UserContext } from '../../walk.js'; +import type { Oas3Decorator, Oas2Decorator } from '../../visitors.js'; export const RegistryDependencies: Oas3Decorator | Oas2Decorator = () => { const registryDependencies = new Set(); diff --git a/packages/core/src/decorators/common/remove-x-internal.ts b/packages/core/src/decorators/common/remove-x-internal.ts index 3974ceda0..bba61d2e9 100644 --- a/packages/core/src/decorators/common/remove-x-internal.ts +++ b/packages/core/src/decorators/common/remove-x-internal.ts @@ -1,8 +1,8 @@ -import { isEmptyArray, isEmptyObject, isPlainObject } from '../../utils'; -import { isRef } from '../../ref-utils'; +import { isEmptyArray, isEmptyObject, isPlainObject } from '../../utils.js'; +import { isRef } from '../../ref-utils.js'; -import type { Oas3Decorator, Oas2Decorator } from '../../visitors'; -import type { UserContext } from '../../walk'; +import type { Oas3Decorator, Oas2Decorator } from '../../visitors.js'; +import type { UserContext } from '../../walk.js'; const DEFAULT_INTERNAL_PROPERTY_NAME = 'x-internal'; diff --git a/packages/core/src/decorators/common/tag-description-override.ts b/packages/core/src/decorators/common/tag-description-override.ts index 4ca16e49d..e56b21e04 100644 --- a/packages/core/src/decorators/common/tag-description-override.ts +++ b/packages/core/src/decorators/common/tag-description-override.ts @@ -1,7 +1,7 @@ -import { readFileAsStringSync } from '../../utils'; +import { readFileAsStringSync } from '../../utils.js'; -import type { Oas3Decorator, Oas2Decorator } from '../../visitors'; -import type { UserContext } from '../../walk'; +import type { Oas3Decorator, Oas2Decorator } from '../../visitors.js'; +import type { UserContext } from '../../walk.js'; export const TagDescriptionOverride: Oas3Decorator | Oas2Decorator = ({ tagNames }) => { return { diff --git a/packages/core/src/decorators/oas2/__tests__/remove-unused-components.test.ts b/packages/core/src/decorators/oas2/__tests__/remove-unused-components.test.ts index e5af08364..fe5bf4621 100644 --- a/packages/core/src/decorators/oas2/__tests__/remove-unused-components.test.ts +++ b/packages/core/src/decorators/oas2/__tests__/remove-unused-components.test.ts @@ -1,7 +1,7 @@ import { outdent } from 'outdent'; -import { parseYamlToDocument, makeConfig } from '../../../../__tests__/utils'; -import { bundleDocument } from '../../../bundle'; -import { BaseResolver } from '../../../resolve'; +import { parseYamlToDocument, makeConfig } from '../../../../__tests__/utils.js'; +import { bundleDocument } from '../../../bundle.js'; +import { BaseResolver } from '../../../resolve.js'; describe('oas2 remove-unused-components', () => { it('should remove unused components', async () => { diff --git a/packages/core/src/decorators/oas2/index.ts b/packages/core/src/decorators/oas2/index.ts index 00d65dde2..f7ed36c8f 100644 --- a/packages/core/src/decorators/oas2/index.ts +++ b/packages/core/src/decorators/oas2/index.ts @@ -1,13 +1,13 @@ -import { RegistryDependencies } from '../common/registry-dependencies'; -import { OperationDescriptionOverride } from '../common/operation-description-override'; -import { TagDescriptionOverride } from '../common/tag-description-override'; -import { InfoDescriptionOverride } from '../common/info-description-override'; -import { InfoOverride } from '../common/info-override'; -import { RemoveXInternal } from '../common/remove-x-internal'; -import { FilterIn } from '../common/filters/filter-in'; -import { FilterOut } from '../common/filters/filter-out'; +import { RegistryDependencies } from '../common/registry-dependencies.js'; +import { OperationDescriptionOverride } from '../common/operation-description-override.js'; +import { TagDescriptionOverride } from '../common/tag-description-override.js'; +import { InfoDescriptionOverride } from '../common/info-description-override.js'; +import { InfoOverride } from '../common/info-override.js'; +import { RemoveXInternal } from '../common/remove-x-internal.js'; +import { FilterIn } from '../common/filters/filter-in.js'; +import { FilterOut } from '../common/filters/filter-out.js'; -import type { Oas2Decorator } from '../../visitors'; +import type { Oas2Decorator } from '../../visitors.js'; export const decorators = { 'registry-dependencies': RegistryDependencies as Oas2Decorator, diff --git a/packages/core/src/decorators/oas2/remove-unused-components.ts b/packages/core/src/decorators/oas2/remove-unused-components.ts index d47b004b7..114de6ead 100644 --- a/packages/core/src/decorators/oas2/remove-unused-components.ts +++ b/packages/core/src/decorators/oas2/remove-unused-components.ts @@ -1,8 +1,8 @@ -import { isEmptyObject } from '../../utils'; +import { isEmptyObject } from '../../utils.js'; -import type { Location } from '../../ref-utils'; -import type { Oas2Decorator } from '../../visitors'; -import type { Oas2Components, Oas2Definition } from '../../typings/swagger'; +import type { Location } from '../../ref-utils.js'; +import type { Oas2Decorator } from '../../visitors.js'; +import type { Oas2Components, Oas2Definition } from '../../typings/swagger.js'; export const RemoveUnusedComponents: Oas2Decorator = () => { const components = new Map< diff --git a/packages/core/src/decorators/oas3/__tests__/remove-unused-components.test.ts b/packages/core/src/decorators/oas3/__tests__/remove-unused-components.test.ts index a6159c0a0..5363da9cb 100644 --- a/packages/core/src/decorators/oas3/__tests__/remove-unused-components.test.ts +++ b/packages/core/src/decorators/oas3/__tests__/remove-unused-components.test.ts @@ -1,7 +1,7 @@ import { outdent } from 'outdent'; -import { parseYamlToDocument, makeConfig } from '../../../../__tests__/utils'; -import { bundleDocument } from '../../../bundle'; -import { BaseResolver } from '../../../resolve'; +import { parseYamlToDocument, makeConfig } from '../../../../__tests__/utils.js'; +import { bundleDocument } from '../../../bundle.js'; +import { BaseResolver } from '../../../resolve.js'; describe('oas3 remove-unused-components', () => { it('should remove unused components', async () => { diff --git a/packages/core/src/decorators/oas3/index.ts b/packages/core/src/decorators/oas3/index.ts index 369b20657..fd33a8049 100644 --- a/packages/core/src/decorators/oas3/index.ts +++ b/packages/core/src/decorators/oas3/index.ts @@ -1,14 +1,14 @@ -import { RegistryDependencies } from '../common/registry-dependencies'; -import { OperationDescriptionOverride } from '../common/operation-description-override'; -import { TagDescriptionOverride } from '../common/tag-description-override'; -import { InfoDescriptionOverride } from '../common/info-description-override'; -import { InfoOverride } from '../common/info-override'; -import { RemoveXInternal } from '../common/remove-x-internal'; -import { FilterIn } from '../common/filters/filter-in'; -import { FilterOut } from '../common/filters/filter-out'; -import { MediaTypeExamplesOverride } from '../common/media-type-examples-override'; +import { RegistryDependencies } from '../common/registry-dependencies.js'; +import { OperationDescriptionOverride } from '../common/operation-description-override.js'; +import { TagDescriptionOverride } from '../common/tag-description-override.js'; +import { InfoDescriptionOverride } from '../common/info-description-override.js'; +import { InfoOverride } from '../common/info-override.js'; +import { RemoveXInternal } from '../common/remove-x-internal.js'; +import { FilterIn } from '../common/filters/filter-in.js'; +import { FilterOut } from '../common/filters/filter-out.js'; +import { MediaTypeExamplesOverride } from '../common/media-type-examples-override.js'; -import type { Oas3Decorator } from '../../visitors'; +import type { Oas3Decorator } from '../../visitors.js'; export const decorators = { 'registry-dependencies': RegistryDependencies as Oas3Decorator, diff --git a/packages/core/src/decorators/oas3/remove-unused-components.ts b/packages/core/src/decorators/oas3/remove-unused-components.ts index 4780961b9..086dee870 100644 --- a/packages/core/src/decorators/oas3/remove-unused-components.ts +++ b/packages/core/src/decorators/oas3/remove-unused-components.ts @@ -1,8 +1,8 @@ -import { isEmptyObject } from '../../utils'; +import { isEmptyObject } from '../../utils.js'; -import type { Location } from '../../ref-utils'; -import type { Oas3Decorator } from '../../visitors'; -import type { Oas3Components, Oas3Definition } from '../../typings/openapi'; +import type { Location } from '../../ref-utils.js'; +import type { Oas3Decorator } from '../../visitors.js'; +import type { Oas3Components, Oas3Definition } from '../../typings/openapi.js'; export const RemoveUnusedComponents: Oas3Decorator = () => { const components = new Map< diff --git a/packages/core/src/format/codeframes.ts b/packages/core/src/format/codeframes.ts index 57b55e14e..070821443 100644 --- a/packages/core/src/format/codeframes.ts +++ b/packages/core/src/format/codeframes.ts @@ -1,8 +1,8 @@ import * as yamlAst from 'yaml-ast-parser'; -import { unescapePointer } from '../ref-utils'; -import { colorize, colorOptions } from '../logger'; +import { unescapePointer } from '../ref-utils.js'; +import { colorize, colorOptions } from '../logger.js'; -import type { LineColLocationObject, Loc, LocationObject } from '../walk'; +import type { LineColLocationObject, Loc, LocationObject } from '../walk.js'; type YAMLMapping = yamlAst.YAMLMapping & { kind: yamlAst.Kind.MAPPING }; type YAMLMap = yamlAst.YamlMap & { kind: yamlAst.Kind.MAP }; diff --git a/packages/core/src/format/format.ts b/packages/core/src/format/format.ts index 7e19eacfa..8cca82abb 100644 --- a/packages/core/src/format/format.ts +++ b/packages/core/src/format/format.ts @@ -1,18 +1,19 @@ import * as path from 'path'; -import { colorOptions, colorize, logger } from '../logger'; -import { output } from '../output'; -import { getCodeframe, getLineColLocation } from './codeframes'; -import { env, isBrowser } from '../env'; -import { isAbsoluteUrl } from '../ref-utils'; +import { colorOptions, colorize, logger } from '../logger.js'; +import { output } from '../output.js'; +import { getCodeframe, getLineColLocation } from './codeframes.js'; +import { env, isBrowser } from '../env.js'; +import { isAbsoluteUrl } from '../ref-utils.js'; +import packageJson from '../../package.json' with { type: 'json' }; import type { NormalizedProblem, ProblemSeverity, LineColLocationObject, LocationObject, -} from '../walk'; +} from '../walk.js'; -const coreVersion = require('../../package.json').version; +const coreVersion = packageJson?.version; export type Totals = { errors: number; diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 16d645f16..4b96a1466 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -6,14 +6,19 @@ export { isTruthy, getProxyAgent, pause, -} from './utils'; -export { Oas3_1Types } from './types/oas3_1'; -export { ArazzoTypes } from './types/arazzo'; -export { Oas3Types } from './types/oas3'; -export { Oas2Types } from './types/oas2'; -export { AsyncApi2Types } from './types/asyncapi2'; -export { AsyncApi3Types } from './types/asyncapi3'; -export { ConfigTypes } from './types/redocly-yaml'; + isNotEmptyObject, + isEmptyObject, + isPlainObject, + CollectFn, + dequal, +} from './utils.js'; +export { Oas3_1Types } from './types/oas3_1.js'; +export { ArazzoTypes } from './types/arazzo.js'; +export { Oas3Types } from './types/oas3.js'; +export { Oas2Types } from './types/oas2.js'; +export { AsyncApi2Types } from './types/asyncapi2.js'; +export { AsyncApi3Types } from './types/asyncapi3.js'; +export { ConfigTypes } from './types/redocly-yaml.js'; export type { Oas3Definition, Oas3_1Definition, @@ -27,11 +32,13 @@ export type { Oas3_1Webhooks, Referenced, OasRef, -} from './typings/openapi'; -export type { Oas2Definition } from './typings/swagger'; -export type { StatsAccumulator, StatsName } from './typings/common'; -export { normalizeTypes } from './types'; -export { Stats } from './rules/other/stats'; + Oas3Parameter, + Oas3Server, +} from './typings/openapi.js'; +export type { Oas2Definition } from './typings/swagger.js'; +export type { StatsAccumulator, StatsName } from './typings/common.js'; +export { normalizeTypes } from './types/index.js'; +export { Stats } from './rules/other/stats.js'; export { Config, @@ -49,11 +56,13 @@ export { RuleSeverity, createConfig, ResolvedApi, -} from './config'; + ConfigValidationError, + RawConfigProcessor, +} from './config/index.js'; -export { RedoclyClient } from './redocly'; +export { RedoclyClient, TOKEN_FILENAME } from './redocly/index.js'; -export * from './redocly/domains'; +export * from './redocly/domains.js'; export { Source, @@ -63,17 +72,17 @@ export { ResolveError, YamlParseError, makeDocumentFromString, -} from './resolve'; -export { parseYaml, stringifyYaml } from './js-yaml'; -export { unescapePointer, isRef, isAbsoluteUrl } from './ref-utils'; +} from './resolve.js'; +export { parseYaml, stringifyYaml } from './js-yaml/index.js'; +export { unescapePointer, isRef, isAbsoluteUrl } from './ref-utils.js'; export { SpecMajorVersion, getMajorSpecVersion, SpecVersion, detectSpec, getTypes, -} from './oas-types'; -export { normalizeVisitors } from './visitors'; +} from './oas-types.js'; +export { normalizeVisitors } from './visitors.js'; export { WalkContext, @@ -83,9 +92,15 @@ export { LineColLocationObject, LocationObject, Loc, -} from './walk'; +} from './walk.js'; -export { getAstNodeByPointer, getLineColLocation } from './format/codeframes'; -export { formatProblems, OutputFormat, getTotals, Totals } from './format/format'; -export { lint, lint as validate, lintDocument, lintFromString, lintConfig } from './lint'; -export { bundle, bundleDocument, mapTypeToComponent, bundleFromString } from './bundle'; +export { getAstNodeByPointer, getLineColLocation } from './format/codeframes.js'; +export { formatProblems, OutputFormat, getTotals, Totals } from './format/format.js'; +export { lint, lint as validate, lintDocument, lintFromString, lintConfig } from './lint.js'; +export { + bundle, + bundleDocument, + mapTypeToComponent, + bundleFromString, + BundleResult, +} from './bundle.js'; diff --git a/packages/core/src/lint.ts b/packages/core/src/lint.ts index d8fa0ec10..d27253d3b 100755 --- a/packages/core/src/lint.ts +++ b/packages/core/src/lint.ts @@ -1,19 +1,19 @@ import { rootRedoclyConfigSchema } from '@redocly/config'; -import { BaseResolver, resolveDocument, makeDocumentFromString } from './resolve'; -import { normalizeVisitors } from './visitors'; -import { walkDocument } from './walk'; -import { initRules } from './config'; -import { normalizeTypes } from './types'; -import { releaseAjvInstance } from './rules/ajv'; -import { SpecVersion, getMajorSpecVersion, detectSpec, getTypes } from './oas-types'; -import { createConfigTypes } from './types/redocly-yaml'; -import { Spec } from './rules/common/spec'; -import { NoUnresolvedRefs } from './rules/no-unresolved-refs'; - -import type { StyleguideConfig, Config } from './config'; -import type { Document, ResolvedRefMap } from './resolve'; -import type { ProblemSeverity, WalkContext } from './walk'; -import type { NodeType } from './types'; +import { BaseResolver, resolveDocument, makeDocumentFromString } from './resolve.js'; +import { normalizeVisitors } from './visitors.js'; +import { walkDocument } from './walk.js'; +import { initRules } from './config/index.js'; +import { normalizeTypes } from './types/index.js'; +import { releaseAjvInstance } from './rules/ajv.js'; +import { SpecVersion, getMajorSpecVersion, detectSpec, getTypes } from './oas-types.js'; +import { createConfigTypes } from './types/redocly-yaml.js'; +import { Spec } from './rules/common/spec.js'; +import { NoUnresolvedRefs } from './rules/no-unresolved-refs.js'; + +import type { StyleguideConfig, Config } from './config/index.js'; +import type { Document, ResolvedRefMap } from './resolve.js'; +import type { ProblemSeverity, WalkContext } from './walk.js'; +import type { NodeType } from './types/index.js'; import type { ArazzoVisitor, Async2Visitor, @@ -22,8 +22,8 @@ import type { Oas2Visitor, Oas3Visitor, RuleInstanceConfig, -} from './visitors'; -import type { CollectFn } from './utils'; +} from './visitors.js'; +import type { CollectFn } from './utils.js'; export async function lint(opts: { ref: string; diff --git a/packages/core/src/logger.ts b/packages/core/src/logger.ts index 3d6232410..a10bcfc51 100644 --- a/packages/core/src/logger.ts +++ b/packages/core/src/logger.ts @@ -1,6 +1,6 @@ import * as colorette from 'colorette'; -import { isBrowser } from './env'; -import { identity } from './utils'; +import { isBrowser } from './env.js'; +import { identity } from './utils.js'; export { options as colorOptions } from 'colorette'; diff --git a/packages/core/src/oas-types.ts b/packages/core/src/oas-types.ts index 6fa8dc7d9..953faa690 100644 --- a/packages/core/src/oas-types.ts +++ b/packages/core/src/oas-types.ts @@ -1,10 +1,10 @@ -import { Oas2Types } from './types/oas2'; -import { Oas3Types } from './types/oas3'; -import { Oas3_1Types } from './types/oas3_1'; -import { AsyncApi2Types } from './types/asyncapi2'; -import { AsyncApi3Types } from './types/asyncapi3'; -import { ArazzoTypes } from './types/arazzo'; -import { isPlainObject } from './utils'; +import { Oas2Types } from './types/oas2.js'; +import { Oas3Types } from './types/oas3.js'; +import { Oas3_1Types } from './types/oas3_1.js'; +import { AsyncApi2Types } from './types/asyncapi2.js'; +import { AsyncApi3Types } from './types/asyncapi3.js'; +import { ArazzoTypes } from './types/arazzo.js'; +import { isPlainObject } from './utils.js'; import type { BuiltInAsync2RuleId, @@ -13,7 +13,7 @@ import type { BuiltInArazzoRuleId, BuiltInOAS2RuleId, BuiltInOAS3RuleId, -} from './types/redocly-yaml'; +} from './types/redocly-yaml.js'; import type { Oas3Rule, Oas3Preprocessor, @@ -25,7 +25,7 @@ import type { Async3Rule, ArazzoPreprocessor, ArazzoRule, -} from './visitors'; +} from './visitors.js'; export enum SpecVersion { OAS2 = 'oas2', diff --git a/packages/core/src/output.ts b/packages/core/src/output.ts index 1583dd7ea..ed04e5473 100644 --- a/packages/core/src/output.ts +++ b/packages/core/src/output.ts @@ -1,4 +1,4 @@ -import { isBrowser } from './env'; +import { isBrowser } from './env.js'; export const output = { write(str: string) { diff --git a/packages/core/src/redocly/__tests__/domains.test.ts b/packages/core/src/redocly/__tests__/domains.test.ts index 848eb0a9c..0f83ddce6 100644 --- a/packages/core/src/redocly/__tests__/domains.test.ts +++ b/packages/core/src/redocly/__tests__/domains.test.ts @@ -1,5 +1,5 @@ -import { RedoclyClient } from '../../index'; -import { setRedoclyDomain, getRedoclyDomain, getDomains, AVAILABLE_REGIONS } from '../domains'; +import { RedoclyClient } from '../../index.js'; +import { setRedoclyDomain, getRedoclyDomain, getDomains, AVAILABLE_REGIONS } from '../domains.js'; describe('domains', () => { const REDOCLY_DOMAIN_US = 'redocly.com'; diff --git a/packages/core/src/redocly/__tests__/redocly-client.test.ts b/packages/core/src/redocly/__tests__/redocly-client.test.ts index 0e19752d6..6aa524b40 100644 --- a/packages/core/src/redocly/__tests__/redocly-client.test.ts +++ b/packages/core/src/redocly/__tests__/redocly-client.test.ts @@ -1,5 +1,5 @@ -import { setRedoclyDomain } from '../domains'; -import { RedoclyClient } from '../index'; +import { setRedoclyDomain } from '../domains.js'; +import { RedoclyClient } from '../index.js'; jest.mock('node-fetch', () => ({ default: jest.fn(() => ({ diff --git a/packages/core/src/redocly/domains.ts b/packages/core/src/redocly/domains.ts index 3085cc169..f9860ed54 100644 --- a/packages/core/src/redocly/domains.ts +++ b/packages/core/src/redocly/domains.ts @@ -1,4 +1,4 @@ -import type { Region } from '../config/types'; +import type { Region } from '../config/types.js'; let redoclyDomain = 'redocly.com'; diff --git a/packages/core/src/redocly/index.ts b/packages/core/src/redocly/index.ts index b02730f6c..0ee22733b 100644 --- a/packages/core/src/redocly/index.ts +++ b/packages/core/src/redocly/index.ts @@ -1,20 +1,20 @@ import { existsSync, readFileSync, writeFileSync, unlinkSync } from 'fs'; import { resolve } from 'path'; import { homedir } from 'os'; -import { RegistryApi } from './registry-api'; -import { env } from '../env'; -import { isNotEmptyObject } from '../utils'; -import { colorize } from '../logger'; +import { RegistryApi } from './registry-api.js'; +import { env } from '../env.js'; +import { isNotEmptyObject } from '../utils.js'; +import { colorize } from '../logger.js'; import { AVAILABLE_REGIONS, DEFAULT_REGION, DOMAINS, getRedoclyDomain, setRedoclyDomain, -} from './domains'; +} from './domains.js'; -import type { RegionalToken, RegionalTokenWithValidity } from './redocly-client-types'; -import type { AccessTokens, Region } from '../config/types'; +import type { RegionalToken, RegionalTokenWithValidity } from './redocly-client-types.js'; +import type { AccessTokens, Region } from '../config/types.js'; export const TOKEN_FILENAME = '.redocly-config.json'; diff --git a/packages/core/src/redocly/redocly-client-types.ts b/packages/core/src/redocly/redocly-client-types.ts index 5e0d3ccf7..c09942403 100644 --- a/packages/core/src/redocly/redocly-client-types.ts +++ b/packages/core/src/redocly/redocly-client-types.ts @@ -1,4 +1,4 @@ -import type { Region } from '../config/types'; +import type { Region } from '../config/types.js'; export interface RegionalToken { region: Region; diff --git a/packages/core/src/redocly/registry-api.ts b/packages/core/src/redocly/registry-api.ts index ff6abafde..610abb24c 100644 --- a/packages/core/src/redocly/registry-api.ts +++ b/packages/core/src/redocly/registry-api.ts @@ -1,6 +1,7 @@ -import fetch from 'node-fetch'; -import { getProxyAgent, isNotEmptyObject } from '../utils'; -import { getRedoclyDomain } from './domains'; +import _fetch from 'node-fetch'; +import { getProxyAgent, isNotEmptyObject } from '../utils.js'; +import { getRedoclyDomain } from './domains.js'; +import packageJson from '../../package.json' with { type: 'json' }; import type { RequestInit, HeadersInit } from 'node-fetch'; import type { @@ -8,10 +9,12 @@ import type { PrepareFileuploadOKResponse, PrepareFileuploadParams, PushApiParams, -} from './registry-api-types'; -import type { AccessTokens, Region } from '../config/types'; +} from './registry-api-types.js'; +import type { AccessTokens, Region } from '../config/types.js'; -const version = require('../../package.json').version; +const fetch = _fetch.default + +const version = packageJson?.version; export class RegistryApi { constructor(private accessTokens: AccessTokens, private region: Region) {} @@ -43,6 +46,7 @@ export class RegistryApi { throw new Error('Unauthorized'); } + const response = await fetch( `${this.getBaseUrl()}${path}`, Object.assign({}, options, { headers, agent: getProxyAgent() }) diff --git a/packages/core/src/ref-utils.ts b/packages/core/src/ref-utils.ts index da746a954..adf86adde 100644 --- a/packages/core/src/ref-utils.ts +++ b/packages/core/src/ref-utils.ts @@ -1,7 +1,7 @@ -import { isTruthy } from './utils'; +import { isTruthy } from './utils.js'; -import type { Source } from './resolve'; -import type { OasRef } from './typings/openapi'; +import type { Source } from './resolve.js'; +import type { OasRef } from './typings/openapi.js'; export function joinPointer(base: string, key: string | number) { if (base === '') base = '#/'; diff --git a/packages/core/src/resolve.ts b/packages/core/src/resolve.ts index fd55c85c0..ac7e15b5e 100644 --- a/packages/core/src/resolve.ts +++ b/packages/core/src/resolve.ts @@ -1,13 +1,20 @@ import * as fs from 'fs'; import * as path from 'path'; -import { isRef, joinPointer, escapePointer, parseRef, isAbsoluteUrl, isAnchor } from './ref-utils'; -import { isNamedType, SpecExtension } from './types'; -import { readFileFromUrl, parseYaml, nextTick } from './utils'; +import { + isRef, + joinPointer, + escapePointer, + parseRef, + isAbsoluteUrl, + isAnchor, +} from './ref-utils.js'; +import { isNamedType, SpecExtension } from './types/index.js'; +import { readFileFromUrl, parseYaml, nextTick } from './utils.js'; import type { YAMLNode, LoadOptions } from 'yaml-ast-parser'; -import type { NormalizedNodeType } from './types'; -import type { ResolveConfig } from './config/types'; -import type { OasRef } from './typings/openapi'; +import type { NormalizedNodeType } from './types/index.js'; +import type { ResolveConfig } from './config/types.js'; +import type { OasRef } from './typings/openapi.js'; export type CollectedRefs = Map; diff --git a/packages/core/src/rules/__tests__/no-unresolved-refs.test.ts b/packages/core/src/rules/__tests__/no-unresolved-refs.test.ts index 650d0ccca..a19699159 100644 --- a/packages/core/src/rules/__tests__/no-unresolved-refs.test.ts +++ b/packages/core/src/rules/__tests__/no-unresolved-refs.test.ts @@ -1,8 +1,8 @@ -import path = require('path'); +import * as path from 'path'; import { outdent } from 'outdent'; -import { lintDocument } from '../../lint'; -import { BaseResolver } from '../../resolve'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../__tests__/utils'; +import { lintDocument } from '../../lint.js'; +import { BaseResolver } from '../../resolve.js'; +import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../__tests__/utils.js'; describe('oas3 boolean-parameter-prefixes', () => { it('should report on unresolved $ref', async () => { diff --git a/packages/core/src/rules/__tests__/utils.test.ts b/packages/core/src/rules/__tests__/utils.test.ts index ab75bb7c2..28bc9cd78 100644 --- a/packages/core/src/rules/__tests__/utils.test.ts +++ b/packages/core/src/rules/__tests__/utils.test.ts @@ -4,7 +4,7 @@ import { missingRequiredField, oasTypeOf, getAdditionalPropertiesOption, -} from '../utils'; +} from '../utils.js'; describe('field-non-empty', () => { it('should match expected message', () => { diff --git a/packages/core/src/rules/ajv.ts b/packages/core/src/rules/ajv.ts index 0e26faa81..a770e38b9 100644 --- a/packages/core/src/rules/ajv.ts +++ b/packages/core/src/rules/ajv.ts @@ -1,11 +1,13 @@ -import Ajv from '@redocly/ajv/dist/2020'; -import { escapePointer } from '../ref-utils'; +import _Ajv from '@redocly/ajv/dist/2020.js'; +import { escapePointer } from '../ref-utils.js'; -import type { Location } from '../ref-utils'; -import type { ValidateFunction, ErrorObject } from '@redocly/ajv/dist/2020'; -import type { ResolveFn } from '../walk'; +import type { Location } from '../ref-utils.js'; +import type { ValidateFunction, ErrorObject } from '@redocly/ajv/dist/2020.js'; +import type { ResolveFn } from '../walk.js'; -let ajvInstance: Ajv | null = null; +const Ajv = _Ajv.default; + +let ajvInstance: _Ajv.default | null = null; export function releaseAjvInstance() { ajvInstance = null; diff --git a/packages/core/src/rules/arazzo/index.ts b/packages/core/src/rules/arazzo/index.ts index 8e1a4b483..eb4c2d3f5 100644 --- a/packages/core/src/rules/arazzo/index.ts +++ b/packages/core/src/rules/arazzo/index.ts @@ -1,8 +1,8 @@ -import { Spec } from '../common/spec'; -import { Assertions } from '../common/assertions'; +import { Spec } from '../common/spec.js'; +import { Assertions } from '../common/assertions/index.js'; -import type { ArazzoRule } from '../../visitors'; -import type { ArazzoRuleSet } from '../../oas-types'; +import type { ArazzoRule } from '../../visitors.js'; +import type { ArazzoRuleSet } from '../../oas-types.js'; export const rules: ArazzoRuleSet<'built-in'> = { spec: Spec as ArazzoRule, diff --git a/packages/core/src/rules/async2/__tests__/channels-kebab-case.test.ts b/packages/core/src/rules/async2/__tests__/channels-kebab-case.test.ts index 843495dba..049ab98b9 100644 --- a/packages/core/src/rules/async2/__tests__/channels-kebab-case.test.ts +++ b/packages/core/src/rules/async2/__tests__/channels-kebab-case.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('Async2 channels-kebab-case', () => { it('should report on no kebab-case channel path', async () => { diff --git a/packages/core/src/rules/async2/__tests__/no-channel-trailing-slash.test.ts b/packages/core/src/rules/async2/__tests__/no-channel-trailing-slash.test.ts index c9ae151f1..b04fe74a6 100644 --- a/packages/core/src/rules/async2/__tests__/no-channel-trailing-slash.test.ts +++ b/packages/core/src/rules/async2/__tests__/no-channel-trailing-slash.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('no-channel-trailing-slash', () => { it('should report on trailing slash in a channel path', async () => { diff --git a/packages/core/src/rules/async2/channels-kebab-case.ts b/packages/core/src/rules/async2/channels-kebab-case.ts index 4a2276b9d..5d2b73555 100644 --- a/packages/core/src/rules/async2/channels-kebab-case.ts +++ b/packages/core/src/rules/async2/channels-kebab-case.ts @@ -1,5 +1,5 @@ -import type { Async2Rule } from '../../visitors'; -import type { UserContext } from '../../walk'; +import type { Async2Rule } from '../../visitors.js'; +import type { UserContext } from '../../walk.js'; export const ChannelsKebabCase: Async2Rule = () => { return { diff --git a/packages/core/src/rules/async2/index.ts b/packages/core/src/rules/async2/index.ts index 324c2639e..b37741b63 100644 --- a/packages/core/src/rules/async2/index.ts +++ b/packages/core/src/rules/async2/index.ts @@ -1,14 +1,14 @@ -import { Assertions } from '../common/assertions'; -import { Spec } from '../common/spec'; -import { InfoContact } from '../common/info-contact'; -import { OperationOperationId } from '../common/operation-operationId'; -import { TagDescription } from '../common/tag-description'; -import { TagsAlphabetical } from '../common/tags-alphabetical'; -import { ChannelsKebabCase } from './channels-kebab-case'; -import { NoChannelTrailingSlash } from './no-channel-trailing-slash'; +import { Assertions } from '../common/assertions/index.js'; +import { Spec } from '../common/spec.js'; +import { InfoContact } from '../common/info-contact.js'; +import { OperationOperationId } from '../common/operation-operationId.js'; +import { TagDescription } from '../common/tag-description.js'; +import { TagsAlphabetical } from '../common/tags-alphabetical.js'; +import { ChannelsKebabCase } from './channels-kebab-case.js'; +import { NoChannelTrailingSlash } from './no-channel-trailing-slash.js'; -import type { Async2Rule } from '../../visitors'; -import type { Async2RuleSet } from '../../oas-types'; +import type { Async2Rule } from '../../visitors.js'; +import type { Async2RuleSet } from '../../oas-types.js'; export const rules: Async2RuleSet<'built-in'> = { spec: Spec as Async2Rule, diff --git a/packages/core/src/rules/async2/no-channel-trailing-slash.ts b/packages/core/src/rules/async2/no-channel-trailing-slash.ts index f1444933c..3e7b8b08f 100644 --- a/packages/core/src/rules/async2/no-channel-trailing-slash.ts +++ b/packages/core/src/rules/async2/no-channel-trailing-slash.ts @@ -1,5 +1,5 @@ -import type { Async2Rule } from '../../visitors'; -import type { UserContext } from '../../walk'; +import type { Async2Rule } from '../../visitors.js'; +import type { UserContext } from '../../walk.js'; export const NoChannelTrailingSlash: Async2Rule = () => { return { diff --git a/packages/core/src/rules/async3/__tests__/channels-kebab-case.test.ts b/packages/core/src/rules/async3/__tests__/channels-kebab-case.test.ts index 3123b8178..2aaff763a 100644 --- a/packages/core/src/rules/async3/__tests__/channels-kebab-case.test.ts +++ b/packages/core/src/rules/async3/__tests__/channels-kebab-case.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('Async2 channels-kebab-case', () => { it('should report on no kebab-case channel path', async () => { diff --git a/packages/core/src/rules/async3/__tests__/no-channel-trailing-slash.test.ts b/packages/core/src/rules/async3/__tests__/no-channel-trailing-slash.test.ts index cb84e9b7f..4b28f1be4 100644 --- a/packages/core/src/rules/async3/__tests__/no-channel-trailing-slash.test.ts +++ b/packages/core/src/rules/async3/__tests__/no-channel-trailing-slash.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('no-channel-trailing-slash', () => { it.only('should report on trailing slash in a channel path', async () => { diff --git a/packages/core/src/rules/async3/channels-kebab-case.ts b/packages/core/src/rules/async3/channels-kebab-case.ts index 1b78796cd..c147599c7 100644 --- a/packages/core/src/rules/async3/channels-kebab-case.ts +++ b/packages/core/src/rules/async3/channels-kebab-case.ts @@ -1,6 +1,6 @@ -import type { Channel } from '../../typings/asyncapi3'; -import type { Async3Rule } from '../../visitors'; -import type { UserContext } from '../../walk'; +import type { Channel } from '../../typings/asyncapi3.js'; +import type { Async3Rule } from '../../visitors.js'; +import type { UserContext } from '../../walk.js'; export const ChannelsKebabCase: Async3Rule = () => { return { diff --git a/packages/core/src/rules/async3/index.ts b/packages/core/src/rules/async3/index.ts index d143fd0cd..d00fc7d72 100644 --- a/packages/core/src/rules/async3/index.ts +++ b/packages/core/src/rules/async3/index.ts @@ -1,14 +1,14 @@ -import { Assertions } from '../common/assertions'; -import { Spec } from '../common/spec'; -import { InfoContact } from '../common/info-contact'; -import { OperationOperationId } from '../common/operation-operationId'; -import { TagDescription } from '../common/tag-description'; -import { TagsAlphabetical } from '../common/tags-alphabetical'; -import { ChannelsKebabCase } from './channels-kebab-case'; -import { NoChannelTrailingSlash } from './no-channel-trailing-slash'; +import { Assertions } from '../common/assertions/index.js'; +import { Spec } from '../common/spec.js'; +import { InfoContact } from '../common/info-contact.js'; +import { OperationOperationId } from '../common/operation-operationId.js'; +import { TagDescription } from '../common/tag-description.js'; +import { TagsAlphabetical } from '../common/tags-alphabetical.js'; +import { ChannelsKebabCase } from './channels-kebab-case.js'; +import { NoChannelTrailingSlash } from './no-channel-trailing-slash.js'; -import type { Async3Rule } from '../../visitors'; -import type { Async3RuleSet } from '../../oas-types'; +import type { Async3Rule } from '../../visitors.js'; +import type { Async3RuleSet } from '../../oas-types.js'; export const rules: Async3RuleSet<'built-in'> = { spec: Spec as Async3Rule, diff --git a/packages/core/src/rules/async3/no-channel-trailing-slash.ts b/packages/core/src/rules/async3/no-channel-trailing-slash.ts index 7e664dab9..6b215aac3 100644 --- a/packages/core/src/rules/async3/no-channel-trailing-slash.ts +++ b/packages/core/src/rules/async3/no-channel-trailing-slash.ts @@ -1,6 +1,6 @@ -import type { Async3Rule } from '../../visitors'; -import type { UserContext } from '../../walk'; -import type { Channel } from '../../typings/asyncapi3'; +import type { Async3Rule } from '../../visitors.js'; +import type { UserContext } from '../../walk.js'; +import type { Channel } from '../../typings/asyncapi3.js'; export const NoChannelTrailingSlash: Async3Rule = () => { return { diff --git a/packages/core/src/rules/common/__tests__/info-license.test.ts b/packages/core/src/rules/common/__tests__/info-license.test.ts index 577ddcb88..ca869f94c 100644 --- a/packages/core/src/rules/common/__tests__/info-license.test.ts +++ b/packages/core/src/rules/common/__tests__/info-license.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('Oas3 info-license', () => { it('should report on info with no license', async () => { diff --git a/packages/core/src/rules/common/__tests__/license-url.test.ts b/packages/core/src/rules/common/__tests__/license-url.test.ts index 86041ab10..9fd2ccf80 100644 --- a/packages/core/src/rules/common/__tests__/license-url.test.ts +++ b/packages/core/src/rules/common/__tests__/license-url.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('Oas3 license-url', () => { it('should report on info.license with no url', async () => { diff --git a/packages/core/src/rules/common/__tests__/no-ambiguous-paths.test.ts b/packages/core/src/rules/common/__tests__/no-ambiguous-paths.test.ts index e89312b21..7935e3cdb 100644 --- a/packages/core/src/rules/common/__tests__/no-ambiguous-paths.test.ts +++ b/packages/core/src/rules/common/__tests__/no-ambiguous-paths.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('no-ambiguous-paths', () => { it('should report on ambiguous paths', async () => { diff --git a/packages/core/src/rules/common/__tests__/no-enum-type-mismatch.test.ts b/packages/core/src/rules/common/__tests__/no-enum-type-mismatch.test.ts index c6c08ed78..0dca950c9 100644 --- a/packages/core/src/rules/common/__tests__/no-enum-type-mismatch.test.ts +++ b/packages/core/src/rules/common/__tests__/no-enum-type-mismatch.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('Oas3 typed enum', () => { it('should not report on enum object if all items match type', async () => { diff --git a/packages/core/src/rules/common/__tests__/no-identical-paths.test.ts b/packages/core/src/rules/common/__tests__/no-identical-paths.test.ts index ac17fada8..39614ea67 100644 --- a/packages/core/src/rules/common/__tests__/no-identical-paths.test.ts +++ b/packages/core/src/rules/common/__tests__/no-identical-paths.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('no-identical-paths', () => { it('should report on identical paths', async () => { diff --git a/packages/core/src/rules/common/__tests__/no-invalid-parameter-examples.test.ts b/packages/core/src/rules/common/__tests__/no-invalid-parameter-examples.test.ts index df1b05eb4..361f79bb7 100644 --- a/packages/core/src/rules/common/__tests__/no-invalid-parameter-examples.test.ts +++ b/packages/core/src/rules/common/__tests__/no-invalid-parameter-examples.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('no-invalid-parameter-examples', () => { it('should report on invalid falsy example', async () => { diff --git a/packages/core/src/rules/common/__tests__/no-invalid-schema-examples.test.ts b/packages/core/src/rules/common/__tests__/no-invalid-schema-examples.test.ts index 96830c976..6f2e8600d 100644 --- a/packages/core/src/rules/common/__tests__/no-invalid-schema-examples.test.ts +++ b/packages/core/src/rules/common/__tests__/no-invalid-schema-examples.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('no-invalid-schema-examples', () => { it('should report on invalid falsy example', async () => { diff --git a/packages/core/src/rules/common/__tests__/no-path-trailing-slash.test.ts b/packages/core/src/rules/common/__tests__/no-path-trailing-slash.test.ts index 869ab1c80..0127e6be2 100644 --- a/packages/core/src/rules/common/__tests__/no-path-trailing-slash.test.ts +++ b/packages/core/src/rules/common/__tests__/no-path-trailing-slash.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('no-path-trailing-slash', () => { it('should report on trailing slash in path', async () => { diff --git a/packages/core/src/rules/common/__tests__/no-required-schema-properties-undefined.test.ts b/packages/core/src/rules/common/__tests__/no-required-schema-properties-undefined.test.ts index eedc4dc6f..1f4495600 100644 --- a/packages/core/src/rules/common/__tests__/no-required-schema-properties-undefined.test.ts +++ b/packages/core/src/rules/common/__tests__/no-required-schema-properties-undefined.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('no-required-schema-properties-undefined', () => { it('should report if one or more of the required properties are undefined', async () => { diff --git a/packages/core/src/rules/common/__tests__/operation-2xx-response.test.ts b/packages/core/src/rules/common/__tests__/operation-2xx-response.test.ts index bd037935f..e94739802 100644 --- a/packages/core/src/rules/common/__tests__/operation-2xx-response.test.ts +++ b/packages/core/src/rules/common/__tests__/operation-2xx-response.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('Oas3 operation-2xx-response', () => { it('should report missing 2xx response', async () => { diff --git a/packages/core/src/rules/common/__tests__/operation-4xx-response.test.ts b/packages/core/src/rules/common/__tests__/operation-4xx-response.test.ts index 6dad72f5e..a6af9a551 100644 --- a/packages/core/src/rules/common/__tests__/operation-4xx-response.test.ts +++ b/packages/core/src/rules/common/__tests__/operation-4xx-response.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('Oas3 operation-4xx-response', () => { it('should report missing 4xx response', async () => { diff --git a/packages/core/src/rules/common/__tests__/operation-operationId-unique.test.ts b/packages/core/src/rules/common/__tests__/operation-operationId-unique.test.ts index 954f1b9dd..1b4fbd6a6 100644 --- a/packages/core/src/rules/common/__tests__/operation-operationId-unique.test.ts +++ b/packages/core/src/rules/common/__tests__/operation-operationId-unique.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('Oas3 operation-operationId-unique', () => { it('should report on for non-unique opid', async () => { diff --git a/packages/core/src/rules/common/__tests__/operation-operationId-url-safe.test.ts b/packages/core/src/rules/common/__tests__/operation-operationId-url-safe.test.ts index 74a8c2ff8..403aade9b 100644 --- a/packages/core/src/rules/common/__tests__/operation-operationId-url-safe.test.ts +++ b/packages/core/src/rules/common/__tests__/operation-operationId-url-safe.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('Oas3 operation-operationId-url-safe', () => { it('should report on invalid operationIds', async () => { diff --git a/packages/core/src/rules/common/__tests__/operation-parameters-unique.test.ts b/packages/core/src/rules/common/__tests__/operation-parameters-unique.test.ts index 286a64891..f1f322333 100644 --- a/packages/core/src/rules/common/__tests__/operation-parameters-unique.test.ts +++ b/packages/core/src/rules/common/__tests__/operation-parameters-unique.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('Oas3 operation-parameters-unique', () => { it('should report on duplicated path params', async () => { diff --git a/packages/core/src/rules/common/__tests__/operation-singular-tag.test.ts b/packages/core/src/rules/common/__tests__/operation-singular-tag.test.ts index 5a071d75e..92a664f90 100644 --- a/packages/core/src/rules/common/__tests__/operation-singular-tag.test.ts +++ b/packages/core/src/rules/common/__tests__/operation-singular-tag.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('Oas3 operation-singular-tag', () => { it('should report on operation object if more than one tag', async () => { diff --git a/packages/core/src/rules/common/__tests__/path-http-verbs-order.test.ts b/packages/core/src/rules/common/__tests__/path-http-verbs-order.test.ts index 9cc3a49f3..9138d9548 100644 --- a/packages/core/src/rules/common/__tests__/path-http-verbs-order.test.ts +++ b/packages/core/src/rules/common/__tests__/path-http-verbs-order.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('Common path-http-verbs-order', () => { it('should report on invalid order', async () => { diff --git a/packages/core/src/rules/common/__tests__/path-not-include-query.test.ts b/packages/core/src/rules/common/__tests__/path-not-include-query.test.ts index 90b50c541..11589ce75 100644 --- a/packages/core/src/rules/common/__tests__/path-not-include-query.test.ts +++ b/packages/core/src/rules/common/__tests__/path-not-include-query.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('Oas3 path-not-include-query', () => { it('should report on path object if query params in pathitem', async () => { diff --git a/packages/core/src/rules/common/__tests__/path-params-defined.test.ts b/packages/core/src/rules/common/__tests__/path-params-defined.test.ts index 1a2bd2ae3..d6d0fe258 100644 --- a/packages/core/src/rules/common/__tests__/path-params-defined.test.ts +++ b/packages/core/src/rules/common/__tests__/path-params-defined.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('Oas3 path-params-defined', () => { it('should not report on defined params', async () => { diff --git a/packages/core/src/rules/common/__tests__/paths-kebab-case.test.ts b/packages/core/src/rules/common/__tests__/paths-kebab-case.test.ts index 87312986d..c225a0ef8 100644 --- a/packages/core/src/rules/common/__tests__/paths-kebab-case.test.ts +++ b/packages/core/src/rules/common/__tests__/paths-kebab-case.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('Oas3 paths-kebab-case', () => { it('should report on no kebab-case path', async () => { diff --git a/packages/core/src/rules/common/__tests__/scalar-property-missing-example.test.ts b/packages/core/src/rules/common/__tests__/scalar-property-missing-example.test.ts index e7facbe3a..8fef4ddd0 100644 --- a/packages/core/src/rules/common/__tests__/scalar-property-missing-example.test.ts +++ b/packages/core/src/rules/common/__tests__/scalar-property-missing-example.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('Oas3 scalar-property-missing-example', () => { it('should report on a scalar property missing example', async () => { diff --git a/packages/core/src/rules/common/__tests__/security-defined.test.ts b/packages/core/src/rules/common/__tests__/security-defined.test.ts index 53decfd3f..937bfe6da 100644 --- a/packages/core/src/rules/common/__tests__/security-defined.test.ts +++ b/packages/core/src/rules/common/__tests__/security-defined.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('Oas3 security-defined', () => { it('should report on securityRequirements object if security scheme is not defined in components', async () => { diff --git a/packages/core/src/rules/common/__tests__/spec-strict-refs.test.ts b/packages/core/src/rules/common/__tests__/spec-strict-refs.test.ts index 3ddce6e54..8798c9ca3 100644 --- a/packages/core/src/rules/common/__tests__/spec-strict-refs.test.ts +++ b/packages/core/src/rules/common/__tests__/spec-strict-refs.test.ts @@ -1,7 +1,11 @@ -import { makeConfig, parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils'; +import { + makeConfig, + parseYamlToDocument, + replaceSourceWithRef, +} from '../../../../__tests__/utils.js'; import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { BaseResolver } from '../../../resolve.js'; describe('Oas3 spec-strict-refs', () => { it('should report about invalid usage of $ref', async () => { diff --git a/packages/core/src/rules/common/__tests__/spec.test.ts b/packages/core/src/rules/common/__tests__/spec.test.ts index ee35721d2..c3d3549ed 100644 --- a/packages/core/src/rules/common/__tests__/spec.test.ts +++ b/packages/core/src/rules/common/__tests__/spec.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('Oas3 spec', () => { it('should report missing schema property', async () => { diff --git a/packages/core/src/rules/common/__tests__/tag-description.test.ts b/packages/core/src/rules/common/__tests__/tag-description.test.ts index 15355a0ad..092c20447 100644 --- a/packages/core/src/rules/common/__tests__/tag-description.test.ts +++ b/packages/core/src/rules/common/__tests__/tag-description.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('Oas3 tag-description', () => { it('should report on tags with no description', async () => { diff --git a/packages/core/src/rules/common/__tests__/tags-alphabetical.test.ts b/packages/core/src/rules/common/__tests__/tags-alphabetical.test.ts index fef94dc72..2172c777d 100644 --- a/packages/core/src/rules/common/__tests__/tags-alphabetical.test.ts +++ b/packages/core/src/rules/common/__tests__/tags-alphabetical.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('Oas3 tags-alphabetical', () => { it('should report on tags object if not sorted alphabetically', async () => { diff --git a/packages/core/src/rules/common/assertions/__tests__/asserts.test.ts b/packages/core/src/rules/common/assertions/__tests__/asserts.test.ts index 45f8bf0c9..ca950c79a 100644 --- a/packages/core/src/rules/common/assertions/__tests__/asserts.test.ts +++ b/packages/core/src/rules/common/assertions/__tests__/asserts.test.ts @@ -1,6 +1,6 @@ -import { Location } from '../../../../ref-utils'; -import { Source } from '../../../../resolve'; -import { AssertionFnContext, Asserts, asserts, buildAssertCustomFunction } from '../asserts'; +import { Location } from '../../../../ref-utils.js'; +import { Source } from '../../../../resolve.js'; +import { AssertionFnContext, Asserts, asserts, buildAssertCustomFunction } from '../asserts.js'; let baseLocation = new Location(jest.fn() as any as Source, 'pointer'); diff --git a/packages/core/src/rules/common/assertions/__tests__/index.test.ts b/packages/core/src/rules/common/assertions/__tests__/index.test.ts index 565430820..60ab7c10a 100644 --- a/packages/core/src/rules/common/assertions/__tests__/index.test.ts +++ b/packages/core/src/rules/common/assertions/__tests__/index.test.ts @@ -1,4 +1,4 @@ -import { Assertions } from '../.'; +import { Assertions } from '../index.js'; const opts = { '0': { diff --git a/packages/core/src/rules/common/assertions/__tests__/utils.test.ts b/packages/core/src/rules/common/assertions/__tests__/utils.test.ts index c27628e94..fff6b0cf9 100644 --- a/packages/core/src/rules/common/assertions/__tests__/utils.test.ts +++ b/packages/core/src/rules/common/assertions/__tests__/utils.test.ts @@ -1,8 +1,8 @@ -import { Assertion, AssertionDefinition } from '..'; -import { AssertionContext } from '../../../../config'; -import { Location } from '../../../../ref-utils'; -import { Source } from '../../../../resolve'; -import { isOrdered, buildVisitorObject, getIntersectionLength, runAssertion } from '../utils'; +import { Assertion, AssertionDefinition } from '../index.js'; +import { AssertionContext } from '../../../../config/index.js'; +import { Location } from '../../../../ref-utils.js'; +import { Source } from '../../../../resolve.js'; +import { isOrdered, buildVisitorObject, getIntersectionLength, runAssertion } from '../utils.js'; describe('Oas3 assertions', () => { describe('Utils', () => { diff --git a/packages/core/src/rules/common/assertions/asserts.ts b/packages/core/src/rules/common/assertions/asserts.ts index 6794f9896..1b7581317 100644 --- a/packages/core/src/rules/common/assertions/asserts.ts +++ b/packages/core/src/rules/common/assertions/asserts.ts @@ -1,9 +1,9 @@ -import { isPlainObject, isString as runOnValue, isTruthy } from '../../../utils'; -import { isOrdered, getIntersectionLength, regexFromString } from './utils'; +import { isPlainObject, isString as runOnValue, isTruthy } from '../../../utils.js'; +import { isOrdered, getIntersectionLength, regexFromString } from './utils.js'; -import type { AssertionContext, AssertResult, CustomFunction } from '../../../config/types'; -import type { Location } from '../../../ref-utils'; -import type { OrderOptions, OrderDirection } from './utils'; +import type { AssertionContext, AssertResult, CustomFunction } from '../../../config/types.js'; +import type { Location } from '../../../ref-utils.js'; +import type { OrderOptions, OrderDirection } from './utils.js'; export type AssertionFnContext = AssertionContext & { baseLocation: Location; rawValue?: any }; diff --git a/packages/core/src/rules/common/assertions/index.ts b/packages/core/src/rules/common/assertions/index.ts index 0436c0399..7be53f6c5 100644 --- a/packages/core/src/rules/common/assertions/index.ts +++ b/packages/core/src/rules/common/assertions/index.ts @@ -1,15 +1,15 @@ -import { buildSubjectVisitor, buildVisitorObject } from './utils'; -import { isString } from '../../../utils'; +import { buildSubjectVisitor, buildVisitorObject } from './utils.js'; +import { isString } from '../../../utils.js'; -import type { asserts, AssertionFn } from './asserts'; +import type { asserts, AssertionFn } from './asserts.js'; import type { ArazzoVisitor, Async2Visitor, Async3Visitor, Oas2Visitor, Oas3Visitor, -} from '../../../visitors'; -import type { RuleSeverity } from '../../../config'; +} from '../../../visitors.js'; +import type { RuleSeverity } from '../../../config/index.js'; export type AssertionLocators = { filterInParentKeys?: (string | number)[]; diff --git a/packages/core/src/rules/common/assertions/utils.ts b/packages/core/src/rules/common/assertions/utils.ts index d14d01033..e1d81d809 100644 --- a/packages/core/src/rules/common/assertions/utils.ts +++ b/packages/core/src/rules/common/assertions/utils.ts @@ -1,18 +1,18 @@ -import { asserts, runOnKeysSet, runOnValuesSet } from './asserts'; -import { colorize } from '../../../logger'; -import { isRef } from '../../../ref-utils'; -import { isTruthy, keysOf, isString } from '../../../utils'; - -import type { UserContext } from 'core/src/walk'; -import type { Asserts } from './asserts'; -import type { AssertionContext, AssertResult } from '../../../config'; -import type { Assertion, AssertionDefinition, AssertionLocators } from '.'; +import { asserts, runOnKeysSet, runOnValuesSet } from './asserts.js'; +import { colorize } from '../../../logger.js'; +import { isRef } from '../../../ref-utils.js'; +import { isTruthy, keysOf, isString } from '../../../utils.js'; + +import type { UserContext } from '../../../walk.js'; +import type { Asserts } from './asserts.js'; +import type { AssertionContext, AssertResult } from '../../../config/index.js'; +import type { Assertion, AssertionDefinition, AssertionLocators } from './index.js'; import type { Oas2Visitor, Oas3Visitor, SkipFunctionContext, VisitFunction, -} from '../../../visitors'; +} from '../../../visitors.js'; export type OrderDirection = 'asc' | 'desc'; diff --git a/packages/core/src/rules/common/info-contact.ts b/packages/core/src/rules/common/info-contact.ts index 70cae48db..f013011d7 100644 --- a/packages/core/src/rules/common/info-contact.ts +++ b/packages/core/src/rules/common/info-contact.ts @@ -1,6 +1,6 @@ -import { missingRequiredField } from '../utils'; +import { missingRequiredField } from '../utils.js'; -import type { Oas3Rule, Oas2Rule } from '../../visitors'; +import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; export const InfoContact: Oas3Rule | Oas2Rule = () => { return { diff --git a/packages/core/src/rules/common/info-license-url.ts b/packages/core/src/rules/common/info-license-url.ts index fcbdc03ea..68896b532 100644 --- a/packages/core/src/rules/common/info-license-url.ts +++ b/packages/core/src/rules/common/info-license-url.ts @@ -1,6 +1,6 @@ -import { validateDefinedAndNonEmpty } from '../utils'; +import { validateDefinedAndNonEmpty } from '../utils.js'; -import type { Oas3Rule, Oas2Rule } from '../../visitors'; +import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; export const InfoLicenseUrl: Oas3Rule | Oas2Rule = () => { return { diff --git a/packages/core/src/rules/common/info-license.ts b/packages/core/src/rules/common/info-license.ts index 1ed70975d..232402635 100644 --- a/packages/core/src/rules/common/info-license.ts +++ b/packages/core/src/rules/common/info-license.ts @@ -1,6 +1,6 @@ -import { missingRequiredField } from '../utils'; +import { missingRequiredField } from '../utils.js'; -import type { Oas3Rule, Oas2Rule } from '../../visitors'; +import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; export const InfoLicense: Oas3Rule | Oas2Rule = () => { return { diff --git a/packages/core/src/rules/common/no-ambiguous-paths.ts b/packages/core/src/rules/common/no-ambiguous-paths.ts index a8d2af5b2..10338fb34 100644 --- a/packages/core/src/rules/common/no-ambiguous-paths.ts +++ b/packages/core/src/rules/common/no-ambiguous-paths.ts @@ -1,7 +1,7 @@ -import type { Oas3Rule, Oas2Rule } from '../../visitors'; -import type { UserContext } from '../../walk'; -import type { Oas3Paths } from '../../typings/openapi'; -import type { Oas2Paths } from '../../typings/swagger'; +import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; +import type { UserContext } from '../../walk.js'; +import type { Oas3Paths } from '../../typings/openapi.js'; +import type { Oas2Paths } from '../../typings/swagger.js'; export const NoAmbiguousPaths: Oas3Rule | Oas2Rule = () => { return { diff --git a/packages/core/src/rules/common/no-enum-type-mismatch.ts b/packages/core/src/rules/common/no-enum-type-mismatch.ts index 9f3b5d402..84ccc93a3 100644 --- a/packages/core/src/rules/common/no-enum-type-mismatch.ts +++ b/packages/core/src/rules/common/no-enum-type-mismatch.ts @@ -1,9 +1,9 @@ -import { matchesJsonSchemaType, oasTypeOf } from '../utils'; +import { matchesJsonSchemaType, oasTypeOf } from '../utils.js'; -import type { Oas3Rule, Oas2Rule } from '../../visitors'; -import type { Oas2Schema } from '../../typings/swagger'; -import type { Oas3Schema } from '../../typings/openapi'; -import type { UserContext } from '../../walk'; +import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; +import type { Oas2Schema } from '../../typings/swagger.js'; +import type { Oas3Schema } from '../../typings/openapi.js'; +import type { UserContext } from '../../walk.js'; export const NoEnumTypeMismatch: Oas3Rule | Oas2Rule = () => { return { diff --git a/packages/core/src/rules/common/no-http-verbs-in-paths.ts b/packages/core/src/rules/common/no-http-verbs-in-paths.ts index 59560154f..62b2f08a9 100644 --- a/packages/core/src/rules/common/no-http-verbs-in-paths.ts +++ b/packages/core/src/rules/common/no-http-verbs-in-paths.ts @@ -1,9 +1,9 @@ -import { isPathParameter, splitCamelCaseIntoWords } from '../../utils'; +import { isPathParameter, splitCamelCaseIntoWords } from '../../utils.js'; -import type { Oas3Rule, Oas2Rule } from '../../visitors'; -import type { Oas2PathItem } from '../../typings/swagger'; -import type { Oas3PathItem } from '../../typings/openapi'; -import type { UserContext } from '../../walk'; +import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; +import type { Oas2PathItem } from '../../typings/swagger.js'; +import type { Oas3PathItem } from '../../typings/openapi.js'; +import type { UserContext } from '../../walk.js'; const httpMethods = ['get', 'head', 'post', 'put', 'patch', 'delete', 'options', 'trace']; diff --git a/packages/core/src/rules/common/no-identical-paths.ts b/packages/core/src/rules/common/no-identical-paths.ts index 988dec3e5..58b29f878 100644 --- a/packages/core/src/rules/common/no-identical-paths.ts +++ b/packages/core/src/rules/common/no-identical-paths.ts @@ -1,7 +1,7 @@ -import type { Oas3Rule, Oas2Rule } from '../../visitors'; -import type { UserContext } from '../../walk'; -import type { Oas3Paths } from '../../typings/openapi'; -import type { Oas2Paths } from '../../typings/swagger'; +import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; +import type { UserContext } from '../../walk.js'; +import type { Oas3Paths } from '../../typings/openapi.js'; +import type { Oas2Paths } from '../../typings/swagger.js'; export const NoIdenticalPaths: Oas3Rule | Oas2Rule = () => { return { diff --git a/packages/core/src/rules/common/no-invalid-parameter-examples.ts b/packages/core/src/rules/common/no-invalid-parameter-examples.ts index 740335dfe..51cbc818d 100644 --- a/packages/core/src/rules/common/no-invalid-parameter-examples.ts +++ b/packages/core/src/rules/common/no-invalid-parameter-examples.ts @@ -1,7 +1,7 @@ -import { getAdditionalPropertiesOption, validateExample } from '../utils'; +import { getAdditionalPropertiesOption, validateExample } from '../utils.js'; -import type { UserContext } from '../../walk'; -import type { Oas3Parameter } from '../../typings/openapi'; +import type { UserContext } from '../../walk.js'; +import type { Oas3Parameter } from '../../typings/openapi.js'; export const NoInvalidParameterExamples: any = (opts: any) => { const allowAdditionalProperties = getAdditionalPropertiesOption(opts) ?? false; diff --git a/packages/core/src/rules/common/no-invalid-schema-examples.ts b/packages/core/src/rules/common/no-invalid-schema-examples.ts index 51f3bf48a..08dbd372d 100644 --- a/packages/core/src/rules/common/no-invalid-schema-examples.ts +++ b/packages/core/src/rules/common/no-invalid-schema-examples.ts @@ -1,7 +1,7 @@ -import { getAdditionalPropertiesOption, validateExample } from '../utils'; +import { getAdditionalPropertiesOption, validateExample } from '../utils.js'; -import type { UserContext } from '../../walk'; -import type { Oas3_1Schema } from '../../typings/openapi'; +import type { UserContext } from '../../walk.js'; +import type { Oas3_1Schema } from '../../typings/openapi.js'; export const NoInvalidSchemaExamples: any = (opts: any) => { const allowAdditionalProperties = getAdditionalPropertiesOption(opts) ?? false; diff --git a/packages/core/src/rules/common/no-path-trailing-slash.ts b/packages/core/src/rules/common/no-path-trailing-slash.ts index 324ad938c..cb7ef89f7 100644 --- a/packages/core/src/rules/common/no-path-trailing-slash.ts +++ b/packages/core/src/rules/common/no-path-trailing-slash.ts @@ -1,5 +1,5 @@ -import type { Oas3Rule, Oas2Rule } from '../../visitors'; -import type { UserContext } from '../../walk'; +import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; +import type { UserContext } from '../../walk.js'; export const NoPathTrailingSlash: Oas3Rule | Oas2Rule = () => { return { diff --git a/packages/core/src/rules/common/no-required-schema-properties-undefined.ts b/packages/core/src/rules/common/no-required-schema-properties-undefined.ts index d52f6c100..1f67ff6c0 100644 --- a/packages/core/src/rules/common/no-required-schema-properties-undefined.ts +++ b/packages/core/src/rules/common/no-required-schema-properties-undefined.ts @@ -1,9 +1,9 @@ -import { isRef } from '../../ref-utils'; +import { isRef } from '../../ref-utils.js'; -import type { Oas2Rule, Oas3Rule } from '../../visitors'; -import type { Oas3Schema, Oas3_1Schema } from '../../typings/openapi'; -import type { Oas2Schema } from 'core/src/typings/swagger'; -import type { UserContext } from 'core/src/walk'; +import type { Oas2Rule, Oas3Rule } from '../../visitors.js'; +import type { Oas3Schema, Oas3_1Schema } from '../../typings/openapi.js'; +import type { Oas2Schema } from '../../typings/swagger.js'; +import type { UserContext } from '../../walk.js'; export const NoRequiredSchemaPropertiesUndefined: Oas3Rule | Oas2Rule = () => { return { diff --git a/packages/core/src/rules/common/operation-2xx-response.ts b/packages/core/src/rules/common/operation-2xx-response.ts index 201fdb6c6..eb944f259 100644 --- a/packages/core/src/rules/common/operation-2xx-response.ts +++ b/packages/core/src/rules/common/operation-2xx-response.ts @@ -1,7 +1,7 @@ -import { validateResponseCodes } from '../utils'; +import { validateResponseCodes } from '../utils.js'; -import type { Oas3Rule, Oas2Rule } from '../../visitors'; -import type { UserContext } from '../../walk'; +import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; +import type { UserContext } from '../../walk.js'; export const Operation2xxResponse: Oas3Rule | Oas2Rule = ({ validateWebhooks }) => { return { diff --git a/packages/core/src/rules/common/operation-4xx-response.ts b/packages/core/src/rules/common/operation-4xx-response.ts index e4f5f8f7b..4291868d7 100644 --- a/packages/core/src/rules/common/operation-4xx-response.ts +++ b/packages/core/src/rules/common/operation-4xx-response.ts @@ -1,7 +1,7 @@ -import { validateResponseCodes } from '../utils'; +import { validateResponseCodes } from '../utils.js'; -import type { Oas3Rule, Oas2Rule } from '../../visitors'; -import type { UserContext } from '../../walk'; +import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; +import type { UserContext } from '../../walk.js'; export const Operation4xxResponse: Oas3Rule | Oas2Rule = ({ validateWebhooks }) => { return { diff --git a/packages/core/src/rules/common/operation-description.ts b/packages/core/src/rules/common/operation-description.ts index 6f2bb45c0..e75575605 100644 --- a/packages/core/src/rules/common/operation-description.ts +++ b/packages/core/src/rules/common/operation-description.ts @@ -1,9 +1,9 @@ -import { validateDefinedAndNonEmpty } from '../utils'; +import { validateDefinedAndNonEmpty } from '../utils.js'; -import type { Oas3Rule, Oas2Rule } from '../../visitors'; -import type { UserContext } from '../../walk'; -import type { Oas2Operation } from '../../typings/swagger'; -import type { Oas3Operation } from '../../typings/openapi'; +import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; +import type { UserContext } from '../../walk.js'; +import type { Oas2Operation } from '../../typings/swagger.js'; +import type { Oas3Operation } from '../../typings/openapi.js'; export const OperationDescription: Oas3Rule | Oas2Rule = () => { return { diff --git a/packages/core/src/rules/common/operation-operationId-unique.ts b/packages/core/src/rules/common/operation-operationId-unique.ts index 54aa597ab..d90d36a37 100644 --- a/packages/core/src/rules/common/operation-operationId-unique.ts +++ b/packages/core/src/rules/common/operation-operationId-unique.ts @@ -1,7 +1,7 @@ -import type { Oas3Rule, Oas2Rule } from '../../visitors'; -import type { Oas2Operation } from '../../typings/swagger'; -import type { Oas3Operation } from '../../typings/openapi'; -import type { UserContext } from '../../walk'; +import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; +import type { Oas2Operation } from '../../typings/swagger.js'; +import type { Oas3Operation } from '../../typings/openapi.js'; +import type { UserContext } from '../../walk.js'; export const OperationIdUnique: Oas3Rule | Oas2Rule = () => { const seenOperations = new Set(); diff --git a/packages/core/src/rules/common/operation-operationId-url-safe.ts b/packages/core/src/rules/common/operation-operationId-url-safe.ts index 5f1c41080..00df6ee4a 100644 --- a/packages/core/src/rules/common/operation-operationId-url-safe.ts +++ b/packages/core/src/rules/common/operation-operationId-url-safe.ts @@ -1,7 +1,7 @@ -import type { Oas3Rule, Oas2Rule } from '../../visitors'; -import type { Oas2Operation } from '../../typings/swagger'; -import type { Oas3Operation } from '../../typings/openapi'; -import type { UserContext } from '../../walk'; +import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; +import type { Oas2Operation } from '../../typings/swagger.js'; +import type { Oas3Operation } from '../../typings/openapi.js'; +import type { UserContext } from '../../walk.js'; // eslint-disable-next-line no-useless-escape const validUrlSymbols = /^[A-Za-z0-9-._~:/?#\[\]@!\$&'()*+,;=]*$/; diff --git a/packages/core/src/rules/common/operation-operationId.ts b/packages/core/src/rules/common/operation-operationId.ts index b759a2ab0..e91877258 100644 --- a/packages/core/src/rules/common/operation-operationId.ts +++ b/packages/core/src/rules/common/operation-operationId.ts @@ -1,9 +1,9 @@ -import { validateDefinedAndNonEmpty } from '../utils'; +import { validateDefinedAndNonEmpty } from '../utils.js'; -import type { Oas3Rule, Oas2Rule } from '../../visitors'; -import type { UserContext } from '../../walk'; -import type { Oas2Operation } from '../../typings/swagger'; -import type { Oas3Operation } from '../../typings/openapi'; +import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; +import type { UserContext } from '../../walk.js'; +import type { Oas2Operation } from '../../typings/swagger.js'; +import type { Oas3Operation } from '../../typings/openapi.js'; export const OperationOperationId: Oas3Rule | Oas2Rule = () => { return { diff --git a/packages/core/src/rules/common/operation-parameters-unique.ts b/packages/core/src/rules/common/operation-parameters-unique.ts index 901dfb26d..43fe71664 100644 --- a/packages/core/src/rules/common/operation-parameters-unique.ts +++ b/packages/core/src/rules/common/operation-parameters-unique.ts @@ -1,7 +1,7 @@ -import type { Oas3Rule, Oas2Rule } from '../../visitors'; -import type { Oas2Parameter } from '../../typings/swagger'; -import type { Oas3Parameter } from '../../typings/openapi'; -import type { UserContext } from '../../walk'; +import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; +import type { Oas2Parameter } from '../../typings/swagger.js'; +import type { Oas3Parameter } from '../../typings/openapi.js'; +import type { UserContext } from '../../walk.js'; export const OperationParametersUnique: Oas3Rule | Oas2Rule = () => { let seenPathParams: Set; diff --git a/packages/core/src/rules/common/operation-singular-tag.ts b/packages/core/src/rules/common/operation-singular-tag.ts index 6e149f9ca..d070a0ac1 100644 --- a/packages/core/src/rules/common/operation-singular-tag.ts +++ b/packages/core/src/rules/common/operation-singular-tag.ts @@ -1,7 +1,7 @@ -import type { Oas3Rule, Oas2Rule } from '../../visitors'; -import type { Oas2Operation } from '../../typings/swagger'; -import type { Oas3Operation } from '../../typings/openapi'; -import type { UserContext } from '../../walk'; +import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; +import type { Oas2Operation } from '../../typings/swagger.js'; +import type { Oas3Operation } from '../../typings/openapi.js'; +import type { UserContext } from '../../walk.js'; export const OperationSingularTag: Oas3Rule | Oas2Rule = () => { return { diff --git a/packages/core/src/rules/common/operation-summary.ts b/packages/core/src/rules/common/operation-summary.ts index 18743ad9e..c1d87d4ac 100644 --- a/packages/core/src/rules/common/operation-summary.ts +++ b/packages/core/src/rules/common/operation-summary.ts @@ -1,9 +1,9 @@ -import { validateDefinedAndNonEmpty } from '../utils'; +import { validateDefinedAndNonEmpty } from '../utils.js'; -import type { Oas3Rule, Oas2Rule } from '../../visitors'; -import type { UserContext } from '../../walk'; -import type { Oas2Operation } from '../../typings/swagger'; -import type { Oas3Operation } from '../../typings/openapi'; +import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; +import type { UserContext } from '../../walk.js'; +import type { Oas2Operation } from '../../typings/swagger.js'; +import type { Oas3Operation } from '../../typings/openapi.js'; export const OperationSummary: Oas3Rule | Oas2Rule = () => { return { diff --git a/packages/core/src/rules/common/operation-tag-defined.ts b/packages/core/src/rules/common/operation-tag-defined.ts index e492dba7e..df8fbb881 100644 --- a/packages/core/src/rules/common/operation-tag-defined.ts +++ b/packages/core/src/rules/common/operation-tag-defined.ts @@ -1,7 +1,7 @@ -import type { Oas3Rule, Oas2Rule } from '../../visitors'; -import type { Oas2Definition, Oas2Operation } from '../../typings/swagger'; -import type { Oas3Definition, Oas3Operation } from '../../typings/openapi'; -import type { UserContext } from '../../walk'; +import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; +import type { Oas2Definition, Oas2Operation } from '../../typings/swagger.js'; +import type { Oas3Definition, Oas3Operation } from '../../typings/openapi.js'; +import type { UserContext } from '../../walk.js'; export const OperationTagDefined: Oas3Rule | Oas2Rule = () => { let definedTags: Set; diff --git a/packages/core/src/rules/common/parameter-description.ts b/packages/core/src/rules/common/parameter-description.ts index f1495b29e..6d59a6ac0 100644 --- a/packages/core/src/rules/common/parameter-description.ts +++ b/packages/core/src/rules/common/parameter-description.ts @@ -1,7 +1,7 @@ -import type { Oas3Rule, Oas2Rule } from '../../visitors'; -import type { Oas2Parameter } from '../../typings/swagger'; -import type { Oas3Parameter } from '../../typings/openapi'; -import type { UserContext } from '../../walk'; +import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; +import type { Oas2Parameter } from '../../typings/swagger.js'; +import type { Oas3Parameter } from '../../typings/openapi.js'; +import type { UserContext } from '../../walk.js'; export const ParameterDescription: Oas3Rule | Oas2Rule = () => { return { diff --git a/packages/core/src/rules/common/path-declaration-must-exist.ts b/packages/core/src/rules/common/path-declaration-must-exist.ts index 8a09ce31b..c9b23ed26 100644 --- a/packages/core/src/rules/common/path-declaration-must-exist.ts +++ b/packages/core/src/rules/common/path-declaration-must-exist.ts @@ -1,5 +1,5 @@ -import type { Oas3Rule, Oas2Rule } from '../../visitors'; -import type { UserContext } from '../../walk'; +import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; +import type { UserContext } from '../../walk.js'; export const PathDeclarationMustExist: Oas3Rule | Oas2Rule = () => { return { diff --git a/packages/core/src/rules/common/path-excludes-patterns.ts b/packages/core/src/rules/common/path-excludes-patterns.ts index 14988cbff..5bbfc4fbc 100644 --- a/packages/core/src/rules/common/path-excludes-patterns.ts +++ b/packages/core/src/rules/common/path-excludes-patterns.ts @@ -1,7 +1,7 @@ -import type { Oas2Rule, Oas3Rule } from '../../visitors'; -import type { Oas2PathItem } from '../../typings/swagger'; -import type { Oas3PathItem } from '../../typings/openapi'; -import type { UserContext } from '../../walk'; +import type { Oas2Rule, Oas3Rule } from '../../visitors.js'; +import type { Oas2PathItem } from '../../typings/swagger.js'; +import type { Oas3PathItem } from '../../typings/openapi.js'; +import type { UserContext } from '../../walk.js'; export const PathExcludesPatterns: Oas3Rule | Oas2Rule = ({ patterns }) => { return { diff --git a/packages/core/src/rules/common/path-http-verbs-order.ts b/packages/core/src/rules/common/path-http-verbs-order.ts index 3bfe0bcdd..6bf5ae4b2 100644 --- a/packages/core/src/rules/common/path-http-verbs-order.ts +++ b/packages/core/src/rules/common/path-http-verbs-order.ts @@ -1,7 +1,7 @@ -import type { Oas3Rule, Oas2Rule } from '../../visitors'; -import type { Oas2PathItem } from '../../typings/swagger'; -import type { Oas3PathItem } from '../../typings/openapi'; -import type { UserContext } from '../../walk'; +import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; +import type { Oas2PathItem } from '../../typings/swagger.js'; +import type { Oas3PathItem } from '../../typings/openapi.js'; +import type { UserContext } from '../../walk.js'; const defaultOrder = ['get', 'head', 'post', 'put', 'patch', 'delete', 'options', 'trace']; diff --git a/packages/core/src/rules/common/path-not-include-query.ts b/packages/core/src/rules/common/path-not-include-query.ts index eaeedfc7c..5d0766b04 100644 --- a/packages/core/src/rules/common/path-not-include-query.ts +++ b/packages/core/src/rules/common/path-not-include-query.ts @@ -1,5 +1,5 @@ -import type { Oas3Rule, Oas2Rule } from '../../visitors'; -import type { UserContext } from '../../walk'; +import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; +import type { UserContext } from '../../walk.js'; export const PathNotIncludeQuery: Oas3Rule | Oas2Rule = () => { return { diff --git a/packages/core/src/rules/common/path-params-defined.ts b/packages/core/src/rules/common/path-params-defined.ts index bbb696b86..b8df3f930 100644 --- a/packages/core/src/rules/common/path-params-defined.ts +++ b/packages/core/src/rules/common/path-params-defined.ts @@ -1,7 +1,7 @@ -import type { Oas3Rule, Oas2Rule } from '../../visitors'; -import type { Oas2Parameter } from '../../typings/swagger'; -import type { Oas3Parameter } from '../../typings/openapi'; -import type { UserContext } from '../../walk'; +import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; +import type { Oas2Parameter } from '../../typings/swagger.js'; +import type { Oas3Parameter } from '../../typings/openapi.js'; +import type { UserContext } from '../../walk.js'; const pathRegex = /\{([a-zA-Z0-9_.-]+)\}+/g; diff --git a/packages/core/src/rules/common/path-segment-plural.ts b/packages/core/src/rules/common/path-segment-plural.ts index 5c9485f46..a5f037c07 100644 --- a/packages/core/src/rules/common/path-segment-plural.ts +++ b/packages/core/src/rules/common/path-segment-plural.ts @@ -1,8 +1,8 @@ import * as pluralize from 'pluralize'; -import { isPathParameter } from '../../utils'; +import { isPathParameter } from '../../utils.js'; -import type { Oas3Rule, Oas2Rule } from '../../visitors'; -import type { UserContext } from '../../walk'; +import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; +import type { UserContext } from '../../walk.js'; export const PathSegmentPlural: Oas3Rule | Oas2Rule = (opts) => { const { ignoreLastPathSegment, exceptions } = opts; diff --git a/packages/core/src/rules/common/paths-kebab-case.ts b/packages/core/src/rules/common/paths-kebab-case.ts index deee184a2..0839543e2 100644 --- a/packages/core/src/rules/common/paths-kebab-case.ts +++ b/packages/core/src/rules/common/paths-kebab-case.ts @@ -1,5 +1,5 @@ -import type { Oas3Rule, Oas2Rule } from '../../visitors'; -import type { UserContext } from '../../walk'; +import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; +import type { UserContext } from '../../walk.js'; export const PathsKebabCase: Oas3Rule | Oas2Rule = () => { return { diff --git a/packages/core/src/rules/common/required-string-property-missing-min-length.ts b/packages/core/src/rules/common/required-string-property-missing-min-length.ts index beb6d1ae3..739674602 100644 --- a/packages/core/src/rules/common/required-string-property-missing-min-length.ts +++ b/packages/core/src/rules/common/required-string-property-missing-min-length.ts @@ -1,7 +1,7 @@ -import type { UserContext } from '../../walk'; -import type { Oas3Schema, Oas3_1Schema } from '../../typings/openapi'; -import type { Oas2Schema } from 'core/src/typings/swagger'; -import type { Oas3Rule } from 'core/src/visitors'; +import type { UserContext } from '../../walk.js'; +import type { Oas3Schema, Oas3_1Schema } from '../../typings/openapi.js'; +import type { Oas2Schema } from '../../typings/swagger.js'; +import type { Oas3Rule } from '../../visitors.js'; export const RequiredStringPropertyMissingMinLength: Oas3Rule = () => { let skipSchemaProperties: boolean; diff --git a/packages/core/src/rules/common/response-contains-header.ts b/packages/core/src/rules/common/response-contains-header.ts index 38ad9d6f7..83cd27a66 100644 --- a/packages/core/src/rules/common/response-contains-header.ts +++ b/packages/core/src/rules/common/response-contains-header.ts @@ -1,9 +1,9 @@ -import { getMatchingStatusCodeRange } from '../../utils'; +import { getMatchingStatusCodeRange } from '../../utils.js'; -import type { Oas2Rule, Oas3Rule } from '../../visitors'; -import type { UserContext } from '../../walk'; -import type { Oas3Response } from '../../typings/openapi'; -import type { Oas2Response } from '../../typings/swagger'; +import type { Oas2Rule, Oas3Rule } from '../../visitors.js'; +import type { UserContext } from '../../walk.js'; +import type { Oas3Response } from '../../typings/openapi.js'; +import type { Oas2Response } from '../../typings/swagger.js'; export const ResponseContainsHeader: Oas3Rule | Oas2Rule = (options) => { const names: Record = options.names || {}; diff --git a/packages/core/src/rules/common/scalar-property-missing-example.ts b/packages/core/src/rules/common/scalar-property-missing-example.ts index 4fd1c4f66..d3b3479ea 100644 --- a/packages/core/src/rules/common/scalar-property-missing-example.ts +++ b/packages/core/src/rules/common/scalar-property-missing-example.ts @@ -1,9 +1,9 @@ -import { SpecVersion } from '../../oas-types'; +import { SpecVersion } from '../../oas-types.js'; -import type { Oas2Rule, Oas3Rule } from '../../visitors'; -import type { UserContext } from '../../walk'; -import type { Oas2Schema } from '../../typings/swagger'; -import type { Oas3Schema, Oas3_1Schema } from '../../typings/openapi'; +import type { Oas2Rule, Oas3Rule } from '../../visitors.js'; +import type { UserContext } from '../../walk.js'; +import type { Oas2Schema } from '../../typings/swagger.js'; +import type { Oas3Schema, Oas3_1Schema } from '../../typings/openapi.js'; const SCALAR_TYPES = ['string', 'integer', 'number', 'boolean', 'null']; diff --git a/packages/core/src/rules/common/security-defined.ts b/packages/core/src/rules/common/security-defined.ts index 1e1ea0b98..81e0499e7 100644 --- a/packages/core/src/rules/common/security-defined.ts +++ b/packages/core/src/rules/common/security-defined.ts @@ -1,18 +1,18 @@ -import type { Oas3Rule, Oas2Rule } from '../../visitors'; -import type { Location } from '../../ref-utils'; -import type { UserContext } from '../../walk'; +import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; +import type { Location } from '../../ref-utils.js'; +import type { UserContext } from '../../walk.js'; import type { Oas2Definition, Oas2Operation, Oas2PathItem, Oas2SecurityScheme, -} from '../../typings/swagger'; +} from '../../typings/swagger.js'; import type { Oas3Definition, Oas3Operation, Oas3PathItem, Oas3SecurityScheme, -} from '../../typings/openapi'; +} from '../../typings/openapi.js'; export const SecurityDefined: Oas3Rule | Oas2Rule = (opts: { exceptions?: { path: string; methods?: string[] }[]; diff --git a/packages/core/src/rules/common/spec-strict-refs.ts b/packages/core/src/rules/common/spec-strict-refs.ts index c7ca6c202..dc1fd1285 100644 --- a/packages/core/src/rules/common/spec-strict-refs.ts +++ b/packages/core/src/rules/common/spec-strict-refs.ts @@ -1,6 +1,6 @@ -import { isRef } from '../../ref-utils'; +import { isRef } from '../../ref-utils.js'; -import type { Oas2Rule, Oas3Rule } from '../../visitors'; +import type { Oas2Rule, Oas3Rule } from '../../visitors.js'; export const SpecStrictRefs: Oas3Rule | Oas2Rule = () => { const nodesToSkip = [ diff --git a/packages/core/src/rules/common/spec.ts b/packages/core/src/rules/common/spec.ts index 3c2dfece5..ffc23520c 100644 --- a/packages/core/src/rules/common/spec.ts +++ b/packages/core/src/rules/common/spec.ts @@ -1,10 +1,10 @@ -import { isNamedType, SpecExtension } from '../../types'; -import { oasTypeOf, matchesJsonSchemaType, getSuggest, validateSchemaEnumType } from '../utils'; -import { isRef } from '../../ref-utils'; -import { isPlainObject } from '../../utils'; +import { isNamedType, SpecExtension } from '../../types/index.js'; +import { oasTypeOf, matchesJsonSchemaType, getSuggest, validateSchemaEnumType } from '../utils.js'; +import { isRef } from '../../ref-utils.js'; +import { isPlainObject } from '../../utils.js'; -import type { UserContext } from '../../walk'; -import type { Oas3Rule, Oas2Rule, Async2Rule, Async3Rule, ArazzoRule } from '../../visitors'; +import type { UserContext } from '../../walk.js'; +import type { Oas3Rule, Oas2Rule, Async2Rule, Async3Rule, ArazzoRule } from '../../visitors.js'; export const Spec: Oas3Rule | Oas2Rule | Async2Rule | Async3Rule | ArazzoRule = () => { return { diff --git a/packages/core/src/rules/common/tag-description.ts b/packages/core/src/rules/common/tag-description.ts index 3b0a6065d..f862667f3 100644 --- a/packages/core/src/rules/common/tag-description.ts +++ b/packages/core/src/rules/common/tag-description.ts @@ -1,6 +1,6 @@ -import { validateDefinedAndNonEmpty } from '../utils'; +import { validateDefinedAndNonEmpty } from '../utils.js'; -import type { Oas3Rule, Oas2Rule } from '../../visitors'; +import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; export const TagDescription: Oas3Rule | Oas2Rule = () => { return { diff --git a/packages/core/src/rules/common/tags-alphabetical.ts b/packages/core/src/rules/common/tags-alphabetical.ts index 63f85f2f5..3e874ede3 100644 --- a/packages/core/src/rules/common/tags-alphabetical.ts +++ b/packages/core/src/rules/common/tags-alphabetical.ts @@ -1,7 +1,7 @@ -import type { Oas3Rule, Oas2Rule } from '../../visitors'; -import type { Oas2Definition, Oas2Tag } from '../../typings/swagger'; -import type { Oas3Definition, Oas3Tag } from '../../typings/openapi'; -import type { UserContext } from '../../walk'; +import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; +import type { Oas2Definition, Oas2Tag } from '../../typings/swagger.js'; +import type { Oas3Definition, Oas3Tag } from '../../typings/openapi.js'; +import type { UserContext } from '../../walk.js'; export const TagsAlphabetical: Oas3Rule | Oas2Rule = ({ ignoreCase = false }) => { return { diff --git a/packages/core/src/rules/no-unresolved-refs.ts b/packages/core/src/rules/no-unresolved-refs.ts index e4058d7b0..9fa2497aa 100644 --- a/packages/core/src/rules/no-unresolved-refs.ts +++ b/packages/core/src/rules/no-unresolved-refs.ts @@ -1,8 +1,8 @@ -import { YamlParseError } from '../resolve'; +import { YamlParseError } from '../resolve.js'; -import type { Oas3Rule } from '../visitors'; -import type { ResolveResult, Problem } from '../walk'; -import type { Location } from '../ref-utils'; +import type { Oas3Rule } from '../visitors.js'; +import type { ResolveResult, Problem } from '../walk.js'; +import type { Location } from '../ref-utils.js'; export const NoUnresolvedRefs: Oas3Rule = () => { return { diff --git a/packages/core/src/rules/oas2/__tests__/boolean-parameter-prefixes.test.ts b/packages/core/src/rules/oas2/__tests__/boolean-parameter-prefixes.test.ts index 32007dd3d..50bcfc2b4 100644 --- a/packages/core/src/rules/oas2/__tests__/boolean-parameter-prefixes.test.ts +++ b/packages/core/src/rules/oas2/__tests__/boolean-parameter-prefixes.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { lintDocument } from '../../../lint'; -import { BaseResolver } from '../../../resolve'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { lintDocument } from '../../../lint.js'; +import { BaseResolver } from '../../../resolve.js'; describe('oas2 boolean-parameter-prefixes', () => { it('should report on boolean param without prefix', async () => { diff --git a/packages/core/src/rules/oas2/__tests__/response-contains-header.test.ts b/packages/core/src/rules/oas2/__tests__/response-contains-header.test.ts index bbb950890..35ec53f3b 100644 --- a/packages/core/src/rules/oas2/__tests__/response-contains-header.test.ts +++ b/packages/core/src/rules/oas2/__tests__/response-contains-header.test.ts @@ -1,7 +1,7 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { parseYamlToDocument, makeConfig } from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('Oas2 response-contains-header', () => { it('should report a response object not containing the header', async () => { diff --git a/packages/core/src/rules/oas2/__tests__/response-contains-property.test.ts b/packages/core/src/rules/oas2/__tests__/response-contains-property.test.ts index 0459f181a..3f9e99e8f 100644 --- a/packages/core/src/rules/oas2/__tests__/response-contains-property.test.ts +++ b/packages/core/src/rules/oas2/__tests__/response-contains-property.test.ts @@ -1,7 +1,7 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { parseYamlToDocument, makeConfig } from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('Oas2 response-contains-property', () => { it('should report a response object not containing the property', async () => { diff --git a/packages/core/src/rules/oas2/__tests__/spec/info.test.ts b/packages/core/src/rules/oas2/__tests__/spec/info.test.ts index 578ed993a..6baa58e97 100644 --- a/packages/core/src/rules/oas2/__tests__/spec/info.test.ts +++ b/packages/core/src/rules/oas2/__tests__/spec/info.test.ts @@ -1,5 +1,5 @@ import { outdent } from 'outdent'; -import { lintDoc } from './utils'; +import { lintDoc } from './utils.js'; describe('OpenAPI Schema 2.0', () => { it('should report if the title of the API is empty ', async () => { diff --git a/packages/core/src/rules/oas2/__tests__/spec/operation.test.ts b/packages/core/src/rules/oas2/__tests__/spec/operation.test.ts index 0fca55c0f..adf532305 100644 --- a/packages/core/src/rules/oas2/__tests__/spec/operation.test.ts +++ b/packages/core/src/rules/oas2/__tests__/spec/operation.test.ts @@ -1,5 +1,5 @@ import { outdent } from 'outdent'; -import { lintDoc } from './utils'; +import { lintDoc } from './utils.js'; describe('OpenAPI Schema 2.0', () => { it('should not report of a valid GET operation object', async () => { diff --git a/packages/core/src/rules/oas2/__tests__/spec/paths.test.ts b/packages/core/src/rules/oas2/__tests__/spec/paths.test.ts index 2c0ceab7a..fec732405 100644 --- a/packages/core/src/rules/oas2/__tests__/spec/paths.test.ts +++ b/packages/core/src/rules/oas2/__tests__/spec/paths.test.ts @@ -1,5 +1,5 @@ import { outdent } from 'outdent'; -import { lintDoc } from './utils'; +import { lintDoc } from './utils.js'; describe('OpenAPI Schema', () => { it('should not report if Path object is valid ', async () => { diff --git a/packages/core/src/rules/oas2/__tests__/spec/referenceableScalars.test.ts b/packages/core/src/rules/oas2/__tests__/spec/referenceableScalars.test.ts index a485cee98..3855aa52a 100644 --- a/packages/core/src/rules/oas2/__tests__/spec/referenceableScalars.test.ts +++ b/packages/core/src/rules/oas2/__tests__/spec/referenceableScalars.test.ts @@ -3,9 +3,9 @@ import { parseYamlToDocument, replaceSourceWithRef, makeConfig, -} from '../../../../../__tests__/utils'; -import { lintDocument } from '../../../../lint'; -import { BaseResolver } from '../../../../resolve'; +} from '../../../../../__tests__/utils.js'; +import { lintDocument } from '../../../../lint.js'; +import { BaseResolver } from '../../../../resolve.js'; describe('Referenceable scalars', () => { it('should not report $ref description', async () => { diff --git a/packages/core/src/rules/oas2/__tests__/spec/utils.ts b/packages/core/src/rules/oas2/__tests__/spec/utils.ts index 9c8bbc976..964dfcb5f 100644 --- a/packages/core/src/rules/oas2/__tests__/spec/utils.ts +++ b/packages/core/src/rules/oas2/__tests__/spec/utils.ts @@ -1,7 +1,7 @@ -import { StyleguideConfig, RuleConfig, resolveStyleguideConfig } from '../../../../config'; -import { parseYamlToDocument } from '../../../../../__tests__/utils'; -import { lintDocument } from '../../../../lint'; -import { BaseResolver } from '../../../../resolve'; +import { StyleguideConfig, RuleConfig, resolveStyleguideConfig } from '../../../../config/index.js'; +import { parseYamlToDocument } from '../../../../../__tests__/utils.js'; +import { lintDocument } from '../../../../lint.js'; +import { BaseResolver } from '../../../../resolve.js'; export async function lintDoc( source: string, diff --git a/packages/core/src/rules/oas2/boolean-parameter-prefixes.ts b/packages/core/src/rules/oas2/boolean-parameter-prefixes.ts index b9aa399c5..0f148076f 100644 --- a/packages/core/src/rules/oas2/boolean-parameter-prefixes.ts +++ b/packages/core/src/rules/oas2/boolean-parameter-prefixes.ts @@ -1,4 +1,4 @@ -import type { Oas2Rule } from '../../visitors'; +import type { Oas2Rule } from '../../visitors.js'; export type BooleanParameterPrefixesOptions = { prefixes?: string[]; diff --git a/packages/core/src/rules/oas2/index.ts b/packages/core/src/rules/oas2/index.ts index f54f2b2e6..5c8c35b3a 100644 --- a/packages/core/src/rules/oas2/index.ts +++ b/packages/core/src/rules/oas2/index.ts @@ -1,49 +1,49 @@ -import { Spec } from '../common/spec'; -import { NoInvalidSchemaExamples } from '../common/no-invalid-schema-examples'; -import { NoInvalidParameterExamples } from '../common/no-invalid-parameter-examples'; -import { InfoContact } from '../common/info-contact'; -import { InfoLicense } from '../common/info-license'; -import { InfoLicenseUrl } from '../common/info-license-url'; -import { BooleanParameterPrefixes } from './boolean-parameter-prefixes'; -import { TagDescription } from '../common/tag-description'; -import { TagsAlphabetical } from '../common/tags-alphabetical'; -import { PathsKebabCase } from '../common/paths-kebab-case'; -import { NoEnumTypeMismatch } from '../common/no-enum-type-mismatch'; -import { NoPathTrailingSlash } from '../common/no-path-trailing-slash'; -import { Operation2xxResponse } from '../common/operation-2xx-response'; -import { Operation4xxResponse } from '../common/operation-4xx-response'; -import { Assertions } from '../common/assertions'; -import { OperationIdUnique } from '../common/operation-operationId-unique'; -import { OperationParametersUnique } from '../common/operation-parameters-unique'; -import { PathParamsDefined } from '../common/path-params-defined'; -import { OperationTagDefined } from '../common/operation-tag-defined'; -import { PathDeclarationMustExist } from '../common/path-declaration-must-exist'; -import { OperationIdUrlSafe } from '../common/operation-operationId-url-safe'; -import { OperationDescription } from '../common/operation-description'; -import { PathNotIncludeQuery } from '../common/path-not-include-query'; -import { ParameterDescription } from '../common/parameter-description'; -import { OperationSingularTag } from '../common/operation-singular-tag'; -import { SecurityDefined } from '../common/security-defined'; -import { NoUnresolvedRefs } from '../no-unresolved-refs'; -import { PathHttpVerbsOrder } from '../common/path-http-verbs-order'; -import { NoIdenticalPaths } from '../common/no-identical-paths'; -import { OperationOperationId } from '../common/operation-operationId'; -import { OperationSummary } from '../common/operation-summary'; -import { NoAmbiguousPaths } from '../common/no-ambiguous-paths'; -import { NoHttpVerbsInPaths } from '../common/no-http-verbs-in-paths'; -import { PathExcludesPatterns } from '../common/path-excludes-patterns'; -import { RequestMimeType } from './request-mime-type'; -import { ResponseMimeType } from './response-mime-type'; -import { PathSegmentPlural } from '../common/path-segment-plural'; -import { ResponseContainsHeader } from '../common/response-contains-header'; -import { ResponseContainsProperty } from './response-contains-property'; -import { ScalarPropertyMissingExample } from '../common/scalar-property-missing-example'; -import { RequiredStringPropertyMissingMinLength } from '../common/required-string-property-missing-min-length'; -import { SpecStrictRefs } from '../common/spec-strict-refs'; -import { NoRequiredSchemaPropertiesUndefined } from '../common/no-required-schema-properties-undefined'; +import { Spec } from '../common/spec.js'; +import { NoInvalidSchemaExamples } from '../common/no-invalid-schema-examples.js'; +import { NoInvalidParameterExamples } from '../common/no-invalid-parameter-examples.js'; +import { InfoContact } from '../common/info-contact.js'; +import { InfoLicense } from '../common/info-license.js'; +import { InfoLicenseUrl } from '../common/info-license-url.js'; +import { BooleanParameterPrefixes } from './boolean-parameter-prefixes.js'; +import { TagDescription } from '../common/tag-description.js'; +import { TagsAlphabetical } from '../common/tags-alphabetical.js'; +import { PathsKebabCase } from '../common/paths-kebab-case.js'; +import { NoEnumTypeMismatch } from '../common/no-enum-type-mismatch.js'; +import { NoPathTrailingSlash } from '../common/no-path-trailing-slash.js'; +import { Operation2xxResponse } from '../common/operation-2xx-response.js'; +import { Operation4xxResponse } from '../common/operation-4xx-response.js'; +import { Assertions } from '../common/assertions/index.js'; +import { OperationIdUnique } from '../common/operation-operationId-unique.js'; +import { OperationParametersUnique } from '../common/operation-parameters-unique.js'; +import { PathParamsDefined } from '../common/path-params-defined.js'; +import { OperationTagDefined } from '../common/operation-tag-defined.js'; +import { PathDeclarationMustExist } from '../common/path-declaration-must-exist.js'; +import { OperationIdUrlSafe } from '../common/operation-operationId-url-safe.js'; +import { OperationDescription } from '../common/operation-description.js'; +import { PathNotIncludeQuery } from '../common/path-not-include-query.js'; +import { ParameterDescription } from '../common/parameter-description.js'; +import { OperationSingularTag } from '../common/operation-singular-tag.js'; +import { SecurityDefined } from '../common/security-defined.js'; +import { NoUnresolvedRefs } from '../no-unresolved-refs.js'; +import { PathHttpVerbsOrder } from '../common/path-http-verbs-order.js'; +import { NoIdenticalPaths } from '../common/no-identical-paths.js'; +import { OperationOperationId } from '../common/operation-operationId.js'; +import { OperationSummary } from '../common/operation-summary.js'; +import { NoAmbiguousPaths } from '../common/no-ambiguous-paths.js'; +import { NoHttpVerbsInPaths } from '../common/no-http-verbs-in-paths.js'; +import { PathExcludesPatterns } from '../common/path-excludes-patterns.js'; +import { RequestMimeType } from './request-mime-type.js'; +import { ResponseMimeType } from './response-mime-type.js'; +import { PathSegmentPlural } from '../common/path-segment-plural.js'; +import { ResponseContainsHeader } from '../common/response-contains-header.js'; +import { ResponseContainsProperty } from './response-contains-property.js'; +import { ScalarPropertyMissingExample } from '../common/scalar-property-missing-example.js'; +import { RequiredStringPropertyMissingMinLength } from '../common/required-string-property-missing-min-length.js'; +import { SpecStrictRefs } from '../common/spec-strict-refs.js'; +import { NoRequiredSchemaPropertiesUndefined } from '../common/no-required-schema-properties-undefined.js'; -import type { Oas2Rule } from '../../visitors'; -import type { Oas2RuleSet } from '../../oas-types'; +import type { Oas2Rule } from '../../visitors.js'; +import type { Oas2RuleSet } from '../../oas-types.js'; export const rules: Oas2RuleSet<'built-in'> = { spec: Spec as Oas2Rule, diff --git a/packages/core/src/rules/oas2/request-mime-type.ts b/packages/core/src/rules/oas2/request-mime-type.ts index 535ed4743..eeb57eaeb 100644 --- a/packages/core/src/rules/oas2/request-mime-type.ts +++ b/packages/core/src/rules/oas2/request-mime-type.ts @@ -1,7 +1,7 @@ -import { validateMimeType } from '../../utils'; +import { validateMimeType } from '../../utils.js'; -import type { Oas2Rule } from '../../visitors'; -import type { UserContext } from '../../walk'; +import type { Oas2Rule } from '../../visitors.js'; +import type { UserContext } from '../../walk.js'; export const RequestMimeType: Oas2Rule = ({ allowedValues }) => { return { diff --git a/packages/core/src/rules/oas2/response-contains-property.ts b/packages/core/src/rules/oas2/response-contains-property.ts index 9ba24814f..25ae934ac 100644 --- a/packages/core/src/rules/oas2/response-contains-property.ts +++ b/packages/core/src/rules/oas2/response-contains-property.ts @@ -1,7 +1,7 @@ -import { getMatchingStatusCodeRange } from '../../utils'; +import { getMatchingStatusCodeRange } from '../../utils.js'; -import type { Oas2Rule } from '../../visitors'; -import type { UserContext } from '../../walk'; +import type { Oas2Rule } from '../../visitors.js'; +import type { UserContext } from '../../walk.js'; export const ResponseContainsProperty: Oas2Rule = (options) => { const names: Record = options.names || {}; diff --git a/packages/core/src/rules/oas2/response-mime-type.ts b/packages/core/src/rules/oas2/response-mime-type.ts index bbbeccdc5..edb823519 100644 --- a/packages/core/src/rules/oas2/response-mime-type.ts +++ b/packages/core/src/rules/oas2/response-mime-type.ts @@ -1,7 +1,7 @@ -import { validateMimeType } from '../../utils'; +import { validateMimeType } from '../../utils.js'; -import type { Oas2Rule } from '../../visitors'; -import type { UserContext } from '../../walk'; +import type { Oas2Rule } from '../../visitors.js'; +import type { UserContext } from '../../walk.js'; export const ResponseMimeType: Oas2Rule = ({ allowedValues }) => { return { diff --git a/packages/core/src/rules/oas3/__tests__/array-parameter-serialization.test.ts b/packages/core/src/rules/oas3/__tests__/array-parameter-serialization.test.ts index bda47b8d8..30f09d880 100644 --- a/packages/core/src/rules/oas3/__tests__/array-parameter-serialization.test.ts +++ b/packages/core/src/rules/oas3/__tests__/array-parameter-serialization.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { lintDocument } from '../../../lint'; -import { BaseResolver } from '../../../resolve'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { lintDocument } from '../../../lint.js'; +import { BaseResolver } from '../../../resolve.js'; describe('oas3 array-parameter-serialization', () => { it('should report on array parameter without style and explode', async () => { diff --git a/packages/core/src/rules/oas3/__tests__/boolean-parameter-prefixes.test.ts b/packages/core/src/rules/oas3/__tests__/boolean-parameter-prefixes.test.ts index a90591466..72623cef3 100644 --- a/packages/core/src/rules/oas3/__tests__/boolean-parameter-prefixes.test.ts +++ b/packages/core/src/rules/oas3/__tests__/boolean-parameter-prefixes.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { lintDocument } from '../../../lint'; -import { BaseResolver } from '../../../resolve'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { lintDocument } from '../../../lint.js'; +import { BaseResolver } from '../../../resolve.js'; describe('oas3 boolean-parameter-prefixes', () => { it('should report on boolean param without prefix', async () => { diff --git a/packages/core/src/rules/oas3/__tests__/component-name-unique.test.ts b/packages/core/src/rules/oas3/__tests__/component-name-unique.test.ts index c79591a9d..7b7ac2883 100644 --- a/packages/core/src/rules/oas3/__tests__/component-name-unique.test.ts +++ b/packages/core/src/rules/oas3/__tests__/component-name-unique.test.ts @@ -1,6 +1,6 @@ import { outdent } from 'outdent'; -import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils'; -import { lintDocumentForTest } from './utils/lint-document-for-test'; +import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils.js'; +import { lintDocumentForTest } from './utils/lint-document-for-test.js'; describe('Oas3 component-name-unique', () => { describe('schema', () => { diff --git a/packages/core/src/rules/oas3/__tests__/no-empty-enum-servers.com.test.ts b/packages/core/src/rules/oas3/__tests__/no-empty-enum-servers.com.test.ts index ac9c12224..086474754 100644 --- a/packages/core/src/rules/oas3/__tests__/no-empty-enum-servers.com.test.ts +++ b/packages/core/src/rules/oas3/__tests__/no-empty-enum-servers.com.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('Oas3 as3-no-server-variables-empty-enum', () => { it('oas3-no-server-variables-empty-enum: should report on server object with empty enum and unknown enum value', async () => { diff --git a/packages/core/src/rules/oas3/__tests__/no-example-value-and-externalValue.test.ts b/packages/core/src/rules/oas3/__tests__/no-example-value-and-externalValue.test.ts index 14d385011..a4b76d9f3 100644 --- a/packages/core/src/rules/oas3/__tests__/no-example-value-and-externalValue.test.ts +++ b/packages/core/src/rules/oas3/__tests__/no-example-value-and-externalValue.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('Oas3 oas3-no-example-value-and-externalValue', () => { it('oas3-no-example-value-and-externalValue: should report on example object with both value and external value', async () => { diff --git a/packages/core/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts b/packages/core/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts index 146e79a75..099240925 100644 --- a/packages/core/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts +++ b/packages/core/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('no-invalid-media-type-examples', () => { it('should report on invalid example', async () => { diff --git a/packages/core/src/rules/oas3/__tests__/no-server-example.com.test.ts b/packages/core/src/rules/oas3/__tests__/no-server-example.com.test.ts index 7a1038375..d00c2c8da 100644 --- a/packages/core/src/rules/oas3/__tests__/no-server-example.com.test.ts +++ b/packages/core/src/rules/oas3/__tests__/no-server-example.com.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('Oas3 oas3-no-server-example.com', () => { it('oas3-no-server-example.com: should report on server object with "example.com" url', async () => { diff --git a/packages/core/src/rules/oas3/__tests__/no-server-trailing-slash.test.ts b/packages/core/src/rules/oas3/__tests__/no-server-trailing-slash.test.ts index 2a2ca1506..448791874 100644 --- a/packages/core/src/rules/oas3/__tests__/no-server-trailing-slash.test.ts +++ b/packages/core/src/rules/oas3/__tests__/no-server-trailing-slash.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('Oas3 oas3-no-server-trailing-slash', () => { it('oas3-no-server-trailing-slash: should report on server object with trailing slash', async () => { diff --git a/packages/core/src/rules/oas3/__tests__/no-unused-components.test.ts b/packages/core/src/rules/oas3/__tests__/no-unused-components.test.ts index 0d9367a37..88a02fef4 100644 --- a/packages/core/src/rules/oas3/__tests__/no-unused-components.test.ts +++ b/packages/core/src/rules/oas3/__tests__/no-unused-components.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('Oas3 no-unused-components', () => { it('should report unused components', async () => { diff --git a/packages/core/src/rules/oas3/__tests__/operation-4xx-problem-details-rfc7807.test.ts b/packages/core/src/rules/oas3/__tests__/operation-4xx-problem-details-rfc7807.test.ts index 5fa9a586f..15a55a083 100644 --- a/packages/core/src/rules/oas3/__tests__/operation-4xx-problem-details-rfc7807.test.ts +++ b/packages/core/src/rules/oas3/__tests__/operation-4xx-problem-details-rfc7807.test.ts @@ -1,7 +1,11 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { + parseYamlToDocument, + replaceSourceWithRef, + makeConfig, +} from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('Oas3 operation-4xx-problem-details-rfc7807', () => { it('should report `4xx` must have content type `application/problem+json` ', async () => { diff --git a/packages/core/src/rules/oas3/__tests__/response-contains-header.test.ts b/packages/core/src/rules/oas3/__tests__/response-contains-header.test.ts index 047c7d4b7..e036971d3 100644 --- a/packages/core/src/rules/oas3/__tests__/response-contains-header.test.ts +++ b/packages/core/src/rules/oas3/__tests__/response-contains-header.test.ts @@ -1,7 +1,7 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { parseYamlToDocument, makeConfig } from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('Oas3 response-contains-header', () => { it('should report a response object not containing the header', async () => { diff --git a/packages/core/src/rules/oas3/__tests__/response-contains-property.test.ts b/packages/core/src/rules/oas3/__tests__/response-contains-property.test.ts index 89cf8f95a..3ac88ffb2 100644 --- a/packages/core/src/rules/oas3/__tests__/response-contains-property.test.ts +++ b/packages/core/src/rules/oas3/__tests__/response-contains-property.test.ts @@ -1,7 +1,7 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { parseYamlToDocument, makeConfig } from '../../../../__tests__/utils.js'; +import { BaseResolver } from '../../../resolve.js'; describe('Oas3 response-contains-property', () => { it('should report a response object not containing the property', async () => { diff --git a/packages/core/src/rules/oas3/__tests__/spec-components-invalid-map-name.test.ts b/packages/core/src/rules/oas3/__tests__/spec-components-invalid-map-name.test.ts index 92f9629fb..9d2b6e3e8 100644 --- a/packages/core/src/rules/oas3/__tests__/spec-components-invalid-map-name.test.ts +++ b/packages/core/src/rules/oas3/__tests__/spec-components-invalid-map-name.test.ts @@ -1,7 +1,7 @@ -import { makeConfig, parseYamlToDocument } from '../../../../__tests__/utils'; +import { makeConfig, parseYamlToDocument } from '../../../../__tests__/utils.js'; import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { BaseResolver } from '../../../resolve'; +import { lintDocument } from '../../../lint.js'; +import { BaseResolver } from '../../../resolve.js'; describe('Oas3 spec-components-invalid-map-name', () => { it('should report about invalid keys inside components', async () => { diff --git a/packages/core/src/rules/oas3/__tests__/spec/callbacks.test.ts b/packages/core/src/rules/oas3/__tests__/spec/callbacks.test.ts index 37c92d365..ec2c5efa8 100644 --- a/packages/core/src/rules/oas3/__tests__/spec/callbacks.test.ts +++ b/packages/core/src/rules/oas3/__tests__/spec/callbacks.test.ts @@ -1,5 +1,5 @@ import { outdent } from 'outdent'; -import { validateDoc } from './utils'; +import { validateDoc } from './utils.js'; it('should not fail on valid callbacks object', async () => { const source = outdent` diff --git a/packages/core/src/rules/oas3/__tests__/spec/info.test.ts b/packages/core/src/rules/oas3/__tests__/spec/info.test.ts index a9262a16f..7526f35ef 100644 --- a/packages/core/src/rules/oas3/__tests__/spec/info.test.ts +++ b/packages/core/src/rules/oas3/__tests__/spec/info.test.ts @@ -1,5 +1,5 @@ import { outdent } from 'outdent'; -import { validateDoc } from './utils'; +import { validateDoc } from './utils.js'; describe('OpenAPI Schema', () => { it('should report if the title of the API is empty ', async () => { diff --git a/packages/core/src/rules/oas3/__tests__/spec/operation.test.ts b/packages/core/src/rules/oas3/__tests__/spec/operation.test.ts index 0904552b1..57fb2e796 100644 --- a/packages/core/src/rules/oas3/__tests__/spec/operation.test.ts +++ b/packages/core/src/rules/oas3/__tests__/spec/operation.test.ts @@ -1,5 +1,5 @@ import { outdent } from 'outdent'; -import { validateDoc } from './utils'; +import { validateDoc } from './utils.js'; it('should not report if summary field is valid', async () => { const source = outdent` diff --git a/packages/core/src/rules/oas3/__tests__/spec/paths.test.ts b/packages/core/src/rules/oas3/__tests__/spec/paths.test.ts index 79512913f..8b89baf0f 100644 --- a/packages/core/src/rules/oas3/__tests__/spec/paths.test.ts +++ b/packages/core/src/rules/oas3/__tests__/spec/paths.test.ts @@ -1,5 +1,5 @@ import { outdent } from 'outdent'; -import { validateDoc } from './utils'; +import { validateDoc } from './utils.js'; describe('OpenAPI Schema', () => { it('should not report if Path object is valid ', async () => { diff --git a/packages/core/src/rules/oas3/__tests__/spec/referenceableScalars.test.ts b/packages/core/src/rules/oas3/__tests__/spec/referenceableScalars.test.ts index 8a31af5e0..af87077d4 100644 --- a/packages/core/src/rules/oas3/__tests__/spec/referenceableScalars.test.ts +++ b/packages/core/src/rules/oas3/__tests__/spec/referenceableScalars.test.ts @@ -1,9 +1,9 @@ import { outdent } from 'outdent'; -import { parseYamlToDocument, replaceSourceWithRef } from '../../../../../__tests__/utils'; -import { lintDocument } from '../../../../lint'; -import { StyleguideConfig } from '../../../..'; -import { BaseResolver } from '../../../../resolve'; -import { resolveStyleguideConfig } from '../../../../config'; +import { parseYamlToDocument, replaceSourceWithRef } from '../../../../../__tests__/utils.js'; +import { lintDocument } from '../../../../lint.js'; +import { StyleguideConfig } from '../../../../index.js'; +import { BaseResolver } from '../../../../resolve.js'; +import { resolveStyleguideConfig } from '../../../../config/index.js'; describe('Referenceable scalars', () => { it('should not report $ref description', async () => { diff --git a/packages/core/src/rules/oas3/__tests__/spec/servers.test.ts b/packages/core/src/rules/oas3/__tests__/spec/servers.test.ts index da5272546..b053f2578 100644 --- a/packages/core/src/rules/oas3/__tests__/spec/servers.test.ts +++ b/packages/core/src/rules/oas3/__tests__/spec/servers.test.ts @@ -1,5 +1,5 @@ import { outdent } from 'outdent'; -import { validateDoc } from './utils'; +import { validateDoc } from './utils.js'; describe('OpenAPI Schema', () => { it('should not report on valid Server Object', async () => { diff --git a/packages/core/src/rules/oas3/__tests__/spec/spec.test.ts b/packages/core/src/rules/oas3/__tests__/spec/spec.test.ts index e41908c4f..114504c47 100644 --- a/packages/core/src/rules/oas3/__tests__/spec/spec.test.ts +++ b/packages/core/src/rules/oas3/__tests__/spec/spec.test.ts @@ -1,9 +1,14 @@ import { outdent } from 'outdent'; -import { lintDocument } from '../../../../lint'; -import { parseYamlToDocument, replaceSourceWithRef } from '../../../../../__tests__/utils'; -import { StyleguideConfig, defaultPlugin, resolvePlugins, resolvePreset } from '../../../../config'; +import { lintDocument } from '../../../../lint.js'; +import { parseYamlToDocument, replaceSourceWithRef } from '../../../../../__tests__/utils.js'; +import { + StyleguideConfig, + defaultPlugin, + resolvePlugins, + resolvePreset, +} from '../../../../config/index.js'; -import { BaseResolver } from '../../../../resolve'; +import { BaseResolver } from '../../../../resolve.js'; const plugins = resolvePlugins([defaultPlugin]); const pressets = resolvePreset('all', plugins); diff --git a/packages/core/src/rules/oas3/__tests__/spec/utils.ts b/packages/core/src/rules/oas3/__tests__/spec/utils.ts index 4057dd4e8..27c50a7f2 100644 --- a/packages/core/src/rules/oas3/__tests__/spec/utils.ts +++ b/packages/core/src/rules/oas3/__tests__/spec/utils.ts @@ -1,7 +1,7 @@ -import { StyleguideConfig, RuleConfig, resolveStyleguideConfig } from '../../../../config'; -import { parseYamlToDocument } from '../../../../../__tests__/utils'; -import { lintDocument } from '../../../../lint'; -import { BaseResolver } from '../../../../resolve'; +import { StyleguideConfig, RuleConfig, resolveStyleguideConfig } from '../../../../config/index.js'; +import { parseYamlToDocument } from '../../../../../__tests__/utils.js'; +import { lintDocument } from '../../../../lint.js'; +import { BaseResolver } from '../../../../resolve.js'; export async function validateDoc( source: string, diff --git a/packages/core/src/rules/oas3/__tests__/utils/lint-document-for-test.ts b/packages/core/src/rules/oas3/__tests__/utils/lint-document-for-test.ts index b13266bef..bae3fa80a 100644 --- a/packages/core/src/rules/oas3/__tests__/utils/lint-document-for-test.ts +++ b/packages/core/src/rules/oas3/__tests__/utils/lint-document-for-test.ts @@ -1,7 +1,7 @@ -import { BaseResolver, Document } from '../../../../resolve'; -import { makeConfig, parseYamlToDocument } from '../../../../../__tests__/utils'; -import { lintDocument } from '../../../../lint'; -import { RuleConfig } from '../../../../config'; +import { BaseResolver, Document } from '../../../../resolve.js'; +import { makeConfig, parseYamlToDocument } from '../../../../../__tests__/utils.js'; +import { lintDocument } from '../../../../lint.js'; +import { RuleConfig } from '../../../../config/index.js'; export async function lintDocumentForTest( rules: Record, diff --git a/packages/core/src/rules/oas3/array-parameter-serialization.ts b/packages/core/src/rules/oas3/array-parameter-serialization.ts index 2ca6e206e..07d1bc021 100644 --- a/packages/core/src/rules/oas3/array-parameter-serialization.ts +++ b/packages/core/src/rules/oas3/array-parameter-serialization.ts @@ -1,7 +1,7 @@ -import { isRef } from '../../ref-utils'; +import { isRef } from '../../ref-utils.js'; -import type { Oas3Rule, Oas3Visitor } from '../../visitors'; -import type { Oas3_1Schema, Oas3Parameter } from '../../typings/openapi'; +import type { Oas3Rule, Oas3Visitor } from '../../visitors.js'; +import type { Oas3_1Schema, Oas3Parameter } from '../../typings/openapi.js'; export type ArrayParameterSerializationOptions = { in?: string[]; diff --git a/packages/core/src/rules/oas3/boolean-parameter-prefixes.ts b/packages/core/src/rules/oas3/boolean-parameter-prefixes.ts index e9ab744f1..dcbe9376f 100644 --- a/packages/core/src/rules/oas3/boolean-parameter-prefixes.ts +++ b/packages/core/src/rules/oas3/boolean-parameter-prefixes.ts @@ -1,4 +1,4 @@ -import type { Oas3Rule } from '../../visitors'; +import type { Oas3Rule } from '../../visitors.js'; export type BooleanParameterPrefixesOptions = { prefixes?: string[]; diff --git a/packages/core/src/rules/oas3/component-name-unique.ts b/packages/core/src/rules/oas3/component-name-unique.ts index caad60179..edee6da19 100644 --- a/packages/core/src/rules/oas3/component-name-unique.ts +++ b/packages/core/src/rules/oas3/component-name-unique.ts @@ -1,5 +1,5 @@ -import type { Problem, UserContext } from '../../walk'; -import type { Oas2Rule, Oas3Rule, Oas3Visitor } from '../../visitors'; +import type { Problem, UserContext } from '../../walk.js'; +import type { Oas2Rule, Oas3Rule, Oas3Visitor } from '../../visitors.js'; import type { Oas3Definition, Oas3Parameter, @@ -7,7 +7,7 @@ import type { Oas3Response, Oas3Schema, OasRef, -} from '../../typings/openapi'; +} from '../../typings/openapi.js'; const TYPE_NAME_SCHEMA = 'Schema'; const TYPE_NAME_PARAMETER = 'Parameter'; diff --git a/packages/core/src/rules/oas3/index.ts b/packages/core/src/rules/oas3/index.ts index 5e0c1df84..60b5ce152 100644 --- a/packages/core/src/rules/oas3/index.ts +++ b/packages/core/src/rules/oas3/index.ts @@ -1,61 +1,61 @@ -import { Spec } from '../common/spec'; -import { Operation2xxResponse } from '../common/operation-2xx-response'; -import { Operation4xxResponse } from '../common/operation-4xx-response'; -import { Assertions } from '../common/assertions'; -import { OperationIdUnique } from '../common/operation-operationId-unique'; -import { OperationParametersUnique } from '../common/operation-parameters-unique'; -import { PathParamsDefined } from '../common/path-params-defined'; -import { OperationTagDefined } from '../common/operation-tag-defined'; -import { NoExampleValueAndExternalValue } from './no-example-value-and-externalValue'; -import { NoEnumTypeMismatch } from '../common/no-enum-type-mismatch'; -import { NoPathTrailingSlash } from '../common/no-path-trailing-slash'; -import { PathDeclarationMustExist } from '../common/path-declaration-must-exist'; -import { OperationIdUrlSafe } from '../common/operation-operationId-url-safe'; -import { TagsAlphabetical } from '../common/tags-alphabetical'; -import { NoServerExample } from './no-server-example.com'; -import { NoServerTrailingSlash } from './no-server-trailing-slash'; -import { TagDescription } from '../common/tag-description'; -import { InfoContact } from '../common/info-contact'; -import { InfoLicense } from '../common/info-license'; -import { InfoLicenseUrl } from '../common/info-license-url'; -import { OperationDescription } from '../common/operation-description'; -import { NoUnusedComponents } from './no-unused-components'; -import { PathNotIncludeQuery } from '../common/path-not-include-query'; -import { ParameterDescription } from '../common/parameter-description'; -import { OperationSingularTag } from '../common/operation-singular-tag'; -import { SecurityDefined } from '../common/security-defined'; -import { NoUnresolvedRefs } from '../no-unresolved-refs'; -import { BooleanParameterPrefixes } from './boolean-parameter-prefixes'; -import { PathsKebabCase } from '../common/paths-kebab-case'; -import { PathHttpVerbsOrder } from '../common/path-http-verbs-order'; -import { NoEmptyServers } from './no-empty-servers'; -import { ValidContentExamples } from './no-invalid-media-type-examples'; -import { NoIdenticalPaths } from '../common/no-identical-paths'; -import { NoUndefinedServerVariable } from './no-undefined-server-variable'; -import { OperationOperationId } from '../common/operation-operationId'; -import { OperationSummary } from '../common/operation-summary'; -import { NoAmbiguousPaths } from '../common/no-ambiguous-paths'; -import { NoServerVariablesEmptyEnum } from './no-server-variables-empty-enum'; -import { NoHttpVerbsInPaths } from '../common/no-http-verbs-in-paths'; -import { RequestMimeType } from './request-mime-type'; -import { ResponseMimeType } from './response-mime-type'; -import { PathSegmentPlural } from '../common/path-segment-plural'; -import { PathExcludesPatterns } from '../common/path-excludes-patterns'; -import { NoInvalidSchemaExamples } from '../common/no-invalid-schema-examples'; -import { NoInvalidParameterExamples } from '../common/no-invalid-parameter-examples'; -import { ResponseContainsHeader } from '../common/response-contains-header'; -import { ResponseContainsProperty } from './response-contains-property'; -import { ScalarPropertyMissingExample } from '../common/scalar-property-missing-example'; -import { SpecComponentsInvalidMapName } from './spec-components-invalid-map-name'; -import { Operation4xxProblemDetailsRfc7807 } from './operation-4xx-problem-details-rfc7807'; -import { RequiredStringPropertyMissingMinLength } from '../common/required-string-property-missing-min-length'; -import { SpecStrictRefs } from '../common/spec-strict-refs'; -import { ComponentNameUnique } from './component-name-unique'; -import { ArrayParameterSerialization } from './array-parameter-serialization'; -import { NoRequiredSchemaPropertiesUndefined } from '../common/no-required-schema-properties-undefined'; +import { Spec } from '../common/spec.js'; +import { Operation2xxResponse } from '../common/operation-2xx-response.js'; +import { Operation4xxResponse } from '../common/operation-4xx-response.js'; +import { Assertions } from '../common/assertions/index.js'; +import { OperationIdUnique } from '../common/operation-operationId-unique.js'; +import { OperationParametersUnique } from '../common/operation-parameters-unique.js'; +import { PathParamsDefined } from '../common/path-params-defined.js'; +import { OperationTagDefined } from '../common/operation-tag-defined.js'; +import { NoExampleValueAndExternalValue } from './no-example-value-and-externalValue.js'; +import { NoEnumTypeMismatch } from '../common/no-enum-type-mismatch.js'; +import { NoPathTrailingSlash } from '../common/no-path-trailing-slash.js'; +import { PathDeclarationMustExist } from '../common/path-declaration-must-exist.js'; +import { OperationIdUrlSafe } from '../common/operation-operationId-url-safe.js'; +import { TagsAlphabetical } from '../common/tags-alphabetical.js'; +import { NoServerExample } from './no-server-example.com.js'; +import { NoServerTrailingSlash } from './no-server-trailing-slash.js'; +import { TagDescription } from '../common/tag-description.js'; +import { InfoContact } from '../common/info-contact.js'; +import { InfoLicense } from '../common/info-license.js'; +import { InfoLicenseUrl } from '../common/info-license-url.js'; +import { OperationDescription } from '../common/operation-description.js'; +import { NoUnusedComponents } from './no-unused-components.js'; +import { PathNotIncludeQuery } from '../common/path-not-include-query.js'; +import { ParameterDescription } from '../common/parameter-description.js'; +import { OperationSingularTag } from '../common/operation-singular-tag.js'; +import { SecurityDefined } from '../common/security-defined.js'; +import { NoUnresolvedRefs } from '../no-unresolved-refs.js'; +import { BooleanParameterPrefixes } from './boolean-parameter-prefixes.js'; +import { PathsKebabCase } from '../common/paths-kebab-case.js'; +import { PathHttpVerbsOrder } from '../common/path-http-verbs-order.js'; +import { NoEmptyServers } from './no-empty-servers.js'; +import { ValidContentExamples } from './no-invalid-media-type-examples.js'; +import { NoIdenticalPaths } from '../common/no-identical-paths.js'; +import { NoUndefinedServerVariable } from './no-undefined-server-variable.js'; +import { OperationOperationId } from '../common/operation-operationId.js'; +import { OperationSummary } from '../common/operation-summary.js'; +import { NoAmbiguousPaths } from '../common/no-ambiguous-paths.js'; +import { NoServerVariablesEmptyEnum } from './no-server-variables-empty-enum.js'; +import { NoHttpVerbsInPaths } from '../common/no-http-verbs-in-paths.js'; +import { RequestMimeType } from './request-mime-type.js'; +import { ResponseMimeType } from './response-mime-type.js'; +import { PathSegmentPlural } from '../common/path-segment-plural.js'; +import { PathExcludesPatterns } from '../common/path-excludes-patterns.js'; +import { NoInvalidSchemaExamples } from '../common/no-invalid-schema-examples.js'; +import { NoInvalidParameterExamples } from '../common/no-invalid-parameter-examples.js'; +import { ResponseContainsHeader } from '../common/response-contains-header.js'; +import { ResponseContainsProperty } from './response-contains-property.js'; +import { ScalarPropertyMissingExample } from '../common/scalar-property-missing-example.js'; +import { SpecComponentsInvalidMapName } from './spec-components-invalid-map-name.js'; +import { Operation4xxProblemDetailsRfc7807 } from './operation-4xx-problem-details-rfc7807.js'; +import { RequiredStringPropertyMissingMinLength } from '../common/required-string-property-missing-min-length.js'; +import { SpecStrictRefs } from '../common/spec-strict-refs.js'; +import { ComponentNameUnique } from './component-name-unique.js'; +import { ArrayParameterSerialization } from './array-parameter-serialization.js'; +import { NoRequiredSchemaPropertiesUndefined } from '../common/no-required-schema-properties-undefined.js'; -import type { Oas3RuleSet } from '../../oas-types'; -import type { Oas3Rule } from '../../visitors'; +import type { Oas3RuleSet } from '../../oas-types.js'; +import type { Oas3Rule } from '../../visitors.js'; export const rules: Oas3RuleSet<'built-in'> = { spec: Spec as Oas3Rule, diff --git a/packages/core/src/rules/oas3/no-empty-servers.ts b/packages/core/src/rules/oas3/no-empty-servers.ts index 781f0f6f9..1092352a3 100644 --- a/packages/core/src/rules/oas3/no-empty-servers.ts +++ b/packages/core/src/rules/oas3/no-empty-servers.ts @@ -1,4 +1,4 @@ -import type { Oas3Rule } from '../../visitors'; +import type { Oas3Rule } from '../../visitors.js'; export const NoEmptyServers: Oas3Rule = () => { return { diff --git a/packages/core/src/rules/oas3/no-example-value-and-externalValue.ts b/packages/core/src/rules/oas3/no-example-value-and-externalValue.ts index c0bfe48c0..320416006 100644 --- a/packages/core/src/rules/oas3/no-example-value-and-externalValue.ts +++ b/packages/core/src/rules/oas3/no-example-value-and-externalValue.ts @@ -1,4 +1,4 @@ -import type { Oas3Rule } from '../../visitors'; +import type { Oas3Rule } from '../../visitors.js'; export const NoExampleValueAndExternalValue: Oas3Rule = () => { return { diff --git a/packages/core/src/rules/oas3/no-invalid-media-type-examples.ts b/packages/core/src/rules/oas3/no-invalid-media-type-examples.ts index 951dde7ac..1f073d9d2 100644 --- a/packages/core/src/rules/oas3/no-invalid-media-type-examples.ts +++ b/packages/core/src/rules/oas3/no-invalid-media-type-examples.ts @@ -1,10 +1,10 @@ -import { isRef } from '../../ref-utils'; -import { getAdditionalPropertiesOption, validateExample } from '../utils'; +import { isRef } from '../../ref-utils.js'; +import { getAdditionalPropertiesOption, validateExample } from '../utils.js'; -import type { Oas3Rule } from '../../visitors'; -import type { Location } from '../../ref-utils'; -import type { Oas3Example } from '../../typings/openapi'; -import type { UserContext } from '../../walk'; +import type { Oas3Rule } from '../../visitors.js'; +import type { Location } from '../../ref-utils.js'; +import type { Oas3Example } from '../../typings/openapi.js'; +import type { UserContext } from '../../walk.js'; export const ValidContentExamples: Oas3Rule = (opts) => { const allowAdditionalProperties = getAdditionalPropertiesOption(opts) ?? false; diff --git a/packages/core/src/rules/oas3/no-server-example.com.ts b/packages/core/src/rules/oas3/no-server-example.com.ts index 641bbac61..ff68c044f 100644 --- a/packages/core/src/rules/oas3/no-server-example.com.ts +++ b/packages/core/src/rules/oas3/no-server-example.com.ts @@ -1,4 +1,4 @@ -import type { Oas3Rule } from '../../visitors'; +import type { Oas3Rule } from '../../visitors.js'; export const NoServerExample: Oas3Rule = () => { return { diff --git a/packages/core/src/rules/oas3/no-server-trailing-slash.ts b/packages/core/src/rules/oas3/no-server-trailing-slash.ts index a7fcb1e71..b9863d4b7 100644 --- a/packages/core/src/rules/oas3/no-server-trailing-slash.ts +++ b/packages/core/src/rules/oas3/no-server-trailing-slash.ts @@ -1,4 +1,4 @@ -import type { Oas3Rule } from '../../visitors'; +import type { Oas3Rule } from '../../visitors.js'; export const NoServerTrailingSlash: Oas3Rule = () => { return { diff --git a/packages/core/src/rules/oas3/no-server-variables-empty-enum.ts b/packages/core/src/rules/oas3/no-server-variables-empty-enum.ts index cb6593e6f..48e032412 100644 --- a/packages/core/src/rules/oas3/no-server-variables-empty-enum.ts +++ b/packages/core/src/rules/oas3/no-server-variables-empty-enum.ts @@ -1,5 +1,5 @@ -import type { Oas3Server } from '../../typings/openapi'; -import type { Oas3Rule } from '../../visitors'; +import type { Oas3Server } from '../../typings/openapi.js'; +import type { Oas3Rule } from '../../visitors.js'; enum enumError { empty = 'empty', diff --git a/packages/core/src/rules/oas3/no-undefined-server-variable.ts b/packages/core/src/rules/oas3/no-undefined-server-variable.ts index 445a1b7ce..99dec419c 100644 --- a/packages/core/src/rules/oas3/no-undefined-server-variable.ts +++ b/packages/core/src/rules/oas3/no-undefined-server-variable.ts @@ -1,4 +1,4 @@ -import type { Oas3Rule } from '../../visitors'; +import type { Oas3Rule } from '../../visitors.js'; export const NoUndefinedServerVariable: Oas3Rule = () => { return { diff --git a/packages/core/src/rules/oas3/no-unused-components.ts b/packages/core/src/rules/oas3/no-unused-components.ts index 0b8aece06..863689807 100644 --- a/packages/core/src/rules/oas3/no-unused-components.ts +++ b/packages/core/src/rules/oas3/no-unused-components.ts @@ -1,5 +1,5 @@ -import type { Oas3Rule } from '../../visitors'; -import type { Location } from '../../ref-utils'; +import type { Oas3Rule } from '../../visitors.js'; +import type { Location } from '../../ref-utils.js'; export const NoUnusedComponents: Oas3Rule = () => { const components = new Map(); diff --git a/packages/core/src/rules/oas3/operation-4xx-problem-details-rfc7807.ts b/packages/core/src/rules/oas3/operation-4xx-problem-details-rfc7807.ts index a682328cf..e2380008c 100644 --- a/packages/core/src/rules/oas3/operation-4xx-problem-details-rfc7807.ts +++ b/packages/core/src/rules/oas3/operation-4xx-problem-details-rfc7807.ts @@ -1,7 +1,7 @@ -import { validateDefinedAndNonEmpty } from '../utils'; +import { validateDefinedAndNonEmpty } from '../utils.js'; -import type { Oas3Rule } from '../../visitors'; -import type { UserContext } from '../../walk'; +import type { Oas3Rule } from '../../visitors.js'; +import type { UserContext } from '../../walk.js'; /** * Validation according to rfc7807 - https://datatracker.ietf.org/doc/html/rfc7807 diff --git a/packages/core/src/rules/oas3/request-mime-type.ts b/packages/core/src/rules/oas3/request-mime-type.ts index 75bbb4099..e1c6f1123 100644 --- a/packages/core/src/rules/oas3/request-mime-type.ts +++ b/packages/core/src/rules/oas3/request-mime-type.ts @@ -1,7 +1,7 @@ -import { validateMimeTypeOAS3 } from '../../utils'; +import { validateMimeTypeOAS3 } from '../../utils.js'; -import type { Oas3Rule } from '../../visitors'; -import type { UserContext } from '../../walk'; +import type { Oas3Rule } from '../../visitors.js'; +import type { UserContext } from '../../walk.js'; export const RequestMimeType: Oas3Rule = ({ allowedValues }) => { return { diff --git a/packages/core/src/rules/oas3/response-contains-property.ts b/packages/core/src/rules/oas3/response-contains-property.ts index 29e1b21fa..3508f3df6 100644 --- a/packages/core/src/rules/oas3/response-contains-property.ts +++ b/packages/core/src/rules/oas3/response-contains-property.ts @@ -1,7 +1,7 @@ -import { getMatchingStatusCodeRange } from '../../utils'; +import { getMatchingStatusCodeRange } from '../../utils.js'; -import type { Oas3Rule } from '../../visitors'; -import type { UserContext } from '../../walk'; +import type { Oas3Rule } from '../../visitors.js'; +import type { UserContext } from '../../walk.js'; export const ResponseContainsProperty: Oas3Rule = (options) => { const names: Record = options.names || {}; diff --git a/packages/core/src/rules/oas3/response-mime-type.ts b/packages/core/src/rules/oas3/response-mime-type.ts index 6ce62330b..121f4b08c 100644 --- a/packages/core/src/rules/oas3/response-mime-type.ts +++ b/packages/core/src/rules/oas3/response-mime-type.ts @@ -1,7 +1,7 @@ -import { validateMimeTypeOAS3 } from '../../utils'; +import { validateMimeTypeOAS3 } from '../../utils.js'; -import type { Oas3Rule } from '../../visitors'; -import type { UserContext } from '../../walk'; +import type { Oas3Rule } from '../../visitors.js'; +import type { UserContext } from '../../walk.js'; export const ResponseMimeType: Oas3Rule = ({ allowedValues }) => { return { diff --git a/packages/core/src/rules/oas3/spec-components-invalid-map-name.ts b/packages/core/src/rules/oas3/spec-components-invalid-map-name.ts index 19937a1d2..79d73e345 100644 --- a/packages/core/src/rules/oas3/spec-components-invalid-map-name.ts +++ b/packages/core/src/rules/oas3/spec-components-invalid-map-name.ts @@ -1,6 +1,6 @@ -import type { Oas3Rule } from '../../visitors'; -import type { Problem, UserContext } from '../../walk'; -import type { Location } from '../../ref-utils'; +import type { Oas3Rule } from '../../visitors.js'; +import type { Problem, UserContext } from '../../walk.js'; +import type { Location } from '../../ref-utils.js'; export const SpecComponentsInvalidMapName: Oas3Rule = () => { const KEYS_REGEX = '^[a-zA-Z0-9\\.\\-_]+$'; diff --git a/packages/core/src/rules/other/stats.ts b/packages/core/src/rules/other/stats.ts index 81a0a524c..2f306a75e 100644 --- a/packages/core/src/rules/other/stats.ts +++ b/packages/core/src/rules/other/stats.ts @@ -1,6 +1,6 @@ -import type { Oas3Parameter, OasRef, Oas3Tag } from '../../typings/openapi'; -import type { Oas2Parameter } from '../../typings/swagger'; -import type { StatsAccumulator } from '../../typings/common'; +import type { Oas3Parameter, OasRef, Oas3Tag } from '../../typings/openapi.js'; +import type { Oas2Parameter } from '../../typings/swagger.js'; +import type { StatsAccumulator } from '../../typings/common.js'; export const Stats = (statsAccumulator: StatsAccumulator) => { return { diff --git a/packages/core/src/rules/utils.ts b/packages/core/src/rules/utils.ts index 7aef11833..c35e3274f 100644 --- a/packages/core/src/rules/utils.ts +++ b/packages/core/src/rules/utils.ts @@ -1,10 +1,10 @@ -import levenshtein = require('js-levenshtein'); -import { Location } from '../ref-utils'; -import { validateJsonSchema } from './ajv'; -import { showErrorForDeprecatedField, showWarningForDeprecatedField } from '../utils'; +import levenshtein from 'js-levenshtein'; +import { Location } from '../ref-utils.js'; +import { validateJsonSchema } from './ajv.js'; +import { showErrorForDeprecatedField, showWarningForDeprecatedField } from '../utils.js'; -import type { Oas3Schema, Oas3_1Schema, Referenced } from '../typings/openapi'; -import type { UserContext } from '../walk'; +import type { Oas3Schema, Oas3_1Schema, Referenced } from '../typings/openapi.js'; +import type { UserContext } from '../walk.js'; export function oasTypeOf(value: unknown) { if (Array.isArray(value)) { diff --git a/packages/core/src/types/arazzo.ts b/packages/core/src/types/arazzo.ts index aec445fe3..305a332b5 100755 --- a/packages/core/src/types/arazzo.ts +++ b/packages/core/src/types/arazzo.ts @@ -1,6 +1,6 @@ -import { getNodeTypesFromJSONSchema } from './json-schema-adapter'; +import { getNodeTypesFromJSONSchema } from './json-schema-adapter.js'; -import type { NodeType } from '.'; +import type { NodeType } from './index.js'; export const ARAZZO_ROOT_TYPE = 'Root'; diff --git a/packages/core/src/types/asyncapi2.ts b/packages/core/src/types/asyncapi2.ts index 3f333aac7..f096ed462 100644 --- a/packages/core/src/types/asyncapi2.ts +++ b/packages/core/src/types/asyncapi2.ts @@ -1,7 +1,7 @@ -import { listOf, mapOf } from '.'; -import { isMappingRef } from '../ref-utils'; +import { listOf, mapOf } from './index.js'; +import { isMappingRef } from '../ref-utils.js'; -import type { NodeType } from '.'; +import type { NodeType } from './index.js'; const Root: NodeType = { properties: { diff --git a/packages/core/src/types/asyncapi3.ts b/packages/core/src/types/asyncapi3.ts index 97cec75ac..ac25cbd06 100644 --- a/packages/core/src/types/asyncapi3.ts +++ b/packages/core/src/types/asyncapi3.ts @@ -1,4 +1,4 @@ -import { listOf, mapOf } from '.'; +import { listOf, mapOf } from './index.js'; import { AsyncApi2Bindings, Schema, @@ -15,9 +15,9 @@ import { Contact, License, MessageExample, -} from './asyncapi2'; +} from './asyncapi2.js'; -import type { NodeType } from '.'; +import type { NodeType } from './index.js'; const Root: NodeType = { properties: { diff --git a/packages/core/src/types/json-schema-adapter.ts b/packages/core/src/types/json-schema-adapter.ts index 0ed401d11..f9bc6fd2d 100644 --- a/packages/core/src/types/json-schema-adapter.ts +++ b/packages/core/src/types/json-schema-adapter.ts @@ -1,11 +1,13 @@ // For internal usage only -import Ajv from '@redocly/ajv/dist/2020'; -import { isPlainObject } from '../utils'; +import _Ajv from '@redocly/ajv/dist/2020.js'; +import { isPlainObject } from '../utils.js'; import type { JSONSchema } from 'json-schema-to-ts'; -import type { NodeType, PropType, ResolveTypeFn } from '.'; -import type { Oas3Schema } from '../typings/openapi'; +import type { NodeType, PropType, ResolveTypeFn } from './index.js'; +import type { Oas3Schema } from '../typings/openapi.js'; + +const Ajv = _Ajv.default; const ajv = new Ajv({ strictSchema: false, diff --git a/packages/core/src/types/oas2.ts b/packages/core/src/types/oas2.ts index 7fb33052f..68dd12acf 100644 --- a/packages/core/src/types/oas2.ts +++ b/packages/core/src/types/oas2.ts @@ -1,7 +1,7 @@ -import { listOf, mapOf } from '.'; +import { listOf, mapOf } from './index.js'; -import type { NodeType } from '.'; -import type { Oas2NodeType } from './redocly-yaml'; +import type { NodeType } from './index.js'; +import type { Oas2NodeType } from './redocly-yaml.js'; const responseCodeRegexp = /^[0-9][0-9Xx]{2}$/; diff --git a/packages/core/src/types/oas3.ts b/packages/core/src/types/oas3.ts index 647e3acf8..1068021ca 100755 --- a/packages/core/src/types/oas3.ts +++ b/packages/core/src/types/oas3.ts @@ -1,8 +1,8 @@ -import { listOf, mapOf } from '.'; -import { isMappingRef } from '../ref-utils'; +import { listOf, mapOf } from './index.js'; +import { isMappingRef } from '../ref-utils.js'; -import type { NodeType } from '.'; -import type { Oas3NodeType } from './redocly-yaml'; +import type { NodeType } from './index.js'; +import type { Oas3NodeType } from './redocly-yaml.js'; const responseCodeRegexp = /^[0-9][0-9Xx]{2}$/; diff --git a/packages/core/src/types/oas3_1.ts b/packages/core/src/types/oas3_1.ts index 80d87a56b..98a1e2344 100755 --- a/packages/core/src/types/oas3_1.ts +++ b/packages/core/src/types/oas3_1.ts @@ -1,8 +1,8 @@ -import { listOf, mapOf } from '.'; -import { Oas3Types } from './oas3'; +import { listOf, mapOf } from './index.js'; +import { Oas3Types } from './oas3.js'; -import type { NodeType } from '.'; -import type { Oas3_1NodeType } from './redocly-yaml'; +import type { NodeType } from './index.js'; +import type { Oas3_1NodeType } from './redocly-yaml.js'; const Root: NodeType = { properties: { diff --git a/packages/core/src/types/redocly-yaml.ts b/packages/core/src/types/redocly-yaml.ts index c436f10fd..c4ef7c562 100644 --- a/packages/core/src/types/redocly-yaml.ts +++ b/packages/core/src/types/redocly-yaml.ts @@ -1,12 +1,12 @@ import { rootRedoclyConfigSchema } from '@redocly/config'; -import { listOf } from '.'; -import { omitObjectProps, pickObjectProps, isCustomRuleId } from '../utils'; -import { getNodeTypesFromJSONSchema } from './json-schema-adapter'; -import { SpecVersion, getTypes } from '../oas-types'; +import { listOf } from './index.js'; +import { omitObjectProps, pickObjectProps, isCustomRuleId } from '../utils.js'; +import { getNodeTypesFromJSONSchema } from './json-schema-adapter.js'; +import { SpecVersion, getTypes } from '../oas-types.js'; import type { JSONSchema } from 'json-schema-to-ts'; -import type { NodeType } from '.'; -import type { Config } from '../config'; +import type { NodeType } from './index.js'; +import type { Config } from '../config/index.js'; const builtInCommonOASRules = [ 'spec', diff --git a/packages/core/src/typings/arazzo.ts b/packages/core/src/typings/arazzo.ts index 5c61171f3..f870a1566 100644 --- a/packages/core/src/typings/arazzo.ts +++ b/packages/core/src/typings/arazzo.ts @@ -12,7 +12,7 @@ import type { criteriaObject, step, workflow, -} from '../types/arazzo'; +} from '../types/arazzo.js'; export type ArazzoDefinition = FromSchema; export type OperationMethod = FromSchema; diff --git a/packages/core/src/typings/swagger.ts b/packages/core/src/typings/swagger.ts index c6fa94bbb..d1a5af9d7 100644 --- a/packages/core/src/typings/swagger.ts +++ b/packages/core/src/typings/swagger.ts @@ -1,5 +1,5 @@ import type { Schema } from 'js-yaml'; -import type { Referenced } from './openapi'; +import type { Referenced } from './openapi.js'; export interface Oas2Definition { swagger: '2.0'; diff --git a/packages/core/src/utils.ts b/packages/core/src/utils.ts index acef7aa7c..070b44ed9 100644 --- a/packages/core/src/utils.ts +++ b/packages/core/src/utils.ts @@ -1,16 +1,18 @@ import * as fs from 'fs'; import { extname } from 'path'; -import * as minimatch from 'minimatch'; -import fetch from 'node-fetch'; -import { parseYaml } from './js-yaml'; -import { env } from './env'; -import { logger, colorize } from './logger'; +import minimatch from 'minimatch'; +import _fetch from 'node-fetch'; +import { parseYaml } from './js-yaml/index.js'; +import { env } from './env.js'; +import { logger, colorize } from './logger.js'; import { HttpsProxyAgent } from 'https-proxy-agent'; -import type { HttpResolveConfig } from './config'; -import type { UserContext } from './walk'; +import type { HttpResolveConfig } from './config/index.js'; +import type { UserContext } from './walk.js'; -export { parseYaml, stringifyYaml } from './js-yaml'; +const fetch = _fetch.default; + +export { parseYaml, stringifyYaml } from './js-yaml/index.js'; export type StackFrame = { prev: StackFrame | null; diff --git a/packages/core/src/visitors.ts b/packages/core/src/visitors.ts index 67775e9d9..3268b7949 100644 --- a/packages/core/src/visitors.ts +++ b/packages/core/src/visitors.ts @@ -1,9 +1,9 @@ -import { SpecExtension } from './types'; +import { SpecExtension } from './types/index.js'; -import type { NormalizedNodeType } from './types'; -import type { Stack } from './utils'; -import type { UserContext, ResolveResult, ProblemSeverity } from './walk'; -import type { Location } from './ref-utils'; +import type { NormalizedNodeType } from './types/index.js'; +import type { Stack } from './utils.js'; +import type { UserContext, ResolveResult, ProblemSeverity } from './walk.js'; +import type { Location } from './ref-utils.js'; import type { Oas3Definition, Oas3ExternalDocs, @@ -31,7 +31,7 @@ import type { Oas3Xml, Oas3Discriminator, Oas3Callback, -} from './typings/openapi'; +} from './typings/openapi.js'; import type { Oas2Definition, Oas2Tag, @@ -48,10 +48,10 @@ import type { Oas2Xml, Oas2Parameter, Oas2SecurityScheme, -} from './typings/swagger'; -import type { Async2Definition } from './typings/asyncapi'; -import type { Async3Definition } from './typings/asyncapi3'; -import type { ArazzoDefinition } from './typings/arazzo'; +} from './typings/swagger.js'; +import type { Async2Definition } from './typings/asyncapi.js'; +import type { Async3Definition } from './typings/asyncapi3.js'; +import type { ArazzoDefinition } from './typings/arazzo.js'; export type SkipFunctionContext = Pick< UserContext, diff --git a/packages/core/src/walk.ts b/packages/core/src/walk.ts index 3847633cd..58fb02d65 100644 --- a/packages/core/src/walk.ts +++ b/packages/core/src/walk.ts @@ -1,11 +1,11 @@ -import { Location, isRef } from './ref-utils'; -import { pushStack, popStack } from './utils'; -import { YamlParseError, makeRefId } from './resolve'; -import { isNamedType, SpecExtension } from './types'; - -import type { SpecVersion } from './oas-types'; -import type { ResolveError, Source, ResolvedRefMap, Document } from './resolve'; -import type { Referenced } from './typings/openapi'; +import { Location, isRef } from './ref-utils.js'; +import { pushStack, popStack } from './utils.js'; +import { YamlParseError, makeRefId } from './resolve.js'; +import { isNamedType, SpecExtension } from './types/index.js'; + +import type { SpecVersion } from './oas-types.js'; +import type { ResolveError, Source, ResolvedRefMap, Document } from './resolve.js'; +import type { Referenced } from './typings/openapi.js'; import type { VisitorLevelContext, NormalizedOasVisitors, @@ -14,9 +14,9 @@ import type { BaseVisitor, NormalizeVisitor, VisitorNode, -} from './visitors'; -import type { NormalizedNodeType } from './types'; -import type { RuleSeverity } from './config'; +} from './visitors.js'; +import type { NormalizedNodeType } from './types/index.js'; +import type { RuleSeverity } from './config/index.js'; export type NonUndefined = | string diff --git a/tsconfig.json b/tsconfig.json index fb5fb64d6..212bf0c01 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,8 +2,10 @@ "compilerOptions": { "composite": true, "declaration": true, - "module": "commonjs", - "target": "ES2020", + "module": "nodenext", + "target": "ES2023", + "moduleResolution": "nodenext", + "esModuleInterop": true, "noImplicitAny": true, "noImplicitReturns": true, "noImplicitThis": true, @@ -14,7 +16,7 @@ "forceConsistentCasingInFileNames": true, "allowJs": false, "lib": ["es2020", "es2020.string", "dom"], - "baseUrl": "./packages", + "sourceMap": true, "skipLibCheck": true } }