Run npm run lint

This commit is contained in:
Eric Liu 2025-03-23 11:26:25 -07:00
commit 2031cb7585
480 changed files with 8985 additions and 9048 deletions

View file

@ -30,10 +30,7 @@
"routify": { "routify": {
"routifyDir": ".routify", "routifyDir": ".routify",
"dynamicImports": true, "dynamicImports": true,
"extensions": [ "extensions": ["svelte", "svx"]
"svelte",
"svx"
]
}, },
"type": "module" "type": "module"
} }

View file

@ -24,8 +24,7 @@
let AsyncPreviewTypeScript; let AsyncPreviewTypeScript;
onMount(async () => { onMount(async () => {
AsyncPreviewTypeScript = (await import("./PreviewTypeScript.svelte")) AsyncPreviewTypeScript = (await import("./PreviewTypeScript.svelte")).default;
.default;
}); });
const mdn_api = "https://developer.mozilla.org/en-US/docs/Web/API/"; const mdn_api = "https://developer.mozilla.org/en-US/docs/Web/API/";

View file

@ -7,11 +7,7 @@
import "prismjs/components/prism-typescript"; import "prismjs/components/prism-typescript";
import copy from "clipboard-copy"; import copy from "clipboard-copy";
$: highlightedCode = highlight( $: highlightedCode = highlight(code, Prism.languages.typescript, "typescript");
code,
Prism.languages.typescript,
"typescript",
);
</script> </script>
{#if type === "multi"} {#if type === "multi"}

View file

@ -1,9 +1,5 @@
<script> <script>
import { import { FluidForm, TextInput, PasswordInput } from "carbon-components-svelte";
FluidForm,
TextInput,
PasswordInput,
} from "carbon-components-svelte";
let password = ""; let password = "";
let invalid = false; let invalid = false;

View file

@ -1,8 +1,7 @@
<script> <script>
import { ImageLoader, Button } from "carbon-components-svelte"; import { ImageLoader, Button } from "carbon-components-svelte";
const src = const src = "https://upload.wikimedia.org/wikipedia/commons/5/51/IBM_logo.svg";
"https://upload.wikimedia.org/wikipedia/commons/5/51/IBM_logo.svg";
const srcError = src + "1"; const srcError = src + "1";
let imageLoader; let imageLoader;

View file

@ -1,9 +1,5 @@
<script> <script>
import { import { Theme, RadioButtonGroup, RadioButton } from "carbon-components-svelte";
Theme,
RadioButtonGroup,
RadioButton,
} from "carbon-components-svelte";
let theme = "g90"; let theme = "g90";
</script> </script>

View file

@ -1,9 +1,5 @@
<script> <script>
import { import { Theme, RadioButtonGroup, RadioButton } from "carbon-components-svelte";
Theme,
RadioButtonGroup,
RadioButton,
} from "carbon-components-svelte";
let theme = "g90"; let theme = "g90";
</script> </script>

View file

@ -25,15 +25,15 @@
let isOpen = false; let isOpen = false;
let selected = "0"; let selected = "0";
let transitions = { let transitions = {
"0": { 0: {
text: "Default (duration: 200ms)", text: "Default (duration: 200ms)",
value: { duration: 200 }, value: { duration: 200 },
}, },
"1": { 1: {
text: "Custom (duration: 600ms, delay: 50ms, easing: expoIn)", text: "Custom (duration: 600ms, delay: 50ms, easing: expoIn)",
value: { duration: 600, delay: 50, easing: expoIn }, value: { duration: 600, delay: 50, easing: expoIn },
}, },
"2": { 2: {
text: "Disabled", text: "Disabled",
value: false, value: false,
}, },

View file

@ -26,9 +26,7 @@
"import": "./src/*.js" "import": "./src/*.js"
} }
}, },
"sideEffects": [ "sideEffects": ["css/*.css"],
"css/*.css"
],
"scripts": { "scripts": {
"test": "vitest", "test": "vitest",
"test:ui": "vite", "test:ui": "vite",
@ -85,12 +83,7 @@
"component library", "component library",
"carbon design system" "carbon design system"
], ],
"files": [ "files": ["src", "types", "css", "telemetry.yml"],
"src",
"types",
"css",
"telemetry.yml"
],
"maintainers": [ "maintainers": [
"Eric Liu (https://github.com/metonym)", "Eric Liu (https://github.com/metonym)",
"Enrico Sacchetti (https://github.com/theetrain)" "Enrico Sacchetti (https://github.com/theetrain)"

View file

@ -1,6 +1,8 @@
// @ts-check // @ts-check
import fs from "node:fs"; import fs from "node:fs";
import componentApi from "../docs/src/COMPONENT_API.json" assert { type: "json" }; import componentApi from "../docs/src/COMPONENT_API.json" assert {
type: "json",
};
import { format } from "prettier"; import { format } from "prettier";
import plugin from "prettier/plugins/typescript"; import plugin from "prettier/plugins/typescript";

View file

@ -119,12 +119,8 @@
hasIconOnly && "bx--btn--icon-only", hasIconOnly && "bx--btn--icon-only",
hasIconOnly && "bx--tooltip__trigger", hasIconOnly && "bx--tooltip__trigger",
hasIconOnly && "bx--tooltip--a11y", hasIconOnly && "bx--tooltip--a11y",
hasIconOnly && hasIconOnly && tooltipPosition && `bx--btn--icon-only--${tooltipPosition}`,
tooltipPosition && hasIconOnly && tooltipAlignment && `bx--tooltip--align-${tooltipAlignment}`,
`bx--btn--icon-only--${tooltipPosition}`,
hasIconOnly &&
tooltipAlignment &&
`bx--tooltip--align-${tooltipAlignment}`,
hasIconOnly && isSelected && kind === "ghost" && "bx--btn--selected", hasIconOnly && isSelected && kind === "ghost" && "bx--btn--selected",
$$restProps.class, $$restProps.class,
] ]

View file

@ -237,27 +237,19 @@
let expanded = false; let expanded = false;
let parentRowId = null; let parentRowId = null;
$: expandedRows = expandedRowIds.reduce( $: expandedRows = expandedRowIds.reduce((a, id) => ({ ...a, [id]: true }), {});
(a, id) => ({ ...a, [id]: true }),
{},
);
let refSelectAll = null; let refSelectAll = null;
$: batchSelectedIds.set(selectedRowIds); $: batchSelectedIds.set(selectedRowIds);
$: rowIds = $tableRows.map((row) => row.id); $: rowIds = $tableRows.map((row) => row.id);
$: expandableRowIds = rowIds.filter( $: expandableRowIds = rowIds.filter((id) => !nonExpandableRowIds.includes(id));
(id) => !nonExpandableRowIds.includes(id), $: selectableRowIds = rowIds.filter((id) => !nonSelectableRowIds.includes(id));
);
$: selectableRowIds = rowIds.filter(
(id) => !nonSelectableRowIds.includes(id),
);
$: selectAll = $: selectAll =
selectableRowIds.length > 0 && selectableRowIds.length > 0 &&
selectedRowIds.length === selectableRowIds.length; selectedRowIds.length === selectableRowIds.length;
$: indeterminate = $: indeterminate =
selectedRowIds.length > 0 && selectedRowIds.length > 0 && selectedRowIds.length < selectableRowIds.length;
selectedRowIds.length < selectableRowIds.length;
$: if (batchExpansion) { $: if (batchExpansion) {
expandable = true; expandable = true;
expanded = expandedRowIds.length === expandableRowIds.length; expanded = expandedRowIds.length === expandableRowIds.length;
@ -305,9 +297,7 @@
} }
} }
const getDisplayedRows = (rows, page, pageSize) => const getDisplayedRows = (rows, page, pageSize) =>
page && pageSize page && pageSize ? rows.slice((page - 1) * pageSize, page * pageSize) : rows;
? rows.slice((page - 1) * pageSize, page * pageSize)
: rows;
$: displayedRows = getDisplayedRows($tableRows, page, pageSize); $: displayedRows = getDisplayedRows($tableRows, page, pageSize);
$: displayedSortedRows = getDisplayedRows(sortedRows, page, pageSize); $: displayedSortedRows = getDisplayedRows(sortedRows, page, pageSize);

View file

@ -181,10 +181,7 @@
}, },
}); });
calendar?.calendarContainer?.setAttribute("role", "application"); calendar?.calendarContainer?.setAttribute("role", "application");
calendar?.calendarContainer?.setAttribute( calendar?.calendarContainer?.setAttribute("aria-label", "calendar-container");
"aria-label",
"calendar-container",
);
} }
onMount(() => { onMount(() => {

View file

@ -97,9 +97,7 @@
if (removedIds.length > 0) { if (removedIds.length > 0) {
dispatch( dispatch(
"remove", "remove",
removedIds.map((id) => removedIds.map((id) => prevFiles.find((file) => id === getFileId(file))),
prevFiles.find((file) => id === getFileId(file)),
),
); );
} }

View file

@ -245,10 +245,7 @@
}); });
function sort() { function sort() {
if ( if (selectionFeedback === "top" || selectionFeedback === "top-after-reopen") {
selectionFeedback === "top" ||
selectionFeedback === "top-after-reopen"
) {
const checkedItems = items const checkedItems = items
.filter((item) => selectedIds.includes(item.id)) .filter((item) => selectedIds.includes(item.id))
.map((item) => ({ ...item, checked: true })); .map((item) => ({ ...item, checked: true }));
@ -257,9 +254,7 @@
.map((item) => ({ ...item, checked: false })); .map((item) => ({ ...item, checked: false }));
return [ return [
...(checkedItems.length > 1 ...(checkedItems.length > 1 ? checkedItems.sort(sortItem) : checkedItems),
? checkedItems.sort(sortItem)
: checkedItems),
...uncheckedItems.sort(sortItem), ...uncheckedItems.sort(sortItem),
]; ];
} }
@ -289,8 +284,7 @@
$: filteredItems = sortedItems.filter((item) => filterItem(item, value)); $: filteredItems = sortedItems.filter((item) => filterItem(item, value));
$: highlightedId = $: highlightedId =
highlightedIndex > -1 highlightedIndex > -1
? ((filterable ? filteredItems : sortedItems)[highlightedIndex]?.id ?? ? ((filterable ? filteredItems : sortedItems)[highlightedIndex]?.id ?? null)
null)
: null; : null;
</script> </script>

View file

@ -28,8 +28,7 @@
* Override the item text * Override the item text
* @type {(min: number, max: number) => string} * @type {(min: number, max: number) => string}
*/ */
export let itemText = (min, max) => export let itemText = (min, max) => `${min}${max} item${max === 1 ? "" : "s"}`;
`${min}${max} item${max === 1 ? "" : "s"}`;
/** /**
* Override the item range text * Override the item range text

View file

@ -100,8 +100,7 @@
const offsetX = e.touches ? e.touches[0].clientX : e.clientX; const offsetX = e.touches ? e.touches[0].clientX : e.clientX;
const { left, width } = trackRef.getBoundingClientRect(); const { left, width } = trackRef.getBoundingClientRect();
let nextValue = let nextValue =
min + min + Math.round(((max - min) * ((offsetX - left) / width)) / step) * step;
Math.round(((max - min) * ((offsetX - left) / width)) / step) * step;
if (nextValue <= min) { if (nextValue <= min) {
nextValue = min; nextValue = min;

View file

@ -150,8 +150,7 @@
if (hideIcon) { if (hideIcon) {
offsetX = -1 * (tooltip.width / 2 - button.width / 2); offsetX = -1 * (tooltip.width / 2 - button.width / 2);
} else { } else {
offsetX = offsetX = -1 * (tooltip.width / 2 - button.width + iconWidth / 2 + 1);
-1 * (tooltip.width / 2 - button.width + iconWidth / 2 + 1);
} }
offsetY = -1 * (tooltip.height + button.height + iconWidth / 2 - 1); offsetY = -1 * (tooltip.height + button.height + iconWidth / 2 - 1);
break; break;

View file

@ -35,8 +35,7 @@
}, },
}); });
$: isCurrentSubmenu = $: isCurrentSubmenu = Object.values($selectedItems).filter(Boolean).length > 0;
Object.values($selectedItems).filter(Boolean).length > 0;
</script> </script>
<svelte:window <svelte:window

View file

@ -1,9 +1,5 @@
<script lang="ts"> <script lang="ts">
import { import { FluidForm, TextInput, PasswordInput } from "carbon-components-svelte";
FluidForm,
TextInput,
PasswordInput,
} from "carbon-components-svelte";
</script> </script>
<FluidForm action="" method="get"> <FluidForm action="" method="get">

View file

@ -1,9 +1,5 @@
<script lang="ts"> <script lang="ts">
import { import { Select, SelectItem, SelectItemGroup } from "carbon-components-svelte";
Select,
SelectItem,
SelectItemGroup,
} from "carbon-components-svelte";
export let selected: string | number | undefined = undefined; export let selected: string | number | undefined = undefined;
</script> </script>