winters27_obsidian-byoc/eslint.bot.config.mjs
winters27 203238db84 chore(lint): mirror ReviewBot config + fix OAuth DefinePlugin regression
Add eslint.bot.config.mjs that runs the obsidianmd ReviewBot's stricter
ruleset locally (require-await, no-misused-promises,
restrict-template-expressions, ui/sentence-case, undescribed-disable
checks, plus its disallow-list of eslint-disable rules). Sweeps every
remaining Required-tier finding the bot flagged: async-no-await across
fs*/settings*/main.ts, sentence-case UI text, undescribed eslint-disable
directives, encryptRClone.worker.ts any-typing and never-template,
plus the worker's async-callback-as-event-listener-return mismatch.

Also fixes a build regression introduced by the same sweep: rewriting
baseTypes.ts from `globalThis.DEFAULT_X` access to a bare-identifier
`typeof` guard broke webpack's DefinePlugin substitution because the
plugin keys still pattern-matched on "globalThis.X". Result was every
OAuth client_id (Dropbox, OneDrive, OneDriveFull, GoogleDrive, Box,
pCloud, Yandex, Koofr) shipped as "" and OAuth flows returned
"invalid client_id". DefinePlugin keys now match the bare identifier.
Verified by grepping the deployed main.js for the pCloud client_id
literal post-build.
2026-04-27 06:30:32 -07:00

90 lines
3.2 KiB
JavaScript

// Strict lint config that mirrors what obsidianmd ReviewBot uses.
// We pass this with --config so it's used instead of the relaxed local config.
import tsparser from "@typescript-eslint/parser";
import { defineConfig } from "eslint/config";
import obsidianmd from "eslint-plugin-obsidianmd";
export default defineConfig([
{
ignores: [
"*.js",
"*.cjs",
"main.js",
"927.main.js",
"node_modules/**",
"dist/**",
"tests/**",
"scripts/**",
"docs/**",
"esbuild.config.mjs",
"esbuild.injecthelper.mjs",
"eslint.config.mjs",
"eslint.bot.config.mjs",
"webpack.config.js",
"vitest.config.ts",
"biome.json",
"versions.json",
"tsconfig.json",
"package-lock.json",
"issues*.json",
"lint-report.json",
"lint-bot.json",
],
},
...obsidianmd.configs.recommended,
{
files: ["package.json"],
rules: {
"obsidianmd/no-plugin-as-component": "off",
"obsidianmd/no-tfile-tfolder-cast": "off",
"obsidianmd/no-view-references-in-plugin": "off",
"obsidianmd/prefer-instanceof": "off",
"obsidianmd/prefer-active-doc": "off",
"obsidianmd/no-unsupported-api": "off",
"obsidianmd/object-assign": "off",
"obsidianmd/prefer-file-manager-trash-file": "off",
"obsidianmd/regex-lookbehind": "off",
"obsidianmd/platform": "off",
"obsidianmd/editor-drop-paste": "off",
"obsidianmd/detach-leaves": "off",
"obsidianmd/no-forbidden-elements": "off",
"obsidianmd/no-static-styles-assignment": "off",
"obsidianmd/prefer-active-window-timers": "off",
"obsidianmd/prefer-abstract-input-suggest": "off",
"obsidianmd/no-sample-code": "off",
"obsidianmd/sample-names": "off",
"obsidianmd/hardcoded-config-path": "off",
"obsidianmd/prefer-get-language": "off",
"obsidianmd/commands/no-command-in-command-id": "off",
"obsidianmd/commands/no-command-in-command-name": "off",
"obsidianmd/commands/no-default-hotkeys": "off",
"obsidianmd/commands/no-plugin-id-in-command-id": "off",
"obsidianmd/commands/no-plugin-name-in-command-name": "off",
"obsidianmd/settings-tab/no-manual-html-headings": "off",
"obsidianmd/settings-tab/no-problematic-settings-headings": "off",
"obsidianmd/vault/iterate": "off",
"obsidianmd/ui/sentence-case": "off",
"obsidianmd/rule-custom-message": "off",
// ReviewBot doesn't flag these in its actual output — keep the bot
// config in sync with reality so we don't chase phantom errors.
"depend/ban-dependencies": ["error", {
presets: ["native", "microutilities", "preferred"],
allowed: ["lodash", "emoji-regex", "dotenv", "builtin-modules", "rimraf", "readable-stream"],
}],
},
},
{
files: ["**/*.ts"],
languageOptions: {
parser: tsparser,
parserOptions: { project: "./tsconfig.json" },
globals: { Buffer: "readonly" },
},
rules: {
// Bot enforces these even though obsidianmd recommended turns them off.
"@typescript-eslint/require-await": "error",
"@typescript-eslint/no-misused-promises": "error",
"@typescript-eslint/restrict-template-expressions": "error",
},
},
]);