chore: update typescript to v5.5.3 (#1640)

* chore: fix the docker smoke test and update typescript to v5.5.3

* revert Dockerfile changes

* run audit fix

* update async3 types
This commit is contained in:
Andrew Tatomyr
2024-07-25 13:46:46 +03:00
committed by GitHub
parent 9855904b3e
commit 6b2b79bd7d
17 changed files with 134 additions and 99 deletions

View File

@@ -13,13 +13,13 @@ module.exports = {
coverageThreshold: {
'packages/core/': {
statements: 80,
branches: 72,
branches: 71,
functions: 73,
lines: 80,
},
'packages/cli/': {
statements: 60,
branches: 52,
branches: 50,
functions: 60,
lines: 60,
},

46
package-lock.json generated
View File

@@ -30,7 +30,7 @@
"ts-jest": "^29.1.1",
"ts-loader": "^8.0.2",
"ts-node": "^9.0.0",
"typescript": "^5.2.2",
"typescript": "5.5.3",
"webpack": "^5.76.0",
"webpack-cli": "^4.10.0"
},
@@ -8865,9 +8865,9 @@
}
},
"node_modules/jsdom/node_modules/ws": {
"version": "8.14.2",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.14.2.tgz",
"integrity": "sha512-wEBG1ftX4jcglPxgFCMJmZ2PLtSbJ2Peg6TmpJFTbe9GZYOQCDPdMYu/Tm0/bGZkw8paZnJY45J4K2PZrLYq8g==",
"version": "8.18.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz",
"integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==",
"dev": true,
"engines": {
"node": ">=10.0.0"
@@ -12651,9 +12651,9 @@
}
},
"node_modules/typescript": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz",
"integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==",
"version": "5.5.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.3.tgz",
"integrity": "sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==",
"dev": true,
"bin": {
"tsc": "bin/tsc",
@@ -13374,9 +13374,9 @@
}
},
"node_modules/ws": {
"version": "7.5.9",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz",
"integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==",
"version": "7.5.10",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz",
"integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==",
"engines": {
"node": ">=8.3.0"
},
@@ -13527,7 +13527,7 @@
"@types/react-dom": "^17.0.0 || ^18.2.7",
"@types/semver": "^7.5.0",
"@types/yargs": "17.0.32",
"typescript": "^5.2.2"
"typescript": "5.5.3"
},
"engines": {
"node": ">=14.19.0",
@@ -13573,7 +13573,7 @@
"@types/node-fetch": "^2.5.7",
"@types/pluralize": "^0.0.29",
"json-schema-to-ts": "^3.1.0",
"typescript": "^5.2.2"
"typescript": "5.5.3"
},
"engines": {
"node": ">=14.19.0",
@@ -16238,7 +16238,7 @@
"semver": "^7.5.2",
"simple-websocket": "^9.0.0",
"styled-components": "^6.0.7",
"typescript": "^5.2.2",
"typescript": "5.5.3",
"yargs": "17.0.1"
},
"dependencies": {
@@ -16280,7 +16280,7 @@
"minimatch": "^5.0.1",
"node-fetch": "^2.6.1",
"pluralize": "^8.0.0",
"typescript": "^5.2.2",
"typescript": "5.5.3",
"yaml-ast-parser": "0.0.43"
},
"dependencies": {
@@ -20334,9 +20334,9 @@
}
},
"ws": {
"version": "8.14.2",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.14.2.tgz",
"integrity": "sha512-wEBG1ftX4jcglPxgFCMJmZ2PLtSbJ2Peg6TmpJFTbe9GZYOQCDPdMYu/Tm0/bGZkw8paZnJY45J4K2PZrLYq8g==",
"version": "8.18.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz",
"integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==",
"dev": true,
"requires": {}
}
@@ -23101,9 +23101,9 @@
}
},
"typescript": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz",
"integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==",
"version": "5.5.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.3.tgz",
"integrity": "sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==",
"dev": true
},
"uglify-js": {
@@ -23609,9 +23609,9 @@
}
},
"ws": {
"version": "7.5.9",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz",
"integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==",
"version": "7.5.10",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz",
"integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==",
"requires": {}
},
"xml-name-validator": {

View File

@@ -77,7 +77,7 @@
"ts-jest": "^29.1.1",
"ts-loader": "^8.0.2",
"ts-node": "^9.0.0",
"typescript": "^5.2.2",
"typescript": "5.5.3",
"webpack": "^5.76.0",
"webpack-cli": "^4.10.0"
}

View File

@@ -64,6 +64,6 @@
"@types/react-dom": "^17.0.0 || ^18.2.7",
"@types/semver": "^7.5.0",
"@types/yargs": "17.0.32",
"typescript": "^5.2.2"
"typescript": "5.5.3"
}
}

View File

@@ -56,6 +56,6 @@
"@types/node-fetch": "^2.5.7",
"@types/pluralize": "^0.0.29",
"json-schema-to-ts": "^3.1.0",
"typescript": "^5.2.2"
"typescript": "5.5.3"
}
}

View File

@@ -18,15 +18,13 @@ import { RemoveUnusedComponents as RemoveUnusedComponentsOas2 } from './decorato
import { RemoveUnusedComponents as RemoveUnusedComponentsOas3 } from './decorators/oas3/remove-unused-components';
import { ConfigTypes } from './types/redocly-yaml';
import type { Oas3Rule, Oas3Visitor, Oas2Visitor } from './visitors';
import type { Oas3Visitor, Oas2Visitor } from './visitors';
import type { NormalizedNodeType, NodeType } from './types';
import type { WalkContext, UserContext, ResolveResult, NormalizedProblem } from './walk';
import type { Config, StyleguideConfig } from './config';
import type { OasRef } from './typings/openapi';
import type { Document, ResolvedRefMap } from './resolve';
export type Oas3RuleSet = Record<string, Oas3Rule>;
export enum OasVersion {
Version2 = 'oas2',
Version3_0 = 'oas3_0',

View File

@@ -1,6 +1,14 @@
import { RuleSet, SpecVersion } from '../oas-types';
import { StyleguideConfig } from './config';
import { isDefined } from '../utils';
import type {
ArazzoRuleSet,
Async2RuleSet,
Async3RuleSet,
Oas2RuleSet,
Oas3RuleSet,
SpecVersion,
} from '../oas-types';
import type { StyleguideConfig } from './config';
import type { ProblemSeverity } from '../walk';
type InitializedRule = {
@@ -9,8 +17,8 @@ type InitializedRule = {
visitor: any;
};
export function initRules<T extends Function, P extends RuleSet<T>>(
rules: P[],
export function initRules(
rules: (Oas3RuleSet | Oas2RuleSet | Async2RuleSet | Async3RuleSet | ArazzoRuleSet)[],
config: StyleguideConfig,
type: 'rules' | 'preprocessors' | 'decorators',
oasVersion: SpecVersion

View File

@@ -6,7 +6,7 @@ import { isRef } from '../../ref-utils';
const DEFAULT_INTERNAL_PROPERTY_NAME = 'x-internal';
export const RemoveXInternal: Oas3Decorator | Oas2Decorator = ({ internalFlagProperty }) => {
const hiddenTag = internalFlagProperty || DEFAULT_INTERNAL_PROPERTY_NAME;
const hiddenTag: string = internalFlagProperty || DEFAULT_INTERNAL_PROPERTY_NAME;
function removeInternal(node: any, ctx: UserContext) {
const { parent, key } = ctx;
@@ -31,7 +31,7 @@ export const RemoveXInternal: Oas3Decorator | Oas2Decorator = ({ internalFlagPro
for (const key of Object.keys(node)) {
node = node as any;
if (isRef(node[key])) {
const resolved = ctx.resolve(node[key]);
const resolved = ctx.resolve<any>(node[key]);
if (resolved.node?.[hiddenTag]) {
delete node[key];
didDelete = true;

View File

@@ -1,3 +1,4 @@
import { rootRedoclyConfigSchema } from '@redocly/config';
import { BaseResolver, resolveDocument, makeDocumentFromString } from './resolve';
import { normalizeVisitors } from './visitors';
import { walkDocument } from './walk';
@@ -12,8 +13,15 @@ import { NoUnresolvedRefs } from './rules/no-unresolved-refs';
import type { Document, ResolvedRefMap } from './resolve';
import type { ProblemSeverity, WalkContext } from './walk';
import type { NodeType } from './types';
import type { NestedVisitObject, Oas3Visitor, RuleInstanceConfig } from './visitors';
import { rootRedoclyConfigSchema } from '@redocly/config';
import type {
ArazzoVisitor,
Async2Visitor,
Async3Visitor,
NestedVisitObject,
Oas2Visitor,
Oas3Visitor,
RuleInstanceConfig,
} from './visitors';
export async function lint(opts: {
ref: string;
@@ -130,7 +138,19 @@ export async function lintConfig(opts: {
);
const rules: (RuleInstanceConfig & {
visitor: NestedVisitObject<unknown, Oas3Visitor | Oas3Visitor[]>;
visitor: NestedVisitObject<
unknown,
| Oas3Visitor
| Oas3Visitor[]
| Oas2Visitor
| Oas2Visitor[]
| Async2Visitor
| Async2Visitor[]
| Async3Visitor
| Async3Visitor[]
| ArazzoVisitor
| ArazzoVisitor[]
>;
})[] = [
{
severity: severity || 'error',

View File

@@ -25,8 +25,6 @@ import {
BuiltInOAS3RuleId,
} from './types/redocly-yaml';
export type RuleSet<T> = Record<string, T>;
export enum SpecVersion {
OAS2 = 'oas2',
OAS3_0 = 'oas3_0',

View File

@@ -5,7 +5,7 @@ import { Assertions } from '../common/assertions';
export const rules: ArazzoRuleSet<'built-in'> = {
spec: Spec as ArazzoRule,
assertions: Assertions,
assertions: Assertions as ArazzoRule,
};
export const preprocessors = {};

View File

@@ -11,13 +11,13 @@ import type { Async2RuleSet } from '../../oas-types';
export const rules: Async2RuleSet<'built-in'> = {
spec: Spec as Async2Rule,
assertions: Assertions,
'info-contact': InfoContact,
'operation-operationId': OperationOperationId,
assertions: Assertions as Async2Rule,
'info-contact': InfoContact as Async2Rule,
'operation-operationId': OperationOperationId as Async2Rule,
'channels-kebab-case': ChannelsKebabCase,
'no-channel-trailing-slash': NoChannelTrailingSlash,
'tag-description': TagDescription,
'tags-alphabetical': TagsAlphabetical,
'tag-description': TagDescription as Async2Rule,
'tags-alphabetical': TagsAlphabetical as Async2Rule,
};
export const preprocessors = {};

View File

@@ -11,13 +11,13 @@ import type { Async3RuleSet } from '../../oas-types';
export const rules: Async3RuleSet<'built-in'> = {
spec: Spec as Async3Rule,
assertions: Assertions,
'info-contact': InfoContact,
'operation-operationId': OperationOperationId,
assertions: Assertions as Async3Rule,
'info-contact': InfoContact as Async3Rule,
'operation-operationId': OperationOperationId as Async3Rule,
'channels-kebab-case': ChannelsKebabCase,
'no-channel-trailing-slash': NoChannelTrailingSlash,
'tag-description': TagDescription,
'tags-alphabetical': TagsAlphabetical,
'tag-description': TagDescription as Async3Rule,
'tags-alphabetical': TagsAlphabetical as Async3Rule,
};
export const preprocessors = {};

View File

@@ -1,9 +1,17 @@
import { asserts, AssertionFn } from './asserts';
import { asserts } from './asserts';
import { buildSubjectVisitor, buildVisitorObject } from './utils';
import { Async2Visitor, Async3Visitor, Oas2Visitor, Oas3Visitor } from '../../../visitors';
import { RuleSeverity } from '../../../config';
import { isString } from '../../../utils';
import type { AssertionFn } from './asserts';
import type {
ArazzoVisitor,
Async2Visitor,
Async3Visitor,
Oas2Visitor,
Oas3Visitor,
} from '../../../visitors';
import type { RuleSeverity } from '../../../config';
export type AssertionLocators = {
filterInParentKeys?: (string | number)[];
filterOutParentKeys?: (string | number)[];
@@ -28,7 +36,8 @@ export type RawAssertion = AssertionDefinition & {
export type Assertion = RawAssertion & { assertionId: string };
export const Assertions = (opts: Record<string, Assertion>) => {
const visitors: (Oas2Visitor | Oas3Visitor | Async2Visitor | Async3Visitor)[] = [];
const visitors: (Oas2Visitor | Oas3Visitor | Async2Visitor | Async3Visitor | ArazzoVisitor)[] =
[];
// As 'Assertions' has an array of asserts,
// that array spreads into an 'opts' object on init rules phase here

View File

@@ -86,10 +86,10 @@ export const rules: Oas2RuleSet<'built-in'> = {
'path-segment-plural': PathSegmentPlural as Oas2Rule,
'response-contains-header': ResponseContainsHeader as Oas2Rule,
'response-contains-property': ResponseContainsProperty as Oas2Rule,
'scalar-property-missing-example': ScalarPropertyMissingExample,
'required-string-property-missing-min-length': RequiredStringPropertyMissingMinLength,
'spec-strict-refs': SpecStrictRefs,
'no-required-schema-properties-undefined': NoRequiredSchemaPropertiesUndefined,
'scalar-property-missing-example': ScalarPropertyMissingExample as Oas2Rule,
'required-string-property-missing-min-length': RequiredStringPropertyMissingMinLength as Oas2Rule,
'spec-strict-refs': SpecStrictRefs as Oas2Rule,
'no-required-schema-properties-undefined': NoRequiredSchemaPropertiesUndefined as Oas2Rule,
};
export const preprocessors = {};

View File

@@ -55,63 +55,65 @@ import { ComponentNameUnique } from './component-name-unique';
import { ArrayParameterSerialization } from './array-parameter-serialization';
import { NoRequiredSchemaPropertiesUndefined } from '../common/no-required-schema-properties-undefined';
import type { Oas3Rule } from '../../visitors';
export const rules: Oas3RuleSet<'built-in'> = {
spec: Spec,
'info-contact': InfoContact,
'info-license': InfoLicense,
'info-license-url': InfoLicenseUrl,
'operation-2xx-response': Operation2xxResponse,
'operation-4xx-response': Operation4xxResponse,
spec: Spec as Oas3Rule,
'info-contact': InfoContact as Oas3Rule,
'info-license': InfoLicense as Oas3Rule,
'info-license-url': InfoLicenseUrl as Oas3Rule,
'operation-2xx-response': Operation2xxResponse as Oas3Rule,
'operation-4xx-response': Operation4xxResponse as Oas3Rule,
'operation-4xx-problem-details-rfc7807': Operation4xxProblemDetailsRfc7807,
assertions: Assertions,
'operation-operationId-unique': OperationIdUnique,
'operation-parameters-unique': OperationParametersUnique,
'operation-tag-defined': OperationTagDefined,
assertions: Assertions as Oas3Rule,
'operation-operationId-unique': OperationIdUnique as Oas3Rule,
'operation-parameters-unique': OperationParametersUnique as Oas3Rule,
'operation-tag-defined': OperationTagDefined as Oas3Rule,
'no-example-value-and-externalValue': NoExampleValueAndExternalValue,
'no-enum-type-mismatch': NoEnumTypeMismatch,
'no-path-trailing-slash': NoPathTrailingSlash,
'no-enum-type-mismatch': NoEnumTypeMismatch as Oas3Rule,
'no-path-trailing-slash': NoPathTrailingSlash as Oas3Rule,
'no-empty-servers': NoEmptyServers,
'path-declaration-must-exist': PathDeclarationMustExist,
'operation-operationId-url-safe': OperationIdUrlSafe,
'operation-operationId': OperationOperationId,
'operation-summary': OperationSummary,
'tags-alphabetical': TagsAlphabetical,
'path-declaration-must-exist': PathDeclarationMustExist as Oas3Rule,
'operation-operationId-url-safe': OperationIdUrlSafe as Oas3Rule,
'operation-operationId': OperationOperationId as Oas3Rule,
'operation-summary': OperationSummary as Oas3Rule,
'tags-alphabetical': TagsAlphabetical as Oas3Rule,
'no-server-example.com': NoServerExample,
'no-server-trailing-slash': NoServerTrailingSlash,
'tag-description': TagDescription,
'operation-description': OperationDescription,
'tag-description': TagDescription as Oas3Rule,
'operation-description': OperationDescription as Oas3Rule,
'no-unused-components': NoUnusedComponents,
'path-not-include-query': PathNotIncludeQuery,
'path-parameters-defined': PathParamsDefined,
'path-params-defined': PathParamsDefined,
'parameter-description': ParameterDescription,
'operation-singular-tag': OperationSingularTag,
'security-defined': SecurityDefined,
'path-not-include-query': PathNotIncludeQuery as Oas3Rule,
'path-parameters-defined': PathParamsDefined as Oas3Rule,
'path-params-defined': PathParamsDefined as Oas3Rule,
'parameter-description': ParameterDescription as Oas3Rule,
'operation-singular-tag': OperationSingularTag as Oas3Rule,
'security-defined': SecurityDefined as Oas3Rule,
'no-unresolved-refs': NoUnresolvedRefs,
'paths-kebab-case': PathsKebabCase,
'paths-kebab-case': PathsKebabCase as Oas3Rule,
'boolean-parameter-prefixes': BooleanParameterPrefixes,
'path-http-verbs-order': PathHttpVerbsOrder,
'path-http-verbs-order': PathHttpVerbsOrder as Oas3Rule,
'no-invalid-media-type-examples': ValidContentExamples,
'no-identical-paths': NoIdenticalPaths,
'no-ambiguous-paths': NoAmbiguousPaths,
'no-identical-paths': NoIdenticalPaths as Oas3Rule,
'no-ambiguous-paths': NoAmbiguousPaths as Oas3Rule,
'no-undefined-server-variable': NoUndefinedServerVariable,
'no-server-variables-empty-enum': NoServerVariablesEmptyEnum,
'no-http-verbs-in-paths': NoHttpVerbsInPaths,
'path-excludes-patterns': PathExcludesPatterns,
'no-http-verbs-in-paths': NoHttpVerbsInPaths as Oas3Rule,
'path-excludes-patterns': PathExcludesPatterns as Oas3Rule,
'request-mime-type': RequestMimeType,
'response-mime-type': ResponseMimeType,
'path-segment-plural': PathSegmentPlural,
'path-segment-plural': PathSegmentPlural as Oas3Rule,
'no-invalid-schema-examples': NoInvalidSchemaExamples,
'no-invalid-parameter-examples': NoInvalidParameterExamples,
'response-contains-header': ResponseContainsHeader,
'response-contains-header': ResponseContainsHeader as Oas3Rule,
'response-contains-property': ResponseContainsProperty,
'scalar-property-missing-example': ScalarPropertyMissingExample,
'scalar-property-missing-example': ScalarPropertyMissingExample as Oas3Rule,
'spec-components-invalid-map-name': SpecComponentsInvalidMapName,
'required-string-property-missing-min-length': RequiredStringPropertyMissingMinLength,
'spec-strict-refs': SpecStrictRefs,
'component-name-unique': ComponentNameUnique,
'spec-strict-refs': SpecStrictRefs as Oas3Rule,
'component-name-unique': ComponentNameUnique as Oas3Rule,
'array-parameter-serialization': ArrayParameterSerialization,
'no-required-schema-properties-undefined': NoRequiredSchemaPropertiesUndefined,
'no-required-schema-properties-undefined': NoRequiredSchemaPropertiesUndefined as Oas3Rule,
};
export const preprocessors = {};

View File

@@ -3,7 +3,7 @@
"composite": true,
"declaration": true,
"module": "commonjs",
"target": "ES2016",
"target": "ES2020",
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,