@atlaskit/code 15.1.2 → 15.2.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.
Files changed (54) hide show
  1. package/CHANGELOG.md +444 -183
  2. package/__perf__/source-code-examples/100-line-example.tsx +49 -40
  3. package/codemods/13.0.0-remove-unnecessary-code-props.tsx +61 -75
  4. package/codemods/13.0.0-rename-imports.tsx +214 -251
  5. package/codemods/14.0.0-lite-mode.tsx +5 -9
  6. package/codemods/__tests__/13.0.0-remove-unnecessary-code-props.tsx +43 -43
  7. package/codemods/__tests__/13.0.0-rename-imports.tsx +143 -143
  8. package/codemods/__tests__/14.0.0-lite-mode/14.0.0-lite-mode.tsx +35 -35
  9. package/codemods/__tests__/14.0.0-lite-mode/remove-language.tsx +21 -21
  10. package/codemods/__tests__/14.0.0-lite-mode/text-to-child.tsx +35 -35
  11. package/codemods/migrations/14.0.0-lite-mode/remove-language.tsx +1 -6
  12. package/codemods/migrations/14.0.0-lite-mode/text-to-child.tsx +53 -61
  13. package/codemods/utils/helpers.tsx +161 -201
  14. package/dist/cjs/internal/theme/styles.js +2 -1
  15. package/dist/es2019/internal/theme/styles.js +2 -1
  16. package/dist/esm/internal/theme/styles.js +2 -1
  17. package/dist/types/bidi-warning/ui/index.d.ts +1 -1
  18. package/dist/types/bidi-warning/ui/styled.d.ts +1 -1
  19. package/dist/types/extract-react-types/code-block.d.ts +16 -16
  20. package/dist/types/internal/hooks/use-highlight.d.ts +1 -1
  21. package/dist/types/internal/utils/get-normalized-language.d.ts +1 -1
  22. package/dist/types/syntax-highlighter/async.d.ts +1 -1
  23. package/dist/types/syntax-highlighter/lib/highlight.d.ts +1 -1
  24. package/dist/types/syntax-highlighter/lib/process/create-line-element.d.ts +1 -1
  25. package/dist/types/syntax-highlighter/lib/process/create-line.d.ts +1 -1
  26. package/dist/types/syntax-highlighter/lib/process/flatten-code-tree.d.ts +1 -1
  27. package/dist/types/syntax-highlighter/lib/process/get-code-tree.d.ts +1 -1
  28. package/dist/types/syntax-highlighter/lib/process/get-inline-line-number.d.ts +1 -1
  29. package/dist/types/syntax-highlighter/lib/process/index.d.ts +1 -1
  30. package/dist/types/syntax-highlighter/lib/react-renderer/create-children.d.ts +2 -2
  31. package/dist/types/syntax-highlighter/lib/react-renderer/create-element.d.ts +2 -2
  32. package/dist/types/syntax-highlighter/lib/react-renderer/index.d.ts +1 -1
  33. package/dist/types/syntax-highlighter/types.d.ts +2 -2
  34. package/dist/types/types.d.ts +1 -1
  35. package/dist/types-ts4.5/bidi-warning/ui/index.d.ts +1 -1
  36. package/dist/types-ts4.5/bidi-warning/ui/styled.d.ts +1 -1
  37. package/dist/types-ts4.5/extract-react-types/code-block.d.ts +16 -16
  38. package/dist/types-ts4.5/internal/hooks/use-highlight.d.ts +1 -1
  39. package/dist/types-ts4.5/internal/utils/get-normalized-language.d.ts +1 -1
  40. package/dist/types-ts4.5/syntax-highlighter/async.d.ts +1 -1
  41. package/dist/types-ts4.5/syntax-highlighter/lib/highlight.d.ts +1 -1
  42. package/dist/types-ts4.5/syntax-highlighter/lib/process/create-line-element.d.ts +1 -1
  43. package/dist/types-ts4.5/syntax-highlighter/lib/process/create-line.d.ts +1 -1
  44. package/dist/types-ts4.5/syntax-highlighter/lib/process/flatten-code-tree.d.ts +1 -1
  45. package/dist/types-ts4.5/syntax-highlighter/lib/process/get-code-tree.d.ts +1 -1
  46. package/dist/types-ts4.5/syntax-highlighter/lib/process/get-inline-line-number.d.ts +1 -1
  47. package/dist/types-ts4.5/syntax-highlighter/lib/process/index.d.ts +1 -1
  48. package/dist/types-ts4.5/syntax-highlighter/lib/react-renderer/create-children.d.ts +2 -2
  49. package/dist/types-ts4.5/syntax-highlighter/lib/react-renderer/create-element.d.ts +2 -2
  50. package/dist/types-ts4.5/syntax-highlighter/lib/react-renderer/index.d.ts +1 -1
  51. package/dist/types-ts4.5/syntax-highlighter/types.d.ts +2 -2
  52. package/dist/types-ts4.5/types.d.ts +1 -1
  53. package/package.json +11 -11
  54. package/report.api.md +807 -807
@@ -7,10 +7,10 @@ const transformer = createTransformer([textToChild]);
7
7
  const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
8
8
 
9
9
  describe('make the test prop a child', () => {
10
- defineInlineTest(
11
- { default: transformer, parser: 'tsx' },
12
- {},
13
- `
10
+ defineInlineTest(
11
+ { default: transformer, parser: 'tsx' },
12
+ {},
13
+ `
14
14
  import React from 'react';
15
15
 
16
16
  import { Code } from '@atlaskit/code';
@@ -25,7 +25,7 @@ describe('make the test prop a child', () => {
25
25
  );
26
26
  }
27
27
  `,
28
- `
28
+ `
29
29
  import React from 'react';
30
30
 
31
31
  import { Code } from '@atlaskit/code';
@@ -40,13 +40,13 @@ describe('make the test prop a child', () => {
40
40
  );
41
41
  }
42
42
  `,
43
- 'should make the text prop a child if it is a string',
44
- );
43
+ 'should make the text prop a child if it is a string',
44
+ );
45
45
 
46
- defineInlineTest(
47
- { default: transformer, parser: 'tsx' },
48
- {},
49
- `
46
+ defineInlineTest(
47
+ { default: transformer, parser: 'tsx' },
48
+ {},
49
+ `
50
50
  import React from 'react';
51
51
 
52
52
  import { Code } from '@atlaskit/code';
@@ -63,7 +63,7 @@ describe('make the test prop a child', () => {
63
63
  );
64
64
  }
65
65
  `,
66
- `
66
+ `
67
67
  import React from 'react';
68
68
 
69
69
  import { Code } from '@atlaskit/code';
@@ -80,13 +80,13 @@ describe('make the test prop a child', () => {
80
80
  );
81
81
  }
82
82
  `,
83
- 'should make the text prop a child if it is a variable',
84
- );
83
+ 'should make the text prop a child if it is a variable',
84
+ );
85
85
 
86
- defineInlineTest(
87
- { default: transformer, parser: 'tsx' },
88
- {},
89
- `
86
+ defineInlineTest(
87
+ { default: transformer, parser: 'tsx' },
88
+ {},
89
+ `
90
90
  import React from 'react';
91
91
 
92
92
  import { Code } from '@atlaskit/code';
@@ -101,7 +101,7 @@ describe('make the test prop a child', () => {
101
101
  );
102
102
  }
103
103
  `,
104
- `
104
+ `
105
105
  import React from 'react';
106
106
 
107
107
  import { Code } from '@atlaskit/code';
@@ -116,13 +116,13 @@ describe('make the test prop a child', () => {
116
116
  );
117
117
  }
118
118
  `,
119
- 'should retain other props when converting to children',
120
- );
119
+ 'should retain other props when converting to children',
120
+ );
121
121
 
122
- defineInlineTest(
123
- { default: transformer, parser: 'tsx' },
124
- {},
125
- `
122
+ defineInlineTest(
123
+ { default: transformer, parser: 'tsx' },
124
+ {},
125
+ `
126
126
  import React from 'react';
127
127
 
128
128
  import { Code } from '@atlaskit/code';
@@ -139,7 +139,7 @@ describe('make the test prop a child', () => {
139
139
  );
140
140
  }
141
141
  `,
142
- `
142
+ `
143
143
  import React from 'react';
144
144
 
145
145
  import { Code } from '@atlaskit/code';
@@ -156,13 +156,13 @@ describe('make the test prop a child', () => {
156
156
  );
157
157
  }
158
158
  `,
159
- 'should retain other props that are spread when converting to children',
160
- );
159
+ 'should retain other props that are spread when converting to children',
160
+ );
161
161
 
162
- defineInlineTest(
163
- { default: transformer, parser: 'tsx' },
164
- {},
165
- `
162
+ defineInlineTest(
163
+ { default: transformer, parser: 'tsx' },
164
+ {},
165
+ `
166
166
  import React from 'react';
167
167
 
168
168
  import { Code } from '@atlaskit/code';
@@ -180,7 +180,7 @@ describe('make the test prop a child', () => {
180
180
  );
181
181
  }
182
182
  `,
183
- `
183
+ `
184
184
  import React from 'react';
185
185
 
186
186
  import { Code } from '@atlaskit/code';
@@ -198,6 +198,6 @@ describe('make the test prop a child', () => {
198
198
  );
199
199
  }
200
200
  `,
201
- 'should make the text prop a child with 2 usages',
202
- );
201
+ 'should make the text prop a child with 2 usages',
202
+ );
203
203
  });
@@ -8,11 +8,6 @@ been removed to make \`Code\` lighter, quicker and more composable. If you need
8
8
  highlighting it is still available in \`CodeBlock\`.
9
9
  `;
10
10
 
11
- const removeLanguageProp = createRemoveFuncFor(
12
- '@atlaskit/code',
13
- 'Code',
14
- 'language',
15
- comment,
16
- );
11
+ const removeLanguageProp = createRemoveFuncFor('@atlaskit/code', 'Code', 'language', comment);
17
12
 
18
13
  export default removeLanguageProp;
@@ -1,75 +1,67 @@
1
- import core, { ASTPath, JSXAttribute, JSXElement } from 'jscodeshift';
2
- import { Collection } from 'jscodeshift/src/Collection';
1
+ import type { ASTPath, default as core, JSXAttribute, JSXElement } from 'jscodeshift';
2
+ import { type Collection } from 'jscodeshift/src/Collection';
3
3
 
4
- import {
5
- getJSXAttributesByName,
6
- getNamedSpecifier,
7
- } from '@atlaskit/codemod-utils';
4
+ import { getJSXAttributesByName, getNamedSpecifier } from '@atlaskit/codemod-utils';
8
5
 
9
6
  const textToChild = (j: core.JSCodeshift, source: Collection<Node>) => {
10
- const specifier = getNamedSpecifier(j, source, '@atlaskit/code', 'Code');
7
+ const specifier = getNamedSpecifier(j, source, '@atlaskit/code', 'Code');
11
8
 
12
- if (!specifier) {
13
- return;
14
- }
9
+ if (!specifier) {
10
+ return;
11
+ }
15
12
 
16
- source.findJSXElements(specifier).forEach((element: ASTPath<JSXElement>) => {
17
- getJSXAttributesByName(j, element, 'text').forEach(
18
- (attribute: ASTPath<JSXAttribute>) => {
19
- const { value } = attribute.node;
20
- if (!value) {
21
- return;
22
- }
13
+ source.findJSXElements(specifier).forEach((element: ASTPath<JSXElement>) => {
14
+ getJSXAttributesByName(j, element, 'text').forEach((attribute: ASTPath<JSXAttribute>) => {
15
+ const { value } = attribute.node;
16
+ if (!value) {
17
+ return;
18
+ }
23
19
 
24
- let codeChild = value;
25
- switch (value.type) {
26
- // case when object value is provided
27
- case 'JSXExpressionContainer':
28
- const { expression } = value;
20
+ let codeChild = value;
21
+ switch (value.type) {
22
+ // case when object value is provided
23
+ case 'JSXExpressionContainer':
24
+ const { expression } = value;
29
25
 
30
- // case when string is provided inside JSX expression
31
- // e.g.: text={"rm -rf"}
32
- if (expression.type === 'StringLiteral') {
33
- codeChild = j.jsxText(expression.value);
34
- }
35
- // case when a variable is provided as value
36
- // e.g.: text={someVariable}
37
- else {
38
- codeChild = j.jsxExpressionContainer(expression);
39
- }
26
+ // case when string is provided inside JSX expression
27
+ // e.g.: text={"rm -rf"}
28
+ if (expression.type === 'StringLiteral') {
29
+ codeChild = j.jsxText(expression.value);
30
+ }
31
+ // case when a variable is provided as value
32
+ // e.g.: text={someVariable}
33
+ else {
34
+ codeChild = j.jsxExpressionContainer(expression);
35
+ }
40
36
 
41
- break;
37
+ break;
42
38
 
43
- // case when string value is provided
44
- // e.g.: text="rm -rf"
45
- case 'StringLiteral':
46
- codeChild = j.jsxText(value.value);
47
- }
39
+ // case when string value is provided
40
+ // e.g.: text="rm -rf"
41
+ case 'StringLiteral':
42
+ codeChild = j.jsxText(value.value);
43
+ }
48
44
 
49
- // Remove text prop
50
- j(attribute).remove();
45
+ // Remove text prop
46
+ j(attribute).remove();
51
47
 
52
- j(element)
53
- .find(j.JSXOpeningElement)
54
- .forEach((openingElement) => {
55
- // @ts-ignore
56
- if (openingElement.value.name.name === specifier) {
57
- // Create opening and closing tag with the text content as a child
58
- j(openingElement).replaceWith(
59
- j.jsxElement(
60
- j.jsxOpeningElement(
61
- j.jsxIdentifier(specifier),
62
- openingElement.value.attributes,
63
- ),
64
- j.jsxClosingElement(j.jsxIdentifier(specifier)),
65
- [codeChild],
66
- ),
67
- );
68
- }
69
- });
70
- },
71
- );
72
- });
48
+ j(element)
49
+ .find(j.JSXOpeningElement)
50
+ .forEach((openingElement) => {
51
+ // @ts-ignore
52
+ if (openingElement.value.name.name === specifier) {
53
+ // Create opening and closing tag with the text content as a child
54
+ j(openingElement).replaceWith(
55
+ j.jsxElement(
56
+ j.jsxOpeningElement(j.jsxIdentifier(specifier), openingElement.value.attributes),
57
+ j.jsxClosingElement(j.jsxIdentifier(specifier)),
58
+ [codeChild],
59
+ ),
60
+ );
61
+ }
62
+ });
63
+ });
64
+ });
73
65
  };
74
66
 
75
67
  export default textToChild;