- Delete old Vite+Svelte frontend - Initialize new SvelteKit project with TypeScript - Configure Tailwind CSS v4 + DaisyUI - Implement JWT authentication with auto-refresh - Create login page with form validation (Zod) - Add protected route guards - Update Docker configuration for single-stage build - Add E2E tests with Playwright (6/11 passing) - Fix Svelte 5 reactivity with $state() runes Known issues: - 5 E2E tests failing (timing/async issues) - Token refresh implementation needs debugging - Validation error display timing
45 lines
1.3 KiB
JavaScript
45 lines
1.3 KiB
JavaScript
import Module from "module";
|
|
import path from "path";
|
|
let espreeCache = null;
|
|
/** Checks if given path is linter path */
|
|
function isLinterPath(p) {
|
|
return (
|
|
// ESLint 6 and above
|
|
p.includes(`eslint${path.sep}lib${path.sep}linter${path.sep}linter.js`) ||
|
|
// ESLint 5
|
|
p.includes(`eslint${path.sep}lib${path.sep}linter.js`));
|
|
}
|
|
/**
|
|
* Load `espree` from the loaded ESLint.
|
|
* If the loaded ESLint was not found, just returns `require("espree")`.
|
|
*/
|
|
export function getEspree() {
|
|
if (!espreeCache) {
|
|
// Lookup the loaded eslint
|
|
const req = Module.createRequire(import.meta.url);
|
|
const linterPath = Object.keys(req.cache || {}).find(isLinterPath);
|
|
if (linterPath) {
|
|
try {
|
|
espreeCache = Module.createRequire(linterPath)("espree");
|
|
}
|
|
catch {
|
|
// ignore
|
|
}
|
|
}
|
|
if (!espreeCache) {
|
|
try {
|
|
return req("espree");
|
|
}
|
|
catch {
|
|
// ignore
|
|
}
|
|
}
|
|
if (!espreeCache) {
|
|
if (typeof require === "function")
|
|
// eslint-disable-next-line @typescript-eslint/no-require-imports -- ignore
|
|
espreeCache = require("espree");
|
|
}
|
|
}
|
|
return espreeCache;
|
|
}
|