Skip to content

Commit f543ac5

Browse files
authored
Merge branch 'main' into line_wrap
2 parents 73a2b33 + d0f7309 commit f543ac5

File tree

10 files changed

+560
-185
lines changed

10 files changed

+560
-185
lines changed

package-lock.json

Lines changed: 522 additions & 136 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
"./highlight/ruby": "./code-view/highlight/ruby.js",
5454
"./highlight/rust": "./code-view/highlight/rust.js",
5555
"./highlight/sh": "./code-view/highlight/sh.js",
56-
"./highlight/swift": "./code-view/highlight/swift.js",
5756
"./highlight/typescript": "./code-view/highlight/typescript.js",
5857
"./highlight/xml": "./code-view/highlight/xml.js",
5958
"./highlight/yaml": "./code-view/highlight/yaml.js",
@@ -79,7 +78,7 @@
7978
"@cloudscape-design/global-styles": "^1.0.1",
8079
"@cloudscape-design/test-utils-converter": "^1.0.0",
8180
"@cloudscape-design/theming-build": "^1",
82-
"@size-limit/preset-small-lib": "^11.0.2",
81+
"@size-limit/preset-small-lib": "^11.1.2",
8382
"@testing-library/jest-dom": "^5.16.5",
8483
"@testing-library/react": "^13.4.0",
8584
"@types/jest-image-snapshot": "^6.1.0",
@@ -90,7 +89,7 @@
9089
"@typescript-eslint/eslint-plugin": "^5.48.0",
9190
"@typescript-eslint/parser": "^5.48.0",
9291
"@vitejs/plugin-react": "^4.2.1",
93-
"@vitest/coverage-istanbul": "^1.1.1",
92+
"@vitest/coverage-v8": "^1.4.0",
9493
"chokidar-cli": "^3.0.0",
9594
"eslint": "^8.31.0",
9695
"eslint-config-prettier": "^8.6.0",
@@ -114,7 +113,7 @@
114113
"react": "^18.2.0",
115114
"react-dom": "^18.2.0",
116115
"react-router-dom": "^6.6.1",
117-
"size-limit": "^11.0.2",
116+
"size-limit": "^11.1.2",
118117
"stylelint": "^15.11.0",
119118
"stylelint-config-recommended-scss": "^12.0.0",
120119
"stylelint-order": "^6.0.3",
@@ -123,7 +122,7 @@
123122
"stylelint-use-logical": "^2.1.0",
124123
"typescript": "4.9.4",
125124
"vite": "^5.0.12",
126-
"vitest": "^1.1.1"
125+
"vitest": "^1.4.0"
127126
},
128127
"//": "ensure that typedoc uses typescript 4.9.4. It prints a warning, but works",
129128
"overrides": {
@@ -143,11 +142,11 @@
143142
"size-limit": [
144143
{
145144
"path": "lib/components/index.js",
146-
"limit": "508b"
145+
"limit": "6.2kb"
147146
},
148147
{
149148
"path": "lib/components/code-view/highlight/javascript.js",
150-
"limit": "1kb"
149+
"limit": "10kb"
151150
}
152151
]
153152
}

scripts/compile-styles.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
3-
import { ThemeBuilder, buildThemedComponentsInternal } from "@cloudscape-design/theming-build";
3+
import { buildStyles } from "@cloudscape-design/theming-build/internal";
44

5-
// Generates scoped styles for the component
6-
// The output includes files like 'styles.css.js', 'styles.scoped.css', and 'styles.selectors.js'
7-
await buildThemedComponentsInternal({
8-
primary: new ThemeBuilder("unused", ":root", []).build(), // "unused" as placeholder and ":root" for global style
9-
componentsOutputDir: "lib/components", // sets the output directory for the processed styles
10-
skip: ["design-tokens", "preset"], // skips generation of design tokens and presets
11-
scssDir: "src", // sets the source directory for SCSS files
12-
variablesMap: {}, // not needed - can be used for custom token-variable mappings
13-
exposed: [], // not needed - can be used for exposing specific design tokens
14-
});
5+
await buildStyles("src", "lib/components");

src/__tests__/__snapshots__/documenter.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

3-
exports[`definition for code-view matches the snapshot > code-view 1`] = `
3+
exports[`definition for code-view matches the snapshot 1`] = `
44
{
55
"events": [],
66
"functions": [],

src/__tests__/base-props-support.test.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
import { render } from "@testing-library/react";
44
import { ReactElement } from "react";
55
import { describe, expect, test } from "vitest";
6+
import * as components from "../../lib/components";
67
import { defaultProps } from "./default-props";
7-
import { requireComponent } from "./utils";
88

9-
describe(`base props support for code-view`, async () => {
10-
const Component = await requireComponent("code-view");
9+
describe(`base props support for code-view`, () => {
10+
const Component = components.CodeView;
1111
const props = defaultProps["code-view" as keyof typeof defaultProps];
1212

1313
function renderComponent(ui: ReactElement) {
@@ -20,11 +20,13 @@ describe(`base props support for code-view`, async () => {
2020
});
2121

2222
test("should not allow id", () => {
23+
// @ts-expect-error id is not supported
2324
const { container } = renderComponent(<Component {...props} id="example" />);
2425
expect(container.querySelector("#example")).toBeNull();
2526
});
2627

2728
test("should not allow className", () => {
29+
// @ts-expect-error className is not supported
2830
const { container } = renderComponent(<Component {...props} className="example" />);
2931
expect(container.querySelector(".example")).toBeNull();
3032
});

src/__tests__/documenter.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33
import { expect, test } from "vitest";
4-
import { requireComponentDefinition } from "./utils";
4+
// @ts-expect-error no types here
5+
import apiDocs from "../../lib/components/internal/api-docs/components";
56

6-
test(`definition for code-view matches the snapshot`, () => {
7-
const definition = requireComponentDefinition("code-view");
8-
expect(definition).toMatchSnapshot("code-view");
7+
test("definition for code-view matches the snapshot", () => {
8+
const definition = apiDocs["code-view"];
9+
expect(definition).toMatchSnapshot();
910
});

src/__tests__/utils.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
import fs from "node:fs";
4+
import path from "node:path";
5+
import url from "node:url";
6+
import { describe, expect, test } from "vitest";
7+
8+
const dirname = path.dirname(url.fileURLToPath(import.meta.url));
9+
const rulesDir = path.resolve(dirname, "../highlight");
10+
const rules = fs.readdirSync(rulesDir).filter((file) => file !== "index.tsx");
11+
12+
describe("highlight rules can be loaded", () => {
13+
test.each(rules)("%s", async (rule) => {
14+
// eslint-disable-next-line no-unsanitized/method
15+
const { default: highlight } = await import(path.join(rulesDir, rule));
16+
expect(highlight("")).toBeDefined();
17+
});
18+
});

src/code-view/highlight/swift.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

vite.unit.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default defineConfig({
1515
setupFiles: ["./src/__tests__/setup.ts"],
1616
coverage: {
1717
enabled: process.env.CI === "true",
18-
provider: "istanbul",
18+
provider: "v8",
1919
include: ["src/**", "lib/components/**"],
2020
exclude: ["**/__tests__/**", "**/*.d.ts", "**/api-docs/**", "**/test-utils/selectors/**"],
2121
},

0 commit comments

Comments
 (0)