diff --git a/.eslintrc.yml b/.eslintrc.yml index 4889443370..536687f7f2 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -12,6 +12,7 @@ parserOptions: sourceType: module plugins: - '@typescript-eslint' + - import rules: '@typescript-eslint/no-unused-vars': - error @@ -20,10 +21,20 @@ rules: '@typescript-eslint/no-var-requires': off '@typescript-eslint/no-empty-function': off '@typescript-eslint/no-inferrable-types': off - '@typescript-eslint/ban-types': warn + '@typescript-eslint/ban-types': error '@typescript-eslint/no-explicit-any': warn # TODO: make it error! no-prototype-builtins: off - no-useless-escape: warn + no-useless-escape: error + '@typescript-eslint/consistent-type-imports': + - error + - prefer: type-imports + import/order: + - error + - groups: + - ['builtin', 'external', 'parent', 'sibling', 'index', 'object'] + - [type] + 'newlines-between': 'always' + import/no-duplicates: error ignorePatterns: - '**/__tests__/' - 'packages/*/lib/' diff --git a/benchmark/package.json b/benchmark/package.json index e5a30f8e96..7b6d23eafc 100644 --- a/benchmark/package.json +++ b/benchmark/package.json @@ -24,7 +24,8 @@ "cli-1.15": "npm:@redocly/cli@1.15.0", "cli-1.16": "npm:@redocly/cli@1.16.0", "cli-1.17": "npm:@redocly/cli@1.17.1", - "cli-1.18": "npm:@redocly/cli@1.18.0", + "cli-1.18": "npm:@redocly/cli@1.18.1", + "cli-1.19": "npm:@redocly/cli@1.19.0", "cli-next": "file:../redocly-cli.tgz" } } diff --git a/jest.config.js b/jest.config.js index bafbcfacd8..bd44084308 100644 --- a/jest.config.js +++ b/jest.config.js @@ -13,8 +13,8 @@ module.exports = { coverageThreshold: { 'packages/core/': { statements: 80, - branches: 71, - functions: 73, + branches: 72, + functions: 74, lines: 80, }, 'packages/cli/': { diff --git a/package-lock.json b/package-lock.json index 728ab11602..bcc0a357df 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,6 +20,7 @@ "@typescript-eslint/eslint-plugin": "^6.8.0", "@typescript-eslint/parser": "^6.8.0", "eslint": "^8.22.0", + "eslint-plugin-import": "^2.29.1", "jest": "^29.0.0", "jest-environment-jsdom": "^29.7.0", "json-schema-to-ts": "^3.0.0", @@ -3743,6 +3744,12 @@ "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.14.tgz", "integrity": "sha512-U3PUjAudAdJBeC2pgN8uTIKgxrb4nlDF3SF0++EldXQvQBGkpFZMSnwQiIoDU77tv45VgNkl/L4ouD+rEomujw==" }, + "node_modules/@types/json5": { + "version": "0.0.29", + "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", + "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", + "dev": true + }, "node_modules/@types/lodash": { "version": "4.14.184", "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.184.tgz", @@ -4495,6 +4502,26 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/array-includes": { + "version": "3.1.8", + "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.8.tgz", + "integrity": "sha512-itaWrbYbqpGXkGhZPGUulwnhVf5Hpy1xiCFsGqyIGglbBxmG5vSjxQen3/WGOjPpNEv1RtBLKxbmVXm8HpJStQ==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.7", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.2", + "es-object-atoms": "^1.0.0", + "get-intrinsic": "^1.2.4", + "is-string": "^1.0.7" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/array-union": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", @@ -4524,14 +4551,52 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/array.prototype.findlastindex": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/array.prototype.findlastindex/-/array.prototype.findlastindex-1.2.5.tgz", + "integrity": "sha512-zfETvRFA8o7EiNn++N5f/kaCw221hrpGsDmcpndVupkPzEc1Wuf3VgC0qby1BbHs7f5DVYjgtEU2LLh5bqeGfQ==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.7", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.2", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.0.0", + "es-shim-unscopables": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/array.prototype.flat": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.3.1.tgz", - "integrity": "sha512-roTU0KWIOmJ4DRLmwKd19Otg0/mT3qPNt0Qb3GWW8iObuZXxrjB/pzn0R3hqpRSWg4HCwqx+0vwOnWnvlOyeIA==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.3.2.tgz", + "integrity": "sha512-djYB+Zx2vLewY8RWlNCUdHjDXs2XOgm602S9E7P/UpHgfeHL00cRiIF+IN/G/aUJ7kGPb6yO/ErDI5V2s8iycA==", "dependencies": { "call-bind": "^1.0.2", - "define-properties": "^1.1.4", - "es-abstract": "^1.20.4", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1", + "es-shim-unscopables": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/array.prototype.flatmap": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/array.prototype.flatmap/-/array.prototype.flatmap-1.3.2.tgz", + "integrity": "sha512-Ewyx0c9PmpcsByhSW4r+9zDU7sGjFc86qf/kKtuSCRdhfbk0SNLLkaT5qvcHnRGgc5NP/ly/y+qkXkqONX54CQ==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1", "es-shim-unscopables": "^1.0.0" }, "engines": { @@ -6083,11 +6148,11 @@ } }, "node_modules/es-shim-unscopables": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/es-shim-unscopables/-/es-shim-unscopables-1.0.0.tgz", - "integrity": "sha512-Jm6GPcCdC30eMLbZ2x8z2WuRwAws3zTBBKuusffYVUrNj/GVSUAZ+xKMaUpfNDR5IbyNA5LJbaecoUVbmUcB1w==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/es-shim-unscopables/-/es-shim-unscopables-1.0.2.tgz", + "integrity": "sha512-J3yBRXCzDu4ULnQwxyToo/OjdMx6akgVC7K6few0a7F/0wLtmKKN7I73AH5T2836UuXRqN7Qg+IIUw/+YJksRw==", "dependencies": { - "has": "^1.0.3" + "hasown": "^2.0.0" } }, "node_modules/es-to-primitive": { @@ -6217,6 +6282,135 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/eslint-import-resolver-node": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.9.tgz", + "integrity": "sha512-WFj2isz22JahUv+B788TlO3N6zL3nNJGU8CcZbPZvVEkBPaJdCV4vy5wyghty5ROFbCRnm132v8BScu5/1BQ8g==", + "dev": true, + "dependencies": { + "debug": "^3.2.7", + "is-core-module": "^2.13.0", + "resolve": "^1.22.4" + } + }, + "node_modules/eslint-import-resolver-node/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/eslint-module-utils": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.8.1.tgz", + "integrity": "sha512-rXDXR3h7cs7dy9RNpUlQf80nX31XWJEyGq1tRMo+6GsO5VmTe4UTwtmonAD4ZkAsrfMVDA2wlGJ3790Ys+D49Q==", + "dev": true, + "dependencies": { + "debug": "^3.2.7" + }, + "engines": { + "node": ">=4" + }, + "peerDependenciesMeta": { + "eslint": { + "optional": true + } + } + }, + "node_modules/eslint-module-utils/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/eslint-plugin-import": { + "version": "2.29.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.29.1.tgz", + "integrity": "sha512-BbPC0cuExzhiMo4Ff1BTVwHpjjv28C5R+btTOGaCRC7UEz801up0JadwkeSk5Ued6TG34uaczuVuH6qyy5YUxw==", + "dev": true, + "dependencies": { + "array-includes": "^3.1.7", + "array.prototype.findlastindex": "^1.2.3", + "array.prototype.flat": "^1.3.2", + "array.prototype.flatmap": "^1.3.2", + "debug": "^3.2.7", + "doctrine": "^2.1.0", + "eslint-import-resolver-node": "^0.3.9", + "eslint-module-utils": "^2.8.0", + "hasown": "^2.0.0", + "is-core-module": "^2.13.1", + "is-glob": "^4.0.3", + "minimatch": "^3.1.2", + "object.fromentries": "^2.0.7", + "object.groupby": "^1.0.1", + "object.values": "^1.1.7", + "semver": "^6.3.1", + "tsconfig-paths": "^3.15.0" + }, + "engines": { + "node": ">=4" + }, + "peerDependencies": { + "eslint": "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8" + } + }, + "node_modules/eslint-plugin-import/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/eslint-plugin-import/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/eslint-plugin-import/node_modules/doctrine": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "dev": true, + "dependencies": { + "esutils": "^2.0.2" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/eslint-plugin-import/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/eslint-plugin-import/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, "node_modules/eslint-scope": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", @@ -7394,11 +7588,14 @@ } }, "node_modules/is-core-module": { - "version": "2.10.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.10.0.tgz", - "integrity": "sha512-Erxj2n/LDAZ7H8WNJXd9tw38GYM3dv8rk8Zcs+jJuxYTW7sozH+SS8NtrSjVL1/vpLvWi1hxy96IzjJ3EHTJJg==", + "version": "2.15.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.15.0.tgz", + "integrity": "sha512-Dd+Lb2/zvk9SKy1TGCt1wFJFo/MWBPMX5x7KcvLajWTGuomczdQX61PvY5yK6SVACwpoexWo81IfFyoKY2QnTA==", "dependencies": { - "has": "^1.0.3" + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -10027,11 +10224,42 @@ "node": ">= 0.4" } }, + "node_modules/object.fromentries": { + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/object.fromentries/-/object.fromentries-2.0.8.tgz", + "integrity": "sha512-k6E21FzySsSK5a21KRADBd/NGneRegFO5pLHfdQLpRDETUNJueLXs3WCzyQ3tFRDYgbq3KHGXfTbi2bs8WQ6rQ==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.7", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.2", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/object.groupby": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/object.groupby/-/object.groupby-1.0.3.tgz", + "integrity": "sha512-+Lhy3TQTuzXI5hevh8sBGqbmurHbbIjAi0Z4S63nthVLmLxfbj4T54a4CfZrXIrt9iP4mVAPYMo/v99taj3wjQ==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.7", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.2" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/object.values": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.2.0.tgz", "integrity": "sha512-yBYjY9QX2hnRmZHAjG/f13MzmBzxzYgQhFrke06TTyKY5zSTEqkOeukBzIdVA3j3ulu8Qa3MbVFShV7T2RmGtQ==", - "peer": true, "dependencies": { "call-bind": "^1.0.7", "define-properties": "^1.2.1", @@ -11153,11 +11381,11 @@ "dev": true }, "node_modules/resolve": { - "version": "1.22.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", - "integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==", + "version": "1.22.8", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", + "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==", "dependencies": { - "is-core-module": "^2.9.0", + "is-core-module": "^2.13.0", "path-parse": "^1.0.7", "supports-preserve-symlinks-flag": "^1.0.0" }, @@ -12477,6 +12705,39 @@ "typescript": ">=2.7" } }, + "node_modules/tsconfig-paths": { + "version": "3.15.0", + "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz", + "integrity": "sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==", + "dev": true, + "dependencies": { + "@types/json5": "^0.0.29", + "json5": "^1.0.2", + "minimist": "^1.2.6", + "strip-bom": "^3.0.0" + } + }, + "node_modules/tsconfig-paths/node_modules/json5": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz", + "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", + "dev": true, + "dependencies": { + "minimist": "^1.2.0" + }, + "bin": { + "json5": "lib/cli.js" + } + }, + "node_modules/tsconfig-paths/node_modules/strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/tty-table": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/tty-table/-/tty-table-4.2.1.tgz", @@ -16513,6 +16774,12 @@ "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.14.tgz", "integrity": "sha512-U3PUjAudAdJBeC2pgN8uTIKgxrb4nlDF3SF0++EldXQvQBGkpFZMSnwQiIoDU77tv45VgNkl/L4ouD+rEomujw==" }, + "@types/json5": { + "version": "0.0.29", + "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", + "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", + "dev": true + }, "@types/lodash": { "version": "4.14.184", "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.184.tgz", @@ -17109,6 +17376,20 @@ "is-array-buffer": "^3.0.4" } }, + "array-includes": { + "version": "3.1.8", + "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.8.tgz", + "integrity": "sha512-itaWrbYbqpGXkGhZPGUulwnhVf5Hpy1xiCFsGqyIGglbBxmG5vSjxQen3/WGOjPpNEv1RtBLKxbmVXm8HpJStQ==", + "dev": true, + "requires": { + "call-bind": "^1.0.7", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.2", + "es-object-atoms": "^1.0.0", + "get-intrinsic": "^1.2.4", + "is-string": "^1.0.7" + } + }, "array-union": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", @@ -17129,14 +17410,40 @@ "is-string": "^1.0.7" } }, + "array.prototype.findlastindex": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/array.prototype.findlastindex/-/array.prototype.findlastindex-1.2.5.tgz", + "integrity": "sha512-zfETvRFA8o7EiNn++N5f/kaCw221hrpGsDmcpndVupkPzEc1Wuf3VgC0qby1BbHs7f5DVYjgtEU2LLh5bqeGfQ==", + "dev": true, + "requires": { + "call-bind": "^1.0.7", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.2", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.0.0", + "es-shim-unscopables": "^1.0.2" + } + }, "array.prototype.flat": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.3.1.tgz", - "integrity": "sha512-roTU0KWIOmJ4DRLmwKd19Otg0/mT3qPNt0Qb3GWW8iObuZXxrjB/pzn0R3hqpRSWg4HCwqx+0vwOnWnvlOyeIA==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.3.2.tgz", + "integrity": "sha512-djYB+Zx2vLewY8RWlNCUdHjDXs2XOgm602S9E7P/UpHgfeHL00cRiIF+IN/G/aUJ7kGPb6yO/ErDI5V2s8iycA==", + "requires": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1", + "es-shim-unscopables": "^1.0.0" + } + }, + "array.prototype.flatmap": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/array.prototype.flatmap/-/array.prototype.flatmap-1.3.2.tgz", + "integrity": "sha512-Ewyx0c9PmpcsByhSW4r+9zDU7sGjFc86qf/kKtuSCRdhfbk0SNLLkaT5qvcHnRGgc5NP/ly/y+qkXkqONX54CQ==", + "dev": true, "requires": { "call-bind": "^1.0.2", - "define-properties": "^1.1.4", - "es-abstract": "^1.20.4", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1", "es-shim-unscopables": "^1.0.0" } }, @@ -18279,11 +18586,11 @@ } }, "es-shim-unscopables": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/es-shim-unscopables/-/es-shim-unscopables-1.0.0.tgz", - "integrity": "sha512-Jm6GPcCdC30eMLbZ2x8z2WuRwAws3zTBBKuusffYVUrNj/GVSUAZ+xKMaUpfNDR5IbyNA5LJbaecoUVbmUcB1w==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/es-shim-unscopables/-/es-shim-unscopables-1.0.2.tgz", + "integrity": "sha512-J3yBRXCzDu4ULnQwxyToo/OjdMx6akgVC7K6few0a7F/0wLtmKKN7I73AH5T2836UuXRqN7Qg+IIUw/+YJksRw==", "requires": { - "has": "^1.0.3" + "hasown": "^2.0.0" } }, "es-to-primitive": { @@ -18416,6 +18723,118 @@ } } }, + "eslint-import-resolver-node": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.9.tgz", + "integrity": "sha512-WFj2isz22JahUv+B788TlO3N6zL3nNJGU8CcZbPZvVEkBPaJdCV4vy5wyghty5ROFbCRnm132v8BScu5/1BQ8g==", + "dev": true, + "requires": { + "debug": "^3.2.7", + "is-core-module": "^2.13.0", + "resolve": "^1.22.4" + }, + "dependencies": { + "debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + } + } + }, + "eslint-module-utils": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.8.1.tgz", + "integrity": "sha512-rXDXR3h7cs7dy9RNpUlQf80nX31XWJEyGq1tRMo+6GsO5VmTe4UTwtmonAD4ZkAsrfMVDA2wlGJ3790Ys+D49Q==", + "dev": true, + "requires": { + "debug": "^3.2.7" + }, + "dependencies": { + "debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + } + } + }, + "eslint-plugin-import": { + "version": "2.29.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.29.1.tgz", + "integrity": "sha512-BbPC0cuExzhiMo4Ff1BTVwHpjjv28C5R+btTOGaCRC7UEz801up0JadwkeSk5Ued6TG34uaczuVuH6qyy5YUxw==", + "dev": true, + "requires": { + "array-includes": "^3.1.7", + "array.prototype.findlastindex": "^1.2.3", + "array.prototype.flat": "^1.3.2", + "array.prototype.flatmap": "^1.3.2", + "debug": "^3.2.7", + "doctrine": "^2.1.0", + "eslint-import-resolver-node": "^0.3.9", + "eslint-module-utils": "^2.8.0", + "hasown": "^2.0.0", + "is-core-module": "^2.13.1", + "is-glob": "^4.0.3", + "minimatch": "^3.1.2", + "object.fromentries": "^2.0.7", + "object.groupby": "^1.0.1", + "object.values": "^1.1.7", + "semver": "^6.3.1", + "tsconfig-paths": "^3.15.0" + }, + "dependencies": { + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "doctrine": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "dev": true, + "requires": { + "esutils": "^2.0.2" + } + }, + "minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true + } + } + }, "eslint-scope": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", @@ -19244,11 +19663,11 @@ "integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==" }, "is-core-module": { - "version": "2.10.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.10.0.tgz", - "integrity": "sha512-Erxj2n/LDAZ7H8WNJXd9tw38GYM3dv8rk8Zcs+jJuxYTW7sozH+SS8NtrSjVL1/vpLvWi1hxy96IzjJ3EHTJJg==", + "version": "2.15.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.15.0.tgz", + "integrity": "sha512-Dd+Lb2/zvk9SKy1TGCt1wFJFo/MWBPMX5x7KcvLajWTGuomczdQX61PvY5yK6SVACwpoexWo81IfFyoKY2QnTA==", "requires": { - "has": "^1.0.3" + "hasown": "^2.0.2" } }, "is-data-view": { @@ -21164,11 +21583,33 @@ "es-object-atoms": "^1.0.0" } }, + "object.fromentries": { + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/object.fromentries/-/object.fromentries-2.0.8.tgz", + "integrity": "sha512-k6E21FzySsSK5a21KRADBd/NGneRegFO5pLHfdQLpRDETUNJueLXs3WCzyQ3tFRDYgbq3KHGXfTbi2bs8WQ6rQ==", + "dev": true, + "requires": { + "call-bind": "^1.0.7", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.2", + "es-object-atoms": "^1.0.0" + } + }, + "object.groupby": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/object.groupby/-/object.groupby-1.0.3.tgz", + "integrity": "sha512-+Lhy3TQTuzXI5hevh8sBGqbmurHbbIjAi0Z4S63nthVLmLxfbj4T54a4CfZrXIrt9iP4mVAPYMo/v99taj3wjQ==", + "dev": true, + "requires": { + "call-bind": "^1.0.7", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.2" + } + }, "object.values": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.2.0.tgz", "integrity": "sha512-yBYjY9QX2hnRmZHAjG/f13MzmBzxzYgQhFrke06TTyKY5zSTEqkOeukBzIdVA3j3ulu8Qa3MbVFShV7T2RmGtQ==", - "peer": true, "requires": { "call-bind": "^1.0.7", "define-properties": "^1.2.1", @@ -21996,11 +22437,11 @@ "dev": true }, "resolve": { - "version": "1.22.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", - "integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==", + "version": "1.22.8", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", + "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==", "requires": { - "is-core-module": "^2.9.0", + "is-core-module": "^2.13.0", "path-parse": "^1.0.7", "supports-preserve-symlinks-flag": "^1.0.0" } @@ -22976,6 +23417,35 @@ "yn": "3.1.1" } }, + "tsconfig-paths": { + "version": "3.15.0", + "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz", + "integrity": "sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==", + "dev": true, + "requires": { + "@types/json5": "^0.0.29", + "json5": "^1.0.2", + "minimist": "^1.2.6", + "strip-bom": "^3.0.0" + }, + "dependencies": { + "json5": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz", + "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", + "dev": true, + "requires": { + "minimist": "^1.2.0" + } + }, + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", + "dev": true + } + } + }, "tty-table": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/tty-table/-/tty-table-4.2.1.tgz", diff --git a/package.json b/package.json index 90244ffbe9..8d71944b18 100644 --- a/package.json +++ b/package.json @@ -67,6 +67,7 @@ "@typescript-eslint/eslint-plugin": "^6.8.0", "@typescript-eslint/parser": "^6.8.0", "eslint": "^8.22.0", + "eslint-plugin-import": "^2.29.1", "jest": "^29.0.0", "jest-environment-jsdom": "^29.7.0", "json-schema-to-ts": "^3.0.0", diff --git a/packages/cli/src/cms/api/api-client.ts b/packages/cli/src/cms/api/api-client.ts index 4d9b5b20c0..3a5183dbfb 100644 --- a/packages/cli/src/cms/api/api-client.ts +++ b/packages/cli/src/cms/api/api-client.ts @@ -1,7 +1,8 @@ -import fetchWithTimeout from '../../utils/fetch-with-timeout'; import fetch from 'node-fetch'; import * as FormData from 'form-data'; import { getProxyAgent } from '@redocly/openapi-core'; +import fetchWithTimeout from '../../utils/fetch-with-timeout'; + import type { Response } from 'node-fetch'; import type { ReadStream } from 'fs'; import type { diff --git a/packages/cli/src/commands/build-docs/utils.ts b/packages/cli/src/commands/build-docs/utils.ts index 568664b6df..1fcc044118 100644 --- a/packages/cli/src/commands/build-docs/utils.ts +++ b/packages/cli/src/commands/build-docs/utils.ts @@ -1,17 +1,17 @@ import { createElement } from 'react'; import { createStore, Redoc } from 'redoc'; -import { Config, isAbsoluteUrl } from '@redocly/openapi-core'; - import { renderToString } from 'react-dom/server'; import { ServerStyleSheet } from 'styled-components'; import { compile } from 'handlebars'; import { dirname, join, resolve } from 'path'; import { existsSync, lstatSync, readFileSync } from 'fs'; - -import type { BuildDocsOptions } from './types'; import { red } from 'colorette'; +import { isAbsoluteUrl } from '@redocly/openapi-core'; import { exitWithError } from '../../utils/miscellaneous'; +import type { Config } from '@redocly/openapi-core'; +import type { BuildDocsOptions } from './types'; + export function getObjectOrJSON( openapiOptions: string | Record, config: Config diff --git a/packages/cli/src/commands/login.ts b/packages/cli/src/commands/login.ts index 8b5c89d644..d0934b3de3 100644 --- a/packages/cli/src/commands/login.ts +++ b/packages/cli/src/commands/login.ts @@ -1,8 +1,9 @@ -import { Region, RedoclyClient } from '@redocly/openapi-core'; import { blue, green, gray } from 'colorette'; +import { RedoclyClient } from '@redocly/openapi-core'; import { promptUser } from '../utils/miscellaneous'; import type { CommandArgs } from '../wrapper'; +import type { Region } from '@redocly/openapi-core'; export function promptClientToken(domain: string) { return promptUser( diff --git a/packages/cli/src/commands/preview-docs/index.ts b/packages/cli/src/commands/preview-docs/index.ts index 9afc0d6317..c075dd88e3 100644 --- a/packages/cli/src/commands/preview-docs/index.ts +++ b/packages/cli/src/commands/preview-docs/index.ts @@ -156,6 +156,7 @@ export async function previewDocs({ } } +// eslint-disable-next-line @typescript-eslint/ban-types export function debounce(func: Function, wait: number, immediate?: boolean) { let timeout: NodeJS.Timeout | null; 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 aafccc9b88..e3c093499c 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 @@ -3,11 +3,11 @@ 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 type { IncomingMessage } from 'http'; import { isSubdir } from '../../../utils/miscellaneous'; +import type { IncomingMessage } from 'http'; + function getPageHTML( htmlTemplate: string, redocOptions: object = {}, @@ -60,7 +60,8 @@ export default async function startPreviewServer( getBundle, getOptions, useRedocPro, - }: { getBundle: Function; getOptions: Function; useRedocPro: boolean } + }: // eslint-disable-next-line @typescript-eslint/ban-types + { getBundle: Function; getOptions: Function; useRedocPro: boolean } ) { const defaultTemplate = path.join(__dirname, 'default.hbs'); const handler = async (request: IncomingMessage, response: any) => { 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 e4f2775db5..38ffacdfa4 100644 --- a/packages/cli/src/commands/preview-docs/preview-server/server.ts +++ b/packages/cli/src/commands/preview-docs/preview-server/server.ts @@ -1,6 +1,7 @@ import * as http from 'http'; import * as zlib from 'zlib'; -import { ReadStream } from 'fs'; + +import type { ReadStream } from 'fs'; const SocketServer = require('simple-websocket/server.js'); diff --git a/packages/cli/src/commands/preview-project/constants.ts b/packages/cli/src/commands/preview-project/constants.ts index ab7e51e5e8..24f2db8b89 100644 --- a/packages/cli/src/commands/preview-project/constants.ts +++ b/packages/cli/src/commands/preview-project/constants.ts @@ -1,4 +1,4 @@ -import { Product } from './types'; +import type { Product } from './types'; export const PRODUCT_PACKAGES = { realm: '@redocly/realm', diff --git a/packages/cli/src/commands/preview-project/types.ts b/packages/cli/src/commands/preview-project/types.ts index 0e88bb0181..b561b0d399 100644 --- a/packages/cli/src/commands/preview-project/types.ts +++ b/packages/cli/src/commands/preview-project/types.ts @@ -1,4 +1,4 @@ -import { PRODUCT_PACKAGES, PRODUCT_PLANS } from './constants'; +import type { PRODUCT_PACKAGES, PRODUCT_PLANS } from './constants'; 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 f3def8831d..ea98a257fe 100644 --- a/packages/cli/src/commands/push.ts +++ b/packages/cli/src/commands/push.ts @@ -6,13 +6,10 @@ import { yellow, green, blue, red } from 'colorette'; import { createHash } from 'crypto'; import { bundle, - Config, RedoclyClient, IGNORE_FILE, - BundleOutputFormat, getTotals, slash, - Region, getMergedConfig, getProxyAgent, } from '@redocly/openapi-core'; @@ -26,11 +23,13 @@ import { import { promptClientToken } from './login'; import { handlePush as handleCMSPush } from '../cms/commands/push'; +import type { Config, BundleOutputFormat, Region } from '@redocly/openapi-core'; import type { CommandArgs } from '../wrapper'; const DEFAULT_VERSION = 'latest'; export const DESTINATION_REGEX = + // eslint-disable-next-line no-useless-escape /^(@(?[\w\-\s]+)\/)?(?[^@]*)@(?[\w\.\-]+)$/; export type PushOptions = { diff --git a/packages/cli/src/commands/stats.ts b/packages/cli/src/commands/stats.ts index 84e438d4ed..4022ed28a8 100755 --- a/packages/cli/src/commands/stats.ts +++ b/packages/cli/src/commands/stats.ts @@ -1,7 +1,6 @@ import { performance } from 'perf_hooks'; import * as colors from 'colorette'; import { - StyleguideConfig, normalizeTypes, BaseResolver, resolveDocument, @@ -12,11 +11,16 @@ import { Stats, bundle, } from '@redocly/openapi-core'; -import { getFallbackApisOrExit } from '../utils/miscellaneous'; -import { printExecutionTime } from '../utils/miscellaneous'; +import { getFallbackApisOrExit, printExecutionTime } from '../utils/miscellaneous'; -import type { StatsAccumulator, StatsName, WalkContext, OutputFormat } from '@redocly/openapi-core'; import type { CommandArgs } from '../wrapper'; +import type { + StatsAccumulator, + StatsName, + WalkContext, + OutputFormat, + StyleguideConfig, +} from '@redocly/openapi-core'; const statsAccumulator: StatsAccumulator = { refs: { metric: '🚗 References', total: 0, color: 'red', items: new Set() }, diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index 4e847b5705..0a95b428c2 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -3,27 +3,33 @@ import './utils/assert-node-version'; import * as yargs from 'yargs'; import * as colors from 'colorette'; -import { outputExtensions, PushArguments, regionChoices } from './types'; 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, PushStatusOptions } from './cms/commands/push-status'; +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 { cacheLatestVersion, notifyUpdateCliVersion } from './utils/update-version-notifier'; +import { + cacheLatestVersion, + notifyUpdateCliVersion, + version, +} from './utils/update-version-notifier'; import { commandWrapper } from './wrapper'; -import { version } from './utils/update-version-notifier'; -import type { Arguments } from 'yargs'; -import type { OutputFormat, RuleSeverity } from '@redocly/openapi-core'; -import type { BuildDocsArgv } from './commands/build-docs/types'; import { previewProject } from './commands/preview-project'; import { PRODUCT_PLANS } from './commands/preview-project/constants'; import { commonPushHandler } from './commands/push'; +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'); } diff --git a/packages/cli/src/types.ts b/packages/cli/src/types.ts index ba130f7cd2..bce718cc74 100644 --- a/packages/cli/src/types.ts +++ b/packages/cli/src/types.ts @@ -9,9 +9,8 @@ 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 PushBhOptions } from './cms/commands/push'; -import type { PushStatusOptions } from './cms/commands/push-status'; 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'; export type Totals = { @@ -31,7 +30,7 @@ export type CommandOptions = | SplitOptions | JoinOptions | PushOptions - | PushBhOptions + | CMSPushOptions | LintOptions | BundleOptions | LoginOptions diff --git a/packages/cli/src/utils/getCommandNameFromArgs.ts b/packages/cli/src/utils/getCommandNameFromArgs.ts index 11d0ca9f71..efa0dcddbc 100644 --- a/packages/cli/src/utils/getCommandNameFromArgs.ts +++ b/packages/cli/src/utils/getCommandNameFromArgs.ts @@ -1,4 +1,4 @@ -import { Arguments } from 'yargs'; +import type { Arguments } from 'yargs'; export function getCommandNameFromArgs(argv: Arguments | undefined): string | number { return argv?._?.[0] ?? ''; diff --git a/packages/core/src/benchmark/utils.ts b/packages/core/src/benchmark/utils.ts index 8379fb9346..283da59d7d 100644 --- a/packages/core/src/benchmark/utils.ts +++ b/packages/core/src/benchmark/utils.ts @@ -1,8 +1,9 @@ import { parseYaml } from '../js-yaml'; -import { Document, Source } from '../resolve'; -import { Oas3RuleSet } from '../oas-types'; +import { Source } from '../resolve'; import { StyleguideConfig, mergeExtends, resolvePlugins } from '../config'; +import type { Document } from '../resolve'; +import type { Oas3RuleSet } from '../oas-types'; import type { RuleConfig, Plugin, ResolvedStyleguideConfig } from '../config/types'; export function parseYamlToDocument(body: string, absoluteRef: string = ''): Document { diff --git a/packages/core/src/bundle.ts b/packages/core/src/bundle.ts index 848f8e2369..be58ab1d13 100755 --- a/packages/core/src/bundle.ts +++ b/packages/core/src/bundle.ts @@ -9,7 +9,7 @@ import { SpecMajorVersion, SpecVersion, } from './oas-types'; -import { isAbsoluteUrl, isRef, Location, refBaseName } from './ref-utils'; +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'; @@ -18,6 +18,7 @@ import { RemoveUnusedComponents as RemoveUnusedComponentsOas2 } from './decorato 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'; diff --git a/packages/core/src/config/builtIn.ts b/packages/core/src/config/builtIn.ts index c8c50e7332..ad3975ce50 100644 --- a/packages/core/src/config/builtIn.ts +++ b/packages/core/src/config/builtIn.ts @@ -2,16 +2,11 @@ import recommended from './recommended'; import recommendedStrict from './recommended-strict'; import all from './all'; import minimal from './minimal'; -import { rules as oas3Rules } from '../rules/oas3'; -import { rules as oas2Rules } from '../rules/oas2'; -import { rules as async2Rules } from '../rules/async2'; -import { rules as async3Rules } from '../rules/async3'; -import { rules as arazzoRules } from '../rules/arazzo'; -import { preprocessors as oas3Preprocessors } from '../rules/oas3'; -import { preprocessors as oas2Preprocessors } from '../rules/oas2'; -import { preprocessors as async2Preprocessors } from '../rules/async2'; -import { preprocessors as async3Preprocessors } from '../rules/async3'; -import { preprocessors as arazzoPreprocessors } from '../rules/arazzo'; +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'; diff --git a/packages/core/src/config/config-resolvers.ts b/packages/core/src/config/config-resolvers.ts index 1edd85cda2..68f59b8834 100644 --- a/packages/core/src/config/config-resolvers.ts +++ b/packages/core/src/config/config-resolvers.ts @@ -1,6 +1,6 @@ import * as path from 'path'; import { isAbsoluteUrl } from '../ref-utils'; -import { pickDefined } from '../utils'; +import { pickDefined, isNotString, isString, isDefined, keysOf } from '../utils'; import { resolveDocument, BaseResolver } from '../resolve'; import { defaultPlugin } from './builtIn'; import { @@ -12,7 +12,6 @@ import { transformConfig, } from './utils'; import { isBrowser } from '../env'; -import { isNotString, isString, isDefined, keysOf } from '../utils'; import { Config } from './config'; import { colorize, logger } from '../logger'; import { asserts, buildAssertCustomFunction } from '../rules/common/assertions/asserts'; diff --git a/packages/core/src/config/config.ts b/packages/core/src/config/config.ts index c3f395519f..780f9c6cbf 100755 --- a/packages/core/src/config/config.ts +++ b/packages/core/src/config/config.ts @@ -2,18 +2,19 @@ import * as fs from 'fs'; import * as path from 'path'; import { parseYaml, stringifyYaml } from '../js-yaml'; import { slash, doesYamlFileExist } from '../utils'; -import { NormalizedProblem } from '../walk'; -import { - SpecVersion, - SpecMajorVersion, +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 type { Oas2RuleSet, Oas3RuleSet, Async2RuleSet, Async3RuleSet, ArazzoRuleSet, } from '../oas-types'; -import { isBrowser } from '../env'; - import type { NodeType } from '../types'; import type { DecoratorConfig, @@ -29,8 +30,6 @@ import type { Telemetry, ThemeRawConfig, } from './types'; -import { getResolveConfig } from './utils'; -import { isAbsoluteUrl } from '../ref-utils'; export const IGNORE_FILE = '.redocly.lint-ignore.yaml'; const IGNORE_BANNER = diff --git a/packages/core/src/config/load.ts b/packages/core/src/config/load.ts index b2f7e5ab97..6f3c1294e5 100644 --- a/packages/core/src/config/load.ts +++ b/packages/core/src/config/load.ts @@ -3,17 +3,17 @@ import * as path from 'path'; import { RedoclyClient } from '../redocly'; import { isEmptyObject } from '../utils'; import { parseYaml } from '../js-yaml'; -import { Config } from './config'; 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 { DOMAINS } from '../redocly/domains'; async function addConfigMetadata({ rawConfig, diff --git a/packages/core/src/config/types.ts b/packages/core/src/config/types.ts index 6a899d9e11..ace6daae4d 100644 --- a/packages/core/src/config/types.ts +++ b/packages/core/src/config/types.ts @@ -1,3 +1,4 @@ +import type { Location } from '../ref-utils'; import type { ProblemSeverity, UserContext } from '../walk'; import type { Oas3PreprocessorsSet, @@ -19,11 +20,9 @@ import type { ArazzoDecoratorsSet, RuleMap, } from '../oas-types'; - import type { NodeType } from '../types'; -import { Location } from '../ref-utils'; import type { SkipFunctionContext } from '../visitors'; -import { +import type { BuiltInAsync2RuleId, BuiltInAsync3RuleId, BuiltInCommonOASRuleId, @@ -171,6 +170,7 @@ export type RawResolveConfig = { export type HttpResolveConfig = { headers: ResolveHeader[]; + // eslint-disable-next-line @typescript-eslint/ban-types customFetch?: Function; }; diff --git a/packages/core/src/config/utils.ts b/packages/core/src/config/utils.ts index 27e3447abf..ed8e2f412c 100644 --- a/packages/core/src/config/utils.ts +++ b/packages/core/src/config/utils.ts @@ -6,6 +6,8 @@ import { showWarningForDeprecatedField, } from '../utils'; import { Config } from './config'; +import { logger, colorize } from '../logger'; + import type { Api, DeprecatedInApi, @@ -21,7 +23,6 @@ import type { StyleguideRawConfig, ThemeConfig, } from './types'; -import { logger, colorize } from '../logger'; export function parsePresetName(presetName: string): { pluginId: string; configName: string } { if (presetName.indexOf('/') > -1) { diff --git a/packages/core/src/decorators/common/filters/filter-helper.ts b/packages/core/src/decorators/common/filters/filter-helper.ts index e9510149bc..c193d913c5 100644 --- a/packages/core/src/decorators/common/filters/filter-helper.ts +++ b/packages/core/src/decorators/common/filters/filter-helper.ts @@ -1,7 +1,8 @@ -import { UserContext } from '../../../walk'; import { isRef } from '../../../ref-utils'; import { isEmptyArray, isEmptyObject, isPlainObject } from '../../../utils'; +import type { UserContext } from '../../../walk'; + export function filter(node: any, ctx: UserContext, criteria: (item: any) => boolean) { const { parent, key } = ctx; let didDelete = false; diff --git a/packages/core/src/decorators/common/filters/filter-in.ts b/packages/core/src/decorators/common/filters/filter-in.ts index 88c602a941..24cdaf5c89 100644 --- a/packages/core/src/decorators/common/filters/filter-in.ts +++ b/packages/core/src/decorators/common/filters/filter-in.ts @@ -1,6 +1,7 @@ -import { Oas2Decorator, Oas3Decorator } from '../../../visitors'; import { checkIfMatchByStrategy, filter } from './filter-helper'; +import type { Oas2Decorator, Oas3Decorator } from '../../../visitors'; + const DEFAULT_STRATEGY = 'any'; export const FilterIn: Oas3Decorator | Oas2Decorator = ({ property, value, matchStrategy }) => { diff --git a/packages/core/src/decorators/common/filters/filter-out.ts b/packages/core/src/decorators/common/filters/filter-out.ts index c7e026c98d..e8efd689e8 100644 --- a/packages/core/src/decorators/common/filters/filter-out.ts +++ b/packages/core/src/decorators/common/filters/filter-out.ts @@ -1,6 +1,7 @@ -import { Oas2Decorator, Oas3Decorator } from '../../../visitors'; import { checkIfMatchByStrategy, filter } from './filter-helper'; +import type { Oas2Decorator, Oas3Decorator } from '../../../visitors'; + const DEFAULT_STRATEGY = 'any'; export const FilterOut: Oas3Decorator | Oas2Decorator = ({ property, value, matchStrategy }) => { diff --git a/packages/core/src/decorators/common/info-description-override.ts b/packages/core/src/decorators/common/info-description-override.ts index 388234ac52..fff0e4ef2c 100644 --- a/packages/core/src/decorators/common/info-description-override.ts +++ b/packages/core/src/decorators/common/info-description-override.ts @@ -1,6 +1,7 @@ -import { Oas3Decorator, Oas2Decorator } from '../../visitors'; import { readFileAsStringSync } from '../../utils'; -import { UserContext } from '../../walk'; + +import type { Oas3Decorator, Oas2Decorator } from '../../visitors'; +import type { UserContext } from '../../walk'; 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 fb74b162ac..9e3b2e2a54 100644 --- a/packages/core/src/decorators/common/info-override.ts +++ b/packages/core/src/decorators/common/info-override.ts @@ -1,4 +1,4 @@ -import { Oas3Decorator, Oas2Decorator } from '../../visitors'; +import type { Oas3Decorator, Oas2Decorator } from '../../visitors'; 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 e16c667f18..8b8037fe37 100644 --- a/packages/core/src/decorators/common/media-type-examples-override.ts +++ b/packages/core/src/decorators/common/media-type-examples-override.ts @@ -1,8 +1,9 @@ -import { Oas3Decorator } from '../../visitors'; -import { Oas3Operation, Oas3RequestBody, Oas3Response } from '../../typings/openapi'; import { yamlAndJsonSyncReader } from '../../utils'; import { isRef } from '../../ref-utils'; -import { NonUndefined, ResolveFn, UserContext } from '../../walk'; + +import type { Oas3Decorator } from '../../visitors'; +import type { Oas3Operation, Oas3RequestBody, Oas3Response } from '../../typings/openapi'; +import type { NonUndefined, ResolveFn, UserContext } from '../../walk'; 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 e4879ab741..c583fb4ff2 100644 --- a/packages/core/src/decorators/common/operation-description-override.ts +++ b/packages/core/src/decorators/common/operation-description-override.ts @@ -1,8 +1,9 @@ -import { Oas3Decorator, Oas2Decorator } from '../../visitors'; -import { Oas2Operation } from '../../typings/swagger'; -import { Oas3Operation } from '../../typings/openapi'; import { readFileAsStringSync } from '../../utils'; -import { UserContext } from '../../walk'; + +import type { Oas3Decorator, Oas2Decorator } from '../../visitors'; +import type { Oas2Operation } from '../../typings/swagger'; +import type { Oas3Operation } from '../../typings/openapi'; +import type { UserContext } from '../../walk'; 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 007361b9b2..abf03e516b 100644 --- a/packages/core/src/decorators/common/registry-dependencies.ts +++ b/packages/core/src/decorators/common/registry-dependencies.ts @@ -1,7 +1,7 @@ -import { UserContext } from '../../walk'; import { isRedoclyRegistryURL } from '../../redocly/domains'; -import { Oas3Decorator, Oas2Decorator } from '../../visitors'; +import type { UserContext } from '../../walk'; +import type { Oas3Decorator, Oas2Decorator } from '../../visitors'; 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 c83b2aa0f7..3974ceda01 100644 --- a/packages/core/src/decorators/common/remove-x-internal.ts +++ b/packages/core/src/decorators/common/remove-x-internal.ts @@ -1,8 +1,9 @@ -import { Oas3Decorator, Oas2Decorator } from '../../visitors'; import { isEmptyArray, isEmptyObject, isPlainObject } from '../../utils'; -import { UserContext } from '../../walk'; import { isRef } from '../../ref-utils'; +import type { Oas3Decorator, Oas2Decorator } from '../../visitors'; +import type { UserContext } from '../../walk'; + const DEFAULT_INTERNAL_PROPERTY_NAME = 'x-internal'; export const RemoveXInternal: Oas3Decorator | Oas2Decorator = ({ internalFlagProperty }) => { diff --git a/packages/core/src/decorators/common/tag-description-override.ts b/packages/core/src/decorators/common/tag-description-override.ts index 886c92f84f..4ca16e49db 100644 --- a/packages/core/src/decorators/common/tag-description-override.ts +++ b/packages/core/src/decorators/common/tag-description-override.ts @@ -1,6 +1,7 @@ -import { Oas3Decorator, Oas2Decorator } from '../../visitors'; import { readFileAsStringSync } from '../../utils'; -import { UserContext } from '../../walk'; + +import type { Oas3Decorator, Oas2Decorator } from '../../visitors'; +import type { UserContext } from '../../walk'; export const TagDescriptionOverride: Oas3Decorator | Oas2Decorator = ({ tagNames }) => { return { diff --git a/packages/core/src/decorators/oas2/index.ts b/packages/core/src/decorators/oas2/index.ts index 7727e09fa4..00d65dde23 100644 --- a/packages/core/src/decorators/oas2/index.ts +++ b/packages/core/src/decorators/oas2/index.ts @@ -1,4 +1,3 @@ -import { Oas2Decorator } from '../../visitors'; import { RegistryDependencies } from '../common/registry-dependencies'; import { OperationDescriptionOverride } from '../common/operation-description-override'; import { TagDescriptionOverride } from '../common/tag-description-override'; @@ -8,6 +7,8 @@ import { RemoveXInternal } from '../common/remove-x-internal'; import { FilterIn } from '../common/filters/filter-in'; import { FilterOut } from '../common/filters/filter-out'; +import type { Oas2Decorator } from '../../visitors'; + export const decorators = { 'registry-dependencies': RegistryDependencies as Oas2Decorator, 'operation-description-override': OperationDescriptionOverride 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 0cd3a9f498..d47b004b7f 100644 --- a/packages/core/src/decorators/oas2/remove-unused-components.ts +++ b/packages/core/src/decorators/oas2/remove-unused-components.ts @@ -1,6 +1,6 @@ -import { Location } from '../../ref-utils'; import { isEmptyObject } from '../../utils'; +import type { Location } from '../../ref-utils'; import type { Oas2Decorator } from '../../visitors'; import type { Oas2Components, Oas2Definition } from '../../typings/swagger'; diff --git a/packages/core/src/decorators/oas3/index.ts b/packages/core/src/decorators/oas3/index.ts index 29381ad8c4..369b20657f 100644 --- a/packages/core/src/decorators/oas3/index.ts +++ b/packages/core/src/decorators/oas3/index.ts @@ -1,4 +1,3 @@ -import { Oas3Decorator } from '../../visitors'; import { RegistryDependencies } from '../common/registry-dependencies'; import { OperationDescriptionOverride } from '../common/operation-description-override'; import { TagDescriptionOverride } from '../common/tag-description-override'; @@ -9,6 +8,8 @@ import { FilterIn } from '../common/filters/filter-in'; import { FilterOut } from '../common/filters/filter-out'; import { MediaTypeExamplesOverride } from '../common/media-type-examples-override'; +import type { Oas3Decorator } from '../../visitors'; + export const decorators = { 'registry-dependencies': RegistryDependencies as Oas3Decorator, 'operation-description-override': OperationDescriptionOverride 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 06f6d1f964..4780961b9c 100644 --- a/packages/core/src/decorators/oas3/remove-unused-components.ts +++ b/packages/core/src/decorators/oas3/remove-unused-components.ts @@ -1,6 +1,6 @@ -import { Location } from '../../ref-utils'; import { isEmptyObject } from '../../utils'; +import type { Location } from '../../ref-utils'; import type { Oas3Decorator } from '../../visitors'; import type { Oas3Components, Oas3Definition } from '../../typings/openapi'; diff --git a/packages/core/src/format/codeframes.ts b/packages/core/src/format/codeframes.ts index d25c232593..57b55e14ea 100644 --- a/packages/core/src/format/codeframes.ts +++ b/packages/core/src/format/codeframes.ts @@ -1,8 +1,9 @@ import * as yamlAst from 'yaml-ast-parser'; import { unescapePointer } from '../ref-utils'; -import { LineColLocationObject, Loc, LocationObject } from '../walk'; import { colorize, colorOptions } from '../logger'; +import type { LineColLocationObject, Loc, LocationObject } from '../walk'; + type YAMLMapping = yamlAst.YAMLMapping & { kind: yamlAst.Kind.MAPPING }; type YAMLMap = yamlAst.YamlMap & { kind: yamlAst.Kind.MAP }; type YAMLAnchorReference = yamlAst.YAMLAnchorReference & { kind: yamlAst.Kind.ANCHOR_REF }; diff --git a/packages/core/src/format/format.ts b/packages/core/src/format/format.ts index 869d8e3bb3..7e19eacfa3 100644 --- a/packages/core/src/format/format.ts +++ b/packages/core/src/format/format.ts @@ -1,14 +1,19 @@ import * as path from 'path'; import { colorOptions, colorize, logger } from '../logger'; import { output } from '../output'; - -const coreVersion = require('../../package.json').version; - -import { NormalizedProblem, ProblemSeverity, LineColLocationObject, LocationObject } from '../walk'; import { getCodeframe, getLineColLocation } from './codeframes'; import { env, isBrowser } from '../env'; import { isAbsoluteUrl } from '../ref-utils'; +import type { + NormalizedProblem, + ProblemSeverity, + LineColLocationObject, + LocationObject, +} from '../walk'; + +const coreVersion = require('../../package.json').version; + export type Totals = { errors: number; warnings: number; diff --git a/packages/core/src/js-yaml/index.ts b/packages/core/src/js-yaml/index.ts index d953ea011b..3abacc12fa 100644 --- a/packages/core/src/js-yaml/index.ts +++ b/packages/core/src/js-yaml/index.ts @@ -1,7 +1,9 @@ // TODO: add a type for "types" https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/js-yaml/index.d.ts // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore -import { JSON_SCHEMA, types, LoadOptions, DumpOptions, load, dump } from 'js-yaml'; +import { JSON_SCHEMA, types, load, dump } from 'js-yaml'; + +import type { LoadOptions, DumpOptions } from 'js-yaml'; const DEFAULT_SCHEMA_WITHOUT_TIMESTAMP = JSON_SCHEMA.extend({ implicit: [types.merge], diff --git a/packages/core/src/lint.ts b/packages/core/src/lint.ts index 3012332c1a..d8fa0ec100 100755 --- a/packages/core/src/lint.ts +++ b/packages/core/src/lint.ts @@ -2,7 +2,7 @@ import { rootRedoclyConfigSchema } from '@redocly/config'; import { BaseResolver, resolveDocument, makeDocumentFromString } from './resolve'; import { normalizeVisitors } from './visitors'; import { walkDocument } from './walk'; -import { StyleguideConfig, Config, initRules } from './config'; +import { initRules } from './config'; import { normalizeTypes } from './types'; import { releaseAjvInstance } from './rules/ajv'; import { SpecVersion, getMajorSpecVersion, detectSpec, getTypes } from './oas-types'; @@ -10,6 +10,7 @@ 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'; diff --git a/packages/core/src/logger.ts b/packages/core/src/logger.ts index 08926ce135..3d6232410e 100644 --- a/packages/core/src/logger.ts +++ b/packages/core/src/logger.ts @@ -1,9 +1,9 @@ import * as colorette from 'colorette'; -export { options as colorOptions } from 'colorette'; - import { isBrowser } from './env'; import { identity } from './utils'; +export { options as colorOptions } from 'colorette'; + export const colorize = new Proxy(colorette, { get(target: typeof colorette, prop: string): typeof identity { if (isBrowser) { diff --git a/packages/core/src/oas-types.ts b/packages/core/src/oas-types.ts index 90ab032ad5..6fa8dc7d9e 100644 --- a/packages/core/src/oas-types.ts +++ b/packages/core/src/oas-types.ts @@ -1,21 +1,11 @@ -import type { - Oas3Rule, - Oas3Preprocessor, - Oas2Rule, - Oas2Preprocessor, - Async2Preprocessor, - Async2Rule, - Async3Preprocessor, - Async3Rule, - ArazzoPreprocessor, - ArazzoRule, -} from './visitors'; 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 type { BuiltInAsync2RuleId, BuiltInAsync3RuleId, @@ -24,7 +14,18 @@ import type { BuiltInOAS2RuleId, BuiltInOAS3RuleId, } from './types/redocly-yaml'; -import { isPlainObject } from './utils'; +import type { + Oas3Rule, + Oas3Preprocessor, + Oas2Rule, + Oas2Preprocessor, + Async2Preprocessor, + Async2Rule, + Async3Preprocessor, + Async3Rule, + ArazzoPreprocessor, + ArazzoRule, +} from './visitors'; export enum SpecVersion { OAS2 = 'oas2', diff --git a/packages/core/src/redocly/domains.ts b/packages/core/src/redocly/domains.ts index 3fa6856fdf..3085cc169a 100644 --- a/packages/core/src/redocly/domains.ts +++ b/packages/core/src/redocly/domains.ts @@ -1,4 +1,4 @@ -import { Region } from '../config/types'; +import type { Region } from '../config/types'; let redoclyDomain = 'redocly.com'; diff --git a/packages/core/src/redocly/index.ts b/packages/core/src/redocly/index.ts index df28bdd60e..b02730f6c8 100644 --- a/packages/core/src/redocly/index.ts +++ b/packages/core/src/redocly/index.ts @@ -3,11 +3,8 @@ import { resolve } from 'path'; import { homedir } from 'os'; import { RegistryApi } from './registry-api'; import { env } from '../env'; -import { RegionalToken, RegionalTokenWithValidity } from './redocly-client-types'; import { isNotEmptyObject } from '../utils'; import { colorize } from '../logger'; - -import type { AccessTokens, Region } from '../config/types'; import { AVAILABLE_REGIONS, DEFAULT_REGION, @@ -16,6 +13,9 @@ import { setRedoclyDomain, } from './domains'; +import type { RegionalToken, RegionalTokenWithValidity } from './redocly-client-types'; +import type { AccessTokens, Region } from '../config/types'; + export const TOKEN_FILENAME = '.redocly-config.json'; export class RedoclyClient { diff --git a/packages/core/src/redocly/registry-api.ts b/packages/core/src/redocly/registry-api.ts index 5d77c6a446..ff6abafde7 100644 --- a/packages/core/src/redocly/registry-api.ts +++ b/packages/core/src/redocly/registry-api.ts @@ -1,4 +1,8 @@ -import fetch, { RequestInit, HeadersInit } from 'node-fetch'; +import fetch from 'node-fetch'; +import { getProxyAgent, isNotEmptyObject } from '../utils'; +import { getRedoclyDomain } from './domains'; + +import type { RequestInit, HeadersInit } from 'node-fetch'; import type { NotFoundProblemResponse, PrepareFileuploadOKResponse, @@ -6,8 +10,6 @@ import type { PushApiParams, } from './registry-api-types'; import type { AccessTokens, Region } from '../config/types'; -import { getProxyAgent, isNotEmptyObject } from '../utils'; -import { getRedoclyDomain } from './domains'; const version = require('../../package.json').version; diff --git a/packages/core/src/ref-utils.ts b/packages/core/src/ref-utils.ts index 0a94c6cc5c..da746a954f 100644 --- a/packages/core/src/ref-utils.ts +++ b/packages/core/src/ref-utils.ts @@ -1,7 +1,8 @@ -import { Source } from './resolve'; -import { OasRef } from './typings/openapi'; import { isTruthy } from './utils'; +import type { Source } from './resolve'; +import type { OasRef } from './typings/openapi'; + export function joinPointer(base: string, key: string | number) { if (base === '') base = '#/'; return base[base.length - 1] === '/' ? base + key : base + '/' + key; @@ -60,6 +61,7 @@ export function pointerBaseName(pointer: string) { } export function refBaseName(ref: string) { + // eslint-disable-next-line no-useless-escape const parts = ref.split(/[\/\\]/); // split by '\' and '/' return parts[parts.length - 1].replace(/\.[^.]+$/, ''); // replace extension with empty string } diff --git a/packages/core/src/resolve.ts b/packages/core/src/resolve.ts index 7093b4f9e1..fd55c85c06 100644 --- a/packages/core/src/resolve.ts +++ b/packages/core/src/resolve.ts @@ -1,11 +1,13 @@ import * as fs from 'fs'; import * as path from 'path'; -import { OasRef } from './typings/openapi'; import { isRef, joinPointer, escapePointer, parseRef, isAbsoluteUrl, isAnchor } from './ref-utils'; -import type { YAMLNode, LoadOptions } from 'yaml-ast-parser'; -import { NormalizedNodeType, isNamedType, SpecExtension } from './types'; +import { isNamedType, SpecExtension } from './types'; import { readFileFromUrl, parseYaml, nextTick } from './utils'; -import { ResolveConfig } from './config/types'; + +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'; export type CollectedRefs = Map; diff --git a/packages/core/src/rules/ajv.ts b/packages/core/src/rules/ajv.ts index 90f101bb0a..0e26faa81c 100644 --- a/packages/core/src/rules/ajv.ts +++ b/packages/core/src/rules/ajv.ts @@ -1,6 +1,7 @@ import Ajv from '@redocly/ajv/dist/2020'; -import { Location, escapePointer } from '../ref-utils'; +import { escapePointer } from '../ref-utils'; +import type { Location } from '../ref-utils'; import type { ValidateFunction, ErrorObject } from '@redocly/ajv/dist/2020'; import type { ResolveFn } from '../walk'; diff --git a/packages/core/src/rules/arazzo/index.ts b/packages/core/src/rules/arazzo/index.ts index 97ddd67195..8e1a4b4835 100644 --- a/packages/core/src/rules/arazzo/index.ts +++ b/packages/core/src/rules/arazzo/index.ts @@ -1,8 +1,9 @@ -import { ArazzoRule } from '../../visitors'; import { Spec } from '../common/spec'; -import type { ArazzoRuleSet } from '../../oas-types'; import { Assertions } from '../common/assertions'; +import type { ArazzoRule } from '../../visitors'; +import type { ArazzoRuleSet } from '../../oas-types'; + export const rules: ArazzoRuleSet<'built-in'> = { spec: Spec as ArazzoRule, assertions: Assertions as ArazzoRule, diff --git a/packages/core/src/rules/async2/channels-kebab-case.ts b/packages/core/src/rules/async2/channels-kebab-case.ts index 63e75f902a..4a2276b9da 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 { Async2Rule } from '../../visitors'; -import { UserContext } from '../../walk'; +import type { Async2Rule } from '../../visitors'; +import type { UserContext } from '../../walk'; export const ChannelsKebabCase: Async2Rule = () => { return { diff --git a/packages/core/src/rules/async2/index.ts b/packages/core/src/rules/async2/index.ts index 066b11d3a7..324c2639e1 100644 --- a/packages/core/src/rules/async2/index.ts +++ b/packages/core/src/rules/async2/index.ts @@ -1,4 +1,3 @@ -import { Async2Rule } from '../../visitors'; import { Assertions } from '../common/assertions'; import { Spec } from '../common/spec'; import { InfoContact } from '../common/info-contact'; @@ -7,6 +6,8 @@ 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 type { Async2Rule } from '../../visitors'; import type { Async2RuleSet } from '../../oas-types'; export const rules: Async2RuleSet<'built-in'> = { 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 1b1ecfe7c7..f1444933c8 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 { Async2Rule } from '../../visitors'; -import { UserContext } from '../../walk'; +import type { Async2Rule } from '../../visitors'; +import type { UserContext } from '../../walk'; export const NoChannelTrailingSlash: Async2Rule = () => { return { diff --git a/packages/core/src/rules/async3/channels-kebab-case.ts b/packages/core/src/rules/async3/channels-kebab-case.ts index a14d78396d..1b78796cd6 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 { Channel } from '../../typings/asyncapi3'; -import { Async3Rule } from '../../visitors'; -import { UserContext } from '../../walk'; +import type { Channel } from '../../typings/asyncapi3'; +import type { Async3Rule } from '../../visitors'; +import type { UserContext } from '../../walk'; export const ChannelsKebabCase: Async3Rule = () => { return { diff --git a/packages/core/src/rules/async3/index.ts b/packages/core/src/rules/async3/index.ts index 9e9115a864..d143fd0cd2 100644 --- a/packages/core/src/rules/async3/index.ts +++ b/packages/core/src/rules/async3/index.ts @@ -1,4 +1,3 @@ -import { Async3Rule } from '../../visitors'; import { Assertions } from '../common/assertions'; import { Spec } from '../common/spec'; import { InfoContact } from '../common/info-contact'; @@ -7,6 +6,8 @@ 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 type { Async3Rule } from '../../visitors'; import type { Async3RuleSet } from '../../oas-types'; export const rules: Async3RuleSet<'built-in'> = { 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 7cc93e0c29..7e664dab9c 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 { Async3Rule } from '../../visitors'; -import { UserContext } from '../../walk'; -import { Channel } from '../../typings/asyncapi3'; +import type { Async3Rule } from '../../visitors'; +import type { UserContext } from '../../walk'; +import type { Channel } from '../../typings/asyncapi3'; export const NoChannelTrailingSlash: Async3Rule = () => { return { diff --git a/packages/core/src/rules/common/assertions/asserts.ts b/packages/core/src/rules/common/assertions/asserts.ts index 6a7646b027..6794f98961 100644 --- a/packages/core/src/rules/common/assertions/asserts.ts +++ b/packages/core/src/rules/common/assertions/asserts.ts @@ -1,13 +1,9 @@ -import { AssertionContext, AssertResult, CustomFunction } from 'core/src/config/types'; -import { Location } from '../../../ref-utils'; import { isPlainObject, isString as runOnValue, isTruthy } from '../../../utils'; -import { - OrderOptions, - OrderDirection, - isOrdered, - getIntersectionLength, - regexFromString, -} from './utils'; +import { isOrdered, getIntersectionLength, regexFromString } from './utils'; + +import type { AssertionContext, AssertResult, CustomFunction } from '../../../config/types'; +import type { Location } from '../../../ref-utils'; +import type { OrderOptions, OrderDirection } from './utils'; 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 4e00f9fb62..0436c0399b 100644 --- a/packages/core/src/rules/common/assertions/index.ts +++ b/packages/core/src/rules/common/assertions/index.ts @@ -1,8 +1,7 @@ -import { asserts } from './asserts'; import { buildSubjectVisitor, buildVisitorObject } from './utils'; import { isString } from '../../../utils'; -import type { AssertionFn } from './asserts'; +import type { asserts, AssertionFn } from './asserts'; import type { ArazzoVisitor, Async2Visitor, diff --git a/packages/core/src/rules/common/assertions/utils.ts b/packages/core/src/rules/common/assertions/utils.ts index 09c24505a6..d14d010335 100644 --- a/packages/core/src/rules/common/assertions/utils.ts +++ b/packages/core/src/rules/common/assertions/utils.ts @@ -1,7 +1,10 @@ -import { asserts, runOnKeysSet, runOnValuesSet, Asserts } from './asserts'; +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 type { @@ -10,7 +13,6 @@ import type { SkipFunctionContext, VisitFunction, } from '../../../visitors'; -import { UserContext } from 'core/src/walk'; 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 27f9de122f..70cae48db2 100644 --- a/packages/core/src/rules/common/info-contact.ts +++ b/packages/core/src/rules/common/info-contact.ts @@ -1,6 +1,7 @@ -import { Oas3Rule, Oas2Rule } from '../../visitors'; import { missingRequiredField } from '../utils'; +import type { Oas3Rule, Oas2Rule } from '../../visitors'; + export const InfoContact: Oas3Rule | Oas2Rule = () => { return { Info(info, { report, location }) { diff --git a/packages/core/src/rules/common/info-license-url.ts b/packages/core/src/rules/common/info-license-url.ts index aafebcd477..fcbdc03ea7 100644 --- a/packages/core/src/rules/common/info-license-url.ts +++ b/packages/core/src/rules/common/info-license-url.ts @@ -1,6 +1,7 @@ -import { Oas3Rule, Oas2Rule } from '../../visitors'; import { validateDefinedAndNonEmpty } from '../utils'; +import type { Oas3Rule, Oas2Rule } from '../../visitors'; + export const InfoLicenseUrl: Oas3Rule | Oas2Rule = () => { return { License(license, ctx) { diff --git a/packages/core/src/rules/common/info-license.ts b/packages/core/src/rules/common/info-license.ts index f45975e6f1..1ed70975d1 100644 --- a/packages/core/src/rules/common/info-license.ts +++ b/packages/core/src/rules/common/info-license.ts @@ -1,6 +1,7 @@ -import { Oas3Rule, Oas2Rule } from '../../visitors'; import { missingRequiredField } from '../utils'; +import type { Oas3Rule, Oas2Rule } from '../../visitors'; + export const InfoLicense: Oas3Rule | Oas2Rule = () => { return { Info(info, { report }) { diff --git a/packages/core/src/rules/common/no-ambiguous-paths.ts b/packages/core/src/rules/common/no-ambiguous-paths.ts index 3edfa0ba96..a8d2af5b27 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 { Oas3Rule, Oas2Rule } from '../../visitors'; -import { UserContext } from '../../walk'; -import { Oas3Paths } from '../../typings/openapi'; -import { Oas2Paths } from '../../typings/swagger'; +import type { Oas3Rule, Oas2Rule } from '../../visitors'; +import type { UserContext } from '../../walk'; +import type { Oas3Paths } from '../../typings/openapi'; +import type { Oas2Paths } from '../../typings/swagger'; 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 d711ac44c5..9f3b5d4027 100644 --- a/packages/core/src/rules/common/no-enum-type-mismatch.ts +++ b/packages/core/src/rules/common/no-enum-type-mismatch.ts @@ -1,8 +1,9 @@ -import { Oas3Rule, Oas2Rule } from '../../visitors'; import { matchesJsonSchemaType, oasTypeOf } from '../utils'; -import { Oas2Schema } from '../../typings/swagger'; -import { Oas3Schema } from '../../typings/openapi'; -import { UserContext } from '../../walk'; + +import type { Oas3Rule, Oas2Rule } from '../../visitors'; +import type { Oas2Schema } from '../../typings/swagger'; +import type { Oas3Schema } from '../../typings/openapi'; +import type { UserContext } from '../../walk'; 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 1ddd0ff57d..59560154fd 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,10 @@ -import { Oas3Rule, Oas2Rule } from '../../visitors'; -import { Oas2PathItem } from '../../typings/swagger'; -import { Oas3PathItem } from '../../typings/openapi'; -import { UserContext } from '../../walk'; import { isPathParameter, splitCamelCaseIntoWords } from '../../utils'; +import type { Oas3Rule, Oas2Rule } from '../../visitors'; +import type { Oas2PathItem } from '../../typings/swagger'; +import type { Oas3PathItem } from '../../typings/openapi'; +import type { UserContext } from '../../walk'; + const httpMethods = ['get', 'head', 'post', 'put', 'patch', 'delete', 'options', 'trace']; export const NoHttpVerbsInPaths: Oas3Rule | Oas2Rule = ({ splitIntoWords }) => { diff --git a/packages/core/src/rules/common/no-identical-paths.ts b/packages/core/src/rules/common/no-identical-paths.ts index a81e5a737c..988dec3e56 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 { Oas3Rule, Oas2Rule } from '../../visitors'; -import { UserContext } from '../../walk'; -import { Oas3Paths } from '../../typings/openapi'; -import { Oas2Paths } from '../../typings/swagger'; +import type { Oas3Rule, Oas2Rule } from '../../visitors'; +import type { UserContext } from '../../walk'; +import type { Oas3Paths } from '../../typings/openapi'; +import type { Oas2Paths } from '../../typings/swagger'; 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 0a4806d435..740335dfeb 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,8 @@ -import { UserContext } from '../../walk'; -import { Oas3Parameter } from '../../typings/openapi'; import { getAdditionalPropertiesOption, validateExample } from '../utils'; +import type { UserContext } from '../../walk'; +import type { Oas3Parameter } from '../../typings/openapi'; + export const NoInvalidParameterExamples: any = (opts: any) => { const allowAdditionalProperties = getAdditionalPropertiesOption(opts) ?? false; return { 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 aa195e504d..324ad938c5 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 { Oas3Rule, Oas2Rule } from '../../visitors'; -import { UserContext } from '../../walk'; +import type { Oas3Rule, Oas2Rule } from '../../visitors'; +import type { UserContext } from '../../walk'; 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 ef26c1262d..d52f6c1004 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,10 @@ -import { Oas2Rule, Oas3Rule } from '../../visitors'; -import { Oas3Schema, Oas3_1Schema } from '../../typings/openapi'; -import { Oas2Schema } from 'core/src/typings/swagger'; -import { UserContext } from 'core/src/walk'; import { isRef } from '../../ref-utils'; +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'; + export const NoRequiredSchemaPropertiesUndefined: Oas3Rule | Oas2Rule = () => { return { Schema: { diff --git a/packages/core/src/rules/common/operation-2xx-response.ts b/packages/core/src/rules/common/operation-2xx-response.ts index 1b0959ebd9..201fdb6c63 100644 --- a/packages/core/src/rules/common/operation-2xx-response.ts +++ b/packages/core/src/rules/common/operation-2xx-response.ts @@ -1,7 +1,8 @@ -import { Oas3Rule, Oas2Rule } from '../../visitors'; -import { UserContext } from '../../walk'; import { validateResponseCodes } from '../utils'; +import type { Oas3Rule, Oas2Rule } from '../../visitors'; +import type { UserContext } from '../../walk'; + export const Operation2xxResponse: Oas3Rule | Oas2Rule = ({ validateWebhooks }) => { return { Paths: { diff --git a/packages/core/src/rules/common/operation-4xx-response.ts b/packages/core/src/rules/common/operation-4xx-response.ts index fdfba4733c..e4f5f8f7b6 100644 --- a/packages/core/src/rules/common/operation-4xx-response.ts +++ b/packages/core/src/rules/common/operation-4xx-response.ts @@ -1,7 +1,8 @@ -import { Oas3Rule, Oas2Rule } from '../../visitors'; -import { UserContext } from '../../walk'; import { validateResponseCodes } from '../utils'; +import type { Oas3Rule, Oas2Rule } from '../../visitors'; +import type { UserContext } from '../../walk'; + export const Operation4xxResponse: Oas3Rule | Oas2Rule = ({ validateWebhooks }) => { return { Paths: { diff --git a/packages/core/src/rules/common/operation-description.ts b/packages/core/src/rules/common/operation-description.ts index c30f0dab66..6f2bb45c04 100644 --- a/packages/core/src/rules/common/operation-description.ts +++ b/packages/core/src/rules/common/operation-description.ts @@ -1,8 +1,9 @@ -import { Oas3Rule, Oas2Rule } from '../../visitors'; import { validateDefinedAndNonEmpty } from '../utils'; -import { UserContext } from '../../walk'; -import { Oas2Operation } from '../../typings/swagger'; -import { Oas3Operation } from '../../typings/openapi'; + +import type { Oas3Rule, Oas2Rule } from '../../visitors'; +import type { UserContext } from '../../walk'; +import type { Oas2Operation } from '../../typings/swagger'; +import type { Oas3Operation } from '../../typings/openapi'; 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 4354064dc6..54aa597abc 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 { Oas3Rule, Oas2Rule } from '../../visitors'; -import { Oas2Operation } from '../../typings/swagger'; -import { Oas3Operation } from '../../typings/openapi'; -import { UserContext } from '../../walk'; +import type { Oas3Rule, Oas2Rule } from '../../visitors'; +import type { Oas2Operation } from '../../typings/swagger'; +import type { Oas3Operation } from '../../typings/openapi'; +import type { UserContext } from '../../walk'; 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 4337431dd6..5f1c410809 100644 --- a/packages/core/src/rules/common/operation-operationId-url-safe.ts +++ b/packages/core/src/rules/common/operation-operationId-url-safe.ts @@ -1,8 +1,9 @@ -import { Oas3Rule, Oas2Rule } from '../../visitors'; -import { Oas2Operation } from '../../typings/swagger'; -import { Oas3Operation } from '../../typings/openapi'; -import { UserContext } from '../../walk'; +import type { Oas3Rule, Oas2Rule } from '../../visitors'; +import type { Oas2Operation } from '../../typings/swagger'; +import type { Oas3Operation } from '../../typings/openapi'; +import type { UserContext } from '../../walk'; +// eslint-disable-next-line no-useless-escape const validUrlSymbols = /^[A-Za-z0-9-._~:/?#\[\]@!\$&'()*+,;=]*$/; export const OperationIdUrlSafe: Oas3Rule | Oas2Rule = () => { diff --git a/packages/core/src/rules/common/operation-operationId.ts b/packages/core/src/rules/common/operation-operationId.ts index d64baaee61..b759a2ab01 100644 --- a/packages/core/src/rules/common/operation-operationId.ts +++ b/packages/core/src/rules/common/operation-operationId.ts @@ -1,8 +1,9 @@ -import { Oas3Rule, Oas2Rule } from '../../visitors'; import { validateDefinedAndNonEmpty } from '../utils'; -import { UserContext } from '../../walk'; -import { Oas2Operation } from '../../typings/swagger'; -import { Oas3Operation } from '../../typings/openapi'; + +import type { Oas3Rule, Oas2Rule } from '../../visitors'; +import type { UserContext } from '../../walk'; +import type { Oas2Operation } from '../../typings/swagger'; +import type { Oas3Operation } from '../../typings/openapi'; 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 73a271aeff..901dfb26d6 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 { Oas3Rule, Oas2Rule } from '../../visitors'; -import { Oas2Parameter } from '../../typings/swagger'; -import { Oas3Parameter } from '../../typings/openapi'; -import { UserContext } from '../../walk'; +import type { Oas3Rule, Oas2Rule } from '../../visitors'; +import type { Oas2Parameter } from '../../typings/swagger'; +import type { Oas3Parameter } from '../../typings/openapi'; +import type { UserContext } from '../../walk'; 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 247ef006d6..6e149f9ca9 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 { Oas3Rule, Oas2Rule } from '../../visitors'; -import { Oas2Operation } from '../../typings/swagger'; -import { Oas3Operation } from '../../typings/openapi'; -import { UserContext } from '../../walk'; +import type { Oas3Rule, Oas2Rule } from '../../visitors'; +import type { Oas2Operation } from '../../typings/swagger'; +import type { Oas3Operation } from '../../typings/openapi'; +import type { UserContext } from '../../walk'; 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 504232d326..18743ad9ed 100644 --- a/packages/core/src/rules/common/operation-summary.ts +++ b/packages/core/src/rules/common/operation-summary.ts @@ -1,8 +1,9 @@ -import { Oas3Rule, Oas2Rule } from '../../visitors'; import { validateDefinedAndNonEmpty } from '../utils'; -import { UserContext } from '../../walk'; -import { Oas2Operation } from '../../typings/swagger'; -import { Oas3Operation } from '../../typings/openapi'; + +import type { Oas3Rule, Oas2Rule } from '../../visitors'; +import type { UserContext } from '../../walk'; +import type { Oas2Operation } from '../../typings/swagger'; +import type { Oas3Operation } from '../../typings/openapi'; 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 a6cc44e60e..e492dba7e2 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 { Oas3Rule, Oas2Rule } from '../../visitors'; -import { Oas2Definition, Oas2Operation } from '../../typings/swagger'; -import { Oas3Definition, Oas3Operation } from '../../typings/openapi'; -import { UserContext } from '../../walk'; +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'; 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 867c29aa33..f1495b29e4 100644 --- a/packages/core/src/rules/common/parameter-description.ts +++ b/packages/core/src/rules/common/parameter-description.ts @@ -1,7 +1,7 @@ -import { Oas3Rule, Oas2Rule } from '../../visitors'; -import { Oas2Parameter } from '../../typings/swagger'; -import { Oas3Parameter } from '../../typings/openapi'; -import { UserContext } from '../../walk'; +import type { Oas3Rule, Oas2Rule } from '../../visitors'; +import type { Oas2Parameter } from '../../typings/swagger'; +import type { Oas3Parameter } from '../../typings/openapi'; +import type { UserContext } from '../../walk'; 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 c311fcb7b3..8a09ce31be 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 { Oas3Rule, Oas2Rule } from '../../visitors'; -import { UserContext } from '../../walk'; +import type { Oas3Rule, Oas2Rule } from '../../visitors'; +import type { UserContext } from '../../walk'; 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 bcbb30a604..14988cbffd 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 { Oas2Rule, Oas3Rule } from '../../visitors'; -import { Oas2PathItem } from '../../typings/swagger'; -import { Oas3PathItem } from '../../typings/openapi'; -import { UserContext } from '../../walk'; +import type { Oas2Rule, Oas3Rule } from '../../visitors'; +import type { Oas2PathItem } from '../../typings/swagger'; +import type { Oas3PathItem } from '../../typings/openapi'; +import type { UserContext } from '../../walk'; 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 9b5f541567..3bfe0bcddd 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 { Oas3Rule, Oas2Rule } from '../../visitors'; -import { Oas2PathItem } from '../../typings/swagger'; -import { Oas3PathItem } from '../../typings/openapi'; -import { UserContext } from '../../walk'; +import type { Oas3Rule, Oas2Rule } from '../../visitors'; +import type { Oas2PathItem } from '../../typings/swagger'; +import type { Oas3PathItem } from '../../typings/openapi'; +import type { UserContext } from '../../walk'; 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 b300cdfdfe..eaeedfc7c4 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 { Oas3Rule, Oas2Rule } from '../../visitors'; -import { UserContext } from '../../walk'; +import type { Oas3Rule, Oas2Rule } from '../../visitors'; +import type { UserContext } from '../../walk'; 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 08bffac514..bbb696b860 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 { Oas3Rule, Oas2Rule } from '../../visitors'; -import { Oas2Parameter } from '../../typings/swagger'; -import { Oas3Parameter } from '../../typings/openapi'; -import { UserContext } from '../../walk'; +import type { Oas3Rule, Oas2Rule } from '../../visitors'; +import type { Oas2Parameter } from '../../typings/swagger'; +import type { Oas3Parameter } from '../../typings/openapi'; +import type { UserContext } from '../../walk'; 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 6e78bbff91..5c9485f46a 100644 --- a/packages/core/src/rules/common/path-segment-plural.ts +++ b/packages/core/src/rules/common/path-segment-plural.ts @@ -1,8 +1,9 @@ import * as pluralize from 'pluralize'; -import { Oas3Rule, Oas2Rule } from '../../visitors'; -import { UserContext } from '../../walk'; import { isPathParameter } from '../../utils'; +import type { Oas3Rule, Oas2Rule } from '../../visitors'; +import type { UserContext } from '../../walk'; + export const PathSegmentPlural: Oas3Rule | Oas2Rule = (opts) => { const { ignoreLastPathSegment, exceptions } = opts; return { diff --git a/packages/core/src/rules/common/paths-kebab-case.ts b/packages/core/src/rules/common/paths-kebab-case.ts index eafad16e80..deee184a2b 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 { Oas3Rule, Oas2Rule } from '../../visitors'; -import { UserContext } from '../../walk'; +import type { Oas3Rule, Oas2Rule } from '../../visitors'; +import type { UserContext } from '../../walk'; 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 38d9448704..beb6d1ae31 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 { UserContext } from '../../walk'; -import { Oas3Schema, Oas3_1Schema } from '../../typings/openapi'; -import { Oas2Schema } from 'core/src/typings/swagger'; -import { Oas3Rule } from 'core/src/visitors'; +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'; 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 2d4193f3bc..38ad9d6f75 100644 --- a/packages/core/src/rules/common/response-contains-header.ts +++ b/packages/core/src/rules/common/response-contains-header.ts @@ -1,9 +1,10 @@ -import { Oas2Rule, Oas3Rule } from '../../visitors'; -import { UserContext } from '../../walk'; -import { Oas3Response } from '../../typings/openapi'; -import { Oas2Response } from '../../typings/swagger'; import { getMatchingStatusCodeRange } from '../../utils'; +import type { Oas2Rule, Oas3Rule } from '../../visitors'; +import type { UserContext } from '../../walk'; +import type { Oas3Response } from '../../typings/openapi'; +import type { Oas2Response } from '../../typings/swagger'; + export const ResponseContainsHeader: Oas3Rule | Oas2Rule = (options) => { const names: Record = options.names || {}; return { 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 248dfb8e4f..4fd1c4f666 100644 --- a/packages/core/src/rules/common/scalar-property-missing-example.ts +++ b/packages/core/src/rules/common/scalar-property-missing-example.ts @@ -1,8 +1,9 @@ +import { SpecVersion } from '../../oas-types'; + 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 { SpecVersion } from '../../oas-types'; 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 5f6012dc96..1e1ea0b98e 100644 --- a/packages/core/src/rules/common/security-defined.ts +++ b/packages/core/src/rules/common/security-defined.ts @@ -1,13 +1,13 @@ -import { Oas3Rule, Oas2Rule } from '../../visitors'; -import { Location } from '../../ref-utils'; -import { UserContext } from '../../walk'; -import { +import type { Oas3Rule, Oas2Rule } from '../../visitors'; +import type { Location } from '../../ref-utils'; +import type { UserContext } from '../../walk'; +import type { Oas2Definition, Oas2Operation, Oas2PathItem, Oas2SecurityScheme, } from '../../typings/swagger'; -import { +import type { Oas3Definition, Oas3Operation, Oas3PathItem, diff --git a/packages/core/src/rules/common/spec-strict-refs.ts b/packages/core/src/rules/common/spec-strict-refs.ts index e1d52261ba..c7ca6c2021 100644 --- a/packages/core/src/rules/common/spec-strict-refs.ts +++ b/packages/core/src/rules/common/spec-strict-refs.ts @@ -1,6 +1,7 @@ -import { Oas2Rule, Oas3Rule } from '../../visitors'; import { isRef } from '../../ref-utils'; +import type { Oas2Rule, Oas3Rule } from '../../visitors'; + export const SpecStrictRefs: Oas3Rule | Oas2Rule = () => { const nodesToSkip = [ 'Schema', diff --git a/packages/core/src/rules/common/spec.ts b/packages/core/src/rules/common/spec.ts index 1e9112c066..3c2dfece5e 100644 --- a/packages/core/src/rules/common/spec.ts +++ b/packages/core/src/rules/common/spec.ts @@ -1,9 +1,10 @@ -import type { Oas3Rule, Oas2Rule, Async2Rule, Async3Rule, ArazzoRule } from '../../visitors'; import { isNamedType, SpecExtension } from '../../types'; import { oasTypeOf, matchesJsonSchemaType, getSuggest, validateSchemaEnumType } from '../utils'; import { isRef } from '../../ref-utils'; import { isPlainObject } from '../../utils'; -import { UserContext } from '../../walk'; + +import type { UserContext } from '../../walk'; +import type { Oas3Rule, Oas2Rule, Async2Rule, Async3Rule, ArazzoRule } from '../../visitors'; 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 9575a9c9ff..3b0a6065dd 100644 --- a/packages/core/src/rules/common/tag-description.ts +++ b/packages/core/src/rules/common/tag-description.ts @@ -1,6 +1,7 @@ -import { Oas3Rule, Oas2Rule } from '../../visitors'; import { validateDefinedAndNonEmpty } from '../utils'; +import type { Oas3Rule, Oas2Rule } from '../../visitors'; + export const TagDescription: Oas3Rule | Oas2Rule = () => { return { Tag(tag, ctx) { diff --git a/packages/core/src/rules/common/tags-alphabetical.ts b/packages/core/src/rules/common/tags-alphabetical.ts index c62fb0612a..63f85f2f52 100644 --- a/packages/core/src/rules/common/tags-alphabetical.ts +++ b/packages/core/src/rules/common/tags-alphabetical.ts @@ -1,7 +1,7 @@ -import { Oas3Rule, Oas2Rule } from '../../visitors'; -import { Oas2Definition, Oas2Tag } from '../../typings/swagger'; -import { Oas3Definition, Oas3Tag } from '../../typings/openapi'; -import { UserContext } from '../../walk'; +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'; 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 96a79cc472..e4058d7b0b 100644 --- a/packages/core/src/rules/no-unresolved-refs.ts +++ b/packages/core/src/rules/no-unresolved-refs.ts @@ -1,7 +1,8 @@ -import { Oas3Rule } from '../visitors'; import { YamlParseError } from '../resolve'; -import { ResolveResult, Problem } from '../walk'; -import { Location } from '../ref-utils'; + +import type { Oas3Rule } from '../visitors'; +import type { ResolveResult, Problem } from '../walk'; +import type { Location } from '../ref-utils'; export const NoUnresolvedRefs: Oas3Rule = () => { return { diff --git a/packages/core/src/rules/oas2/boolean-parameter-prefixes.ts b/packages/core/src/rules/oas2/boolean-parameter-prefixes.ts index 871e9706c9..b9aa399c5d 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 { Oas2Rule } from '../../visitors'; +import type { Oas2Rule } from '../../visitors'; export type BooleanParameterPrefixesOptions = { prefixes?: string[]; diff --git a/packages/core/src/rules/oas2/index.ts b/packages/core/src/rules/oas2/index.ts index 5ecca8bd6e..f54f2b2e64 100644 --- a/packages/core/src/rules/oas2/index.ts +++ b/packages/core/src/rules/oas2/index.ts @@ -1,4 +1,3 @@ -import { Oas2Rule } from '../../visitors'; import { Spec } from '../common/spec'; import { NoInvalidSchemaExamples } from '../common/no-invalid-schema-examples'; import { NoInvalidParameterExamples } from '../common/no-invalid-parameter-examples'; @@ -43,7 +42,8 @@ import { RequiredStringPropertyMissingMinLength } from '../common/required-strin import { SpecStrictRefs } from '../common/spec-strict-refs'; import { NoRequiredSchemaPropertiesUndefined } from '../common/no-required-schema-properties-undefined'; -import type { Oas2RuleSet } from 'core/src/oas-types'; +import type { Oas2Rule } from '../../visitors'; +import type { Oas2RuleSet } from '../../oas-types'; 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 9041d79179..535ed47432 100644 --- a/packages/core/src/rules/oas2/request-mime-type.ts +++ b/packages/core/src/rules/oas2/request-mime-type.ts @@ -1,6 +1,7 @@ +import { validateMimeType } from '../../utils'; + import type { Oas2Rule } from '../../visitors'; import type { UserContext } from '../../walk'; -import { validateMimeType } from '../../utils'; 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 b3cd8e040d..9ba24814fc 100644 --- a/packages/core/src/rules/oas2/response-contains-property.ts +++ b/packages/core/src/rules/oas2/response-contains-property.ts @@ -1,7 +1,8 @@ -import { Oas2Rule } from '../../visitors'; -import { UserContext } from '../../walk'; import { getMatchingStatusCodeRange } from '../../utils'; +import type { Oas2Rule } from '../../visitors'; +import type { UserContext } from '../../walk'; + export const ResponseContainsProperty: Oas2Rule = (options) => { const names: Record = options.names || {}; let key: string | number; diff --git a/packages/core/src/rules/oas2/response-mime-type.ts b/packages/core/src/rules/oas2/response-mime-type.ts index 893ba45ae0..bbbeccdc53 100644 --- a/packages/core/src/rules/oas2/response-mime-type.ts +++ b/packages/core/src/rules/oas2/response-mime-type.ts @@ -1,6 +1,7 @@ +import { validateMimeType } from '../../utils'; + import type { Oas2Rule } from '../../visitors'; import type { UserContext } from '../../walk'; -import { validateMimeType } from '../../utils'; export const ResponseMimeType: Oas2Rule = ({ allowedValues }) => { return { diff --git a/packages/core/src/rules/oas3/array-parameter-serialization.ts b/packages/core/src/rules/oas3/array-parameter-serialization.ts index b93f20f61c..2ca6e206e5 100644 --- a/packages/core/src/rules/oas3/array-parameter-serialization.ts +++ b/packages/core/src/rules/oas3/array-parameter-serialization.ts @@ -1,6 +1,7 @@ -import { Oas3Rule, Oas3Visitor } from '../../visitors'; import { isRef } from '../../ref-utils'; -import { Oas3_1Schema, Oas3Parameter } from '../../typings/openapi'; + +import type { Oas3Rule, Oas3Visitor } from '../../visitors'; +import type { Oas3_1Schema, Oas3Parameter } from '../../typings/openapi'; 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 4cbd548cc5..e9ab744f1f 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 { Oas3Rule } from '../../visitors'; +import type { Oas3Rule } from '../../visitors'; 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 6f8df48091..caad601796 100644 --- a/packages/core/src/rules/oas3/component-name-unique.ts +++ b/packages/core/src/rules/oas3/component-name-unique.ts @@ -1,6 +1,6 @@ -import { Problem, UserContext } from '../../walk'; -import { Oas2Rule, Oas3Rule, Oas3Visitor } from '../../visitors'; -import { +import type { Problem, UserContext } from '../../walk'; +import type { Oas2Rule, Oas3Rule, Oas3Visitor } from '../../visitors'; +import type { Oas3Definition, Oas3Parameter, Oas3RequestBody, diff --git a/packages/core/src/rules/oas3/index.ts b/packages/core/src/rules/oas3/index.ts index d8d1334793..5e0c1df84d 100644 --- a/packages/core/src/rules/oas3/index.ts +++ b/packages/core/src/rules/oas3/index.ts @@ -1,4 +1,3 @@ -import { Oas3RuleSet } from '../../oas-types'; import { Spec } from '../common/spec'; import { Operation2xxResponse } from '../common/operation-2xx-response'; import { Operation4xxResponse } from '../common/operation-4xx-response'; @@ -55,6 +54,7 @@ import { ComponentNameUnique } from './component-name-unique'; import { ArrayParameterSerialization } from './array-parameter-serialization'; import { NoRequiredSchemaPropertiesUndefined } from '../common/no-required-schema-properties-undefined'; +import type { Oas3RuleSet } from '../../oas-types'; import type { Oas3Rule } from '../../visitors'; export const rules: Oas3RuleSet<'built-in'> = { diff --git a/packages/core/src/rules/oas3/no-empty-servers.ts b/packages/core/src/rules/oas3/no-empty-servers.ts index 8755ad0c4b..781f0f6f9b 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 { Oas3Rule } from '../../visitors'; +import type { Oas3Rule } from '../../visitors'; 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 340975de04..c0bfe48c09 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 { Oas3Rule } from '../../visitors'; +import type { Oas3Rule } from '../../visitors'; 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 ce13441e1f..951dde7ac8 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,8 +1,10 @@ -import { Oas3Rule } from '../../visitors'; -import { Location, isRef } from '../../ref-utils'; -import { Oas3Example } from '../../typings/openapi'; +import { isRef } from '../../ref-utils'; import { getAdditionalPropertiesOption, validateExample } from '../utils'; -import { UserContext } from '../../walk'; + +import type { Oas3Rule } from '../../visitors'; +import type { Location } from '../../ref-utils'; +import type { Oas3Example } from '../../typings/openapi'; +import type { UserContext } from '../../walk'; 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 955bbb80a9..641bbac612 100644 --- a/packages/core/src/rules/oas3/no-server-example.com.ts +++ b/packages/core/src/rules/oas3/no-server-example.com.ts @@ -1,8 +1,9 @@ -import { Oas3Rule } from '../../visitors'; +import type { Oas3Rule } from '../../visitors'; export const NoServerExample: Oas3Rule = () => { return { Server(server, { report, location }) { + // eslint-disable-next-line no-useless-escape const pattern = /^(.*[\/.])?(example\.com|localhost)([\/:?].*|$)/; if (server.url && pattern.test(server.url)) { report({ 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 7656d58745..a7fcb1e717 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 { Oas3Rule } from '../../visitors'; +import type { Oas3Rule } from '../../visitors'; 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 273e0ecf4e..cb6593e6f4 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 { Oas3Server } from 'core/src/typings/openapi'; -import { Oas3Rule } from '../../visitors'; +import type { Oas3Server } from '../../typings/openapi'; +import type { Oas3Rule } from '../../visitors'; 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 2f8a6a18c4..445a1b7ce4 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 { Oas3Rule } from '../../visitors'; +import type { Oas3Rule } from '../../visitors'; 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 258a0fb1c0..0b8aece061 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 { Oas3Rule } from '../../visitors'; -import { Location } from '../../ref-utils'; +import type { Oas3Rule } from '../../visitors'; +import type { Location } from '../../ref-utils'; 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 a4ccdd7086..a682328cfe 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,6 +1,7 @@ +import { validateDefinedAndNonEmpty } from '../utils'; + import type { Oas3Rule } from '../../visitors'; import type { UserContext } from '../../walk'; -import { validateDefinedAndNonEmpty } from '../utils'; /** * 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 2027203355..75bbb4099e 100644 --- a/packages/core/src/rules/oas3/request-mime-type.ts +++ b/packages/core/src/rules/oas3/request-mime-type.ts @@ -1,6 +1,7 @@ +import { validateMimeTypeOAS3 } from '../../utils'; + import type { Oas3Rule } from '../../visitors'; import type { UserContext } from '../../walk'; -import { validateMimeTypeOAS3 } from '../../utils'; 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 afd7da4666..29e1b21fa6 100644 --- a/packages/core/src/rules/oas3/response-contains-property.ts +++ b/packages/core/src/rules/oas3/response-contains-property.ts @@ -1,7 +1,8 @@ -import { Oas3Rule } from '../../visitors'; -import { UserContext } from '../../walk'; import { getMatchingStatusCodeRange } from '../../utils'; +import type { Oas3Rule } from '../../visitors'; +import type { UserContext } from '../../walk'; + export const ResponseContainsProperty: Oas3Rule = (options) => { const names: Record = options.names || {}; let key: string | number; diff --git a/packages/core/src/rules/oas3/response-mime-type.ts b/packages/core/src/rules/oas3/response-mime-type.ts index ab7bf1bf6a..6ce62330b4 100644 --- a/packages/core/src/rules/oas3/response-mime-type.ts +++ b/packages/core/src/rules/oas3/response-mime-type.ts @@ -1,6 +1,7 @@ +import { validateMimeTypeOAS3 } from '../../utils'; + import type { Oas3Rule } from '../../visitors'; import type { UserContext } from '../../walk'; -import { validateMimeTypeOAS3 } from '../../utils'; 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 0765aae310..19937a1d24 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 { Oas3Rule } from '../../visitors'; -import { Problem, UserContext } from '../../walk'; -import { Location } from '../../ref-utils'; +import type { Oas3Rule } from '../../visitors'; +import type { Problem, UserContext } from '../../walk'; +import type { Location } from '../../ref-utils'; 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 cb4e573e03..81a0a524c5 100644 --- a/packages/core/src/rules/other/stats.ts +++ b/packages/core/src/rules/other/stats.ts @@ -1,6 +1,6 @@ -import { Oas3Parameter, OasRef, Oas3Tag } from '../../typings/openapi'; -import { Oas2Parameter } from '../../typings/swagger'; -import { StatsAccumulator } from '../../typings/common'; +import type { Oas3Parameter, OasRef, Oas3Tag } from '../../typings/openapi'; +import type { Oas2Parameter } from '../../typings/swagger'; +import type { StatsAccumulator } from '../../typings/common'; export const Stats = (statsAccumulator: StatsAccumulator) => { return { diff --git a/packages/core/src/rules/utils.ts b/packages/core/src/rules/utils.ts index 30b85dddb5..7aef11833a 100644 --- a/packages/core/src/rules/utils.ts +++ b/packages/core/src/rules/utils.ts @@ -1,10 +1,11 @@ import levenshtein = require('js-levenshtein'); -import { UserContext } from '../walk'; import { Location } from '../ref-utils'; import { validateJsonSchema } from './ajv'; -import { Oas3Schema, Oas3_1Schema, Referenced } from '../typings/openapi'; import { showErrorForDeprecatedField, showWarningForDeprecatedField } from '../utils'; +import type { Oas3Schema, Oas3_1Schema, Referenced } from '../typings/openapi'; +import type { UserContext } from '../walk'; + export function oasTypeOf(value: unknown) { if (Array.isArray(value)) { return 'array'; diff --git a/packages/core/src/types/arazzo.ts b/packages/core/src/types/arazzo.ts index c7aad23fd0..aec445fe31 100755 --- a/packages/core/src/types/arazzo.ts +++ b/packages/core/src/types/arazzo.ts @@ -1,7 +1,7 @@ -import type { NodeType } from '.'; - import { getNodeTypesFromJSONSchema } from './json-schema-adapter'; +import type { NodeType } from '.'; + export const ARAZZO_ROOT_TYPE = 'Root'; export const operationMethod = { diff --git a/packages/core/src/types/asyncapi2.ts b/packages/core/src/types/asyncapi2.ts index 913e495951..3f333aac73 100644 --- a/packages/core/src/types/asyncapi2.ts +++ b/packages/core/src/types/asyncapi2.ts @@ -1,6 +1,8 @@ -import { NodeType, listOf, mapOf } from '.'; +import { listOf, mapOf } from '.'; import { isMappingRef } from '../ref-utils'; +import type { NodeType } from '.'; + const Root: NodeType = { properties: { asyncapi: null, // TODO: validate semver format and supported version @@ -129,6 +131,7 @@ const Server: NodeType = { export const ServerMap: NodeType = { properties: {}, additionalProperties: (_value: any, key: string) => + // eslint-disable-next-line no-useless-escape key.match(/^[A-Za-z0-9_\-]+$/) ? 'Server' : undefined, }; diff --git a/packages/core/src/types/asyncapi3.ts b/packages/core/src/types/asyncapi3.ts index 776abc8d29..97cec75ac0 100644 --- a/packages/core/src/types/asyncapi3.ts +++ b/packages/core/src/types/asyncapi3.ts @@ -1,4 +1,4 @@ -import { NodeType, listOf, mapOf } from '.'; +import { listOf, mapOf } from '.'; import { AsyncApi2Bindings, Schema, @@ -17,6 +17,8 @@ import { MessageExample, } from './asyncapi2'; +import type { NodeType } from '.'; + const Root: NodeType = { properties: { asyncapi: { type: 'string', enum: ['3.0.0'] }, diff --git a/packages/core/src/types/json-schema-adapter.ts b/packages/core/src/types/json-schema-adapter.ts index daa23fec85..0ed401d11f 100644 --- a/packages/core/src/types/json-schema-adapter.ts +++ b/packages/core/src/types/json-schema-adapter.ts @@ -3,9 +3,9 @@ import Ajv from '@redocly/ajv/dist/2020'; import { isPlainObject } from '../utils'; -import type { NodeType, PropType, ResolveTypeFn } from '.'; import type { JSONSchema } from 'json-schema-to-ts'; -import { Oas3Schema } from '../typings/openapi'; +import type { NodeType, PropType, ResolveTypeFn } from '.'; +import type { Oas3Schema } from '../typings/openapi'; const ajv = new Ajv({ strictSchema: false, diff --git a/packages/core/src/types/redocly-yaml.ts b/packages/core/src/types/redocly-yaml.ts index a89709612e..c436f10fdd 100644 --- a/packages/core/src/types/redocly-yaml.ts +++ b/packages/core/src/types/redocly-yaml.ts @@ -2,11 +2,11 @@ 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 type { NodeType } from '.'; import type { JSONSchema } from 'json-schema-to-ts'; -import { SpecVersion, getTypes } from '../oas-types'; -import { Config } from '../config'; +import type { NodeType } from '.'; +import type { Config } from '../config'; const builtInCommonOASRules = [ 'spec', diff --git a/packages/core/src/typings/swagger.ts b/packages/core/src/typings/swagger.ts index b220cbaffd..c6fa94bbbb 100644 --- a/packages/core/src/typings/swagger.ts +++ b/packages/core/src/typings/swagger.ts @@ -1,5 +1,5 @@ -import { Referenced } from './openapi'; -import { Schema } from 'js-yaml'; +import type { Schema } from 'js-yaml'; +import type { Referenced } from './openapi'; export interface Oas2Definition { swagger: '2.0'; diff --git a/packages/core/src/visitors.ts b/packages/core/src/visitors.ts index e5c17f43b3..67775e9d98 100644 --- a/packages/core/src/visitors.ts +++ b/packages/core/src/visitors.ts @@ -237,30 +237,35 @@ const legacyTypesMap = { }; type Oas3NestedVisitor = { + // eslint-disable-next-line @typescript-eslint/ban-types [T in keyof Oas3FlatVisitor]: Oas3FlatVisitor[T] extends Function ? Oas3FlatVisitor[T] : Oas3FlatVisitor[T] & NestedVisitor; }; type Oas2NestedVisitor = { + // eslint-disable-next-line @typescript-eslint/ban-types [T in keyof Oas2FlatVisitor]: Oas2FlatVisitor[T] extends Function ? Oas2FlatVisitor[T] : Oas2FlatVisitor[T] & NestedVisitor; }; type Async2NestedVisitor = { + // eslint-disable-next-line @typescript-eslint/ban-types [T in keyof Async2FlatVisitor]: Async2FlatVisitor[T] extends Function ? Async2FlatVisitor[T] : Async2FlatVisitor[T] & NestedVisitor; }; type Async3NestedVisitor = { + // eslint-disable-next-line @typescript-eslint/ban-types [T in keyof Async3FlatVisitor]: Async3FlatVisitor[T] extends Function ? Async3FlatVisitor[T] : Async3FlatVisitor[T] & NestedVisitor; }; type ArazzoNestedVisitor = { + // eslint-disable-next-line @typescript-eslint/ban-types [T in keyof ArazzoFlatVisitor]: ArazzoFlatVisitor[T] extends Function ? ArazzoFlatVisitor[T] : ArazzoFlatVisitor[T] & NestedVisitor; diff --git a/packages/core/src/walk.ts b/packages/core/src/walk.ts index f1f302197d..3847633cd4 100644 --- a/packages/core/src/walk.ts +++ b/packages/core/src/walk.ts @@ -1,9 +1,10 @@ import { Location, isRef } from './ref-utils'; import { pushStack, popStack } from './utils'; -import { ResolveError, YamlParseError, Source, makeRefId } from './resolve'; -import { SpecVersion } from './oas-types'; +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 type { VisitorLevelContext, @@ -14,7 +15,6 @@ import type { NormalizeVisitor, VisitorNode, } from './visitors'; -import type { ResolvedRefMap, Document } from './resolve'; import type { NormalizedNodeType } from './types'; import type { RuleSeverity } from './config';