@atlaskit/button 17.17.2 → 17.17.3
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/CHANGELOG.md +10 -1
- package/__perf__/button.tsx +6 -6
- package/__perf__/custom.tsx +6 -6
- package/__perf__/customised.tsx +1 -3
- package/__perf__/utils/example-runner.tsx +32 -36
- package/__perf__/utils/interaction-tasks.tsx +65 -86
- package/codemods/15.0.0-lite-mode.tsx +32 -36
- package/codemods/15.1.1-data-testid.tsx +136 -142
- package/codemods/__tests__/15.0.0-lite-mode/optimistic.tsx +121 -121
- package/codemods/__tests__/15.0.0-lite-mode/safe.tsx +54 -54
- package/codemods/__tests__/15.0.0-lite-mode/shared.tsx +96 -97
- package/codemods/__tests__/15.1.1-data-testid/rename-data-testid.tsx +32 -32
- package/codemods/__tests__/_framework.tsx +32 -32
- package/codemods/helpers/15.0.0-runner.tsx +135 -137
- package/codemods/helpers/helpers-generic.tsx +524 -556
- package/codemods/optimistic-15.0.0-lite-mode.tsx +208 -231
- package/dist/cjs/old-button/shared/button-base.js +1 -1
- package/dist/es2019/new-button/variants/default/link.js +2 -2
- package/dist/es2019/new-button/variants/icon/link.js +3 -3
- package/dist/es2019/old-button/shared/button-base.js +1 -1
- package/dist/esm/new-button/variants/default/link.js +2 -2
- package/dist/esm/new-button/variants/icon/link.js +3 -3
- package/dist/esm/old-button/shared/button-base.js +1 -1
- package/dist/types/entry-points/loading-button.d.ts +1 -1
- package/dist/types/entry-points/new.d.ts +3 -3
- package/dist/types/entry-points/types.d.ts +2 -2
- package/dist/types/index.d.ts +3 -3
- package/dist/types/new.d.ts +3 -3
- package/dist/types-ts4.5/entry-points/loading-button.d.ts +1 -1
- package/dist/types-ts4.5/entry-points/new.d.ts +3 -3
- package/dist/types-ts4.5/entry-points/types.d.ts +2 -2
- package/dist/types-ts4.5/index.d.ts +3 -3
- package/dist/types-ts4.5/new.d.ts +3 -3
- package/extract-react-types/custom-theme-button-props.tsx +2 -4
- package/extract-react-types/legacy-button/custom-theme-button-props.tsx +2 -4
- package/extract-react-types/legacy-button/loading-button-props.tsx +1 -1
- package/extract-react-types/legacy-button/shared-props.tsx +1 -1
- package/extract-react-types/loading-button-props.tsx +1 -1
- package/extract-react-types/new-button/containers/split-button/split-button-props.tsx +1 -1
- package/extract-react-types/new-button/variants/default/button-props.tsx +1 -1
- package/extract-react-types/new-button/variants/default/common-default-button-props.tsx +4 -4
- package/extract-react-types/new-button/variants/default/link-button-props.tsx +4 -4
- package/extract-react-types/new-button/variants/icon-button/common-icon-button-props.tsx +4 -4
- package/extract-react-types/new-button/variants/icon-button/icon-button-props.tsx +1 -1
- package/extract-react-types/new-button/variants/icon-button/link-icon-button-props.tsx +2 -4
- package/extract-react-types/shared-props.tsx +1 -1
- package/package.json +2 -2
- package/report.api.md +78 -96
|
@@ -2,169 +2,163 @@ import type { API, default as core, FileInfo, Options } from 'jscodeshift';
|
|
|
2
2
|
import { type Collection } from 'jscodeshift/src/Collection';
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
addCommentToStartOfFile,
|
|
6
|
+
getDefaultSpecifierName,
|
|
7
|
+
getJSXAttributesByName,
|
|
8
|
+
hasImportDeclaration,
|
|
9
|
+
type Nullable,
|
|
10
10
|
} from './helpers/helpers-generic';
|
|
11
11
|
const relevantEntryPoints = [
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
'@atlaskit/button',
|
|
13
|
+
'@atlaskit/button/standard-button',
|
|
14
|
+
'@atlaskit/button/loading-button',
|
|
15
|
+
'@atlaskit/button/custom-theme-button',
|
|
16
16
|
];
|
|
17
17
|
|
|
18
18
|
function isRelevant(j: core.JSCodeshift, source: string): boolean {
|
|
19
|
-
|
|
20
|
-
hasImportDeclaration(j, source, entryPoint),
|
|
21
|
-
);
|
|
19
|
+
return relevantEntryPoints.some((entryPoint) => hasImportDeclaration(j, source, entryPoint));
|
|
22
20
|
}
|
|
23
21
|
|
|
24
22
|
function renameProp({
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
j,
|
|
24
|
+
base,
|
|
25
|
+
component,
|
|
26
|
+
attributeFrom,
|
|
27
|
+
attributeTo,
|
|
30
28
|
}: {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
j: core.JSCodeshift;
|
|
30
|
+
base: Collection<any>;
|
|
31
|
+
component: string;
|
|
32
|
+
attributeFrom: string;
|
|
33
|
+
attributeTo: string;
|
|
36
34
|
}) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
35
|
+
base.findJSXElements(component).forEach((element) => {
|
|
36
|
+
const first = getJSXAttributesByName({
|
|
37
|
+
j,
|
|
38
|
+
element: element.value,
|
|
39
|
+
attributeName: attributeFrom,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// not using attribute
|
|
43
|
+
if (!first.length) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// let's check to see if they are using the to attribute
|
|
48
|
+
const second = getJSXAttributesByName({
|
|
49
|
+
j,
|
|
50
|
+
element: element.value,
|
|
51
|
+
attributeName: attributeTo,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// if the attribute we are moving to already exists we are in trouble
|
|
55
|
+
if (second.length) {
|
|
56
|
+
addCommentToStartOfFile({
|
|
57
|
+
j,
|
|
58
|
+
base,
|
|
59
|
+
message: `
|
|
62
60
|
Cannot rename ${attributeFrom} to ${attributeTo} on ${component}.
|
|
63
61
|
A ${component} was detected with both ${attributeFrom} and ${attributeTo} props.
|
|
64
62
|
Please remove the ${attributeFrom} prop and check your tests`,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
});
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
68
66
|
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
first.find(j.JSXIdentifier).replaceWith(j.jsxIdentifier(attributeTo));
|
|
68
|
+
});
|
|
71
69
|
}
|
|
72
70
|
|
|
73
71
|
export function getNamedImportName({
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
72
|
+
j,
|
|
73
|
+
base,
|
|
74
|
+
importPath,
|
|
75
|
+
originalName,
|
|
78
76
|
}: {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
77
|
+
j: core.JSCodeshift;
|
|
78
|
+
base: Collection<any>;
|
|
79
|
+
originalName: string;
|
|
80
|
+
importPath: string;
|
|
83
81
|
}): Nullable<string> {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
82
|
+
const name: Nullable<string> =
|
|
83
|
+
base
|
|
84
|
+
.find(j.ImportDeclaration)
|
|
85
|
+
.filter((path) => path.node.source.value === importPath)
|
|
86
|
+
.find(j.ImportSpecifier)
|
|
87
|
+
.nodes()
|
|
88
|
+
.map((specifier): Nullable<string> => {
|
|
89
|
+
if (specifier.imported.name === originalName) {
|
|
90
|
+
// aliased
|
|
91
|
+
if (specifier.local) {
|
|
92
|
+
return specifier.local.name;
|
|
93
|
+
}
|
|
94
|
+
// not aliased
|
|
95
|
+
return originalName;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return null;
|
|
99
|
+
})
|
|
100
|
+
.filter(Boolean)[0] || null;
|
|
101
|
+
return name;
|
|
104
102
|
}
|
|
105
103
|
|
|
106
|
-
export default function transformer(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
return base.toSource({ quote: 'single' });
|
|
104
|
+
export default function transformer(file: FileInfo, { jscodeshift: j }: API, options: Options) {
|
|
105
|
+
if (!isRelevant(j, file.source)) {
|
|
106
|
+
return file.source;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const base: Collection<any> = j(file.source);
|
|
110
|
+
|
|
111
|
+
// renaming default imports for entry points
|
|
112
|
+
relevantEntryPoints.forEach((importPath) => {
|
|
113
|
+
const defaultName: Nullable<string> = getDefaultSpecifierName({
|
|
114
|
+
j,
|
|
115
|
+
base,
|
|
116
|
+
packageName: importPath,
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
if (defaultName != null) {
|
|
120
|
+
renameProp({
|
|
121
|
+
j,
|
|
122
|
+
base,
|
|
123
|
+
component: defaultName,
|
|
124
|
+
attributeFrom: 'data-testid',
|
|
125
|
+
attributeTo: 'testId',
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// named imports
|
|
131
|
+
const standard = getNamedImportName({
|
|
132
|
+
j,
|
|
133
|
+
base,
|
|
134
|
+
importPath: '@atlaskit/button',
|
|
135
|
+
originalName: 'StandardButton',
|
|
136
|
+
});
|
|
137
|
+
const loading = getNamedImportName({
|
|
138
|
+
j,
|
|
139
|
+
base,
|
|
140
|
+
importPath: '@atlaskit/button',
|
|
141
|
+
originalName: 'LoadingButton',
|
|
142
|
+
});
|
|
143
|
+
const customTheme = getNamedImportName({
|
|
144
|
+
j,
|
|
145
|
+
base,
|
|
146
|
+
importPath: '@atlaskit/button',
|
|
147
|
+
originalName: 'CustomThemeButton',
|
|
148
|
+
});
|
|
149
|
+
[standard, loading, customTheme].forEach((name) => {
|
|
150
|
+
if (name != null) {
|
|
151
|
+
renameProp({
|
|
152
|
+
j,
|
|
153
|
+
base,
|
|
154
|
+
component: name,
|
|
155
|
+
attributeFrom: 'data-testid',
|
|
156
|
+
attributeTo: 'testId',
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
return base.toSource({ quote: 'single' });
|
|
168
162
|
}
|
|
169
163
|
|
|
170
164
|
// Note: not exporting a 'parser' because doing so
|