Skip to content

Commit ab3a491

Browse files
authored
feat: convert to TypeScript (#1910)
1 parent 545867f commit ab3a491

File tree

4,306 files changed

+27942
-25523
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

4,306 files changed

+27942
-25523
lines changed

.babelrc

+6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
"safari": "11"
99
}
1010
}
11+
],
12+
[
13+
"@babel/preset-typescript",
14+
{
15+
"allowDeclareFields": true
16+
}
1117
]
1218
],
1319
"env": {

.nycrc

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
2-
"include": ["src/**/*.js"],
2+
"include": ["src/**/*.js", "src/**/*.ts"],
33
"exclude": [
44
"**/test",
55
"**/mock",
66
"demo",
7-
"**/*.marko.js",
8-
"**/*.stories.js",
9-
"**/style.js",
7+
"**/*.marko.*",
8+
"**/*.stories.*",
9+
"**/style",
1010
"src/common/test-utils",
1111
"src/components/ebay-icon/icons",
1212
"src/components/ebay-star-rating/icons"

.storybook/main.js

-43
This file was deleted.

.storybook/main.ts

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import fsp from "node:fs/promises";
2+
3+
import { mergeConfig } from "vite";
4+
5+
// This is done because lasso does not work with readme.md?raw
6+
// Lasso is being used to run our browser tests with @marko/test
7+
// If we get rid of lasso we should remove this code and switch all readmes to use ?raw
8+
const markdownMatch = /\.md$/;
9+
const rawMarkdown = {
10+
name: "markdown-loader",
11+
async load(id: string) {
12+
if (markdownMatch.test(id)) {
13+
// raw query, read file and return as string
14+
return `export default ${JSON.stringify(
15+
await fsp.readFile(id, "utf-8"),
16+
)}`;
17+
}
18+
},
19+
};
20+
21+
export default {
22+
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
23+
framework: "@storybook/marko-vite",
24+
addons: [
25+
{
26+
name: "@storybook/addon-docs",
27+
options: {
28+
transcludeMarkdown: true,
29+
},
30+
},
31+
"@storybook/addon-essentials",
32+
"@storybook/addon-a11y",
33+
],
34+
docs: {
35+
autodocs: true,
36+
defaultName: "Documentation",
37+
},
38+
async viteFinal(config: any) {
39+
return mergeConfig(config, {
40+
plugins: [rawMarkdown],
41+
});
42+
},
43+
};
File renamed without changes.
File renamed without changes.

.storybook/storybook-code-source/index.js

-76
This file was deleted.
+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
function tagToString(
2+
tagName: string,
3+
args: any,
4+
plurarls: Record<string, string> = {},
5+
indent = "",
6+
fromAttribute = false
7+
) {
8+
const nextIndex = indent + "\t";
9+
const { body, attrs } = argsToString(args, plurarls, nextIndex);
10+
let formattedTagName = tagName;
11+
if (fromAttribute) {
12+
formattedTagName = `@${plurarls[formattedTagName] || formattedTagName}`;
13+
}
14+
return `<${
15+
formattedTagName +
16+
attrs +
17+
(body
18+
? `>\n${body.replace(
19+
/^|\n/gm,
20+
`$&${nextIndex}`
21+
)}\n</${formattedTagName}>`
22+
: `/>`)
23+
}`;
24+
}
25+
26+
function argsToString(
27+
args: any,
28+
plurarls: Record<string, string>,
29+
indent: string
30+
) {
31+
let attrs = "";
32+
let body = "";
33+
for (const key in args) {
34+
if (
35+
Object.prototype.hasOwnProperty.call(args, key) &&
36+
key !== "renderBody"
37+
) {
38+
const val = args[key];
39+
const dashCaseKey = key.replace(
40+
/([a-z])([A-Z])/g,
41+
(m, m1, m2) => `${m1}-${m2.toLowerCase()}`
42+
);
43+
if (Array.isArray(val)) {
44+
for (const item of val) {
45+
body += tagToString(
46+
dashCaseKey,
47+
item,
48+
plurarls,
49+
indent,
50+
true
51+
);
52+
}
53+
} else if (val && typeof val === "object") {
54+
if (key === "spread") {
55+
Object.keys(val).forEach((spreadKey) => {
56+
attrs += ` ${spreadKey}=${JSON.stringify(
57+
val[spreadKey]
58+
)}`;
59+
});
60+
} else
61+
body += tagToString(
62+
dashCaseKey,
63+
val,
64+
plurarls,
65+
indent,
66+
true
67+
);
68+
} else {
69+
attrs += ` ${dashCaseKey}=${JSON.stringify(val)}`;
70+
}
71+
}
72+
}
73+
if (args.renderBody) {
74+
body += args.renderBody;
75+
}
76+
77+
return { attrs, body };
78+
}
79+
80+
export { tagToString };

.storybook/theme.js

-18
This file was deleted.

.storybook/theme.ts

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { create } from "@storybook/theming";
2+
3+
export default create({
4+
base: "light",
5+
6+
// Typography
7+
fontBase: '"Market Sans", Arial',
8+
colorSecondary: "#97BB59",
9+
appBg: "#F8FBF8",
10+
11+
// Brand assets
12+
brandTitle: "eBayUI Core",
13+
brandUrl: "/",
14+
brandImage:
15+
"https://upload.wikimedia.org/wikipedia/commons/thumb/1/1b/EBay_logo.svg/1280px-EBay_logo.svg.png",
16+
brandTarget: "/",
17+
});

.storybook/utils.js

-42
This file was deleted.

0 commit comments

Comments
 (0)