mirror of
https://github.com/lossless-group/image-gin.git
synced 2026-07-22 06:49:33 +00:00
Applies all required fixes from the bot's review of PR #12524 (obsidianmd/obsidian-releases). ESLint now passes 0 errors with the Obsidian community ruleset; tsc passes; production build is clean. 3 warnings remain (FileManager.trashFile preference — non-blocking). Lint setup: - Adopted eslint-plugin-obsidianmd@^0.2.9 in eslint.config.mjs - Mirrored the bot's rule surface locally so violations surface in `pnpm lint` instead of the marketplace PR thread - Configured the ui/sentence-case rule with a brand allowlist (Recraft, Magnific, Freepik, Ideogram, ImageKit, Imgur, Anthropic, Claude, OpenAI, Obsidian, WebP, JSON, YAML, URL, API, CDN) Code fixes (263 → 0): - console.log/info → console.debug across all sources - UI strings normalized to sentence case (~150 sites) - Command IDs / names: dropped "image-gin-" plugin-id prefix on the drop-gate reset command; renamed problematic settings heading ("Image cache settings" → "Image cache") - Settings tab section headers via setHeading() instead of <h2>/<h3> - Inline element.style.* migrated to a new CSS class set in src/styles/marketplace-compliance.css (~60 sites collapsed to ~10 reusable classes: image-gin-row, image-gin-row-tight, image-gin-text-area + variants, image-gin-cache-stats, image-gin-error-text, image-gin-error-banner, image-gin-preview, image-gin-thumb, image-gin-hidden) - TFile cast → instanceof check (BatchDirectoryConvertLocalToRemote) - require('fs')/require('path') → ES imports (allowed since isDesktopOnly: true) - Hardcoded ".obsidian/plugins/image-gin/..." paths replaced with ${vault.configDir}/plugins/image-gin/... (logger, imageCacheService) - Async input handlers wrapped: addEventListener('input', () => void (async () => { ... })()) so the listener type matches - forEach((opt) => dd.addOption(...)) blocks made void-returning - JSON.parse results typed as unknown then narrowed - Logger console-method dispatch rewritten as a switch instead of dynamic console[level] indexing - Replaced builtin-modules dev-dependency with node:module's builtinModules — same data, no extra package - DragEventCopy/PasteEventCopy classes (which used 'instanceof' on user classes) replaced with sentinel-tagged factory functions (makeSyntheticDragEvent / isSyntheticDropEvent) so we don't trip the obsidianmd/prefer-instanceof rule for non-Obsidian classes Bumps version to 0.2.1. Plan + design rationale: context-v/issues/Obsidian-Review-Bot-Feedback-on-Perplexed-Submission.md context-v/reminders/Obsidian-Marketplace-Compliance.md Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
70 lines
1.6 KiB
JavaScript
70 lines
1.6 KiB
JavaScript
import esbuild from 'esbuild';
|
|
import process from 'node:process';
|
|
import { builtinModules as builtins } from 'node:module';
|
|
|
|
const banner = `/*
|
|
* Image Gin Plugin for Obsidian
|
|
* Generated: ${new Date().toISOString()}
|
|
* Build: ${process.env.NODE_ENV || 'development'}
|
|
*/`;
|
|
|
|
const isProduction = process.argv[2] === 'production' || process.env.NODE_ENV === 'production';
|
|
|
|
const external = [
|
|
'obsidian',
|
|
'electron',
|
|
'@codemirror/autocomplete',
|
|
'@codemirror/collab',
|
|
'@codemirror/commands',
|
|
'@codemirror/language',
|
|
'@codemirror/lint',
|
|
'@codemirror/search',
|
|
'@codemirror/state',
|
|
'@codemirror/view',
|
|
'@lezer/common',
|
|
'@lezer/highlight',
|
|
'@lezer/lr',
|
|
...builtins
|
|
];
|
|
|
|
// Build the CSS file
|
|
await esbuild.build({
|
|
entryPoints: ['src/styles/current-file-modal.css'],
|
|
bundle: true,
|
|
minify: isProduction,
|
|
outfile: 'styles.css',
|
|
loader: { '.css': 'css' },
|
|
logLevel: 'info',
|
|
sourcemap: !isProduction ? 'inline' : false
|
|
});
|
|
|
|
const context = await esbuild.context({
|
|
banner: {
|
|
js: banner,
|
|
},
|
|
entryPoints: ['main.ts'],
|
|
bundle: true,
|
|
external: [...external, './styles.css'],
|
|
format: 'cjs',
|
|
platform: 'node',
|
|
target: 'es2022',
|
|
treeShaking: true,
|
|
sourcemap: !isProduction ? 'inline' : false,
|
|
minify: isProduction,
|
|
define: {
|
|
'process.env.NODE_ENV': `"${isProduction ? 'production' : 'development'}"`,
|
|
},
|
|
logLevel: 'info',
|
|
outfile: 'main.js',
|
|
loader: { '.css': 'text' },
|
|
});
|
|
|
|
if (isProduction) {
|
|
// Build only for production
|
|
await context.rebuild();
|
|
process.exit(0);
|
|
} else {
|
|
// Enable watch mode for development
|
|
await context.watch();
|
|
console.log('Watching for changes...');
|
|
}
|