mirror of
https://github.com/fancive/obsidian-parallel-reader.git
synced 2026-07-22 06:53:43 +00:00
Add eslint v9 + @typescript-eslint/parser + eslint-plugin-obsidianmd as
a dedicated `npm run lint:obsidian` track, separate from the existing
biome lint. Apply autofixes from the recommended config and resolve the
follow-on type/test issues.
- prefer-create-el: createEl('div'/'span') -> createDiv/createSpan
- prefer-active-window-timers: setTimeout/clearTimeout -> activeWindow.*
+ retype timer holders from ReturnType<typeof setTimeout> to number
- prefer-active-doc: drop globalThis.fetch in streaming
- no-useless-catch: drop no-op rethrow wrapper
- no-restricted-globals: streaming.ts is exempted because requestUrl
does not support streaming responses
- @typescript-eslint/no-unsafe-*: disabled (out of scope for an Obsidian
plugin lint pass; tsc + biome already cover type safety)
- tests: polyfill globalThis.activeWindow so unit tests still run in Node
Change-Id: I43cc652e29a66d490e2834e940843c39b211b80b
45 lines
1.4 KiB
JavaScript
45 lines
1.4 KiB
JavaScript
const assert = require('assert');
|
|
const esbuild = require('esbuild');
|
|
const fs = require('fs');
|
|
const os = require('os');
|
|
const path = require('path');
|
|
|
|
// Polyfill Obsidian's `activeWindow` global for Node test runtime.
|
|
if (typeof globalThis.activeWindow === 'undefined') {
|
|
globalThis.activeWindow = globalThis;
|
|
}
|
|
|
|
const repoRoot = path.join(__dirname, '..');
|
|
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'parallel-reader-tests-'));
|
|
|
|
async function requireBundledModule(relativePath) {
|
|
const entry = path.join(repoRoot, relativePath);
|
|
const outfile = path.join(tempDir, relativePath.replace(/[/.]/g, '_') + '.cjs');
|
|
await esbuild.build({
|
|
entryPoints: [entry],
|
|
bundle: true,
|
|
platform: 'node',
|
|
format: 'cjs',
|
|
outfile,
|
|
plugins: [
|
|
{
|
|
name: 'obsidian-stub',
|
|
setup(build) {
|
|
build.onResolve({ filter: /^obsidian$/ }, () => ({ path: 'obsidian-stub', namespace: 'stub' }));
|
|
build.onLoad({ filter: /.*/, namespace: 'stub' }, () => ({
|
|
contents:
|
|
'module.exports = { requestUrl: async () => { throw new Error("requestUrl not available in direct module tests"); } };',
|
|
loader: 'js',
|
|
}));
|
|
},
|
|
},
|
|
],
|
|
});
|
|
return require(outfile);
|
|
}
|
|
|
|
function cleanup() {
|
|
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
}
|
|
|
|
module.exports = { assert, requireBundledModule, cleanup, repoRoot, tempDir };
|