@storybook/codemod 0.0.0-pr-23609-sha-f47ef339

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 (119) hide show
  1. package/README.md +262 -0
  2. package/dist/index.d.ts +7 -0
  3. package/dist/index.js +1 -0
  4. package/dist/transforms/add-component-parameters.d.ts +22 -0
  5. package/dist/transforms/add-component-parameters.js +1 -0
  6. package/dist/transforms/csf-2-to-3.d.ts +8 -0
  7. package/dist/transforms/csf-2-to-3.js +3 -0
  8. package/dist/transforms/csf-hoist-story-annotations.d.ts +26 -0
  9. package/dist/transforms/csf-hoist-story-annotations.js +1 -0
  10. package/dist/transforms/mdx-to-csf.d.ts +7 -0
  11. package/dist/transforms/mdx-to-csf.js +61 -0
  12. package/dist/transforms/move-builtin-addons.d.ts +3 -0
  13. package/dist/transforms/move-builtin-addons.js +1 -0
  14. package/dist/transforms/storiesof-to-csf.d.ts +24 -0
  15. package/dist/transforms/storiesof-to-csf.js +1 -0
  16. package/dist/transforms/update-addon-info.d.ts +27 -0
  17. package/dist/transforms/update-addon-info.js +1 -0
  18. package/dist/transforms/update-organisation-name.d.ts +25 -0
  19. package/dist/transforms/update-organisation-name.js +1 -0
  20. package/dist/transforms/upgrade-deprecated-types.d.ts +10 -0
  21. package/dist/transforms/upgrade-deprecated-types.js +2 -0
  22. package/dist/transforms/upgrade-hierarchy-separators.d.ts +3 -0
  23. package/dist/transforms/upgrade-hierarchy-separators.js +1 -0
  24. package/jest.config.js +9 -0
  25. package/package.json +102 -0
  26. package/project.json +6 -0
  27. package/src/index.ts +103 -0
  28. package/src/lib/utils.test.js +9 -0
  29. package/src/lib/utils.ts +29 -0
  30. package/src/transforms/__testfixtures__/add-component-parameters/add-component-parameters.input.js +44 -0
  31. package/src/transforms/__testfixtures__/add-component-parameters/add-component-parameters.output.snapshot +68 -0
  32. package/src/transforms/__testfixtures__/csf-hoist-story-annotations/basic.input.js +25 -0
  33. package/src/transforms/__testfixtures__/csf-hoist-story-annotations/basic.output.snapshot +27 -0
  34. package/src/transforms/__testfixtures__/csf-hoist-story-annotations/overrides.input.js +25 -0
  35. package/src/transforms/__testfixtures__/csf-hoist-story-annotations/overrides.output.snapshot +28 -0
  36. package/src/transforms/__testfixtures__/csf-hoist-story-annotations/variable.input.js +13 -0
  37. package/src/transforms/__testfixtures__/csf-hoist-story-annotations/variable.output.snapshot +17 -0
  38. package/src/transforms/__testfixtures__/mdx-to-csf/basic.input.mdx +18 -0
  39. package/src/transforms/__testfixtures__/mdx-to-csf/basic.output.snapshot +40 -0
  40. package/src/transforms/__testfixtures__/mdx-to-csf/component-id.input.mdx +6 -0
  41. package/src/transforms/__testfixtures__/mdx-to-csf/component-id.output.snapshot +17 -0
  42. package/src/transforms/__testfixtures__/mdx-to-csf/decorators.input.mdx +8 -0
  43. package/src/transforms/__testfixtures__/mdx-to-csf/decorators.output.snapshot +18 -0
  44. package/src/transforms/__testfixtures__/mdx-to-csf/exclude-stories.input.mdx +19 -0
  45. package/src/transforms/__testfixtures__/mdx-to-csf/exclude-stories.output.snapshot +39 -0
  46. package/src/transforms/__testfixtures__/mdx-to-csf/parameters.input.mdx +14 -0
  47. package/src/transforms/__testfixtures__/mdx-to-csf/parameters.output.snapshot +23 -0
  48. package/src/transforms/__testfixtures__/mdx-to-csf/plaintext.input.mdx +3 -0
  49. package/src/transforms/__testfixtures__/mdx-to-csf/plaintext.output.snapshot +11 -0
  50. package/src/transforms/__testfixtures__/mdx-to-csf/story-function.input.mdx +10 -0
  51. package/src/transforms/__testfixtures__/mdx-to-csf/story-function.output.snapshot +18 -0
  52. package/src/transforms/__testfixtures__/mdx-to-csf/story-parameters.input.mdx +18 -0
  53. package/src/transforms/__testfixtures__/mdx-to-csf/story-parameters.output.snapshot +32 -0
  54. package/src/transforms/__testfixtures__/mdx-to-csf/story-refs.input.mdx +22 -0
  55. package/src/transforms/__testfixtures__/mdx-to-csf/story-refs.output.snapshot +34 -0
  56. package/src/transforms/__testfixtures__/move-builtin-addons/default.input.js +2 -0
  57. package/src/transforms/__testfixtures__/move-builtin-addons/default.output.snapshot +8 -0
  58. package/src/transforms/__testfixtures__/move-builtin-addons/with-no-change.input.js +3 -0
  59. package/src/transforms/__testfixtures__/move-builtin-addons/with-no-change.output.snapshot +7 -0
  60. package/src/transforms/__testfixtures__/storiesof-to-csf/basic.input.js +18 -0
  61. package/src/transforms/__testfixtures__/storiesof-to-csf/basic.output.snapshot +45 -0
  62. package/src/transforms/__testfixtures__/storiesof-to-csf/collision.input.js +11 -0
  63. package/src/transforms/__testfixtures__/storiesof-to-csf/collision.output.snapshot +38 -0
  64. package/src/transforms/__testfixtures__/storiesof-to-csf/const.input.js +1 -0
  65. package/src/transforms/__testfixtures__/storiesof-to-csf/const.output.snapshot +13 -0
  66. package/src/transforms/__testfixtures__/storiesof-to-csf/decorators.input.js +9 -0
  67. package/src/transforms/__testfixtures__/storiesof-to-csf/decorators.output.snapshot +18 -0
  68. package/src/transforms/__testfixtures__/storiesof-to-csf/default.input.js +7 -0
  69. package/src/transforms/__testfixtures__/storiesof-to-csf/default.output.snapshot +17 -0
  70. package/src/transforms/__testfixtures__/storiesof-to-csf/digit.input.js +1 -0
  71. package/src/transforms/__testfixtures__/storiesof-to-csf/digit.output.js +5 -0
  72. package/src/transforms/__testfixtures__/storiesof-to-csf/digit.output.snapshot +9 -0
  73. package/src/transforms/__testfixtures__/storiesof-to-csf/export-destructuring.input.js +11 -0
  74. package/src/transforms/__testfixtures__/storiesof-to-csf/export-destructuring.output.snapshot +23 -0
  75. package/src/transforms/__testfixtures__/storiesof-to-csf/export-function.input.js +12 -0
  76. package/src/transforms/__testfixtures__/storiesof-to-csf/export-function.output.snapshot +23 -0
  77. package/src/transforms/__testfixtures__/storiesof-to-csf/export-names.input.js +14 -0
  78. package/src/transforms/__testfixtures__/storiesof-to-csf/export-names.output.snapshot +26 -0
  79. package/src/transforms/__testfixtures__/storiesof-to-csf/exports.input.js +2 -0
  80. package/src/transforms/__testfixtures__/storiesof-to-csf/exports.output.snapshot +16 -0
  81. package/src/transforms/__testfixtures__/storiesof-to-csf/module.input.js +12 -0
  82. package/src/transforms/__testfixtures__/storiesof-to-csf/module.output.snapshot +16 -0
  83. package/src/transforms/__testfixtures__/storiesof-to-csf/multi.input.js +14 -0
  84. package/src/transforms/__testfixtures__/storiesof-to-csf/multi.output.snapshot +39 -0
  85. package/src/transforms/__testfixtures__/storiesof-to-csf/parameters-as-var.input.js +8 -0
  86. package/src/transforms/__testfixtures__/storiesof-to-csf/parameters-as-var.output.snapshot +20 -0
  87. package/src/transforms/__testfixtures__/storiesof-to-csf/parameters.input.js +10 -0
  88. package/src/transforms/__testfixtures__/storiesof-to-csf/parameters.output.snapshot +23 -0
  89. package/src/transforms/__testfixtures__/storiesof-to-csf/storiesof-var.input.js +11 -0
  90. package/src/transforms/__testfixtures__/storiesof-to-csf/storiesof-var.output.snapshot +23 -0
  91. package/src/transforms/__testfixtures__/storiesof-to-csf/story-decorators.input.js +11 -0
  92. package/src/transforms/__testfixtures__/storiesof-to-csf/story-decorators.output.snapshot +29 -0
  93. package/src/transforms/__testfixtures__/storiesof-to-csf/story-parameters.input.js +14 -0
  94. package/src/transforms/__testfixtures__/storiesof-to-csf/story-parameters.output.snapshot +32 -0
  95. package/src/transforms/__testfixtures__/update-addon-info/update-addon-info.input.js +184 -0
  96. package/src/transforms/__testfixtures__/update-addon-info/update-addon-info.output.snapshot +184 -0
  97. package/src/transforms/__testfixtures__/update-organisation-name/update-organisation-name.input.js +19 -0
  98. package/src/transforms/__testfixtures__/update-organisation-name/update-organisation-name.output.snapshot +23 -0
  99. package/src/transforms/__testfixtures__/upgrade-hierarchy-separators/csf.input.js +3 -0
  100. package/src/transforms/__testfixtures__/upgrade-hierarchy-separators/csf.output.snapshot +7 -0
  101. package/src/transforms/__testfixtures__/upgrade-hierarchy-separators/dynamic-storiesof.input.js +5 -0
  102. package/src/transforms/__testfixtures__/upgrade-hierarchy-separators/dynamic-storiesof.output.snapshot +9 -0
  103. package/src/transforms/__testfixtures__/upgrade-hierarchy-separators/storiesof.input.js +8 -0
  104. package/src/transforms/__testfixtures__/upgrade-hierarchy-separators/storiesof.output.snapshot +12 -0
  105. package/src/transforms/__tests__/csf-2-to-3.test.ts +439 -0
  106. package/src/transforms/__tests__/mdx-to-csf.test.ts +628 -0
  107. package/src/transforms/__tests__/transforms.tests.js +32 -0
  108. package/src/transforms/__tests__/upgrade-deprecated-types.test.ts +170 -0
  109. package/src/transforms/add-component-parameters.js +62 -0
  110. package/src/transforms/csf-2-to-3.ts +336 -0
  111. package/src/transforms/csf-hoist-story-annotations.js +97 -0
  112. package/src/transforms/mdx-to-csf.ts +340 -0
  113. package/src/transforms/move-builtin-addons.js +32 -0
  114. package/src/transforms/storiesof-to-csf.js +277 -0
  115. package/src/transforms/update-addon-info.js +114 -0
  116. package/src/transforms/update-organisation-name.js +71 -0
  117. package/src/transforms/upgrade-deprecated-types.ts +142 -0
  118. package/src/transforms/upgrade-hierarchy-separators.js +39 -0
  119. package/tsconfig.json +10 -0
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Takes the deprecated addon-info API, addWithInfo, and
3
+ * converts to the new withInfo API.
4
+ *
5
+ * Example of deprecated addWithInfo API:
6
+ *
7
+ * storiesOf('Button')
8
+ * .addWithInfo(
9
+ * 'story name',
10
+ * 'Story description.',
11
+ * () => (
12
+ * <Button label="The Button" />
13
+ * )
14
+ * )
15
+ *
16
+ * Converts to the new withInfo API:
17
+ *
18
+ * storiesOf('Button')
19
+ * .add('story name', withInfo(
20
+ * 'Story description.'
21
+ * )(() => (
22
+ * <Button label="The Button" />
23
+ * )))
24
+ */
25
+ export default function transformer(file, api) {
26
+ const j = api.jscodeshift;
27
+ const root = j(file.source);
28
+
29
+ /**
30
+ * Returns a list of parameters for the withInfo function. The contents
31
+ * of this list is either the second argument from the original
32
+ * addWithInfo function, if no additional options were used, or a
33
+ * combined object of all the options from the original function.
34
+ * @param {list} args - original addWithInfo function parameters
35
+ * @return {list} the modified list of parameters for the new function
36
+ */
37
+ const getOptions = (args) => {
38
+ if (args[3] === undefined) {
39
+ if (args[2] === undefined) {
40
+ // when the optional description string is not supplied for addWithInfo, use story name
41
+ return [args[0]];
42
+ }
43
+ return [args[1]];
44
+ }
45
+ return [
46
+ j.objectExpression([
47
+ j.property('init', j.identifier('text'), args[1]),
48
+ ...args[3].properties,
49
+ ]),
50
+ ];
51
+ };
52
+
53
+ /**
54
+ * Constructs the new withInfo function from the parameters of the
55
+ * original addWithInfo function.
56
+ * @param {CallExpression} addWithInfoExpression - original function
57
+ * @returns {CallExpression} the new withInfo function
58
+ */
59
+ const withInfo = (addWithInfoExpression) => {
60
+ const { node } = addWithInfoExpression;
61
+ const args = node.arguments;
62
+
63
+ // if optional description string is not supplied, the story component becomes second arg
64
+ const storyComponent = args[2] ? args[2] : args[1];
65
+
66
+ node.callee.property.name = 'add';
67
+ node.arguments = [
68
+ args[0],
69
+ j.callExpression(j.callExpression(j.identifier('withInfo'), getOptions(args)), [
70
+ storyComponent,
71
+ ]),
72
+ ];
73
+
74
+ return node;
75
+ };
76
+
77
+ /**
78
+ * Checks for - import { withInfo } from "@storybook/addon-info";
79
+ * Adds the import if necessary.
80
+ */
81
+ const checkWithInfoImport = () => {
82
+ const importExists = root
83
+ .find(j.ImportDeclaration)
84
+ .filter((imp) => imp.node.source.value === '@storybook/addon-info')
85
+ .size();
86
+
87
+ if (importExists) return;
88
+
89
+ root
90
+ .find(j.ImportDeclaration)
91
+ .at(-1)
92
+ .insertAfter(
93
+ j.importDeclaration(
94
+ [j.importSpecifier(j.identifier('withInfo'))],
95
+ j.literal('@storybook/addon-info')
96
+ )
97
+ );
98
+ };
99
+
100
+ const addWithInfoExpressions = root.find(j.CallExpression, {
101
+ callee: {
102
+ property: {
103
+ name: 'addWithInfo',
104
+ },
105
+ },
106
+ });
107
+
108
+ if (addWithInfoExpressions.size()) {
109
+ checkWithInfoImport();
110
+ addWithInfoExpressions.replaceWith(withInfo);
111
+ }
112
+
113
+ return root.toSource();
114
+ }
@@ -0,0 +1,71 @@
1
+ export const packageNames = {
2
+ '@kadira/react-storybook-decorator-centered': '@storybook/addon-centered',
3
+ '@kadira/storybook-addons': '@storybook/preview-api',
4
+ '@kadira/storybook-addon-actions': '@storybook/addon-actions',
5
+ '@kadira/storybook-addon-comments': '@storybook/addon-comments',
6
+ '@kadira/storybook-addon-graphql': '@storybook/addon-graphql',
7
+ '@kadira/storybook-addon-info': '@storybook/addon-info',
8
+ '@kadira/storybook-addon-knobs': '@storybook/addon-knobs',
9
+ '@kadira/storybook-addon-links': '@storybook/addon-links',
10
+ '@kadira/storybook-addon-notes': '@storybook/addon-notes',
11
+ '@kadira/storybook-addon-options': '@storybook/addon-options',
12
+ '@kadira/storybook-channels': '@storybook/channels',
13
+ '@kadira/storybook-channel-postmsg': '@storybook/channel-postmessage',
14
+ '@kadira/storybook-channel-websocket': '@storybook/channel-websocket',
15
+ '@kadira/storybook-ui': '@storybook/manager',
16
+ '@kadira/react-native-storybook': '@storybook/react-native',
17
+ '@kadira/react-storybook': '@storybook/react',
18
+ '@kadira/getstorybook': '@storybook/cli',
19
+ '@kadira/storybook': '@storybook/react',
20
+ storyshots: '@storybook/addon-storyshots',
21
+ getstorybook: '@storybook/cli',
22
+ };
23
+
24
+ export default function transformer(file, api) {
25
+ const j = api.jscodeshift;
26
+
27
+ const packageNamesKeys = Object.keys(packageNames);
28
+
29
+ /**
30
+ * Checks whether the node value matches a Storybook package
31
+ * @param {string} the import declaration node
32
+ * @returns {string} whether the node value matches a Storybook package
33
+ */
34
+ const getMatch = (oldpart) => packageNamesKeys.find((newpart) => oldpart.match(newpart));
35
+
36
+ /**
37
+ * Returns the name of the Storybook packages with the organisation name,
38
+ * replacing the old `@kadira/` prefix.
39
+ * @param {string} oldPackageName the name of the old package
40
+ * @return {string} the new package name
41
+ * @example
42
+ * // returns '@storybook/storybook'
43
+ * getNewPackageName('@kadira/storybook')
44
+ */
45
+ const getNewPackageName = (oldPackageName) => {
46
+ const match = getMatch(oldPackageName);
47
+
48
+ if (match) {
49
+ const replacement = packageNames[match];
50
+ return oldPackageName.replace(match, replacement);
51
+ }
52
+ return oldPackageName;
53
+ };
54
+
55
+ /**
56
+ * updatePackageName - updates the source name of the Storybook packages
57
+ * @param {ImportDeclaration} declaration the import declaration
58
+ * @returns {ImportDeclaration.Node} the import declaration node
59
+ */
60
+ const updatePackageName = (declaration) => {
61
+ // eslint-disable-next-line no-param-reassign
62
+ declaration.node.source.value = getNewPackageName(declaration.node.source.value);
63
+
64
+ return declaration.node;
65
+ };
66
+
67
+ return j(file.source)
68
+ .find(j.ImportDeclaration)
69
+ .replaceWith(updatePackageName)
70
+ .toSource({ quote: 'single' });
71
+ }
@@ -0,0 +1,142 @@
1
+ /* eslint-disable no-underscore-dangle */
2
+ import prettier from 'prettier';
3
+ import type { API, FileInfo } from 'jscodeshift';
4
+ import type { BabelFile, NodePath } from '@babel/core';
5
+ import * as babel from '@babel/core';
6
+ import { loadCsf } from '@storybook/csf-tools';
7
+ import * as recast from 'recast';
8
+ import * as t from '@babel/types';
9
+
10
+ const logger = console;
11
+
12
+ const deprecatedTypes = [
13
+ 'ComponentStory',
14
+ 'ComponentStoryFn',
15
+ 'ComponentStoryObj',
16
+ 'ComponentMeta',
17
+ 'Story',
18
+ ];
19
+
20
+ function migrateType(oldType: string) {
21
+ if (oldType === 'Story' || oldType === 'ComponentStory') return 'StoryFn';
22
+ return oldType.replace('Component', '');
23
+ }
24
+
25
+ export default function transform(info: FileInfo, api: API, options: { parser?: string }) {
26
+ // TODO what do I need to with the title?
27
+ const fileNode = loadCsf(info.source, { makeTitle: (title) => title })._ast;
28
+ // @ts-expect-error File is not yet exposed, see https://github.com/babel/babel/issues/11350#issuecomment-644118606
29
+ const file: BabelFile = new babel.File(
30
+ { filename: info.path },
31
+ { code: info.source, ast: fileNode }
32
+ );
33
+
34
+ upgradeDeprecatedTypes(file);
35
+
36
+ let output = recast.print(file.path.node).code;
37
+
38
+ try {
39
+ const prettierConfig = prettier.resolveConfig.sync('.', { editorconfig: true }) || {
40
+ printWidth: 100,
41
+ tabWidth: 2,
42
+ bracketSpacing: true,
43
+ trailingComma: 'es5',
44
+ singleQuote: true,
45
+ };
46
+
47
+ output = prettier.format(output, { ...prettierConfig, filepath: info.path });
48
+ } catch (e) {
49
+ logger.log(`Failed applying prettier to ${info.path}.`);
50
+ }
51
+
52
+ return output;
53
+ }
54
+
55
+ export const parser = 'tsx';
56
+
57
+ export function upgradeDeprecatedTypes(file: BabelFile) {
58
+ const importedNamespaces: Set<string> = new Set();
59
+ const typeReferencesToUpdate: Set<string> = new Set();
60
+ const existingImports: { name: string; isAlias: boolean; path: NodePath }[] = [];
61
+
62
+ file.path.traverse({
63
+ ImportDeclaration: (path) => {
64
+ existingImports.push(
65
+ ...path.get('specifiers').map((specifier) => ({
66
+ name: specifier.node.local.name,
67
+ isAlias: !(
68
+ specifier.isImportSpecifier() &&
69
+ t.isIdentifier(specifier.node.imported) &&
70
+ specifier.node.local.name === specifier.node.imported.name
71
+ ),
72
+ path: specifier,
73
+ }))
74
+ );
75
+
76
+ const source = path.node.source.value;
77
+ if (!source.startsWith('@storybook')) return;
78
+
79
+ path.get('specifiers').forEach((specifier) => {
80
+ if (specifier.isImportNamespaceSpecifier()) {
81
+ importedNamespaces.add(specifier.node.local.name);
82
+ }
83
+ if (!specifier.isImportSpecifier()) return;
84
+ const imported = specifier.get('imported');
85
+ if (!imported.isIdentifier()) return;
86
+
87
+ // if we find a deprecated import
88
+ if (deprecatedTypes.includes(imported.node.name)) {
89
+ // we don't have to rewrite type references for aliased imports
90
+ if (imported.node.name === specifier.node.local.name) {
91
+ typeReferencesToUpdate.add(specifier.node.local.name);
92
+ }
93
+
94
+ const newType = migrateType(imported.node.name);
95
+
96
+ // replace the deprecated import type when the new type isn't yet imported
97
+ // note that we don't replace the local name of the specifier
98
+ if (!existingImports.some((it) => it.name === newType)) {
99
+ imported.replaceWith(t.identifier(newType));
100
+ existingImports.push({ name: newType, isAlias: false, path: specifier });
101
+ } else {
102
+ // if the existing import has the same local name but is an alias we throw
103
+ // we could have imported the type with an alias, but seems to much effort
104
+ const existingImport = existingImports.find((it) => it.name === newType && it.isAlias);
105
+ if (existingImport) {
106
+ throw existingImport.path.buildCodeFrameError(
107
+ 'This codemod does not support local imports that are called the same as a storybook import.\n' +
108
+ 'Rename this local import and try again.'
109
+ );
110
+ } else {
111
+ // if the type already exists, without being aliased
112
+ // we can safely remove the deprecated import now
113
+ specifier.remove();
114
+ }
115
+ }
116
+ }
117
+ });
118
+ },
119
+ });
120
+
121
+ file.path.traverse({
122
+ TSTypeReference: (path) => {
123
+ const typeName = path.get('typeName');
124
+ if (typeName.isIdentifier()) {
125
+ if (typeReferencesToUpdate.has(typeName.node.name)) {
126
+ typeName.replaceWith(t.identifier(migrateType(typeName.node.name)));
127
+ }
128
+ } else if (typeName.isTSQualifiedName()) {
129
+ // For example SB.StoryObj
130
+ const namespace = typeName.get('left');
131
+ if (namespace.isIdentifier()) {
132
+ if (importedNamespaces.has(namespace.node.name)) {
133
+ const right = typeName.get('right');
134
+ if (deprecatedTypes.includes(right.node.name)) {
135
+ right.replaceWith(t.identifier(migrateType(right.node.name)));
136
+ }
137
+ }
138
+ }
139
+ }
140
+ },
141
+ });
142
+ }
@@ -0,0 +1,39 @@
1
+ function upgradeSeparator(path) {
2
+ return path.replace(/[|.]/g, '/');
3
+ }
4
+
5
+ export default function transformer(file, api, options) {
6
+ const j = api.jscodeshift;
7
+ const root = j(file.source);
8
+
9
+ // storiesOf(...)
10
+ root
11
+ .find(j.CallExpression)
12
+ .filter((call) => call.node.callee.name === 'storiesOf')
13
+ .filter(
14
+ (call) =>
15
+ call.node.arguments.length > 0 &&
16
+ ['Literal', 'StringLiteral'].includes(call.node.arguments[0].type)
17
+ )
18
+ .forEach((call) => {
19
+ const arg0 = call.node.arguments[0];
20
+ arg0.value = upgradeSeparator(arg0.value);
21
+ });
22
+
23
+ // export default { title: ... }
24
+ root
25
+ .find(j.ExportDefaultDeclaration)
26
+ .filter((def) => def.node.declaration.properties.map((p) => p.key.name).includes('title'))
27
+ .forEach((def) => {
28
+ if (def.node.declaration && def.node.declaration.properties) {
29
+ def.node.declaration.properties.forEach((p) => {
30
+ if (p.key.name === 'title') {
31
+ // eslint-disable-next-line no-param-reassign
32
+ p.value.value = upgradeSeparator(p.value.value);
33
+ }
34
+ });
35
+ }
36
+ });
37
+
38
+ return root.toSource({ quote: 'single' });
39
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "skipLibCheck": true,
5
+ "allowJs": true,
6
+ "strict": false
7
+ },
8
+ "include": ["src/**/*"],
9
+ "exclude": ["node_modules", "__testfixtures__", "__tests__"]
10
+ }