mirror of
https://github.com/quartz-community/plugin-template.git
synced 2026-07-22 02:50:24 +00:00
feat: add build-time manifest validation and event cleanup guidance
This commit is contained in:
parent
ea06f6850c
commit
434551b80d
4 changed files with 45 additions and 0 deletions
|
|
@ -21,6 +21,13 @@
|
|||
"varsIgnorePattern": "^_",
|
||||
"caughtErrorsIgnorePattern": "^_"
|
||||
}
|
||||
],
|
||||
"no-restricted-syntax": [
|
||||
"warn",
|
||||
{
|
||||
"selector": "Program:has(CallExpression[callee.property.name='addEventListener']):not(:has(CallExpression[callee.object.name='window'][callee.property.name='addCleanup']))",
|
||||
"message": "addEventListener should be paired with window.addCleanup() for proper SPA cleanup. See ARCHITECTURE.md for details."
|
||||
}
|
||||
]
|
||||
},
|
||||
"overrides": [
|
||||
|
|
|
|||
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -6,6 +6,8 @@ node_modules/
|
|||
# Build output
|
||||
build/
|
||||
*.tsbuildinfo
|
||||
!src/build/
|
||||
!src/build/**
|
||||
|
||||
# Logs
|
||||
logs
|
||||
|
|
|
|||
33
src/build/validate-manifest.ts
Normal file
33
src/build/validate-manifest.ts
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
export function validateManifest(): void {
|
||||
const pkgPath = path.resolve("package.json");
|
||||
if (!fs.existsSync(pkgPath)) {
|
||||
throw new Error("package.json not found");
|
||||
}
|
||||
|
||||
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
||||
const quartz = pkg.quartz;
|
||||
|
||||
if (!quartz) {
|
||||
console.warn(
|
||||
"\x1b[33m⚠ No 'quartz' field in package.json. Plugin may not load correctly in Quartz.\x1b[0m",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const warnings: string[] = [];
|
||||
|
||||
if (!quartz.name) warnings.push("quartz.name is missing");
|
||||
if (!quartz.displayName) warnings.push("quartz.displayName is missing");
|
||||
if (!quartz.category) warnings.push("quartz.category is missing");
|
||||
if (!quartz.version) warnings.push("quartz.version is missing");
|
||||
|
||||
if (warnings.length > 0) {
|
||||
console.warn("\x1b[33m⚠ Plugin manifest warnings:\x1b[0m");
|
||||
for (const w of warnings) {
|
||||
console.warn(` - ${w}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,9 @@
|
|||
import { defineConfig } from "tsup";
|
||||
import type { Plugin } from "esbuild";
|
||||
import path from "path";
|
||||
import { validateManifest } from "./src/build/validate-manifest";
|
||||
|
||||
validateManifest();
|
||||
|
||||
/**
|
||||
* Esbuild plugin that bundles `.inline.ts` files into browser-ready JavaScript strings.
|
||||
|
|
|
|||
Loading…
Reference in a new issue