From 9bcac1af2da5c9c915584747116a04829e0ab17b Mon Sep 17 00:00:00 2001 From: Keavon Chambers Date: Sat, 21 Mar 2026 00:08:32 -0700 Subject: [PATCH] Remove JS module import prefixes and use absolute paths to the frontend directory (#3924) * Remove JS module import prefixes * Fix code review mistakes --- frontend/branding-installer.js | 1 - frontend/eslint.config.js | 35 +- frontend/src/App.svelte | 12 +- frontend/src/components/Editor.svelte | 44 +- .../floating-menus/ColorPicker.svelte | 30 +- .../components/floating-menus/Dialog.svelte | 22 +- .../floating-menus/EyedropperPreview.svelte | 3 +- .../components/floating-menus/MenuList.svelte | 22 +- .../floating-menus/NodeCatalog.svelte | 14 +- .../components/floating-menus/Tooltip.svelte | 14 +- .../src/components/layout/FloatingMenu.svelte | 8 +- .../src/components/layout/LayoutCol.svelte | 2 +- .../src/components/layout/LayoutRow.svelte | 2 +- frontend/src/components/panels/Data.svelte | 10 +- .../src/components/panels/Document.svelte | 34 +- frontend/src/components/panels/Layers.svelte | 26 +- .../src/components/panels/Properties.svelte | 10 +- frontend/src/components/panels/Welcome.svelte | 20 +- frontend/src/components/views/Graph.svelte | 22 +- .../components/widgets/WidgetLayout.svelte | 9 +- .../components/widgets/WidgetSection.svelte | 12 +- .../src/components/widgets/WidgetSpan.svelte | 50 ++- .../src/components/widgets/WidgetTable.svelte | 5 +- .../buttons/BreadcrumbTrailButtons.svelte | 7 +- .../widgets/buttons/IconButton.svelte | 7 +- .../widgets/buttons/ImageButton.svelte | 4 +- .../buttons/ParameterExposeButton.svelte | 5 +- .../widgets/buttons/PopoverButton.svelte | 15 +- .../widgets/buttons/TextButton.svelte | 14 +- .../widgets/inputs/CheckboxInput.svelte | 10 +- .../widgets/inputs/ColorInput.svelte | 10 +- .../widgets/inputs/CurveInput.svelte | 6 +- .../widgets/inputs/DropdownInput.svelte | 12 +- .../widgets/inputs/FieldInput.svelte | 10 +- .../widgets/inputs/NumberInput.svelte | 14 +- .../widgets/inputs/RadioInput.svelte | 10 +- .../widgets/inputs/ReferencePointInput.svelte | 3 +- .../widgets/inputs/ScrollbarInput.svelte | 3 +- .../widgets/inputs/SpectrumInput.svelte | 14 +- .../widgets/inputs/TextAreaInput.svelte | 6 +- .../widgets/inputs/TextInput.svelte | 6 +- .../widgets/inputs/WorkingColorsInput.svelte | 12 +- .../widgets/labels/IconLabel.svelte | 9 +- .../widgets/labels/ImageLabel.svelte | 2 +- .../widgets/labels/Separator.svelte | 2 +- .../widgets/labels/ShortcutLabel.svelte | 13 +- .../widgets/labels/TextLabel.svelte | 3 +- .../src/components/window/MainWindow.svelte | 24 +- frontend/src/components/window/Panel.svelte | 22 +- .../src/components/window/StatusBar.svelte | 12 +- .../src/components/window/TitleBar.svelte | 22 +- .../src/components/window/Workspace.svelte | 12 +- frontend/src/icons.ts | 390 +++++++++--------- frontend/src/main.ts | 3 +- frontend/src/managers/clipboard.ts | 4 +- frontend/src/managers/fonts.ts | 2 +- frontend/src/managers/input.ts | 14 +- frontend/src/managers/localization.ts | 4 +- frontend/src/managers/panic.ts | 2 +- frontend/src/managers/persistence.ts | 6 +- frontend/src/stores/app-window.ts | 3 +- frontend/src/stores/dialog.ts | 7 +- frontend/src/stores/document.ts | 5 +- frontend/src/stores/fullscreen.ts | 1 - frontend/src/stores/node-graph.ts | 3 +- frontend/src/stores/portfolio.ts | 7 +- frontend/src/stores/tooltip.ts | 5 +- frontend/src/subscriptions-router.ts | 2 +- frontend/src/utility-functions/clipboard.ts | 6 +- frontend/src/utility-functions/colors.ts | 4 +- .../src/utility-functions/crash-report.ts | 4 +- frontend/src/utility-functions/files.ts | 4 +- frontend/src/utility-functions/images.ts | 14 +- frontend/src/utility-functions/input.ts | 19 +- frontend/src/utility-functions/network.ts | 2 +- frontend/src/utility-functions/persistence.ts | 5 +- frontend/src/utility-functions/viewports.ts | 2 +- frontend/src/utility-functions/widgets.ts | 2 +- frontend/tsconfig.json | 6 +- frontend/vite.config.ts | 10 +- 80 files changed, 574 insertions(+), 658 deletions(-) diff --git a/frontend/branding-installer.js b/frontend/branding-installer.js index d8a6aca7b5..640d0fa355 100644 --- a/frontend/branding-installer.js +++ b/frontend/branding-installer.js @@ -7,7 +7,6 @@ import https from "https"; import path from "path"; import { fileURLToPath } from "url"; import zlib from "zlib"; - import * as tar from "tar"; const __filename = fileURLToPath(import.meta.url); diff --git a/frontend/eslint.config.js b/frontend/eslint.config.js index 5faa1d3bce..66206b3f7a 100644 --- a/frontend/eslint.config.js +++ b/frontend/eslint.config.js @@ -6,6 +6,17 @@ import pluginSvelte from "eslint-plugin-svelte"; import globals from "globals"; import ts from "typescript-eslint"; +const importOrder = { + alphabetize: { order: "asc", caseInsensitive: true }, + "newlines-between": "never", + warnOnUnassignedImports: true, + pathGroups: [ + { pattern: "/**", group: "internal" }, + { pattern: "/../**", group: "internal" }, + ], + pathGroupsExcludedImportTypes: [], +}; + export default defineConfig([ js.configs.recommended, ts.configs.recommended, @@ -52,7 +63,15 @@ export default defineConfig([ "no-bitwise": "off", "no-shadow": "off", "no-use-before-define": "off", - "no-restricted-imports": ["error", { patterns: [".*", "!@graphite/*"] }], + "no-restricted-imports": [ + "error", + { + patterns: [ + { group: ["./**", "../**"], message: "\nImports must be absolute (e.g. '/src/') not relative (e.g. './')." }, + { group: ["src/**", "assets/**", "wasm/**"], message: "\nLocal imports must start with '/' (e.g. '/src/' not 'src/')." }, + ], + }, + ], // TypeScript plugin config (for TS-specific linting) "@typescript-eslint/indent": "off", @@ -95,17 +114,13 @@ export default defineConfig([ "import/prefer-default-export": "off", "import/no-relative-packages": "error", "import/no-named-as-default-member": "off", - "import/order": [ - "error", - { - alphabetize: { order: "asc", caseInsensitive: true }, - pathGroups: [{ pattern: "**/*.svelte", group: "unknown", position: "after" }], - "newlines-between": "always-and-inside-groups", - warnOnUnassignedImports: true, - }, - ], + "import/order": ["error", importOrder], }, }, + { + files: ["**/icons.ts"], + rules: { "import/order": ["error", { ...importOrder, "newlines-between": "ignore" }] }, + }, { files: ["**/*.svelte"], languageOptions: { diff --git a/frontend/src/App.svelte b/frontend/src/App.svelte index 4ad22865d1..dd94bd4037 100644 --- a/frontend/src/App.svelte +++ b/frontend/src/App.svelte @@ -1,14 +1,12 @@