Skip to content

Commit b674882

Browse files
author
Daniel A. White
committed
chore(deps): upgrade dependencies
1 parent c30d690 commit b674882

File tree

12 files changed

+10773
-9254
lines changed

12 files changed

+10773
-9254
lines changed

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ version: 2
33
jobs:
44
test_node:
55
docker:
6-
- image: cimg/node:16.13
6+
- image: cimg/node:18.20
77
steps:
88
- checkout
99
- run: yarn
1010
- run: yarn test.prod
1111

1212
release:
1313
docker:
14-
- image: circleci/node:16.13
14+
- image: cimg/node:18.20
1515
steps:
1616
- checkout
1717
- run: yarn

.storybook/main.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,9 @@ module.exports = {
44
addons: ['@storybook/addon-essentials'],
55
core: {
66
builder: "webpack5"
7-
}
7+
},
8+
// From https://github.com/hipstersmoothie/react-docgen-typescript-plugin/issues/78#issuecomment-1409224863
9+
typescript: {
10+
reactDocgen: 'react-docgen-typescript-plugin'
11+
},
812
};

package.json

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,20 @@
6161
"@stoplight/markdown-viewer": "^5.3.3",
6262
"@stoplight/mosaic": "^1.32.0",
6363
"@stoplight/mosaic-code-viewer": "^1.32.0",
64-
"@stoplight/scripts": "9.2.0",
64+
"@stoplight/scripts": "10.0.0",
6565
"@stoplight/types": "^13.7.0",
66-
"@storybook/addon-essentials": "^6.4.14",
67-
"@storybook/builder-webpack5": "^6.4.14",
68-
"@storybook/core": "6.4.14",
69-
"@storybook/manager-webpack5": "^6.4.14",
70-
"@storybook/react": "^6.4.14",
66+
"@storybook/addon-essentials": "^6.5.0",
67+
"@storybook/builder-webpack5": "^6.5.0",
68+
"@storybook/core": "^6.5.0",
69+
"@storybook/manager-webpack5": "^6.5.0",
70+
"@storybook/react": "^6.5.0",
7171
"@types/classnames": "^2.2.11",
7272
"@types/enzyme": "^3.10.8",
73-
"@types/jest": "^26.0.18",
73+
"@types/jest": "^29.5.12",
7474
"@types/lodash": "^4.14.149",
7575
"@types/node": "^12.7.2",
76-
"@types/react": "16.9.56",
77-
"@types/react-dom": "16.9.13",
76+
"@types/react": "^16.14.0",
77+
"@types/react-dom": "^16.9.0",
7878
"@types/treeify": "^1.0.0",
7979
"@typescript-eslint/eslint-plugin": "^5.7.0",
8080
"@typescript-eslint/parser": "^5.7.0",
@@ -87,22 +87,25 @@
8787
"eslint": "^8.4.1",
8888
"eslint-plugin-import": "^2.25.3",
8989
"eslint-plugin-jest": "^25.3.0",
90-
"eslint-plugin-prettier": "^4.0.0",
90+
"eslint-plugin-prettier": "^5.1.3",
9191
"eslint-plugin-react": "^7.27.1",
9292
"eslint-plugin-react-hooks": "^4.3.0",
9393
"eslint-plugin-simple-import-sort": "^7.0.0",
94-
"jest": "^26.6.2",
94+
"jest": "^29.7.0",
9595
"jest-enzyme": "^7.1.2",
96-
"prettier": "^2.5.1",
96+
"prettier": "^3.2.2",
9797
"react": "^16.14.0",
98+
"react-docgen-typescript-plugin": "^1.0.6",
9899
"react-dom": "^16.14.0",
99-
"rollup-plugin-terser": "^5.3.0",
100100
"size-limit": "^4.11.0",
101101
"treeify": "^1.1.0",
102-
"ts-jest": "^26.4.4",
103-
"typescript": "4.5.5",
102+
"ts-jest": "^29.1.4",
103+
"typescript": "5.4.5",
104104
"webpack": "^5.67.0"
105105
},
106+
"resolutions": {
107+
"jest-environment-jsdom": "^29.7.0"
108+
},
106109
"lint-staged": {
107110
"*.{ts,tsx}$": [
108111
"yarn lint.fix"

src/components/SchemaRow/TopLevelSchemaRow.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { isPlainObject } from '@stoplight/json';
12
import { isRegularNode, RegularNode } from '@stoplight/json-schema-tree';
23
import { Box, Flex, HStack, Icon, Menu, Pressable } from '@stoplight/mosaic';
34
import { useUpdateAtom } from 'jotai/utils';
@@ -26,7 +27,13 @@ export const TopLevelSchemaRow = ({
2627
const childNodes = React.useMemo(() => visibleChildren(selectedChoice.type), [selectedChoice.type]);
2728
const nestingLevel = 0;
2829

29-
const nodeId = schemaNode.fragment?.['x-stoplight']?.id;
30+
const nodeId = (() => {
31+
if (isPlainObject(schemaNode.fragment) && isPlainObject(schemaNode.fragment['x-stoplight'])) {
32+
const id = schemaNode.fragment['x-stoplight'].id;
33+
return typeof id === 'string' ? id : undefined;
34+
}
35+
return undefined;
36+
})();
3037
const [totalVendorExtensions, vendorExtensions] = React.useMemo(
3138
() => extractVendorExtensions(schemaNode.fragment),
3239
[schemaNode.fragment],

src/components/shared/Validations.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable prettier/prettier */
12
import { isRegularNode, RegularNode } from '@stoplight/json-schema-tree';
23
import { Flex, HStack, Text } from '@stoplight/mosaic';
34
import { Dictionary } from '@stoplight/types';
@@ -29,6 +30,8 @@ export const numberValidationNames = [
2930
'exclusiveMaximum',
3031
];
3132

33+
type NumberValidationNames = typeof numberValidationNames;
34+
3235
const exampleValidationNames = ['examples'];
3336

3437
const excludedValidations = ['exclusiveMinimum', 'exclusiveMaximum', 'readOnly', 'writeOnly'];
@@ -92,8 +95,14 @@ const oasFormats = {
9295
},
9396
};
9497

98+
function isOasFormat(format: string): format is keyof typeof oasFormats {
99+
return format in oasFormats;
100+
}
101+
95102
function filterOutOasFormatValidations(format: string, values: Dictionary<unknown>) {
96-
if (!(format in oasFormats)) return values;
103+
if (!isOasFormat(format)) {
104+
return values;
105+
}
97106

98107
const newValues = { ...values };
99108

@@ -125,7 +134,7 @@ export const Validations: React.FunctionComponent<IValidations> = ({ validations
125134
const NumberValidations = ({
126135
validations,
127136
}: {
128-
validations: Partial<Record<typeof numberValidationNames[number], unknown>>;
137+
validations: Partial<Record<NumberValidationNames[number], unknown>>;
129138
}) => {
130139
const entries = Object.entries(validations);
131140
if (!entries.length) {

src/consts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const COMBINER_PRETTY_NAMES: Readonly<Dictionary<string, SchemaCombinerNa
88
[SchemaCombinerName.OneOf]: 'or',
99
};
1010

11-
export const COMMON_JSON_SCHEMA_AND_OAS_FORMATS = {
11+
export const COMMON_JSON_SCHEMA_AND_OAS_FORMATS: Readonly<Record<string, readonly string[]>> = {
1212
// strings are omitted because they are the default type to apply format to
1313
number: ['byte', 'int32', 'int64', 'float', 'double'],
1414
get integer() {

src/hash.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { isPlainObject } from '@stoplight/json';
12
import type { SchemaNode } from '@stoplight/json-schema-tree';
23
// @ts-expect-error: no types
34
import * as fnv from 'fnv-plus';
@@ -16,8 +17,12 @@ export const hash = (value: string, skipHashing: boolean = SKIP_HASHING): string
1617
};
1718

1819
export const getNodeId = (node: SchemaNode, parentId?: string): string => {
19-
const nodeId = node.fragment?.['x-stoplight']?.id;
20-
if (nodeId) return nodeId;
20+
const fragment = node.fragment;
21+
22+
if (isPlainObject(fragment) && isPlainObject(fragment['x-stoplight'])) {
23+
const nodeId = fragment['x-stoplight'].id;
24+
if (typeof nodeId === 'string') return nodeId;
25+
}
2126

2227
const key = node.path[node.path.length - 1];
2328

src/hooks/useIsOnScreen.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ export const useIsOnScreen = (ref: RefObject<HTMLElement>) => {
44
const [isOnScreen, setIsOnScreen] = useState(true);
55

66
useEffect(() => {
7-
let observer: IntersectionObserver | null = null;
7+
let observer: IntersectionObserver | undefined;
88

99
if (ref.current) {
1010
const scrollParent = getScrollParent(ref.current);
11-
const observer = new IntersectionObserver(
11+
observer = new IntersectionObserver(
1212
([entry]) => {
1313
setIsOnScreen(entry.isIntersecting);
1414
},

src/utils/extractVendorExtensions.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ export function extractVendorExtensions(fragment: SchemaFragment | boolean): Ven
1616
return [0, {}];
1717
}
1818

19-
const extensionKeys = Object.keys(fragment).filter(key => key.startsWith('x-'));
20-
let vendorExtensions = {};
21-
extensionKeys.forEach(key => {
22-
vendorExtensions[key] = fragment[key];
23-
});
19+
const extensionKeys = Object.entries(fragment).filter(([key]) => key.startsWith('x-'));
20+
let vendorExtensions: VendorExtensionsList = {};
21+
22+
for (const [key, value] of extensionKeys) {
23+
vendorExtensions[key] = value;
24+
}
2425

2526
return [extensionKeys.length, vendorExtensions];
2627
}

src/utils/getApplicableFormats.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { isPlainObject } from '@stoplight/json';
12
import { RegularNode, SchemaNodeKind } from '@stoplight/json-schema-tree';
23

34
import { COMMON_JSON_SCHEMA_AND_OAS_FORMATS } from '../consts';
@@ -9,6 +10,7 @@ export function getApplicableFormats(schemaNode: RegularNode): [type: SchemaNode
910
// which is specific to OpenAPI and not supported by JSON Schema itself.
1011

1112
if (
13+
isPlainObject(schemaNode.fragment) &&
1214
schemaNode.fragment['contentMediaType'] === 'application/octet-stream' &&
1315
schemaNode.types &&
1416
schemaNode.types.length > 0

0 commit comments

Comments
 (0)