mirror of
https://github.com/lossless-group/perplexed-plugin.git
synced 2026-07-22 06:49:50 +00:00
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>
80 lines
2.4 KiB
JavaScript
80 lines
2.4 KiB
JavaScript
import js from "@eslint/js";
|
|
import tseslint from "typescript-eslint";
|
|
import globals from "globals";
|
|
import obsidianmd from "eslint-plugin-obsidianmd";
|
|
|
|
export default tseslint.config(
|
|
{
|
|
ignores: ["node_modules/", "main.js", "**/*.mjs", "test-*.sh"],
|
|
},
|
|
js.configs.recommended,
|
|
...tseslint.configs.recommended,
|
|
...tseslint.configs.strict,
|
|
// Obsidian community-plugin rules — mirrors what ObsidianReviewBot
|
|
// enforces server-side at submission time. Keep this enabled so
|
|
// violations surface in `pnpm build`, not in the marketplace PR review.
|
|
...obsidianmd.configs.recommended,
|
|
{
|
|
files: ["**/*.ts"],
|
|
languageOptions: {
|
|
parserOptions: {
|
|
ecmaVersion: "latest",
|
|
sourceType: "module",
|
|
project: "./tsconfig.json",
|
|
},
|
|
globals: {
|
|
...globals.node,
|
|
...globals.browser,
|
|
},
|
|
},
|
|
rules: {
|
|
"no-unused-vars": "off",
|
|
"@typescript-eslint/no-unused-vars": ["error", { args: "none", caughtErrors: "none" }],
|
|
"@typescript-eslint/ban-ts-comment": "off",
|
|
"no-prototype-builtins": "off",
|
|
"@typescript-eslint/no-empty-function": "off",
|
|
"@typescript-eslint/no-explicit-any": "error",
|
|
"@typescript-eslint/no-unnecessary-type-assertion": "error",
|
|
"@typescript-eslint/no-floating-promises": "error",
|
|
"@typescript-eslint/no-base-to-string": "error",
|
|
"@typescript-eslint/no-misused-promises": "error",
|
|
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
"@typescript-eslint/no-non-null-assertion": "off",
|
|
"@typescript-eslint/consistent-type-imports": "error",
|
|
// Bot's exact ban: only warn / error / debug allowed.
|
|
"no-console": ["error", { allow: ["warn", "error", "debug"] }],
|
|
// Override the obsidianmd recommended sentence-case rule with our
|
|
// brand allowlist — these are real proper nouns and should remain
|
|
// capitalized in UI text. `enforceCamelCaseLower` is left off so
|
|
// proper nouns aren't lowercased mid-string. `allowAutoFix` lets
|
|
// `eslint --fix` apply suggestions for the trivial cases.
|
|
"obsidianmd/ui/sentence-case": [
|
|
"error",
|
|
{
|
|
brands: [
|
|
"Perplexity",
|
|
"Perplexica",
|
|
"Vane",
|
|
"Claude",
|
|
"Anthropic",
|
|
"LM Studio",
|
|
"LMStudio",
|
|
"Imgur",
|
|
"ImageKit",
|
|
"OpenAI",
|
|
"Ollama",
|
|
"Sonar",
|
|
"Llama",
|
|
"GPT",
|
|
"YAML",
|
|
"JSON",
|
|
"URL",
|
|
"API",
|
|
],
|
|
acronyms: ["AI", "ID", "URL", "API", "JSON", "YAML", "HTTP", "HTTPS", "GPU", "CPU"],
|
|
allowAutoFix: true,
|
|
},
|
|
],
|
|
},
|
|
},
|
|
);
|