@atlaskit/codemod-utils 4.1.0 → 4.1.1
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 +6 -0
- package/dist/cjs/utils/support.js +51 -9
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/utils/support.js +49 -10
- package/dist/es2019/version.json +1 -1
- package/dist/esm/utils/support.js +49 -10
- package/dist/esm/version.json +1 -1
- package/dist/types/utils/support.d.ts +13 -0
- package/package.json +1 -1
- package/report.api.md +225 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/codemod-utils
|
|
2
2
|
|
|
3
|
+
## 4.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`edc6fef0c8f`](https://bitbucket.org/atlassian/atlassian-frontend/commits/edc6fef0c8f) - Fix printf format specifier matching within `matchesStringWithFormatSpecifier` for fuzzy matching interpolated placeholder values
|
|
8
|
+
|
|
3
9
|
## 4.1.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -14,6 +14,8 @@ exports.getJSXAttributesByName = exports.getDynamicImportName = exports.getDefau
|
|
|
14
14
|
exports.getNamedSpecifier = getNamedSpecifier;
|
|
15
15
|
exports.getSafeImportName = getSafeImportName;
|
|
16
16
|
exports.isEmpty = exports.hasJSXAttributesByName = exports.hasImportDeclarationFromAnyPackageEntrypoint = exports.hasImportDeclaration = void 0;
|
|
17
|
+
exports.matchesStringWithFormatSpecifier = matchesStringWithFormatSpecifier;
|
|
18
|
+
exports.placeholderStringMatches = placeholderStringMatches;
|
|
17
19
|
exports.removeImport = removeImport;
|
|
18
20
|
exports.testMethodVariantEach = exports.shiftDefaultImport = void 0;
|
|
19
21
|
exports.tryCreateImport = tryCreateImport;
|
|
@@ -190,18 +192,58 @@ var debug = function debug(component) {
|
|
|
190
192
|
|
|
191
193
|
exports.debug = debug;
|
|
192
194
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
195
|
+
function placeholderStringMatches(placeholderStr, resolvedStr) {
|
|
196
|
+
if (placeholderStr === resolvedStr) {
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
var value = '';
|
|
201
|
+
var offset = 0;
|
|
202
|
+
var partsPlaceholder = placeholderStr.split(' ');
|
|
203
|
+
var partsResolved = resolvedStr.split(' ');
|
|
204
|
+
partsPlaceholder.forEach(function (p, i) {
|
|
205
|
+
// Placeholder
|
|
206
|
+
if (p.startsWith('%')) {
|
|
207
|
+
// Trim remaining words from current position to avoid premature matching from previous parts
|
|
208
|
+
var remainingWords = partsResolved.slice(i + offset);
|
|
209
|
+
var nextWordIndex = remainingWords.indexOf(partsPlaceholder[i + 1]);
|
|
210
|
+
var hasNextWord = nextWordIndex !== -1;
|
|
211
|
+
|
|
212
|
+
if (hasNextWord) {
|
|
213
|
+
offset += nextWordIndex - 1;
|
|
214
|
+
}
|
|
196
215
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
216
|
+
var insert = remainingWords.slice(0, hasNextWord ? nextWordIndex : undefined).join(' ');
|
|
217
|
+
value += "".concat(insert, " "); // Regular words
|
|
218
|
+
} else {
|
|
219
|
+
value += "".concat(p, " ");
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
return value.trimRight() === resolvedStr;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Check whether a value contains a Format Specifier (printf placeholder)
|
|
226
|
+
*
|
|
227
|
+
* @see https://jestjs.io/docs/api#testeachtablename-fn-timeout
|
|
228
|
+
* @see https://nodejs.org/api/util.html#utilformatformat-args
|
|
229
|
+
*
|
|
230
|
+
* @param argValue The string potentially containing a format specifier (e.g. 'Foo %s')
|
|
231
|
+
* @param str The string that has replaced a format specifier with a tangible value (e.g. 'Foo Bar`)
|
|
232
|
+
*
|
|
233
|
+
* @returns Boolean: True if the strings matched (after considering the placeholder), or false if not.
|
|
234
|
+
*/
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
function matchesStringWithFormatSpecifier(argValue, str) {
|
|
238
|
+
var value = String(argValue); // Check whether value contains a printf format placeholder e.g. %s, %d etc
|
|
239
|
+
|
|
240
|
+
if (value && value.match(/%(p|s|d|i|f|j|o|#)/g)) {
|
|
241
|
+
return placeholderStringMatches(value, str);
|
|
201
242
|
} else {
|
|
243
|
+
// No format specifier placeholder
|
|
202
244
|
return false;
|
|
203
245
|
}
|
|
204
|
-
}
|
|
246
|
+
}
|
|
205
247
|
|
|
206
248
|
var checkForTemplateLiteralsWithPlaceholders = function checkForTemplateLiteralsWithPlaceholders(quasis, str) {
|
|
207
249
|
var templateStrs = quasis.map(function (quasi) {
|
|
@@ -220,7 +262,7 @@ var callExpressionArgMatchesString = function callExpressionArgMatchesString(arg
|
|
|
220
262
|
return true;
|
|
221
263
|
} else {
|
|
222
264
|
// Eg: 'should contain %s'
|
|
223
|
-
return
|
|
265
|
+
return matchesStringWithFormatSpecifier(arg.value, str);
|
|
224
266
|
}
|
|
225
267
|
}
|
|
226
268
|
|
package/dist/cjs/version.json
CHANGED
|
@@ -135,18 +135,57 @@ const debug = component => (j, source) => {
|
|
|
135
135
|
});
|
|
136
136
|
};
|
|
137
137
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
138
|
+
export function placeholderStringMatches(placeholderStr, resolvedStr) {
|
|
139
|
+
if (placeholderStr === resolvedStr) {
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
let value = '';
|
|
144
|
+
let offset = 0;
|
|
145
|
+
const partsPlaceholder = placeholderStr.split(' ');
|
|
146
|
+
const partsResolved = resolvedStr.split(' ');
|
|
147
|
+
partsPlaceholder.forEach((p, i) => {
|
|
148
|
+
// Placeholder
|
|
149
|
+
if (p.startsWith('%')) {
|
|
150
|
+
// Trim remaining words from current position to avoid premature matching from previous parts
|
|
151
|
+
const remainingWords = partsResolved.slice(i + offset);
|
|
152
|
+
const nextWordIndex = remainingWords.indexOf(partsPlaceholder[i + 1]);
|
|
153
|
+
const hasNextWord = nextWordIndex !== -1;
|
|
154
|
+
|
|
155
|
+
if (hasNextWord) {
|
|
156
|
+
offset += nextWordIndex - 1;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const insert = remainingWords.slice(0, hasNextWord ? nextWordIndex : undefined).join(' ');
|
|
160
|
+
value += `${insert} `; // Regular words
|
|
161
|
+
} else {
|
|
162
|
+
value += `${p} `;
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
return value.trimRight() === resolvedStr;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Check whether a value contains a Format Specifier (printf placeholder)
|
|
169
|
+
*
|
|
170
|
+
* @see https://jestjs.io/docs/api#testeachtablename-fn-timeout
|
|
171
|
+
* @see https://nodejs.org/api/util.html#utilformatformat-args
|
|
172
|
+
*
|
|
173
|
+
* @param argValue The string potentially containing a format specifier (e.g. 'Foo %s')
|
|
174
|
+
* @param str The string that has replaced a format specifier with a tangible value (e.g. 'Foo Bar`)
|
|
175
|
+
*
|
|
176
|
+
* @returns Boolean: True if the strings matched (after considering the placeholder), or false if not.
|
|
177
|
+
*/
|
|
178
|
+
|
|
179
|
+
export function matchesStringWithFormatSpecifier(argValue, str) {
|
|
180
|
+
const value = String(argValue); // Check whether value contains a printf format placeholder e.g. %s, %d etc
|
|
181
|
+
|
|
182
|
+
if (value && value.match(/%(p|s|d|i|f|j|o|#)/g)) {
|
|
183
|
+
return placeholderStringMatches(value, str);
|
|
146
184
|
} else {
|
|
185
|
+
// No format specifier placeholder
|
|
147
186
|
return false;
|
|
148
187
|
}
|
|
149
|
-
}
|
|
188
|
+
}
|
|
150
189
|
|
|
151
190
|
const checkForTemplateLiteralsWithPlaceholders = (quasis, str) => {
|
|
152
191
|
const templateStrs = quasis.map(quasi => quasi.value.raw.trim()).join('.*');
|
|
@@ -163,7 +202,7 @@ const callExpressionArgMatchesString = (arg, str) => {
|
|
|
163
202
|
return true;
|
|
164
203
|
} else {
|
|
165
204
|
// Eg: 'should contain %s'
|
|
166
|
-
return
|
|
205
|
+
return matchesStringWithFormatSpecifier(arg.value, str);
|
|
167
206
|
}
|
|
168
207
|
}
|
|
169
208
|
|
package/dist/es2019/version.json
CHANGED
|
@@ -153,18 +153,57 @@ var debug = function debug(component) {
|
|
|
153
153
|
};
|
|
154
154
|
};
|
|
155
155
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
156
|
+
export function placeholderStringMatches(placeholderStr, resolvedStr) {
|
|
157
|
+
if (placeholderStr === resolvedStr) {
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
var value = '';
|
|
162
|
+
var offset = 0;
|
|
163
|
+
var partsPlaceholder = placeholderStr.split(' ');
|
|
164
|
+
var partsResolved = resolvedStr.split(' ');
|
|
165
|
+
partsPlaceholder.forEach(function (p, i) {
|
|
166
|
+
// Placeholder
|
|
167
|
+
if (p.startsWith('%')) {
|
|
168
|
+
// Trim remaining words from current position to avoid premature matching from previous parts
|
|
169
|
+
var remainingWords = partsResolved.slice(i + offset);
|
|
170
|
+
var nextWordIndex = remainingWords.indexOf(partsPlaceholder[i + 1]);
|
|
171
|
+
var hasNextWord = nextWordIndex !== -1;
|
|
172
|
+
|
|
173
|
+
if (hasNextWord) {
|
|
174
|
+
offset += nextWordIndex - 1;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
var insert = remainingWords.slice(0, hasNextWord ? nextWordIndex : undefined).join(' ');
|
|
178
|
+
value += "".concat(insert, " "); // Regular words
|
|
179
|
+
} else {
|
|
180
|
+
value += "".concat(p, " ");
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
return value.trimRight() === resolvedStr;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Check whether a value contains a Format Specifier (printf placeholder)
|
|
187
|
+
*
|
|
188
|
+
* @see https://jestjs.io/docs/api#testeachtablename-fn-timeout
|
|
189
|
+
* @see https://nodejs.org/api/util.html#utilformatformat-args
|
|
190
|
+
*
|
|
191
|
+
* @param argValue The string potentially containing a format specifier (e.g. 'Foo %s')
|
|
192
|
+
* @param str The string that has replaced a format specifier with a tangible value (e.g. 'Foo Bar`)
|
|
193
|
+
*
|
|
194
|
+
* @returns Boolean: True if the strings matched (after considering the placeholder), or false if not.
|
|
195
|
+
*/
|
|
196
|
+
|
|
197
|
+
export function matchesStringWithFormatSpecifier(argValue, str) {
|
|
198
|
+
var value = String(argValue); // Check whether value contains a printf format placeholder e.g. %s, %d etc
|
|
199
|
+
|
|
200
|
+
if (value && value.match(/%(p|s|d|i|f|j|o|#)/g)) {
|
|
201
|
+
return placeholderStringMatches(value, str);
|
|
164
202
|
} else {
|
|
203
|
+
// No format specifier placeholder
|
|
165
204
|
return false;
|
|
166
205
|
}
|
|
167
|
-
}
|
|
206
|
+
}
|
|
168
207
|
|
|
169
208
|
var checkForTemplateLiteralsWithPlaceholders = function checkForTemplateLiteralsWithPlaceholders(quasis, str) {
|
|
170
209
|
var templateStrs = quasis.map(function (quasi) {
|
|
@@ -183,7 +222,7 @@ var callExpressionArgMatchesString = function callExpressionArgMatchesString(arg
|
|
|
183
222
|
return true;
|
|
184
223
|
} else {
|
|
185
224
|
// Eg: 'should contain %s'
|
|
186
|
-
return
|
|
225
|
+
return matchesStringWithFormatSpecifier(arg.value, str);
|
|
187
226
|
}
|
|
188
227
|
}
|
|
189
228
|
|
package/dist/esm/version.json
CHANGED
|
@@ -16,6 +16,19 @@ declare const isEmpty: any;
|
|
|
16
16
|
declare const hasImportDeclaration: (j: core.JSCodeshift, source: Collection<Node>, importPath: string) => boolean;
|
|
17
17
|
declare const hasImportDeclarationFromAnyPackageEntrypoint: (j: core.JSCodeshift, source: Collection<Node>, packageName: string) => boolean;
|
|
18
18
|
declare const debug: (component: string) => (j: core.JSCodeshift, source: Collection<Node>) => void;
|
|
19
|
+
export declare function placeholderStringMatches(placeholderStr: string, resolvedStr: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Check whether a value contains a Format Specifier (printf placeholder)
|
|
22
|
+
*
|
|
23
|
+
* @see https://jestjs.io/docs/api#testeachtablename-fn-timeout
|
|
24
|
+
* @see https://nodejs.org/api/util.html#utilformatformat-args
|
|
25
|
+
*
|
|
26
|
+
* @param argValue The string potentially containing a format specifier (e.g. 'Foo %s')
|
|
27
|
+
* @param str The string that has replaced a format specifier with a tangible value (e.g. 'Foo Bar`)
|
|
28
|
+
*
|
|
29
|
+
* @returns Boolean: True if the strings matched (after considering the placeholder), or false if not.
|
|
30
|
+
*/
|
|
31
|
+
export declare function matchesStringWithFormatSpecifier(argValue: string | number | boolean | RegExp | null, str: string): boolean;
|
|
19
32
|
declare const callExpressionArgMatchesString: (arg: CallExpression['arguments'][number], str: string) => boolean;
|
|
20
33
|
declare const testMethodVariantEach: (path: ASTPath<CallExpression>, testMethods: Set<string>) => boolean;
|
|
21
34
|
declare const hasJSXAttributesByName: (j: core.JSCodeshift, element: ASTPath<any>, attributeName: string) => boolean;
|
package/package.json
CHANGED
package/report.api.md
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
## API Report File for "@atlaskit/codemod-utils"
|
|
2
|
+
|
|
3
|
+
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { API } from 'jscodeshift';
|
|
7
|
+
import { ASTPath } from 'jscodeshift';
|
|
8
|
+
import { CallExpression } from 'jscodeshift';
|
|
9
|
+
import { Collection } from 'jscodeshift/src/Collection';
|
|
10
|
+
import core from 'jscodeshift';
|
|
11
|
+
import { FileInfo } from 'jscodeshift';
|
|
12
|
+
import { ImportDeclaration } from 'jscodeshift';
|
|
13
|
+
import { ImportDefaultSpecifier } from 'jscodeshift';
|
|
14
|
+
import { ImportSpecifier } from 'jscodeshift';
|
|
15
|
+
import { JSXAttribute } from 'jscodeshift';
|
|
16
|
+
import { JSXElement } from 'jscodeshift';
|
|
17
|
+
import { Options } from 'jscodeshift';
|
|
18
|
+
import { Program } from 'jscodeshift';
|
|
19
|
+
import { VariableDeclaration } from 'jscodeshift';
|
|
20
|
+
import { VariableDeclarator } from 'jscodeshift';
|
|
21
|
+
|
|
22
|
+
export declare function addCommentBefore(
|
|
23
|
+
j: core.JSCodeshift,
|
|
24
|
+
target:
|
|
25
|
+
| Collection<Program>
|
|
26
|
+
| Collection<ImportDeclaration>
|
|
27
|
+
| Collection<JSXElement>
|
|
28
|
+
| Collection<JSXAttribute>
|
|
29
|
+
| Collection<CallExpression>
|
|
30
|
+
| Collection<VariableDeclarator>,
|
|
31
|
+
message: string,
|
|
32
|
+
commentType?: 'block' | 'line',
|
|
33
|
+
messagePrefix?: string,
|
|
34
|
+
): void;
|
|
35
|
+
|
|
36
|
+
export declare const addCommentToStartOfFile: ({
|
|
37
|
+
j,
|
|
38
|
+
base,
|
|
39
|
+
message,
|
|
40
|
+
}: {
|
|
41
|
+
j: core.JSCodeshift;
|
|
42
|
+
base: Collection<Node>;
|
|
43
|
+
message: string;
|
|
44
|
+
}) => void;
|
|
45
|
+
|
|
46
|
+
export declare const addDynamicImport: (
|
|
47
|
+
j: core.JSCodeshift,
|
|
48
|
+
target: Collection<VariableDeclaration>,
|
|
49
|
+
name: string,
|
|
50
|
+
packageEndpoint: string,
|
|
51
|
+
) => void;
|
|
52
|
+
|
|
53
|
+
export declare function addToImport(
|
|
54
|
+
j: core.JSCodeshift,
|
|
55
|
+
base: Collection<any>,
|
|
56
|
+
importSpecifier: ImportSpecifier | ImportDefaultSpecifier,
|
|
57
|
+
packageName: string,
|
|
58
|
+
): void;
|
|
59
|
+
|
|
60
|
+
export declare const callExpressionArgMatchesString: (
|
|
61
|
+
arg: CallExpression['arguments'][number],
|
|
62
|
+
str: string,
|
|
63
|
+
) => boolean;
|
|
64
|
+
|
|
65
|
+
export declare const changeImportEntryPoint: (
|
|
66
|
+
oldPackageName: string,
|
|
67
|
+
importToConvert: string,
|
|
68
|
+
newPackageName: string,
|
|
69
|
+
shouldBeTypeImport?: boolean | undefined,
|
|
70
|
+
) => (j: core.JSCodeshift, root: Collection<Node>) => void;
|
|
71
|
+
|
|
72
|
+
export declare const createConvertFuncFor: (
|
|
73
|
+
component: string,
|
|
74
|
+
from: string,
|
|
75
|
+
to: string,
|
|
76
|
+
predicate?: ((value: any) => boolean) | undefined,
|
|
77
|
+
) => (j: core.JSCodeshift, source: Collection<Node>) => void;
|
|
78
|
+
|
|
79
|
+
export declare const createRemoveFuncAddCommentFor: (
|
|
80
|
+
component: string,
|
|
81
|
+
prop: string,
|
|
82
|
+
comment?: string | undefined,
|
|
83
|
+
) => (j: core.JSCodeshift, source: Collection<Node>) => void;
|
|
84
|
+
|
|
85
|
+
export declare const createRemoveFuncFor: (
|
|
86
|
+
component: string,
|
|
87
|
+
importName: string,
|
|
88
|
+
prop: string,
|
|
89
|
+
predicate?: (j: core.JSCodeshift, element: ASTPath<any>) => boolean,
|
|
90
|
+
comment?: string | undefined,
|
|
91
|
+
) => (j: core.JSCodeshift, source: Collection<Node>) => void;
|
|
92
|
+
|
|
93
|
+
export declare const createRenameFuncFor: (
|
|
94
|
+
component: string,
|
|
95
|
+
from: string,
|
|
96
|
+
to: string,
|
|
97
|
+
) => (j: core.JSCodeshift, source: Collection<Node>) => void;
|
|
98
|
+
|
|
99
|
+
export declare const createRenameImportFor: (
|
|
100
|
+
component: string,
|
|
101
|
+
from: string,
|
|
102
|
+
to: string,
|
|
103
|
+
) => (j: core.JSCodeshift, source: Collection<Node>) => void;
|
|
104
|
+
|
|
105
|
+
export declare const createRenameJSXFunc: (
|
|
106
|
+
packagePath: string,
|
|
107
|
+
from: string,
|
|
108
|
+
to: string,
|
|
109
|
+
fallback?: string | undefined,
|
|
110
|
+
) => (j: core.JSCodeshift, source: any) => void;
|
|
111
|
+
|
|
112
|
+
export declare const createTransformer: (
|
|
113
|
+
migrates: ((j: core.JSCodeshift, source: Collection<Node>) => void)[],
|
|
114
|
+
shouldApplyTransform?:
|
|
115
|
+
| ((j: core.JSCodeshift, source: Collection<Node>) => boolean)
|
|
116
|
+
| undefined,
|
|
117
|
+
) => (fileInfo: FileInfo, { jscodeshift: j }: API, options: Options) => string;
|
|
118
|
+
|
|
119
|
+
export declare const doesIdentifierExist: (
|
|
120
|
+
j: core.JSCodeshift,
|
|
121
|
+
base: Collection<any>,
|
|
122
|
+
name: string,
|
|
123
|
+
) => boolean;
|
|
124
|
+
|
|
125
|
+
export declare const elevateComponentToNewEntryPoint: (
|
|
126
|
+
pkg: string,
|
|
127
|
+
toPkg: string,
|
|
128
|
+
innerElementName: string,
|
|
129
|
+
) => (j: core.JSCodeshift, root: any) => void;
|
|
130
|
+
|
|
131
|
+
export declare const flattenCertainChildPropsAsProp: (
|
|
132
|
+
component: string,
|
|
133
|
+
propName: string,
|
|
134
|
+
childProps: string[],
|
|
135
|
+
) => (j: core.JSCodeshift, source: Collection<Node>) => void;
|
|
136
|
+
|
|
137
|
+
export declare const getDefaultSpecifier: (
|
|
138
|
+
j: core.JSCodeshift,
|
|
139
|
+
source: Collection<Node>,
|
|
140
|
+
specifier: string,
|
|
141
|
+
) => string | null;
|
|
142
|
+
|
|
143
|
+
export declare const getDynamicImportName: (
|
|
144
|
+
j: core.JSCodeshift,
|
|
145
|
+
source: Collection<any>,
|
|
146
|
+
importPath: string,
|
|
147
|
+
) => string | null;
|
|
148
|
+
|
|
149
|
+
export declare const getJSXAttributesByName: (
|
|
150
|
+
j: core.JSCodeshift,
|
|
151
|
+
element: ASTPath<any>,
|
|
152
|
+
attributeName: string,
|
|
153
|
+
) => Collection<JSXAttribute>;
|
|
154
|
+
|
|
155
|
+
export declare function getNamedSpecifier(
|
|
156
|
+
j: core.JSCodeshift,
|
|
157
|
+
source: Collection<Node>,
|
|
158
|
+
specifier: string,
|
|
159
|
+
importName: string,
|
|
160
|
+
): string | null;
|
|
161
|
+
|
|
162
|
+
export declare function getSafeImportName({
|
|
163
|
+
j,
|
|
164
|
+
base,
|
|
165
|
+
currentDefaultSpecifierName,
|
|
166
|
+
desiredName,
|
|
167
|
+
fallbackName,
|
|
168
|
+
}: {
|
|
169
|
+
j: core.JSCodeshift;
|
|
170
|
+
base: Collection<any>;
|
|
171
|
+
currentDefaultSpecifierName: string | null;
|
|
172
|
+
desiredName: string;
|
|
173
|
+
fallbackName: string;
|
|
174
|
+
}): string;
|
|
175
|
+
|
|
176
|
+
export declare const hasImportDeclaration: (
|
|
177
|
+
j: core.JSCodeshift,
|
|
178
|
+
source: Collection<Node>,
|
|
179
|
+
importPath: string,
|
|
180
|
+
) => boolean;
|
|
181
|
+
|
|
182
|
+
export declare const hasImportDeclarationFromAnyPackageEntrypoint: (
|
|
183
|
+
j: core.JSCodeshift,
|
|
184
|
+
source: Collection<Node>,
|
|
185
|
+
packageName: string,
|
|
186
|
+
) => boolean;
|
|
187
|
+
|
|
188
|
+
export declare const hasJSXAttributesByName: (
|
|
189
|
+
j: core.JSCodeshift,
|
|
190
|
+
element: ASTPath<any>,
|
|
191
|
+
attributeName: string,
|
|
192
|
+
) => boolean;
|
|
193
|
+
|
|
194
|
+
export declare function removeImport(
|
|
195
|
+
j: core.JSCodeshift,
|
|
196
|
+
base: Collection<any>,
|
|
197
|
+
packageName: string,
|
|
198
|
+
): void;
|
|
199
|
+
|
|
200
|
+
export declare const renameNamedImportWithAliasName: (
|
|
201
|
+
component: string,
|
|
202
|
+
from: string,
|
|
203
|
+
to: string,
|
|
204
|
+
) => (j: core.JSCodeshift, source: Collection<Node>) => void;
|
|
205
|
+
|
|
206
|
+
export declare const replaceImportStatementFor: (
|
|
207
|
+
pkg: string,
|
|
208
|
+
convertMap: any,
|
|
209
|
+
) => (j: core.JSCodeshift, root: Collection<Node>) => void;
|
|
210
|
+
|
|
211
|
+
export declare const testMethodVariantEach: (
|
|
212
|
+
path: ASTPath<CallExpression>,
|
|
213
|
+
testMethods: Set<string>,
|
|
214
|
+
) => boolean;
|
|
215
|
+
|
|
216
|
+
export declare function tryCreateImport(
|
|
217
|
+
j: core.JSCodeshift,
|
|
218
|
+
base: Collection<any>,
|
|
219
|
+
relativeToPackage: string,
|
|
220
|
+
packageName: string,
|
|
221
|
+
shouldBeTypeImport?: boolean,
|
|
222
|
+
): void;
|
|
223
|
+
|
|
224
|
+
export {};
|
|
225
|
+
```
|