ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
Load two stylesheets nothing imported; lint for orphans
Juan Denisc98952b9070a
diff --git a/frontend/package.json b/frontend/package.jsonindex b932022d..530c8114 100644--- a/frontend/package.json+++ b/frontend/package.json@@ -9,7 +9,7 @@"test": "node --test","test:browser": "node scripts/settings-browser.mjs","test:settings-ui": "node scripts/settings-ui-browser.mjs",- "lint": "node scripts/lint.mjs && node scripts/check-font-integrity.mjs && node scripts/check-settings-index.mjs && node scripts/check-theme-tokens.mjs && node scripts/check-frontend-boundaries.mjs && node scripts/check-style-ownership.mjs && node scripts/check-status-one-door.mjs && node scripts/check-shared-fields.mjs && node scripts/check-tables.mjs && node scripts/check-type-scale.mjs && node scripts/check-geometry.mjs && node scripts/check-status-scss.mjs && node scripts/check-i18n-literals.mjs && node scripts/check-intl-door.mjs && node scripts/extract-i18n.mjs --check && node scripts/check-i18n.mjs && node scripts/check-logical-properties.mjs && node scripts/generate-vendor-shims.mjs --check && node ../scripts/check-html-sinks.mjs",+ "lint": "node scripts/lint.mjs && node scripts/check-font-integrity.mjs && node scripts/check-settings-index.mjs && node scripts/check-theme-tokens.mjs && node scripts/check-frontend-boundaries.mjs && node scripts/check-style-ownership.mjs && node scripts/check-status-one-door.mjs && node scripts/check-shared-fields.mjs && node scripts/check-tables.mjs && node scripts/check-type-scale.mjs && node scripts/check-geometry.mjs && node scripts/check-status-scss.mjs && node scripts/check-i18n-literals.mjs && node scripts/check-intl-door.mjs && node scripts/extract-i18n.mjs --check && node scripts/check-i18n.mjs && node scripts/check-logical-properties.mjs && node scripts/generate-vendor-shims.mjs --check && node ../scripts/check-html-sinks.mjs && node scripts/check-orphan-files.mjs","lint:baseline": "node scripts/lint.mjs --update","test:controls": "node scripts/controls-browser.mjs","test:metrics": "node scripts/metrics-browser.mjs",diff --git a/frontend/scripts/check-orphan-files.mjs b/frontend/scripts/check-orphan-files.mjsnew file mode 100644index 00000000..b0d8435c--- /dev/null+++ b/frontend/scripts/check-orphan-files.mjs@@ -0,0 +1,75 @@+#!/usr/bin/env node+// Fails when a source file under src/ is imported by nothing.+//+// Components, hooks and stylesheets used to outlive the last code that used+// them (20 files, ~2,000 lines, found in one audit), each still costing+// review time and translation strings. Resolution follows relative and `@/`+// imports, dynamic `import()`, and SCSS `@import`/`@use` (bare paths are+// relative to the importing stylesheet). Entry points and glob-loaded trees+// are roots; deliberate keeps live in KEEP with a reason.+//+// Usage (from frontend/): node scripts/check-orphan-files.mjs++import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';+import { dirname, join, posix, relative, resolve } from 'node:path';+import { fileURLToPath } from 'node:url';++const here = dirname(fileURLToPath(import.meta.url));+const src = resolve(here, '../src').split('\\').join('/');++// file (relative to src/) -> why it stays without an importer+const KEEP = {+ 'main.jsx': 'entry point',+ 'styles/main.scss': 'entry stylesheet',+ 'plugins/runtime/vendorManifest.js': 'read by the vendor-shim generator and extension bundle checks',+ 'components/domains/CutoverDrawer.jsx': 'built, never mounted: wire into Domains or delete (product call)',+ 'components/settings/MemberActionsCard.jsx': 'built, never mounted: wire in or delete (product call)',+ 'components/dashboard/AccountSecurityNudge.jsx': 'built, never mounted: wire in or delete (product call)',+ 'styles/pages/_cutover.scss': 'styles CutoverDrawer above; goes or gets imported with it',+ 'utils/snapshotBones.js': 'imported by scripts/capture-skeletons.mjs',+};+// Trees loaded by import.meta.glob, tests, and bundled extension copies.+const ROOT_TREES = [/\/__tests__\//, /\.test\.(m?js|jsx)$/, /^plugins\/serverkit-/, /^plugins\/[^/]+\/index\./,+ /^data\/themes\//, /^i18n\/locales\//];++const walk = (d) => readdirSync(d, { withFileTypes: true }).flatMap((e) =>+ e.isDirectory() ? walk(join(d, e.name)) : [join(d, e.name).split('\\').join('/')]);+const files = walk(src).filter((f) => /\.(jsx?|mjs|scss)$/.test(f));+const referenced = new Set();+const EXT = ['', '.js', '.jsx', '.mjs', '.scss', '/index.js', '/index.jsx'];++function resolveSpec(from, spec) {+ let base;+ if (spec.startsWith('@/')) base = `${src}/${spec.slice(2)}`;+ else if (spec.startsWith('.') || from.endsWith('.scss')) base = posix.join(posix.dirname(from), spec);+ else return;+ for (const ext of EXT) {+ for (const candidate of [base + ext, posix.join(posix.dirname(base), `_${posix.basename(base)}`) + ext]) {+ if (existsSync(candidate) && statSync(candidate).isFile()) {+ referenced.add(candidate);+ return;+ }+ }+ }+}++const IMPORT = /(?:from\s+|import\s*\(\s*|import\s+|@import\s+|@use\s+|@forward\s+)['"]([^'"]+)['"]/g;+for (const file of files) {+ for (const match of readFileSync(file, 'utf8').matchAll(IMPORT)) resolveSpec(file, match[1]);+}++const orphans = files+ .map((f) => relative(src, f).split('\\').join('/'))+ .filter((rel) => !referenced.has(`${src}/${rel}`) && !KEEP[rel] && !ROOT_TREES.some((re) => re.test(rel)));+const staleKeeps = Object.keys(KEEP).filter((rel) => !existsSync(`${src}/${rel}`));++if (orphans.length || staleKeeps.length) {+ if (orphans.length) {+ console.error(`\n${orphans.length} file(s) under src/ are imported by nothing:\n`);+ for (const rel of orphans) console.error(` ${rel}`);+ console.error('\nDelete them, or add them to KEEP in scripts/check-orphan-files.mjs with a reason.\n');+ }+ if (staleKeeps.length) console.error(`KEEP lists files that no longer exist: ${staleKeeps.join(', ')}\n`);+ process.exit(1);+}+console.log(`✓ orphan files: every one of ${files.length} source files is imported (${Object.keys(KEEP).length} kept by reason).`);diff --git a/frontend/src/styles/main.scss b/frontend/src/styles/main.scssindex db11724a..96666eb9 100644--- a/frontend/src/styles/main.scss+++ b/frontend/src/styles/main.scss@@ -63,6 +63,7 @@@import 'components/_linked-apps';@import 'components/_api-settings';@import 'components/_empty-state';+@import 'components/_extensions'; // ExtensionBoundary failure card (was never imported)@import 'components/_status-badge';@import 'components/_connection-status';@import 'components/_detail-tabs';@@ -125,6 +126,7 @@@import 'pages/_storage';@import 'pages/_notification-center';@import 'pages/_connections';+@import 'pages/_coexistence'; // Coexistence page (was never imported)@import 'pages/_file-manager';@import 'pages/_ftp-server';@import 'pages/_firewall';