obsidian-plugin-dev-kit 0.0.0-stage → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (329) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +223 -2
  3. package/bin/opdk.js +34 -0
  4. package/dist/build/args.d.ts +10 -0
  5. package/dist/build/args.js +45 -0
  6. package/dist/build/bundle-check.d.ts +17 -0
  7. package/dist/build/bundle-check.js +42 -0
  8. package/dist/build/bundle-file.d.ts +4 -0
  9. package/dist/build/bundle-file.js +29 -0
  10. package/dist/build/commands.d.ts +5 -0
  11. package/dist/build/commands.js +109 -0
  12. package/dist/build/config.d.ts +3 -0
  13. package/dist/build/config.js +103 -0
  14. package/dist/build/css-imports.d.ts +23 -0
  15. package/dist/build/css-imports.js +50 -0
  16. package/dist/build/css-step.d.ts +10 -0
  17. package/dist/build/css-step.js +27 -0
  18. package/dist/build/css.d.ts +24 -0
  19. package/dist/build/css.js +47 -0
  20. package/dist/build/options.d.ts +55 -0
  21. package/dist/build/options.js +70 -0
  22. package/dist/build/release.d.ts +5 -0
  23. package/dist/build/release.js +34 -0
  24. package/dist/build/report.d.ts +7 -0
  25. package/dist/build/report.js +16 -0
  26. package/dist/build/vault.d.ts +26 -0
  27. package/dist/build/vault.js +290 -0
  28. package/dist/build-info.json +1 -0
  29. package/dist/cli/argv.d.ts +14 -0
  30. package/dist/cli/argv.js +18 -0
  31. package/dist/cli/commands.d.ts +3 -0
  32. package/dist/cli/commands.js +7 -0
  33. package/dist/cli/main.d.ts +2 -0
  34. package/dist/cli/main.js +23 -0
  35. package/dist/cli/process-reporter.d.ts +5 -0
  36. package/dist/cli/process-reporter.js +15 -0
  37. package/dist/cli/registry.d.ts +4 -0
  38. package/dist/cli/registry.js +15 -0
  39. package/dist/cli/reporter.d.ts +53 -0
  40. package/dist/cli/reporter.js +100 -0
  41. package/dist/cli/run.d.ts +9 -0
  42. package/dist/cli/run.js +61 -0
  43. package/dist/cli/types.d.ts +27 -0
  44. package/dist/cli/types.js +1 -0
  45. package/dist/cli/version.d.ts +13 -0
  46. package/dist/cli/version.js +61 -0
  47. package/dist/config/define-config.d.ts +3 -0
  48. package/dist/config/define-config.js +4 -0
  49. package/dist/config/load-config.d.ts +6 -0
  50. package/dist/config/load-config.js +70 -0
  51. package/dist/config/manifest.d.ts +3 -0
  52. package/dist/config/manifest.js +72 -0
  53. package/dist/config/types.d.ts +146 -0
  54. package/dist/config/types.js +23 -0
  55. package/dist/demo/args.d.ts +4 -0
  56. package/dist/demo/args.js +13 -0
  57. package/dist/demo/checks.d.ts +56 -0
  58. package/dist/demo/checks.js +124 -0
  59. package/dist/demo/commands.d.ts +3 -0
  60. package/dist/demo/commands.js +65 -0
  61. package/dist/demo/config.d.ts +57 -0
  62. package/dist/demo/config.js +337 -0
  63. package/dist/demo/ffmpeg-run.d.ts +18 -0
  64. package/dist/demo/ffmpeg-run.js +59 -0
  65. package/dist/demo/ffmpeg.d.ts +63 -0
  66. package/dist/demo/ffmpeg.js +111 -0
  67. package/dist/demo/films.d.ts +46 -0
  68. package/dist/demo/films.js +134 -0
  69. package/dist/demo/phone-layout.d.ts +38 -0
  70. package/dist/demo/phone-layout.js +98 -0
  71. package/dist/demo/phone-render.d.ts +28 -0
  72. package/dist/demo/phone-render.js +124 -0
  73. package/dist/demo/published.d.ts +16 -0
  74. package/dist/demo/published.js +72 -0
  75. package/dist/demo/run.d.ts +31 -0
  76. package/dist/demo/run.js +397 -0
  77. package/dist/demo/stills.d.ts +21 -0
  78. package/dist/demo/stills.js +62 -0
  79. package/dist/e2e/artifacts.d.ts +27 -0
  80. package/dist/e2e/artifacts.js +90 -0
  81. package/dist/e2e/cleanup.d.ts +54 -0
  82. package/dist/e2e/cleanup.js +109 -0
  83. package/dist/e2e/config.d.ts +9 -0
  84. package/dist/e2e/config.js +42 -0
  85. package/dist/e2e/create-test.d.ts +37 -0
  86. package/dist/e2e/create-test.js +109 -0
  87. package/dist/e2e/demo/clip.d.ts +21 -0
  88. package/dist/e2e/demo/clip.js +44 -0
  89. package/dist/e2e/demo/create-demo.d.ts +42 -0
  90. package/dist/e2e/demo/create-demo.js +439 -0
  91. package/dist/e2e/demo/manifest.d.ts +76 -0
  92. package/dist/e2e/demo/manifest.js +168 -0
  93. package/dist/e2e/demo/names.d.ts +18 -0
  94. package/dist/e2e/demo/names.js +44 -0
  95. package/dist/e2e/demo/options.d.ts +22 -0
  96. package/dist/e2e/demo/options.js +59 -0
  97. package/dist/e2e/demo/ownership.d.ts +27 -0
  98. package/dist/e2e/demo/ownership.js +65 -0
  99. package/dist/e2e/demo/page-scripts.d.ts +82 -0
  100. package/dist/e2e/demo/page-scripts.js +250 -0
  101. package/dist/e2e/demo/png.d.ts +8 -0
  102. package/dist/e2e/demo/png.js +23 -0
  103. package/dist/e2e/demo/presets.d.ts +43 -0
  104. package/dist/e2e/demo/presets.js +20 -0
  105. package/dist/e2e/demo/privacy.d.ts +18 -0
  106. package/dist/e2e/demo/privacy.js +30 -0
  107. package/dist/e2e/demo/still-options.d.ts +22 -0
  108. package/dist/e2e/demo/still-options.js +68 -0
  109. package/dist/e2e/demo/types.d.ts +184 -0
  110. package/dist/e2e/demo/types.js +1 -0
  111. package/dist/e2e/electron-binary.d.ts +15 -0
  112. package/dist/e2e/electron-binary.js +30 -0
  113. package/dist/e2e/fixtures.d.ts +62 -0
  114. package/dist/e2e/fixtures.js +68 -0
  115. package/dist/e2e/gate.d.ts +4 -0
  116. package/dist/e2e/gate.js +8 -0
  117. package/dist/e2e/global-setup.d.ts +11 -0
  118. package/dist/e2e/global-setup.js +17 -0
  119. package/dist/e2e/helpers/commands.d.ts +14 -0
  120. package/dist/e2e/helpers/commands.js +56 -0
  121. package/dist/e2e/helpers/create-helpers.d.ts +24 -0
  122. package/dist/e2e/helpers/create-helpers.js +582 -0
  123. package/dist/e2e/helpers/device-metrics.d.ts +21 -0
  124. package/dist/e2e/helpers/device-metrics.js +25 -0
  125. package/dist/e2e/helpers/ime.d.ts +13 -0
  126. package/dist/e2e/helpers/ime.js +19 -0
  127. package/dist/e2e/helpers/layout-page-scripts.d.ts +103 -0
  128. package/dist/e2e/helpers/layout-page-scripts.js +224 -0
  129. package/dist/e2e/helpers/layout.d.ts +83 -0
  130. package/dist/e2e/helpers/layout.js +148 -0
  131. package/dist/e2e/helpers/mobile.d.ts +31 -0
  132. package/dist/e2e/helpers/mobile.js +26 -0
  133. package/dist/e2e/helpers/page-scripts.d.ts +194 -0
  134. package/dist/e2e/helpers/page-scripts.js +467 -0
  135. package/dist/e2e/helpers/settings.d.ts +8 -0
  136. package/dist/e2e/helpers/settings.js +16 -0
  137. package/dist/e2e/helpers/settle.d.ts +28 -0
  138. package/dist/e2e/helpers/settle.js +33 -0
  139. package/dist/e2e/helpers/types.d.ts +193 -0
  140. package/dist/e2e/helpers/types.js +1 -0
  141. package/dist/e2e/helpers/view-mode.d.ts +23 -0
  142. package/dist/e2e/helpers/view-mode.js +35 -0
  143. package/dist/e2e/index.d.ts +14 -0
  144. package/dist/e2e/index.js +4 -0
  145. package/dist/e2e/internals.d.ts +155 -0
  146. package/dist/e2e/internals.js +8 -0
  147. package/dist/e2e/obsidian-path.d.ts +17 -0
  148. package/dist/e2e/obsidian-path.js +31 -0
  149. package/dist/e2e/options.d.ts +123 -0
  150. package/dist/e2e/options.js +244 -0
  151. package/dist/e2e/page-scripts.d.ts +45 -0
  152. package/dist/e2e/page-scripts.js +53 -0
  153. package/dist/e2e/peers.d.ts +9 -0
  154. package/dist/e2e/peers.js +19 -0
  155. package/dist/e2e/plugins.d.ts +32 -0
  156. package/dist/e2e/plugins.js +119 -0
  157. package/dist/e2e/process-tree.d.ts +33 -0
  158. package/dist/e2e/process-tree.js +133 -0
  159. package/dist/e2e/readiness.d.ts +23 -0
  160. package/dist/e2e/readiness.js +63 -0
  161. package/dist/e2e/seed.d.ts +34 -0
  162. package/dist/e2e/seed.js +122 -0
  163. package/dist/e2e/session.d.ts +71 -0
  164. package/dist/e2e/session.js +266 -0
  165. package/dist/e2e/vault.d.ts +52 -0
  166. package/dist/e2e/vault.js +146 -0
  167. package/dist/e2e/version.d.ts +25 -0
  168. package/dist/e2e/version.js +40 -0
  169. package/dist/eslint/index.d.ts +2 -0
  170. package/dist/eslint/index.js +1 -0
  171. package/dist/eslint/obsidian-plugin.d.ts +49 -0
  172. package/dist/eslint/obsidian-plugin.js +115 -0
  173. package/dist/index.d.ts +3 -0
  174. package/dist/index.js +1 -0
  175. package/dist/kit/args.d.ts +7 -0
  176. package/dist/kit/args.js +21 -0
  177. package/dist/kit/commands.d.ts +3 -0
  178. package/dist/kit/commands.js +52 -0
  179. package/dist/kit/files.d.ts +3 -0
  180. package/dist/kit/files.js +24 -0
  181. package/dist/kit/pins.d.ts +89 -0
  182. package/dist/kit/pins.js +178 -0
  183. package/dist/kit/remote.d.ts +13 -0
  184. package/dist/kit/remote.js +33 -0
  185. package/dist/kit/runners.d.ts +11 -0
  186. package/dist/kit/runners.js +53 -0
  187. package/dist/kit/terminal-text.d.ts +6 -0
  188. package/dist/kit/terminal-text.js +20 -0
  189. package/dist/kit/upgrade.d.ts +26 -0
  190. package/dist/kit/upgrade.js +162 -0
  191. package/dist/peers/resolve.d.ts +8 -0
  192. package/dist/peers/resolve.js +28 -0
  193. package/dist/peers/versions.d.ts +30 -0
  194. package/dist/peers/versions.js +32 -0
  195. package/dist/release/api-check.d.ts +27 -0
  196. package/dist/release/api-check.js +119 -0
  197. package/dist/release/args.d.ts +40 -0
  198. package/dist/release/args.js +120 -0
  199. package/dist/release/assets.d.ts +21 -0
  200. package/dist/release/assets.js +35 -0
  201. package/dist/release/build-check.d.ts +43 -0
  202. package/dist/release/build-check.js +184 -0
  203. package/dist/release/build-script.d.ts +12 -0
  204. package/dist/release/build-script.js +30 -0
  205. package/dist/release/build-tagged.d.ts +26 -0
  206. package/dist/release/build-tagged.js +52 -0
  207. package/dist/release/bump.d.ts +24 -0
  208. package/dist/release/bump.js +58 -0
  209. package/dist/release/changelog.d.ts +25 -0
  210. package/dist/release/changelog.js +148 -0
  211. package/dist/release/check.d.ts +38 -0
  212. package/dist/release/check.js +150 -0
  213. package/dist/release/commands.d.ts +3 -0
  214. package/dist/release/commands.js +154 -0
  215. package/dist/release/committed-tree.d.ts +63 -0
  216. package/dist/release/committed-tree.js +118 -0
  217. package/dist/release/config.d.ts +3 -0
  218. package/dist/release/config.js +28 -0
  219. package/dist/release/gh-access.d.ts +14 -0
  220. package/dist/release/gh-access.js +45 -0
  221. package/dist/release/gh.d.ts +10 -0
  222. package/dist/release/gh.js +33 -0
  223. package/dist/release/git.d.ts +49 -0
  224. package/dist/release/git.js +111 -0
  225. package/dist/release/interrupt.d.ts +30 -0
  226. package/dist/release/interrupt.js +60 -0
  227. package/dist/release/json.d.ts +33 -0
  228. package/dist/release/json.js +81 -0
  229. package/dist/release/kit-check.d.ts +8 -0
  230. package/dist/release/kit-check.js +51 -0
  231. package/dist/release/manifest-rules.d.ts +23 -0
  232. package/dist/release/manifest-rules.js +255 -0
  233. package/dist/release/preflight.d.ts +10 -0
  234. package/dist/release/preflight.js +65 -0
  235. package/dist/release/problems.d.ts +24 -0
  236. package/dist/release/problems.js +11 -0
  237. package/dist/release/project-files.d.ts +14 -0
  238. package/dist/release/project-files.js +16 -0
  239. package/dist/release/publish-command.d.ts +21 -0
  240. package/dist/release/publish-command.js +83 -0
  241. package/dist/release/publish-git.d.ts +37 -0
  242. package/dist/release/publish-git.js +108 -0
  243. package/dist/release/publish-state.d.ts +29 -0
  244. package/dist/release/publish-state.js +70 -0
  245. package/dist/release/publish-verify.d.ts +41 -0
  246. package/dist/release/publish-verify.js +112 -0
  247. package/dist/release/publish-wait.d.ts +25 -0
  248. package/dist/release/publish-wait.js +56 -0
  249. package/dist/release/publish.d.ts +35 -0
  250. package/dist/release/publish.js +181 -0
  251. package/dist/release/release-assets.d.ts +39 -0
  252. package/dist/release/release-assets.js +68 -0
  253. package/dist/release/release.d.ts +37 -0
  254. package/dist/release/release.js +179 -0
  255. package/dist/release/remote.d.ts +12 -0
  256. package/dist/release/remote.js +15 -0
  257. package/dist/release/reproducible.d.ts +16 -0
  258. package/dist/release/reproducible.js +34 -0
  259. package/dist/release/run-tests.d.ts +5 -0
  260. package/dist/release/run-tests.js +17 -0
  261. package/dist/release/semver.d.ts +8 -0
  262. package/dist/release/semver.js +60 -0
  263. package/dist/release/version-rules.d.ts +28 -0
  264. package/dist/release/version-rules.js +63 -0
  265. package/dist/release/versions-json.d.ts +15 -0
  266. package/dist/release/versions-json.js +88 -0
  267. package/dist/release/workflow-run.d.ts +44 -0
  268. package/dist/release/workflow-run.js +71 -0
  269. package/dist/scanner/code-checks.d.ts +41 -0
  270. package/dist/scanner/code-checks.js +82 -0
  271. package/dist/scanner/commands.d.ts +3 -0
  272. package/dist/scanner/commands.js +43 -0
  273. package/dist/scanner/config.d.ts +7 -0
  274. package/dist/scanner/config.js +25 -0
  275. package/dist/scanner/css-check.d.ts +26 -0
  276. package/dist/scanner/css-check.js +63 -0
  277. package/dist/scanner/eslint-nesting.d.ts +16 -0
  278. package/dist/scanner/eslint-nesting.js +45 -0
  279. package/dist/scanner/findings.d.ts +23 -0
  280. package/dist/scanner/findings.js +21 -0
  281. package/dist/scanner/git-files.d.ts +16 -0
  282. package/dist/scanner/git-files.js +73 -0
  283. package/dist/scanner/lint.d.ts +47 -0
  284. package/dist/scanner/lint.js +163 -0
  285. package/dist/scanner/meta-checks.d.ts +8 -0
  286. package/dist/scanner/meta-checks.js +22 -0
  287. package/dist/scanner/outside-project.d.ts +19 -0
  288. package/dist/scanner/outside-project.js +20 -0
  289. package/dist/scanner/run.d.ts +19 -0
  290. package/dist/scanner/run.js +78 -0
  291. package/dist/scanner/scanner-config.d.ts +114 -0
  292. package/dist/scanner/scanner-config.js +207 -0
  293. package/dist/scanner/typescript-gate.d.ts +30 -0
  294. package/dist/scanner/typescript-gate.js +73 -0
  295. package/dist/vitest/build-config.d.ts +17 -0
  296. package/dist/vitest/build-config.js +106 -0
  297. package/dist/vitest/define-unit-config.d.ts +27 -0
  298. package/dist/vitest/define-unit-config.js +45 -0
  299. package/dist/vitest/dom/elements.d.ts +87 -0
  300. package/dist/vitest/dom/elements.js +291 -0
  301. package/dist/vitest/dom/index.d.ts +1 -0
  302. package/dist/vitest/dom/index.js +1 -0
  303. package/dist/vitest/dom/install.d.ts +8 -0
  304. package/dist/vitest/dom/install.js +261 -0
  305. package/dist/vitest/dom/setup.d.ts +1 -0
  306. package/dist/vitest/dom/setup.js +3 -0
  307. package/dist/vitest/index.d.ts +3 -0
  308. package/dist/vitest/index.js +2 -0
  309. package/dist/vitest/options.d.ts +92 -0
  310. package/dist/vitest/options.js +136 -0
  311. package/dist/vitest/peers.d.ts +10 -0
  312. package/dist/vitest/peers.js +51 -0
  313. package/dist/vitest/workspace-root.d.ts +7 -0
  314. package/dist/vitest/workspace-root.js +39 -0
  315. package/docs/build.md +232 -0
  316. package/docs/ci.md +182 -0
  317. package/docs/demo.md +364 -0
  318. package/docs/e2e.md +563 -0
  319. package/docs/release.md +374 -0
  320. package/docs/scanner.md +204 -0
  321. package/docs/unit.md +291 -0
  322. package/package.json +100 -4
  323. package/plugins/opdk/skills/audit/SKILL.md +81 -0
  324. package/plugins/opdk/skills/build/SKILL.md +79 -0
  325. package/plugins/opdk/skills/demo/SKILL.md +102 -0
  326. package/plugins/opdk/skills/e2e/SKILL.md +132 -0
  327. package/plugins/opdk/skills/release/SKILL.md +84 -0
  328. package/plugins/opdk/skills/scanner/SKILL.md +60 -0
  329. package/plugins/opdk/skills/unit/SKILL.md +90 -0
@@ -0,0 +1,73 @@
1
+ import { execFile } from "node:child_process";
2
+ import { lstatSync, statSync } from "node:fs";
3
+ import path from "node:path";
4
+ import { promisify } from "node:util";
5
+ const run = promisify(execFile);
6
+ /** Splits `git ls-files -z` output into paths, dropping the empty entry after the last NUL. */
7
+ export function parseLsFiles(output) {
8
+ return output.split("\0").filter((entry) => entry !== "");
9
+ }
10
+ /**
11
+ * `env` without the `GIT_*` variables. A git hook or a worktree session exports `GIT_DIR`, `GIT_WORK_TREE` or
12
+ * `GIT_INDEX_FILE`, which would point `git ls-files` at another repository than the one in `cwd`.
13
+ */
14
+ export function gitFreeEnvironment(env) {
15
+ return Object.fromEntries(Object.entries(env).filter(([name]) => !name.startsWith("GIT_")));
16
+ }
17
+ /**
18
+ * The files git tracks under `cwd`, as paths relative to it with `/` separators, minus entries that are not
19
+ * regular files on disk (deleted in the working tree but not yet committed, submodule folders, symlinks: the
20
+ * scanner reads the repository's files, and a link to a file outside the plugin folder is not one of them).
21
+ * Untracked build output (`main.js`, `coverage/`, `.preview/`) never reaches the scanner, so it is not here.
22
+ *
23
+ * Throws, saying what to do, when git is missing or `cwd` is not inside a repository.
24
+ */
25
+ export async function listTrackedFiles(cwd) {
26
+ let stdout;
27
+ try {
28
+ ({ stdout } = await run("git", ["ls-files", "-z"], { cwd, env: gitFreeEnvironment(process.env), encoding: "utf8", maxBuffer: 64 * 1024 * 1024 }));
29
+ }
30
+ catch (error) {
31
+ throw new Error(describeGitFailure(error, cwd), { cause: error });
32
+ }
33
+ return parseLsFiles(stdout).filter((file) => isRegularFile(path.join(cwd, file)));
34
+ }
35
+ function describeGitFailure(error, cwd) {
36
+ if (error instanceof Error && "code" in error && error.code === "ENOENT") {
37
+ // Node reports a missing working directory with the same code as a missing git binary.
38
+ if (!isDirectory(cwd)) {
39
+ return `${cwd} is not a folder, so there is nothing to scan. Run opdk from the plugin root.`;
40
+ }
41
+ return "git is not installed or not on PATH. opdk scan reads the files git tracks, as the scanner reads the repository.";
42
+ }
43
+ const stderr = error instanceof Error && "stderr" in error && typeof error.stderr === "string" ? error.stderr.trim() : "";
44
+ if (/not a git repository/i.test(stderr)) {
45
+ return `${cwd} is not inside a git repository. opdk scan reads the files git tracks, so build output stays out of the scan: run \`git init\` and \`git add\` the plugin's files, or run opdk from the plugin repository.`;
46
+ }
47
+ return `git ls-files failed in ${cwd}: ${stderr === "" ? String(error) : stderr}`;
48
+ }
49
+ function isDirectory(folder) {
50
+ try {
51
+ return statSync(folder).isDirectory();
52
+ }
53
+ catch (error) {
54
+ if (isMissing(error)) {
55
+ return false;
56
+ }
57
+ throw error;
58
+ }
59
+ }
60
+ function isRegularFile(file) {
61
+ try {
62
+ return lstatSync(file).isFile();
63
+ }
64
+ catch (error) {
65
+ if (isMissing(error)) {
66
+ return false;
67
+ }
68
+ throw new Error(`opdk scan could not read ${file}: ${error instanceof Error ? error.message : String(error)}. Check its permissions, or run opdk from the plugin root.`, { cause: error });
69
+ }
70
+ }
71
+ function isMissing(error) {
72
+ return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
73
+ }
@@ -0,0 +1,47 @@
1
+ import { ESLint } from "eslint";
2
+ import type { Finding } from "./findings.js";
3
+ /**
4
+ * typescript-eslint's wording for a file that the kit allows as a default project (`eslint.config.*`) and that a
5
+ * tsconfig covers as well. It is a plugin-setup clash, not a finding: the file is linted again with the project
6
+ * service alone. A test pins it against the installed typescript-eslint.
7
+ */
8
+ export declare const DEFAULT_PROJECT_CLASH_MESSAGE = "was included by allowDefaultProject but also was found in the project service";
9
+ /** True when the file is both a default project and in a tsconfig, so it must be linted without `allowDefaultProject`. */
10
+ export declare function isDefaultProjectClash(result: ESLint.LintResult): boolean;
11
+ /** `ESLint.LintResult[]` as findings: one per message, errors and warnings alike (both lower the score). */
12
+ export declare function toFindings(results: readonly ESLint.LintResult[], cwd: string): Finding[];
13
+ /** `text` with every import of the kit pointed at a package that does not exist. Pure. */
14
+ export declare function hideKitImports(text: string): string;
15
+ /**
16
+ * What the `no-unsafe-call` and `no-unsafe-assignment` findings of a script that imports the kit come from, and the fix. A block
17
+ * `eslint-disable` comment in the file is not one: it fails the plugin's own lint (unused directive,
18
+ * `eslint-comments/disable-enable-pair`) and the scan then reports `disable-enable-pair` instead. For a config,
19
+ * renaming it to `eslint.config.mjs` takes the file off the scanner's list (`**\/*.mjs` is ignored), and
20
+ * `obsidianPlugin()` works from it. Any other file has no such way out: only a tsconfig that does not cover it does.
21
+ */
22
+ export declare const KIT_IMPORT_HINT = "The scanner installs the kit without building it, so this import is unresolved there. Name the file with the .mjs extension (eslint.config.mjs): the scanner ignores .mjs files.";
23
+ /** The hint for a file that is not an `eslint.config.*`: the `.mjs` remedy does not apply to it. */
24
+ export declare const KIT_IMPORT_FILE_HINT = "The scanner installs the kit without building it, so this import is unresolved there. Keep the file out of every tsconfig.json (type-check e2e through a root tsconfig.e2e.json, which the scanner does not look for).";
25
+ /** The hint for a finding in `filePath` (absolute or relative): the `.mjs` rename only for an `eslint.config.*`. Pure. */
26
+ export declare function kitImportHint(filePath: string): string;
27
+ /**
28
+ * One advisory finding per file the scanner does not report: the lint findings of a file that no tsconfig covers.
29
+ * The live scanner type-checks with the project service and reports nothing for a file outside every project (a
30
+ * plugin's `site/assets/site.js` has 36 findings here and none on its scorecard). They stay visible as a `!` line,
31
+ * and do not fail the scan. Inferred from that one scorecard, not confirmed by the scanner's authors.
32
+ */
33
+ export declare function summariseOutsideProject(results: readonly ESLint.LintResult[], cwd: string): Finding[];
34
+ export interface LintOutcome {
35
+ readonly findings: Finding[];
36
+ /** Files linted at all (ignored ones excluded). */
37
+ readonly linted: number;
38
+ /** Files no tsconfig covers: their findings are advisory, the scanner does not report them. */
39
+ readonly untyped: number;
40
+ }
41
+ /**
42
+ * The scanner's ESLint pass over `files` (paths relative to `cwd`), with its own configuration. Files no tsconfig
43
+ * covers are linted again without type information instead of failing to parse, but only as advisory lines (the
44
+ * live scanner does not report them), and an `eslint.config.*` that a tsconfig covers is linted again with types and
45
+ * without `allowDefaultProject`.
46
+ */
47
+ export declare function runScannerLint(cwd: string, files: readonly string[]): Promise<LintOutcome>;
@@ -0,0 +1,163 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { createRequire } from "node:module";
3
+ import path from "node:path";
4
+ import { ESLint } from "eslint";
5
+ import { isOutsideProject } from "./outside-project.js";
6
+ import { createScannerConfig } from "./scanner-config.js";
7
+ /**
8
+ * typescript-eslint keeps one project service per process, built from the options of the first file it parses, so
9
+ * `allowDefaultProject` of the first ESLint instance would stick to the retry. The parser's own `clearCaches`
10
+ * (documented for tooling that lints in several passes) drops it. It is loaded through typescript-eslint, so it is
11
+ * the copy typescript-eslint uses and not a second one; the kit has no dependency of its own on the parser.
12
+ */
13
+ function clearTypescriptEslintCaches() {
14
+ const requireFromHere = createRequire(import.meta.url);
15
+ const requireFromTypescriptEslint = createRequire(requireFromHere.resolve("typescript-eslint"));
16
+ const parser = requireFromTypescriptEslint("@typescript-eslint/parser");
17
+ if (typeof parser !== "object" || parser === null || !("clearCaches" in parser) || typeof parser.clearCaches !== "function") {
18
+ throw new Error("[scan] Cannot re-lint eslint.config with types: @typescript-eslint/parser has no clearCaches(). Install the typescript-eslint version the kit pins.");
19
+ }
20
+ Reflect.apply(parser.clearCaches, parser, []);
21
+ }
22
+ function newEslint(cwd, typeAware, allowDefaultProject = true) {
23
+ return new ESLint({
24
+ cwd,
25
+ overrideConfigFile: true,
26
+ baseConfig: createScannerConfig({ cwd, typeAware, allowDefaultProject }),
27
+ warnIgnored: false,
28
+ errorOnUnmatchedPattern: false,
29
+ });
30
+ }
31
+ /**
32
+ * typescript-eslint's wording for a file that the kit allows as a default project (`eslint.config.*`) and that a
33
+ * tsconfig covers as well. It is a plugin-setup clash, not a finding: the file is linted again with the project
34
+ * service alone. A test pins it against the installed typescript-eslint.
35
+ */
36
+ export const DEFAULT_PROJECT_CLASH_MESSAGE = "was included by allowDefaultProject but also was found in the project service";
37
+ /** True when the file is both a default project and in a tsconfig, so it must be linted without `allowDefaultProject`. */
38
+ export function isDefaultProjectClash(result) {
39
+ return result.messages.some((message) => message.message.includes(DEFAULT_PROJECT_CLASH_MESSAGE));
40
+ }
41
+ /** `ESLint.LintResult[]` as findings: one per message, errors and warnings alike (both lower the score). */
42
+ export function toFindings(results, cwd) {
43
+ return results.flatMap((result) => {
44
+ const file = path.relative(cwd, result.filePath).split(path.sep).join("/");
45
+ return result.messages.map((message) => ({
46
+ check: "lint",
47
+ file,
48
+ // ESLint leaves `line` out of a parse error, whatever its typing says.
49
+ line: typeof message.line === "number" ? message.line : 0,
50
+ rule: message.ruleId ?? "parse-error",
51
+ message: message.message,
52
+ }));
53
+ });
54
+ }
55
+ /**
56
+ * The scanner installs a plugin's dependencies without running their install scripts, so a package that only builds
57
+ * itself in `prepare` has no `dist/` there, and what it exports is unresolved: an `eslint.config.js` that calls
58
+ * `obsidianPlugin()` from the kit gets `no-unsafe-call` and `no-unsafe-assignment` (the spread of the result) on the
59
+ * live scorecard. Inferred from one plugin's 1.7.2 scorecard, where exactly those two warnings sit on the line
60
+ * that calls the kit's helper, and supported by a second plugin's scorecard, where the `no-unsafe-*` warnings of
61
+ * `e2e/` sit on the lines that use the kit's e2e helpers; reproduced by deleting the kit's `dist/eslint`. It is not confirmed by the scanner's
62
+ * authors. The module specifiers keep their line, so the findings point at the right place.
63
+ */
64
+ const KIT_SPECIFIER = /(\bfrom\s*|\bimport\s*\(?\s*|\brequire\s*\(\s*)(["'])obsidian-plugin-dev-kit((?:\/[^"']*)?)\2/g;
65
+ /** `text` with every import of the kit pointed at a package that does not exist. Pure. */
66
+ export function hideKitImports(text) {
67
+ return text.replace(KIT_SPECIFIER, (_match, lead, quote, subpath) => `${lead}${quote}obsidian-plugin-dev-kit-not-built${subpath}${quote}`);
68
+ }
69
+ const SCRIPT_FILE = /\.(?:[cm]?[jt]s|[jt]sx)$/;
70
+ /**
71
+ * What the `no-unsafe-call` and `no-unsafe-assignment` findings of a script that imports the kit come from, and the fix. A block
72
+ * `eslint-disable` comment in the file is not one: it fails the plugin's own lint (unused directive,
73
+ * `eslint-comments/disable-enable-pair`) and the scan then reports `disable-enable-pair` instead. For a config,
74
+ * renaming it to `eslint.config.mjs` takes the file off the scanner's list (`**\/*.mjs` is ignored), and
75
+ * `obsidianPlugin()` works from it. Any other file has no such way out: only a tsconfig that does not cover it does.
76
+ */
77
+ export const KIT_IMPORT_HINT = "The scanner installs the kit without building it, so this import is unresolved there. Name the file with the .mjs extension (eslint.config.mjs): the scanner ignores .mjs files.";
78
+ /** The hint for a file that is not an `eslint.config.*`: the `.mjs` remedy does not apply to it. */
79
+ export const KIT_IMPORT_FILE_HINT = "The scanner installs the kit without building it, so this import is unresolved there. Keep the file out of every tsconfig.json (type-check e2e through a root tsconfig.e2e.json, which the scanner does not look for).";
80
+ const CONFIG_FILE = /^eslint\.config\.[^/]+$/;
81
+ /** The hint for a finding in `filePath` (absolute or relative): the `.mjs` rename only for an `eslint.config.*`. Pure. */
82
+ export function kitImportHint(filePath) {
83
+ return CONFIG_FILE.test(path.basename(filePath)) ? KIT_IMPORT_HINT : KIT_IMPORT_FILE_HINT;
84
+ }
85
+ /** `results` of a script that imports the kit, with the hint added to the unresolved-import findings. */
86
+ function withKitHint(results) {
87
+ return results.map((result) => ({
88
+ ...result,
89
+ messages: result.messages.map((message) => message.ruleId === "@typescript-eslint/no-unsafe-call" || message.ruleId === "@typescript-eslint/no-unsafe-assignment" ? { ...message, message: `${message.message} ${kitImportHint(result.filePath)}` } : message),
90
+ }));
91
+ }
92
+ /** Lints `files` (absolute paths); a script that imports the kit is linted from text where that import cannot resolve. */
93
+ async function lintFilePaths(eslint, files) {
94
+ const importsKit = new Map();
95
+ for (const file of files.filter((candidate) => SCRIPT_FILE.test(candidate))) {
96
+ const text = readFileSync(file, "utf8");
97
+ if (hideKitImports(text) !== text) {
98
+ importsKit.set(file, hideKitImports(text));
99
+ }
100
+ }
101
+ const plain = files.filter((file) => !importsKit.has(file));
102
+ const results = plain.length === 0 ? [] : await eslint.lintFiles(plain);
103
+ for (const [filePath, text] of importsKit) {
104
+ results.push(...withKitHint(await eslint.lintText(text, { filePath })));
105
+ }
106
+ return results;
107
+ }
108
+ /**
109
+ * One advisory finding per file the scanner does not report: the lint findings of a file that no tsconfig covers.
110
+ * The live scanner type-checks with the project service and reports nothing for a file outside every project (a
111
+ * plugin's `site/assets/site.js` has 36 findings here and none on its scorecard). They stay visible as a `!` line,
112
+ * and do not fail the scan. Inferred from that one scorecard, not confirmed by the scanner's authors.
113
+ */
114
+ export function summariseOutsideProject(results, cwd) {
115
+ const byFile = new Map();
116
+ for (const finding of toFindings(results, cwd)) {
117
+ byFile.set(finding.file, [...(byFile.get(finding.file) ?? []), finding]);
118
+ }
119
+ const summaries = [];
120
+ for (const [file, own] of byFile) {
121
+ const first = own[0];
122
+ if (first !== undefined) {
123
+ summaries.push({
124
+ check: "lint",
125
+ file,
126
+ line: first.line,
127
+ rule: "outside-tsconfig",
128
+ message: `${String(own.length)} lint finding${own.length === 1 ? "" : "s"} in a file no tsconfig covers (first: ${first.rule}). The scorecard compared did not list files outside every tsconfig project (inferred from one scorecard), and would if a tsconfig covered this one.`,
129
+ advisory: true,
130
+ });
131
+ }
132
+ }
133
+ return summaries;
134
+ }
135
+ /**
136
+ * The scanner's ESLint pass over `files` (paths relative to `cwd`), with its own configuration. Files no tsconfig
137
+ * covers are linted again without type information instead of failing to parse, but only as advisory lines (the
138
+ * live scanner does not report them), and an `eslint.config.*` that a tsconfig covers is linted again with types and
139
+ * without `allowDefaultProject`.
140
+ */
141
+ export async function runScannerLint(cwd, files) {
142
+ const typed = await lintFilePaths(newEslint(cwd, true), files.map((file) => path.join(cwd, file)));
143
+ const outside = typed.filter(isOutsideProject);
144
+ const clashing = typed.filter(isDefaultProjectClash);
145
+ const untypedResults = outside.length === 0 ? [] : await lintFilePaths(newEslint(cwd, false), outside.map((result) => result.filePath));
146
+ let retypedResults = [];
147
+ if (clashing.length > 0) {
148
+ clearTypescriptEslintCaches();
149
+ try {
150
+ retypedResults = await lintFilePaths(newEslint(cwd, true, false), clashing.map((result) => result.filePath));
151
+ }
152
+ finally {
153
+ // The service built for this pass has no default project; later passes in this process start fresh.
154
+ clearTypescriptEslintCaches();
155
+ }
156
+ }
157
+ const reported = [...typed.filter((result) => !isOutsideProject(result) && !isDefaultProjectClash(result)), ...retypedResults];
158
+ return {
159
+ findings: [...toFindings(reported, cwd), ...summariseOutsideProject(untypedResults, cwd)],
160
+ linted: reported.length + untypedResults.length,
161
+ untyped: untypedResults.length,
162
+ };
163
+ }
@@ -0,0 +1,8 @@
1
+ import type { Manifest } from "../config/types.js";
2
+ import type { Finding } from "./findings.js";
3
+ /**
4
+ * `manifest.json`: the description must not begin with the plugin name; the scorecard counts
5
+ * "<Name> is a ..." as redundant. The name comes from the manifest, so no plugin is hardcoded. The scanner's ESLint
6
+ * configuration switches `obsidianmd/validate-manifest` off for `manifest.json`, so this is not covered there.
7
+ */
8
+ export declare function checkManifestDescription(manifest: Manifest): Finding[];
@@ -0,0 +1,22 @@
1
+ /**
2
+ * `manifest.json`: the description must not begin with the plugin name; the scorecard counts
3
+ * "<Name> is a ..." as redundant. The name comes from the manifest, so no plugin is hardcoded. The scanner's ESLint
4
+ * configuration switches `obsidianmd/validate-manifest` off for `manifest.json`, so this is not covered there.
5
+ */
6
+ export function checkManifestDescription(manifest) {
7
+ const description = manifest.description ?? "";
8
+ const name = manifest.name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
9
+ // \b after a name ending in a symbol (for example "Foo+") would never match; the lookahead is the same test.
10
+ if (!new RegExp(`^\\s*${name}(?![A-Za-z0-9_])`, "i").test(description)) {
11
+ return [];
12
+ }
13
+ return [
14
+ {
15
+ check: "meta",
16
+ file: "manifest.json",
17
+ line: 1,
18
+ rule: "manifest-description-no-name-prefix",
19
+ message: `The description must not start with the plugin name. Current: ${JSON.stringify(description.slice(0, 80))}`,
20
+ },
21
+ ];
22
+ }
@@ -0,0 +1,19 @@
1
+ import type { ESLint } from "eslint";
2
+ /**
3
+ * Kept apart from lint.ts so `opdk release check` (the API check) can use `isOutsideProject` without importing the
4
+ * scanner's lint run. Keep this file free of side effects.
5
+ */
6
+ /**
7
+ * typescript-eslint's wording for a file no tsconfig covers. The scanner lints such a file without type
8
+ * information instead of failing, so the retry in `runScannerLint` is keyed on this message; a test pins it
9
+ * against the installed typescript-eslint.
10
+ */
11
+ export declare const PROJECT_SERVICE_MESSAGE = "was not found by the project service";
12
+ /**
13
+ * TypeScript's TS18003: the tsconfig's `include` matches no file at all. On Linux the project service
14
+ * reports this instead of `PROJECT_SERVICE_MESSAGE` for a file next to such a tsconfig (seen on GitHub
15
+ * Actions, not on macOS), and the file is just as much outside every project.
16
+ */
17
+ export declare const NO_INPUTS_MESSAGE = "No inputs were found in config file";
18
+ /** True when typescript-eslint could not place the file in any tsconfig project, so it must be linted without types. */
19
+ export declare function isOutsideProject(result: ESLint.LintResult): boolean;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Kept apart from lint.ts so `opdk release check` (the API check) can use `isOutsideProject` without importing the
3
+ * scanner's lint run. Keep this file free of side effects.
4
+ */
5
+ /**
6
+ * typescript-eslint's wording for a file no tsconfig covers. The scanner lints such a file without type
7
+ * information instead of failing, so the retry in `runScannerLint` is keyed on this message; a test pins it
8
+ * against the installed typescript-eslint.
9
+ */
10
+ export const PROJECT_SERVICE_MESSAGE = "was not found by the project service";
11
+ /**
12
+ * TypeScript's TS18003: the tsconfig's `include` matches no file at all. On Linux the project service
13
+ * reports this instead of `PROJECT_SERVICE_MESSAGE` for a file next to such a tsconfig (seen on GitHub
14
+ * Actions, not on macOS), and the file is just as much outside every project.
15
+ */
16
+ export const NO_INPUTS_MESSAGE = "No inputs were found in config file";
17
+ /** True when typescript-eslint could not place the file in any tsconfig project, so it must be linted without types. */
18
+ export function isOutsideProject(result) {
19
+ return result.messages.some((message) => message.message.includes(PROJECT_SERVICE_MESSAGE) || message.message.includes(NO_INPUTS_MESSAGE));
20
+ }
@@ -0,0 +1,19 @@
1
+ import type { Reporter } from "../cli/reporter.js";
2
+ import type { Manifest } from "../config/types.js";
3
+ import { type Finding, type ScanCheck } from "./findings.js";
4
+ export interface ScanInput {
5
+ readonly cwd: string;
6
+ readonly manifest: Manifest;
7
+ readonly reporter: Reporter;
8
+ /** Reads the ESLint version that `eslint-plugin-obsidianmd` resolves. Tests inject it; the default reads the install. */
9
+ readonly readNestedEslintVersion?: () => string;
10
+ /** Reads the version of the TypeScript the plugin installs, or `undefined` when there is none. Tests inject it; the default reads the install. */
11
+ readonly readTypescriptVersion?: () => string | undefined;
12
+ }
13
+ /**
14
+ * Prints one check: a `✓` line when it found nothing, otherwise the findings under a `✗` line (stderr). Advisory
15
+ * findings print as `!` lines and do not count. Returns the number of findings that fail the scan.
16
+ */
17
+ export declare function reportCheck(check: ScanCheck, findings: readonly Finding[], scope: string, reporter: Reporter): number;
18
+ /** `opdk scan`: the scanner's ESLint pass, the CSS check and the source checks over the tracked files. Returns the exit code. */
19
+ export declare function runScan({ cwd, manifest, reporter, readNestedEslintVersion, readTypescriptVersion }: ScanInput): Promise<number>;
@@ -0,0 +1,78 @@
1
+ import { readFileSync } from "node:fs";
2
+ import path from "node:path";
3
+ import { checkCode, isShippedSource } from "./code-checks.js";
4
+ import { checkCss } from "./css-check.js";
5
+ import { eslintMismatchWarning } from "./eslint-nesting.js";
6
+ import { findingsOf, formatFinding, SCAN_CHECKS } from "./findings.js";
7
+ import { listTrackedFiles } from "./git-files.js";
8
+ import { runScannerLint } from "./lint.js";
9
+ import { checkManifestDescription } from "./meta-checks.js";
10
+ import { MIRRORED_OBSIDIANMD_VERSION } from "./scanner-config.js";
11
+ import { describeTypescriptGap, readPluginTypescriptVersion } from "./typescript-gate.js";
12
+ const plural = (count, noun) => `${String(count)} ${noun}${count === 1 ? "" : "s"}`;
13
+ function readSources(cwd, files) {
14
+ return files.map((file) => ({ path: file, text: readFileSync(path.join(cwd, file), "utf8") }));
15
+ }
16
+ /**
17
+ * Prints one check: a `✓` line when it found nothing, otherwise the findings under a `✗` line (stderr). Advisory
18
+ * findings print as `!` lines and do not count. Returns the number of findings that fail the scan.
19
+ */
20
+ export function reportCheck(check, findings, scope, reporter) {
21
+ const own = findingsOf(findings, check);
22
+ const failing = own.filter((finding) => finding.advisory !== true);
23
+ for (const finding of own.filter((candidate) => candidate.advisory === true)) {
24
+ reporter.warn(check, formatFinding(finding));
25
+ }
26
+ if (failing.length === 0) {
27
+ reporter.success(check, `0 findings (${scope})`);
28
+ }
29
+ else {
30
+ reporter.failure(check, `${plural(failing.length, "finding")} (${scope}):`, { details: failing.map(formatFinding) });
31
+ }
32
+ return failing.length;
33
+ }
34
+ /** `opdk scan`: the scanner's ESLint pass, the CSS check and the source checks over the tracked files. Returns the exit code. */
35
+ export async function runScan({ cwd, manifest, reporter, readNestedEslintVersion, readTypescriptVersion = readPluginTypescriptVersion }) {
36
+ const files = await listTrackedFiles(cwd);
37
+ if (files.length === 0) {
38
+ reporter.failure("scan", `${manifest.id}: no files to scan (git tracks none in this folder).`, {
39
+ hint: "Run `git add` for the plugin's files, or run opdk from the plugin repository.",
40
+ });
41
+ return 1;
42
+ }
43
+ const typescriptVersion = readTypescriptVersion();
44
+ const gap = describeTypescriptGap(typescriptVersion);
45
+ if (gap !== undefined) {
46
+ reporter.failure("scan", `${manifest.id}: ${gap.message}`, { hint: gap.hint });
47
+ return 1;
48
+ }
49
+ reporter.info("scan", `${manifest.id}: ${plural(files.length, "tracked file")}`);
50
+ const cssFiles = readSources(cwd, files.filter((file) => file.endsWith(".css")));
51
+ const codeFiles = readSources(cwd, files.filter(isShippedSource));
52
+ const mismatch = eslintMismatchWarning(undefined, readNestedEslintVersion);
53
+ if (mismatch !== undefined) {
54
+ reporter.warn("lint", mismatch);
55
+ }
56
+ const lint = await runScannerLint(cwd, files);
57
+ const findings = [
58
+ ...lint.findings,
59
+ ...(await checkCss(cssFiles)),
60
+ ...checkCode(codeFiles),
61
+ ...checkManifestDescription(manifest),
62
+ ];
63
+ const scope = {
64
+ lint: `${plural(lint.linted, "file")}, eslint-plugin-obsidianmd ${MIRRORED_OBSIDIANMD_VERSION}, typescript ${String(typescriptVersion)}${lint.untyped > 0 ? `, ${String(lint.untyped)} outside every tsconfig, advisory` : ""}`,
65
+ css: plural(cssFiles.length, "file"),
66
+ code: plural(codeFiles.length, "file"),
67
+ meta: "manifest.json",
68
+ };
69
+ const failing = SCAN_CHECKS.reduce((total, check) => total + reportCheck(check, findings, scope[check], reporter), 0);
70
+ if (failing > 0) {
71
+ reporter.failure("scan", `${manifest.id}: ${plural(failing, "finding")}, each one lowers the community scorecard.`, {
72
+ hint: "Fix them and rerun `opdk scan`. Each line reads file:line rule message.",
73
+ });
74
+ return 1;
75
+ }
76
+ reporter.success("scan", `${manifest.id}: 0 findings in ${plural(files.length, "tracked file")}`);
77
+ return 0;
78
+ }
@@ -0,0 +1,114 @@
1
+ /**
2
+ * The community plugin scanner's ESLint configuration, which `opdk scan` runs over the plugin.
3
+ *
4
+ * Licence: the configuration text is copied from eslint-plugin-obsidianmd (obsidianmd/eslint-plugin, Dynalist Inc.,
5
+ * MIT licence); keep this notice.
6
+ *
7
+ * Mirrors "Full scanner-equivalent configuration" in the section "Community plugin scanner configuration" of
8
+ * eslint-plugin-obsidianmd's docs/configuration.md (https://github.com/obsidianmd/eslint-plugin), version
9
+ * 0.5.1, diffed on 2026-11-10 against the tag's file. Re-diff it on every bump of that package: a test pins the
10
+ * version so a bump cannot go unnoticed.
11
+ *
12
+ * What differs from the upstream text, each on purpose:
13
+ * - `tsconfigRootDir` is the plugin root (upstream's snippet says `process.cwd()`), and the project service is on
14
+ * from the start, as the scanner has it.
15
+ * - `typeAware: false` lints a file no tsconfig covers without type information (typescript-eslint's type-aware rules
16
+ * and the obsidianmd rules that read the type checker switched off, and core `no-implied-eval` on for TypeScript
17
+ * in place of the type-aware rule), where upstream's snippet reports "was not found by the project service". The
18
+ * live scanner does not list such files at all (a site script with 36 findings here has none on its scorecard), so
19
+ * `opdk scan` shows what this pass finds as advisory lines only. A file that cannot be parsed fails this pass too.
20
+ * - The ignore list is upstream's `globalIgnores` (48 entries) with two changes. First, `eslint` is removed from the
21
+ * `**\/{astro,babel,...}.config.*` group, so the plugin's `eslint.config.js` and `.ts` are linted (`.mjs`, `.cjs`,
22
+ * `.mts` and `.cts` stay ignored by their extension globs), with type information
23
+ * (`allowDefaultProject`, above). 0.5.1's text ignores it, but the live scanner lints it: one plugin's public
24
+ * scorecard reports four `no-unsafe-*` warnings in its `eslint.config.js`. The kit follows the live scanner
25
+ * (owner decision, 2026-11-11). Re-check this on every bump of the package. Second, `**\/e2e/**` is removed: see
26
+ * the next entry. Of upstream's list, its first three, `main.js`,
27
+ * `**\/*.min.js` and `**\/{dist,build,out,release}/**`, are upstream's stand-ins for bundled and minified
28
+ * output (the scanner recognises it by name and, in a TypeScript project, by content). A plugin written in
29
+ * JavaScript should drop `main.js`, as upstream says.
30
+ * - e2e folders. Upstream ignores `**\/e2e/**` and the preset exempts it from the runtime rules, but the live scanner
31
+ * lints the files in `e2e/` that a `tsconfig.json` covers. One plugin's release added `e2e/tsconfig.json` (it
32
+ * extends the root one and includes `./**\/*.ts`) and its scorecard lists 21 findings in three files of `e2e/`:
33
+ * `no-unsafe-*`, and also `prefer-window-timers`, `no-global-this` and `no-nodejs-modules`, so the runtime
34
+ * exemption does not apply there either. The `no-unsafe-*` ones all come from imports of the kit, unresolved on
35
+ * the scanner (see `hideKitImports`); only keeping the files out of every tsconfig removes them. The release
36
+ * before, with no e2e tsconfig, listed nothing from `e2e/`, and another plugin (helpers only in a root
37
+ * `tsconfig.e2e.json`, which the project service does not read) lists nothing: a file outside every
38
+ * `tsconfig.json` is not reported, as the entry above says. The two scorecards agree with the "kit not built"
39
+ * inference of `hideKitImports`. `*.spec.*` files in `e2e/` are not listed either; `**\/*.spec.*` ignores them. So the folder is no longer
40
+ * ignored, and its exemption is lifted (`E2E_FILE_PATTERNS`, in `withoutRuntimeExemptions`), except for
41
+ * `obsidianmd/prefer-active-doc`: that scorecard has none for the one `document` use in `e2e/fixtures.ts`, so it stays
42
+ * off there (`E2E_EXEMPT_RULE`; one data point, see its comment for the three explanations). `**\/e2e-tests/**` and
43
+ * `**\/*.e2e.*` stay ignored, and stay exempt in the preset: no scorecard shows a plugin with either.
44
+ * - Upstream imports `defineConfig` and `globalIgnores` from "eslint/config"; plain arrays and `{ ignores }`
45
+ * objects do the same here and work on every ESLint the kit supports.
46
+ * - The preset exempts test, worker and tooling files from the rules about code that runs inside Obsidian
47
+ * (`no-nodejs-modules`, `prefer-active-doc`, `regex-lookbehind` and the like) with `ignores` lists that include
48
+ * `global-setup.*`, `*.setup.*` and `test-setup.*`. The scanner's own ignore list does not name those, and the
49
+ * live scanner reports `obsidianmd/no-nodejs-modules` for a `global-setup.ts` that imports `node:fs` (one
50
+ * scorecard, the only evidence). So the exemption is lifted for the setup files only (`withoutRuntimeExemptions`,
51
+ * `SETUP_FILE_PATTERNS`); workers and the other exempted files stay exempt.
52
+ * - Every finding counts, whatever its severity. The scanner turns most rules into warnings, and a warning still
53
+ * lowers the score; `opdk scan` fails on both. Upstream's note says the real scanner downgrades unlisted rules
54
+ * to `warn`, which does not change what is reported.
55
+ *
56
+ * The scanner keeps layers by submission date. This is the newest one: upstream's snippet is the configuration all
57
+ * layers build on, and the kit adds what the newest layer changes, so a plugin sees what a plugin submitted today
58
+ * would see. That layer turns `@typescript-eslint/no-unsafe-*` and the two command-id rules back on at `warn`
59
+ * (see the block marked "newest" below); its other additions, the obsidianmd rules at `error`, are already
60
+ * `error` in the recommended config for TypeScript. The older layers report less, so a clean scan here is clean in them too.
61
+ */
62
+ import type { Linter } from "eslint";
63
+ /** The eslint-plugin-obsidianmd version this configuration was diffed against. */
64
+ export declare const MIRRORED_OBSIDIANMD_VERSION = "0.5.1";
65
+ /** The paths the scanner leaves out: upstream's `globalIgnores` list (upstream's 48 less the `e2e` folder, with `eslint` removed from the tool-config group), so the root `eslint.config.js` and `.ts` and the files of `e2e/` are linted, as the live scanner does. */
66
+ export declare const SCANNER_IGNORES: readonly string[];
67
+ /**
68
+ * The e2e folder, whose exemption from the preset's runtime rules is lifted as well: one plugin's scorecard has
69
+ * `prefer-window-timers`, `no-global-this` and `no-nodejs-modules` for files in `e2e/`. Only the folder `e2e`, not
70
+ * `e2e-tests` or `*.e2e.*` (no evidence). Files under it that the scanner's list names (`*.spec.*`) stay out.
71
+ */
72
+ export declare const E2E_FILE_PATTERNS: readonly string[];
73
+ /**
74
+ * The runtime rule that stays off in `E2E_FILE_PATTERNS` after the lift. one plugin's scorecard has no
75
+ * `prefer-active-doc` for the `document.querySelector(...)` in `e2e/fixtures.ts` (inside a `win.evaluate` callback,
76
+ * the only non-spec use of `document` in its `e2e/`), while the same file has `prefer-window-timers` in the same
77
+ * callback. The preset puts these rules in one block, so the kit switches this one off for the folder. One data point, and three
78
+ * explanations fit it: the scanner exempts the rule in `e2e/`, it skips `document` inside such a callback, or it does
79
+ * not report the rule on any tsconfig-covered file (no scorecard seen has shown it on one). The kit cannot tell them
80
+ * apart, and keeps the off scoped to `e2e/`.
81
+ */
82
+ export declare const E2E_EXEMPT_RULE = "obsidianmd/prefer-active-doc";
83
+ /**
84
+ * The test-setup files, whose exemption from the preset's runtime rules is lifted (as is the e2e folder's,
85
+ * `E2E_FILE_PATTERNS`). The scanner's ignore list names none of them, and the one scorecard that shows it has a `global-setup.ts` with three `no-nodejs-modules`
86
+ * warnings. The other names are the same family in the preset's own list (`*-global-setup.*`, `test-setup.*`,
87
+ * `setupTests.*`, `*.setup.*`), run by a test runner in Node like that file, and the scanner's list does not name them
88
+ * either; they are inferred from that one scorecard, not seen on their own. Everything else the preset exempts stays
89
+ * exempt: worker files (a Worker has no `activeWindow`, so `prefer-window-timers` and `no-global-this` would be wrong
90
+ * advice there), `test-helpers`, `test-support` and `test-utils` folders, `*.testing.*`, `testUtils*`, and tool configs
91
+ * and scripts, none of which has evidence.
92
+ */
93
+ export declare const SETUP_FILE_PATTERNS: readonly string[];
94
+ /**
95
+ * The blocks of the preset that carry `ignores` (its exemption of test, worker and tooling files) as the same blocks
96
+ * that apply only to `SETUP_FILE_PATTERNS` and `E2E_FILE_PATTERNS`, without `ignores`. Later blocks override earlier
97
+ * ones, so putting these after the preset turns the rules back on for the setup files and the e2e folder and no other
98
+ * exempted file. Plugins and parsers stay with the original blocks. Flat config reads a nested `files` array as "all
99
+ * of these", so each pattern of the block is paired with each lifted pattern.
100
+ */
101
+ export declare function withoutRuntimeExemptions(blocks: readonly Linter.Config[]): Linter.Config[];
102
+ export interface ScannerConfigOptions {
103
+ /** Plugin root: where `tsconfig.json` is looked up from. */
104
+ readonly cwd: string;
105
+ /**
106
+ * Whether the project service may take `eslint.config.*` as a default project (the default). It must be off for
107
+ * a plugin whose tsconfig already covers that file: typescript-eslint then throws "was included by
108
+ * allowDefaultProject but also was found in the project service", and the file is linted again with this off.
109
+ */
110
+ readonly allowDefaultProject?: boolean;
111
+ /** `false` lints without type information, for files no tsconfig covers. */
112
+ readonly typeAware: boolean;
113
+ }
114
+ export declare function createScannerConfig({ cwd, typeAware, allowDefaultProject }: ScannerConfigOptions): Linter.Config[];