@cornerstonejs/codemods 6.0.0-beta.1 → 6.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.oxlintrc.json +4 -0
- package/package.json +1 -1
- package/registry/cornerstone3d/6/README.md +46 -0
- package/registry/cornerstone3d/6/classes-and-types/README.md +16 -0
- package/registry/cornerstone3d/6/classes-and-types/scripts/classes-and-types.ts +32 -90
- package/registry/cornerstone3d/6/classes-and-types/scripts/lib.ts +864 -16
- package/registry/cornerstone3d/6/classes-and-types/tests/tsx/jsx-in-a-js-file/expected.js +31 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/tsx/jsx-in-a-js-file/input.js +31 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/tsx/jsx-in-a-js-file/metrics.json +46 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/tsx/not-analysed-a-name-declared-twice/expected.tsx +34 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/tsx/not-analysed-a-name-declared-twice/input.tsx +34 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/tsx/not-analysed-a-name-declared-twice/metrics.json +12 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/positive-classes/metrics.json +10 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/renamed-classes-make-two-operands-one/expected.ts +61 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/renamed-classes-make-two-operands-one/input.ts +65 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/renamed-classes-make-two-operands-one/metrics.json +36 -0
- package/registry/cornerstone3d/6/display-sets/README.md +4 -0
- package/registry/cornerstone3d/6/display-sets/scripts/display-sets.ts +4 -2
- package/registry/cornerstone3d/6/display-sets/scripts/lib.ts +864 -16
- package/registry/cornerstone3d/6/display-sets/tests/tsx/jsx-in-a-js-file/expected.js +45 -0
- package/registry/cornerstone3d/6/display-sets/tests/tsx/jsx-in-a-js-file/input.js +39 -0
- package/registry/cornerstone3d/6/display-sets/tests/tsx/jsx-in-a-js-file/metrics.json +84 -0
- package/registry/cornerstone3d/6/display-sets/tests/tsx/not-analysed-a-name-declared-twice/expected.tsx +42 -0
- package/registry/cornerstone3d/6/display-sets/tests/tsx/not-analysed-a-name-declared-twice/input.tsx +42 -0
- package/registry/cornerstone3d/6/display-sets/tests/tsx/not-analysed-a-name-declared-twice/metrics.json +12 -0
- package/registry/cornerstone3d/6/events/README.md +4 -0
- package/registry/cornerstone3d/6/events/scripts/events.ts +5 -3
- package/registry/cornerstone3d/6/events/scripts/lib.ts +864 -16
- package/registry/cornerstone3d/6/events/tests/tsx/jsx-in-a-js-file/expected.js +18 -0
- package/registry/cornerstone3d/6/events/tests/tsx/jsx-in-a-js-file/input.js +18 -0
- package/registry/cornerstone3d/6/events/tests/tsx/jsx-in-a-js-file/metrics.json +38 -0
- package/registry/cornerstone3d/6/events/tests/tsx/not-analysed-a-name-declared-twice/expected.tsx +21 -0
- package/registry/cornerstone3d/6/events/tests/tsx/not-analysed-a-name-declared-twice/input.tsx +21 -0
- package/registry/cornerstone3d/6/events/tests/tsx/not-analysed-a-name-declared-twice/metrics.json +12 -0
- package/registry/cornerstone3d/6/settings/README.md +4 -0
- package/registry/cornerstone3d/6/settings/scripts/lib.ts +864 -16
- package/registry/cornerstone3d/6/settings/scripts/settings.ts +5 -3
- package/registry/cornerstone3d/6/settings/tests/tsx/jsx-in-a-js-file/expected.js +18 -0
- package/registry/cornerstone3d/6/settings/tests/tsx/jsx-in-a-js-file/input.js +18 -0
- package/registry/cornerstone3d/6/settings/tests/tsx/jsx-in-a-js-file/metrics.json +46 -0
- package/registry/cornerstone3d/6/settings/tests/tsx/not-analysed-a-name-declared-twice/expected.tsx +21 -0
- package/registry/cornerstone3d/6/settings/tests/tsx/not-analysed-a-name-declared-twice/input.tsx +21 -0
- package/registry/cornerstone3d/6/settings/tests/tsx/not-analysed-a-name-declared-twice/metrics.json +12 -0
- package/registry/cornerstone3d/6/tools/README.md +5 -0
- package/registry/cornerstone3d/6/tools/scripts/lib.ts +864 -16
- package/registry/cornerstone3d/6/tools/scripts/tools.ts +6 -3
- package/registry/cornerstone3d/6/tools/tests/tsx/jsx-in-a-js-file/expected.js +35 -0
- package/registry/cornerstone3d/6/tools/tests/tsx/jsx-in-a-js-file/input.js +35 -0
- package/registry/cornerstone3d/6/tools/tests/tsx/jsx-in-a-js-file/metrics.json +52 -0
- package/registry/cornerstone3d/6/tools/tests/tsx/not-analysed-a-name-declared-twice/expected.tsx +38 -0
- package/registry/cornerstone3d/6/tools/tests/tsx/not-analysed-a-name-declared-twice/input.tsx +38 -0
- package/registry/cornerstone3d/6/tools/tests/tsx/not-analysed-a-name-declared-twice/metrics.json +12 -0
- package/registry/cornerstone3d/6/viewport-members/README.md +5 -0
- package/registry/cornerstone3d/6/viewport-members/scripts/lib.ts +864 -16
- package/registry/cornerstone3d/6/viewport-members/scripts/viewport-members.ts +5 -3
- package/registry/cornerstone3d/6/viewport-members/tests/tsx/jsx-in-a-js-file/expected.js +41 -0
- package/registry/cornerstone3d/6/viewport-members/tests/tsx/jsx-in-a-js-file/input.js +41 -0
- package/registry/cornerstone3d/6/viewport-members/tests/tsx/jsx-in-a-js-file/metrics.json +108 -0
- package/registry/cornerstone3d/6/viewport-members/tests/tsx/not-analysed-a-name-declared-twice/expected.tsx +44 -0
- package/registry/cornerstone3d/6/viewport-members/tests/tsx/not-analysed-a-name-declared-twice/input.tsx +44 -0
- package/registry/cornerstone3d/6/viewport-members/tests/tsx/not-analysed-a-name-declared-twice/metrics.json +12 -0
- package/registry/cornerstone3d/6/viewport-types/README.md +35 -0
- package/registry/cornerstone3d/6/viewport-types/scripts/lib.ts +864 -16
- package/registry/cornerstone3d/6/viewport-types/scripts/viewport-types.ts +192 -4
- package/registry/cornerstone3d/6/viewport-types/tests/tsx/jsx-in-a-js-file/expected.js +76 -0
- package/registry/cornerstone3d/6/viewport-types/tests/tsx/jsx-in-a-js-file/input.js +76 -0
- package/registry/cornerstone3d/6/viewport-types/tests/tsx/jsx-in-a-js-file/metrics.json +102 -0
- package/registry/cornerstone3d/6/viewport-types/tests/tsx/not-analysed-a-name-declared-twice/expected.tsx +79 -0
- package/registry/cornerstone3d/6/viewport-types/tests/tsx/not-analysed-a-name-declared-twice/input.tsx +79 -0
- package/registry/cornerstone3d/6/viewport-types/tests/tsx/not-analysed-a-name-declared-twice/metrics.json +12 -0
- package/registry/cornerstone3d/6/viewport-types/tests/tsx/not-analysed-a-name-declared-twice-in-a-js-file/expected.js +78 -0
- package/registry/cornerstone3d/6/viewport-types/tests/tsx/not-analysed-a-name-declared-twice-in-a-js-file/input.js +78 -0
- package/registry/cornerstone3d/6/viewport-types/tests/tsx/not-analysed-a-name-declared-twice-in-a-js-file/metrics.json +12 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/ohif-returns-of-two-types-become-one/expected.ts +173 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/ohif-returns-of-two-types-become-one/input.ts +173 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/ohif-returns-of-two-types-become-one/metrics.json +166 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/ohif-two-operands-become-one/expected.ts +103 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/ohif-two-operands-become-one/input.ts +103 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/ohif-two-operands-become-one/metrics.json +78 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/* eslint-disable no-duplicate-case */
|
|
2
|
+
import { Enums as csEnums, RenderingEngine } from '@cornerstonejs/core';
|
|
3
|
+
|
|
4
|
+
const { ViewportType } = csEnums;
|
|
5
|
+
|
|
6
|
+
type ViewportLike = {
|
|
7
|
+
requestedType?: csEnums.ViewportType;
|
|
8
|
+
type?: csEnums.ViewportType;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export function getLegacyViewportType(viewport: unknown): csEnums.ViewportType | undefined {
|
|
12
|
+
const vp = viewport as ViewportLike | null | undefined;
|
|
13
|
+
return vp?.requestedType ?? vp?.type;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function isVolume3DViewportType(viewport: unknown): boolean {
|
|
17
|
+
const legacyType = getLegacyViewportType(viewport);
|
|
18
|
+
return legacyType === ViewportType.VOLUME_3D || legacyType === ViewportType.VOLUME_3D;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function isNotVideo(type: string) {
|
|
22
|
+
return type !== ViewportType.VIDEO && type !== ViewportType.VIDEO;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function isSignalOrSlide(type: string) {
|
|
26
|
+
return (
|
|
27
|
+
(type === ViewportType.ECG) ||
|
|
28
|
+
type === ViewportType.WHOLE_SLIDE ||
|
|
29
|
+
(type === ViewportType.ECG)
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function laneOf(type: string) {
|
|
34
|
+
switch (type) {
|
|
35
|
+
case ViewportType.ECG:
|
|
36
|
+
return 'legacy';
|
|
37
|
+
case ViewportType.ECG:
|
|
38
|
+
return 'next';
|
|
39
|
+
case ViewportType.PLANAR:
|
|
40
|
+
case ViewportType.VOLUME_3D:
|
|
41
|
+
return 'next';
|
|
42
|
+
default:
|
|
43
|
+
return 'other';
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function isVideo(type: csEnums.ViewportType) {
|
|
48
|
+
return [ViewportType.VIDEO, ViewportType.VIDEO].includes(type);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const THREE_D_TYPES = [
|
|
52
|
+
ViewportType.VOLUME_3D,
|
|
53
|
+
ViewportType.VOLUME_3D,
|
|
54
|
+
] as const;
|
|
55
|
+
|
|
56
|
+
export function is3D(type: csEnums.ViewportType) {
|
|
57
|
+
return THREE_D_TYPES.includes(type);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export const typesToEnable = [ViewportType.VIDEO, ViewportType.VIDEO];
|
|
61
|
+
|
|
62
|
+
export function differentTests(type: string, other: string) {
|
|
63
|
+
return (
|
|
64
|
+
type === ViewportType.VIDEO ||
|
|
65
|
+
type === ViewportType.ECG ||
|
|
66
|
+
other === ViewportType.VIDEO
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function sameTestTwiceBefore(type: string) {
|
|
71
|
+
return (
|
|
72
|
+
type === ViewportType.VOLUME_3D || type === ViewportType.VOLUME_3D
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function innerChain(type: string, ready: boolean) {
|
|
77
|
+
return (
|
|
78
|
+
type === ViewportType.VOLUME_3D ||
|
|
79
|
+
(ready && type === ViewportType.VOLUME_3D)
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function stackOrVolume(type: string) {
|
|
84
|
+
return type === ViewportType.STACK || type === ViewportType.ORTHOGRAPHIC;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export async function memberAndString(
|
|
88
|
+
engine: RenderingEngine,
|
|
89
|
+
imageIds: string[]
|
|
90
|
+
) {
|
|
91
|
+
const viewport = engine.getViewport('stack');
|
|
92
|
+
|
|
93
|
+
await viewport.setStack(imageIds);
|
|
94
|
+
|
|
95
|
+
return viewport.getCurrentMode() === 'stack' || viewport.getCurrentMode() === 'stack';
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function castOperand(type: string) {
|
|
99
|
+
return (
|
|
100
|
+
type === ViewportType.WHOLE_SLIDE ||
|
|
101
|
+
type === (ViewportType.WHOLE_SLIDE as string)
|
|
102
|
+
);
|
|
103
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/* eslint-disable no-duplicate-case */
|
|
2
|
+
import { Enums as csEnums, RenderingEngine } from '@cornerstonejs/core';
|
|
3
|
+
|
|
4
|
+
const { ViewportType } = csEnums;
|
|
5
|
+
|
|
6
|
+
type ViewportLike = {
|
|
7
|
+
requestedType?: csEnums.ViewportType;
|
|
8
|
+
type?: csEnums.ViewportType;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export function getLegacyViewportType(viewport: unknown): csEnums.ViewportType | undefined {
|
|
12
|
+
const vp = viewport as ViewportLike | null | undefined;
|
|
13
|
+
return vp?.requestedType ?? vp?.type;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function isVolume3DViewportType(viewport: unknown): boolean {
|
|
17
|
+
const legacyType = getLegacyViewportType(viewport);
|
|
18
|
+
return legacyType === ViewportType.VOLUME_3D || legacyType === ViewportType.VOLUME_3D_NEXT;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function isNotVideo(type: string) {
|
|
22
|
+
return type !== ViewportType.VIDEO_NEXT && type !== ViewportType.VIDEO;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function isSignalOrSlide(type: string) {
|
|
26
|
+
return (
|
|
27
|
+
(type === ViewportType.ECG) ||
|
|
28
|
+
type === ViewportType.WHOLE_SLIDE ||
|
|
29
|
+
(type === ViewportType.ECG_NEXT)
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function laneOf(type: string) {
|
|
34
|
+
switch (type) {
|
|
35
|
+
case ViewportType.ECG:
|
|
36
|
+
return 'legacy';
|
|
37
|
+
case ViewportType.ECG_NEXT:
|
|
38
|
+
return 'next';
|
|
39
|
+
case ViewportType.PLANAR_NEXT:
|
|
40
|
+
case ViewportType.VOLUME_3D_NEXT:
|
|
41
|
+
return 'next';
|
|
42
|
+
default:
|
|
43
|
+
return 'other';
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function isVideo(type: csEnums.ViewportType) {
|
|
48
|
+
return [ViewportType.VIDEO, ViewportType.VIDEO_NEXT].includes(type);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const THREE_D_TYPES = [
|
|
52
|
+
ViewportType.VOLUME_3D,
|
|
53
|
+
ViewportType.VOLUME_3D_NEXT,
|
|
54
|
+
] as const;
|
|
55
|
+
|
|
56
|
+
export function is3D(type: csEnums.ViewportType) {
|
|
57
|
+
return THREE_D_TYPES.includes(type);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export const typesToEnable = [ViewportType.VIDEO, ViewportType.VIDEO_NEXT];
|
|
61
|
+
|
|
62
|
+
export function differentTests(type: string, other: string) {
|
|
63
|
+
return (
|
|
64
|
+
type === ViewportType.VIDEO_NEXT ||
|
|
65
|
+
type === ViewportType.ECG_NEXT ||
|
|
66
|
+
other === ViewportType.VIDEO
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function sameTestTwiceBefore(type: string) {
|
|
71
|
+
return (
|
|
72
|
+
type === ViewportType.VOLUME_3D_NEXT || type === ViewportType.VOLUME_3D_NEXT
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function innerChain(type: string, ready: boolean) {
|
|
77
|
+
return (
|
|
78
|
+
type === ViewportType.VOLUME_3D ||
|
|
79
|
+
(ready && type === ViewportType.VOLUME_3D_NEXT)
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function stackOrVolume(type: string) {
|
|
84
|
+
return type === ViewportType.STACK || type === ViewportType.ORTHOGRAPHIC;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export async function memberAndString(
|
|
88
|
+
engine: RenderingEngine,
|
|
89
|
+
imageIds: string[]
|
|
90
|
+
) {
|
|
91
|
+
const viewport = engine.getViewport('stack');
|
|
92
|
+
|
|
93
|
+
await viewport.setStack(imageIds);
|
|
94
|
+
|
|
95
|
+
return viewport.type === ViewportType.STACK || viewport.type === 'stack';
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function castOperand(type: string) {
|
|
99
|
+
return (
|
|
100
|
+
type === ViewportType.WHOLE_SLIDE ||
|
|
101
|
+
type === (ViewportType.WHOLE_SLIDE_NEXT as string)
|
|
102
|
+
);
|
|
103
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cornerstone3d-6-manual": [
|
|
3
|
+
{
|
|
4
|
+
"cardinality": {
|
|
5
|
+
"file": "input.ts",
|
|
6
|
+
"line": "84",
|
|
7
|
+
"rule": "ViewportType.ORTHOGRAPHIC"
|
|
8
|
+
},
|
|
9
|
+
"count": 1
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"cardinality": {
|
|
13
|
+
"file": "input.ts",
|
|
14
|
+
"line": "84",
|
|
15
|
+
"rule": "ViewportType.STACK"
|
|
16
|
+
},
|
|
17
|
+
"count": 1
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"cornerstone3d-6-review": [
|
|
21
|
+
{
|
|
22
|
+
"cardinality": {
|
|
23
|
+
"file": "input.ts",
|
|
24
|
+
"line": "101",
|
|
25
|
+
"rule": "ViewportType.WHOLE_SLIDE: two operands of one || are the same now, read what each tested in 5.x"
|
|
26
|
+
},
|
|
27
|
+
"count": 1
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"cardinality": {
|
|
31
|
+
"file": "input.ts",
|
|
32
|
+
"line": "18",
|
|
33
|
+
"rule": "ViewportType.VOLUME_3D: two operands of one || are the same now, read what each tested in 5.x"
|
|
34
|
+
},
|
|
35
|
+
"count": 1
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"cardinality": {
|
|
39
|
+
"file": "input.ts",
|
|
40
|
+
"line": "22",
|
|
41
|
+
"rule": "ViewportType.VIDEO: two operands of one && are the same now, read what each tested in 5.x"
|
|
42
|
+
},
|
|
43
|
+
"count": 1
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"cardinality": {
|
|
47
|
+
"file": "input.ts",
|
|
48
|
+
"line": "29",
|
|
49
|
+
"rule": "ViewportType.ECG: two operands of one || are the same now, read what each tested in 5.x"
|
|
50
|
+
},
|
|
51
|
+
"count": 1
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"cardinality": {
|
|
55
|
+
"file": "input.ts",
|
|
56
|
+
"line": "37",
|
|
57
|
+
"rule": "ViewportType.ECG: two case labels of one switch are the same now, read what each chose in 5.x"
|
|
58
|
+
},
|
|
59
|
+
"count": 1
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"cardinality": {
|
|
63
|
+
"file": "input.ts",
|
|
64
|
+
"line": "48",
|
|
65
|
+
"rule": "ViewportType.VIDEO: two entries of one list used with includes are the same now, read what each named in 5.x"
|
|
66
|
+
},
|
|
67
|
+
"count": 1
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"cardinality": {
|
|
71
|
+
"file": "input.ts",
|
|
72
|
+
"line": "53",
|
|
73
|
+
"rule": "ViewportType.VOLUME_3D: two entries of one list used with includes are the same now, read what each named in 5.x"
|
|
74
|
+
},
|
|
75
|
+
"count": 1
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
}
|