lossless-group_perplexed-pl.../esbuild.config.mjs
mpstaton 7b17b3b6e7 chore(marketplace): pass ObsidianReviewBot lint cleanly
Applies all required fixes from the bot's review of PR #12513
(obsidianmd/obsidian-releases). ESLint now passes 0 errors with the
Obsidian community ruleset; tsc passes; production build is clean.

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
  (Perplexity, Perplexica, Vane, Claude, Anthropic, LM Studio, Imgur,
  ImageKit, OpenAI, Ollama, Sonar, Llama, GPT, YAML, JSON, URL, API)
  so legitimate proper nouns aren't lowercased

Code fixes (487 → 0):

- console.log/info → console.debug across all sources (~130 sites)
- UI strings normalized to sentence case (~150 sites)
- Command IDs and names cleaned up: dropped "command" suffix, dropped
  "perplexed" plugin-name prefix
- Settings tab section headers switched from createEl('h2') to
  new Setting().setHeading() (5 sites)
- Inline element.style.color/width/minHeight/fontFamily migrated to
  a new CSS class (.perplexed-json-textarea + .is-tall / .is-extra-tall)
  in src/styles/settings-tab.css (8 textarea sites, 32 style assignments)
- Async input handlers wrapped: addEventListener('input', () => void
  (async () => { ... })()) so the listener type matches (8 sites)
- forEach((opt) => dd.addOption(...)) blocks made void-returning to
  satisfy no-misused-promises (9 modal sites)
- JSON.parse results typed as unknown then narrowed
- throw <string> → throw new Error(<string>)
- ${unknown} interpolations narrowed via instanceof Error
- Removed dotenv runtime dependency: published plugins shouldn't read
  .env at runtime; user enters API keys via the settings tab
- Replaced builtin-modules dev-dependency with node:module's
  builtinModules — same data, no extra package
- Logger console-method dispatch rewritten as a switch instead of
  dynamic console[level] indexing (which the bot rejects)

Streaming exceptions:

- src/services/{perplexityService,lmStudioService,perplexicaService}.ts
  retain `fetch()` for SSE / chunked streaming because Obsidian's
  `requestUrl` buffers the whole body. Each site has an
  `eslint-disable-next-line no-restricted-globals` with the marketplace
  `/skip` justification inline. Plan to surface these on the PR with
  a `/skip` reply.

Reference docs:

- context-v/issues/Obsidian-Review-Bot-Feedback-on-Perplexed-Submission.md
  (issue log distilled into…)
- context-v/reminders/Obsidian-Marketplace-Compliance.md (the rules
  themselves, reusable for image-gin and cite-wide submissions)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 02:39:06 -05:00

68 lines
1.5 KiB
JavaScript

import esbuild from 'esbuild';
import process from 'node:process';
import { builtinModules as builtins } from 'node:module';
const banner = `/*
* Content Farm 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
];
// First, build the CSS file
await esbuild.build({
entryPoints: ['src/styles/main.css'],
bundle: true,
minify: isProduction,
outfile: 'styles.css',
loader: { '.css': 'css' },
});
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...');
}