From c22dc1f969cdad40d1e506d610c4c984ca6bd4a5 Mon Sep 17 00:00:00 2001 From: Lukas Wolfsteiner Date: Mon, 6 Jul 2026 11:20:56 +0200 Subject: [PATCH] build: modernize TypeScript and esbuild configuration Set compile and bundle target to ES2021 since Obsidian runs on modern Electron. Replace individual strict flags with strict: true and add noFallthroughCasesInSwitch, skipLibCheck and forceConsistentCasingInFileNames. Switch module resolution to bundler, removing the need for deprecation workarounds on TypeScript 6. Drop baseUrl, allowJs and importHelpers; tests now import sources via relative paths. Aligns the project with the modernized obsidian-sample-plugin configuration. Co-authored-by: Cursor --- esbuild.config.mjs | 2 +- jest.config.cjs | 1 - tests/block-parser.test.ts | 2 +- tests/note-parser.test.ts | 2 +- tests/note-search.test.ts | 2 +- tests/raindrop-search.test.ts | 2 +- tsconfig.json | 31 ++++++++----------------------- 7 files changed, 13 insertions(+), 29 deletions(-) diff --git a/esbuild.config.mjs b/esbuild.config.mjs index 1c74a14..8960818 100644 --- a/esbuild.config.mjs +++ b/esbuild.config.mjs @@ -33,7 +33,7 @@ const context = await esbuild.context({ "@lezer/lr", ...builtinModules], format: "cjs", - target: "es2018", + target: "es2021", logLevel: "info", sourcemap: prod ? false : "inline", treeShaking: true, diff --git a/jest.config.cjs b/jest.config.cjs index 6e0200c..73d4a37 100644 --- a/jest.config.cjs +++ b/jest.config.cjs @@ -1,7 +1,6 @@ module.exports = { preset: "ts-jest", testEnvironment: "jsdom", - moduleDirectories: ["node_modules", "src"], moduleNameMapper: { "^obsidian$": "/tests/__mocks__/obsidian.ts", }, diff --git a/tests/block-parser.test.ts b/tests/block-parser.test.ts index 69d5b68..c15cc43 100644 --- a/tests/block-parser.test.ts +++ b/tests/block-parser.test.ts @@ -1,4 +1,4 @@ -import { extractFirstRaindropBlock, parseRaindropBlock } from "block-parser"; +import { extractFirstRaindropBlock, parseRaindropBlock } from "../src/block-parser"; describe("parseRaindropBlock", () => { it("parses supported key-value options", () => { diff --git a/tests/note-parser.test.ts b/tests/note-parser.test.ts index 887e266..55d074d 100644 --- a/tests/note-parser.test.ts +++ b/tests/note-parser.test.ts @@ -1,5 +1,5 @@ import type { CachedMetadata } from "obsidian"; -import { getNoteRaindropReferences, getUrlKey } from "note-parser"; +import { getNoteRaindropReferences, getUrlKey } from "../src/note-parser"; describe("getNoteRaindropReferences", () => { it("extracts unique tags and urls from a note", () => { diff --git a/tests/note-search.test.ts b/tests/note-search.test.ts index cffa11b..d9531f8 100644 --- a/tests/note-search.test.ts +++ b/tests/note-search.test.ts @@ -1,5 +1,5 @@ import type { CachedMetadata } from "obsidian"; -import { buildNoteRaindropSearch } from "note-search"; +import { buildNoteRaindropSearch } from "../src/note-search"; describe("buildNoteRaindropSearch", () => { it("builds an OR query from note tags and urls", () => { diff --git a/tests/raindrop-search.test.ts b/tests/raindrop-search.test.ts index 037074a..3c93530 100644 --- a/tests/raindrop-search.test.ts +++ b/tests/raindrop-search.test.ts @@ -1,4 +1,4 @@ -import { buildRaindropSearchQuery, buildRaindropTagSearch, formatRaindropTagFilter } from "raindrop-search"; +import { buildRaindropSearchQuery, buildRaindropTagSearch, formatRaindropTagFilter } from "../src/raindrop-search"; describe("formatRaindropTagFilter", () => { it("formats simple tags without quotes", () => { diff --git a/tsconfig.json b/tsconfig.json index 3810100..3209515 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,35 +1,20 @@ { "compilerOptions": { - "ignoreDeprecations": "6.0", - "rootDir": ".", - "baseUrl": "src", "inlineSourceMap": true, "inlineSources": true, "module": "ESNext", - "target": "ES6", - "allowJs": true, - "noImplicitAny": true, - "noImplicitThis": true, + "target": "ES2021", + "strict": true, "noImplicitReturns": true, - "moduleResolution": "node", - "importHelpers": true, + "noFallthroughCasesInSwitch": true, "noUncheckedIndexedAccess": true, + "moduleResolution": "bundler", "isolatedModules": true, - "strictNullChecks": true, - "strictBindCallApply": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, "allowSyntheticDefaultImports": true, - "useUnknownInCatchVariables": true, "types": ["jest"], - "lib": [ - "DOM", - "ES5", - "ES6", - "ES7", - "ES2020" - ] + "lib": ["ES2021", "DOM"] }, - "include": [ - "src/**/*.ts", - "tests/**/*.ts" - ] + "include": ["src/**/*.ts", "tests/**/*.ts"] }