@@ -17,7 +17,9 @@ However, it is also available for use outside of this project and compatible wit
17
17
18
18
## Imports
19
19
20
- ### ` hasImportDeclaration(j, source, sourcePath) `
20
+ ### ` hasImportDeclaration `
21
+
22
+ ` hasImportDeclaration(j, source, sourcePath) `
21
23
22
24
Finds an import declaration by source name
23
25
@@ -38,7 +40,9 @@ import { hasImportDeclaration } from '@codeshift/utils';
38
40
hasImportDeclaration (j, source, ' react' ); // True
39
41
```
40
42
41
- ### ` getImportDeclaration(j, source, sourcePath) `
43
+ ### ` getImportDeclaration `
44
+
45
+ ` getImportDeclaration(j, source, sourcePath) `
42
46
43
47
Returns an import declaration by source name
44
48
@@ -59,7 +63,9 @@ import { getImportDeclaration } from '@codeshift/utils';
59
63
getImportDeclaration (j, source, ' react' );
60
64
```
61
65
62
- ### ` removeImportDeclaration(j, source, sourcePath) `
66
+ ### ` removeImportDeclaration `
67
+
68
+ ` removeImportDeclaration(j, source, sourcePath) `
63
69
64
70
Removes an import declaration by source name
65
71
@@ -85,7 +91,9 @@ removeImportDeclaration(j, source, 'react');
85
91
- import React, { useEffect } from 'react';
86
92
```
87
93
88
- ### ` renameImportDeclaration(j, source, sourcePath, newSourcePath) `
94
+ ### ` renameImportDeclaration `
95
+
96
+ ` renameImportDeclaration(j, source, sourcePath, newSourcePath) `
89
97
90
98
Renames an import declaration by source name
91
99
@@ -112,7 +120,9 @@ renameImportDeclaration(j, source, 'react', 'preact');
112
120
+ import React, { useEffect } from 'preact';
113
121
```
114
122
115
- ### ` getDefaultImportSpecifier(j, source, sourcePath) `
123
+ ### ` getDefaultImportSpecifier `
124
+
125
+ ` getDefaultImportSpecifier(j, source, sourcePath) `
116
126
117
127
Finds a default import specifier
118
128
@@ -133,7 +143,9 @@ import { getDefaultImportSpecifier } from '@codeshift/utils';
133
143
getDefaultImportSpecifier (j, source, ' react' ); // Collection containing 'React'
134
144
```
135
145
136
- ### ` getDefaultImportSpecifierName(j, source, sourcePath) `
146
+ ### ` getDefaultImportSpecifierName `
147
+
148
+ ` getDefaultImportSpecifierName(j, source, sourcePath) `
137
149
138
150
Finds a default import specifier and returns its name
139
151
@@ -154,7 +166,9 @@ import { getDefaultImportSpecifierName } from '@codeshift/utils';
154
166
getDefaultImportSpecifierName (j, source, ' react' ); // Collection containing 'React'
155
167
```
156
168
157
- ### ` hasDefaultImportSpecifier(j, source, sourcePath) `
169
+ ### ` hasDefaultImportSpecifier `
170
+
171
+ ` hasDefaultImportSpecifier(j, source, sourcePath) `
158
172
159
173
Attempts to find a default import specifier and returns a boolean result
160
174
@@ -175,7 +189,9 @@ import { hasDefaultImportSpecifier } from '@codeshift/utils';
175
189
hasDefaultImportSpecifier (j, source, ' react' ); // True
176
190
```
177
191
178
- ### ` removeDefaultImportSpecifier(j, source, sourcePath) `
192
+ ### ` removeDefaultImportSpecifier `
193
+
194
+ ` removeDefaultImportSpecifier(j, source, sourcePath) `
179
195
180
196
Attempts to remove a default import specifier
181
197
@@ -201,7 +217,9 @@ removeDefaultImportSpecifier(j, source, 'React');
201
217
+ import { useEffect } from 'react';
202
218
```
203
219
204
- ### ` hasImportSpecifier(j, source, sourcePath) `
220
+ ### ` hasImportSpecifier `
221
+
222
+ ` hasImportSpecifier(j, source, sourcePath) `
205
223
206
224
Checks for an import import specifier
207
225
@@ -222,7 +240,9 @@ import { hasImportSpecifier } from '@codeshift/utils';
222
240
hasImportSpecifier (j, source, ' react' , ' useEffect' ); // True
223
241
```
224
242
225
- ### ` getImportSpecifier(j, specifier, source) `
243
+ ### ` getImportSpecifier `
244
+
245
+ ` getImportSpecifier(j, specifier, source) `
226
246
227
247
Finds an import specifier by name
228
248
@@ -243,7 +263,9 @@ import { getImportSpecifier } from '@codeshift/utils';
243
263
getImportSpecifier (j, source, ' useEffect' ); // Collection containing 'useEffect'
244
264
```
245
265
246
- ### ` getImportSpecifierName(j, specifier, source) `
266
+ ### ` getImportSpecifierName `
267
+
268
+ ` getImportSpecifierName(j, specifier, source) `
247
269
248
270
Returns the local name of an import. This is useful for cases where an import specifier is potentially aliased.
249
271
@@ -264,7 +286,9 @@ import { getImportSpecifierName } from '@codeshift/utils';
264
286
getImportSpecifierName (j, source, ' useEffect' , ' react' ); // 'foo'
265
287
```
266
288
267
- ### ` insertImportSpecifier(j, source, specifier) `
289
+ ### ` insertImportSpecifier `
290
+
291
+ ` insertImportSpecifier(j, source, specifier) `
268
292
269
293
Inserts an import specifier
270
294
@@ -293,7 +317,9 @@ insertImportSpecifier(j, source, 'useMemo', 'react'); // Collection containing '
293
317
294
318
## JSX
295
319
296
- ### ` getJSXAttributes(j, source, attributeName) `
320
+ ### ` getJSXAttributes `
321
+
322
+ ` getJSXAttributes(j, source, attributeName) `
297
323
298
324
Finds a JSX attributeName (aka prop) by name
299
325
@@ -316,7 +342,9 @@ import { getJSXAttributes } from '@codeshift/utils';
316
342
getJSXAttributes (j, source, ' primary' ); // Collection containing 'primary'
317
343
```
318
344
319
- ### ` hasJSXAttributes(j, source, attributeName) `
345
+ ### ` hasJSXAttributes `
346
+
347
+ ` hasJSXAttributes(j, source, attributeName) `
320
348
321
349
Finds a JSX attributeName (aka prop) by name and returns true if found
322
350
@@ -341,7 +369,9 @@ hasJSXAttributes(j, source, 'primary'); // Found!
341
369
342
370
## Comments
343
371
344
- ### ` insertCommentBefore(j, source, message, prefix) `
372
+ ### ` insertCommentBefore `
373
+
374
+ ` insertCommentBefore(j, source, message, prefix) `
345
375
346
376
Appends a comment before the provided node
347
377
@@ -376,7 +406,9 @@ import React from 'react';
376
406
const App = () => < Button primary> Say hello< / Button> ;
377
407
```
378
408
379
- ### ` insertCommentToStartOfFile(j, source, message) `
409
+ ### ` insertCommentToStartOfFile `
410
+
411
+ ` insertCommentToStartOfFile(j, source, message) `
380
412
381
413
Appends a comment to the start of a file
382
414
@@ -413,7 +445,9 @@ const App = () => <Button primary>Say hello</Button>;
413
445
414
446
## Motions
415
447
416
- ### ` applyMotions(j, source, motions) `
448
+ ### ` applyMotions `
449
+
450
+ ` applyMotions(j, source, motions) `
417
451
418
452
A helper function to apply an array of motions in sequence.
419
453
0 commit comments