Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

chore(lint): enable no-undef + enumerate project + browser globals (#3657)

LearningCircuita877891ab6df
diff --git a/eslint.config.js b/eslint.config.js
index 9720edc938..66a7dc2a5b 100644
--- a/eslint.config.js
+++ b/eslint.config.js
@@ -47,7 +47,7 @@ export default [
},
rules: {
- "no-undef": "off", // browser globals not fully enumerated yet
+ "no-undef": "error", // globals enumerated below in languageOptions.globals
"no-unused-vars": ["warn", {
"args": "after-used",
"argsIgnorePattern": "^_",
@@ -278,7 +278,68 @@ export default [
IntersectionObserver: "readonly",
requestAnimationFrame: "readonly",
cancelAnimationFrame: "readonly",
+ requestIdleCallback: "readonly",
performance: "readonly",
+ // Browser dialogs and built-in APIs
+ alert: "readonly",
+ confirm: "readonly",
+ prompt: "readonly",
+ AbortController: "readonly",
+ getComputedStyle: "readonly",
+ XMLHttpRequest: "readonly",
+ Image: "readonly",
+ Notification: "readonly",
+ CSS: "readonly",
+ // The deprecated `event` magic global — IE-era leftover. Some inline
+ // template handlers still use it; mark readonly so the rule doesn't
+ // flag them while we phase that out.
+ event: "readonly",
+ // Project globals — all exposed via window.<name> = ... at module init.
+ // SafeLogger: security/safe-logger.js (sanitises console output)
+ // URLBuilder, URLS, URLValidator: URL helpers loaded in base.html
+ // ResearchStates: config/constants.js — research-status state machine
+ // safeFetch: utils/safe-fetch.js — fetch wrapper with URL validation
+ // escapeHtml, sanitizeHtml: security/xss-protection.js — XSS escaping
+ // LDR_CONSTANTS: config/constants.js — shared frontend constants
+ // DeleteManager: deletion/delete_manager.js — deletion UI helper
+ SafeLogger: "readonly",
+ URLBuilder: "readonly",
+ URLS: "readonly",
+ URLValidator: "readonly",
+ ResearchStates: "readonly",
+ safeFetch: "readonly",
+ escapeHtml: "readonly",
+ sanitizeHtml: "readonly",
+ LDR_CONSTANTS: "readonly",
+ DeleteManager: "readonly",
+ // Top-level helper in services/ui.js used as a fallback before
+ // window.escapeHtml is loaded.
+ escapeHtmlFallback: "readonly",
+ // Helpers exposed via window.X = ... in components/news.js
+ showModal: "readonly",
+ hideModal: "readonly",
+ showEmptyState: "readonly",
+ showLoadingState: "readonly",
+ showErrorState: "readonly",
+ showMessage: "readonly",
+ formatTimeAgo: "readonly",
+ createTag: "readonly",
+ debounce: "readonly",
+ // Markdown helper in services/ui.js
+ renderMarkdown: "readonly",
+ // Page-injected globals from Jinja template inline scripts
+ COLLECTION_ID: "readonly",
+ DEFAULT_LIBRARY_COLLECTION_ID: "readonly",
+ COLLECTIONS_DATA: "readonly",
+ // Third-party libs loaded via <script> tags in base.html / per-page templates
+ bootstrap: "readonly",
+ Chart: "readonly",
+ DOMPurify: "readonly",
+ marked: "readonly",
+ Prism: "readonly",
+ jsPDF: "readonly",
+ html2canvas: "readonly",
+ io: "readonly",
// Node.js globals (for config files)
module: "readonly",
require: "readonly",
@@ -314,5 +375,32 @@ export default [
rules: {
"no-console": "off",
},
+ languageOptions: {
+ globals: {
+ // Test framework globals (vitest / jest / mocha-style)
+ describe: "readonly",
+ it: "readonly",
+ test: "readonly",
+ expect: "readonly",
+ vi: "readonly",
+ jest: "readonly",
+ beforeEach: "readonly",
+ afterEach: "readonly",
+ beforeAll: "readonly",
+ afterAll: "readonly",
+ before: "readonly",
+ after: "readonly",
+ // Browser globals used inside page.evaluate(...) callbacks — they
+ // run in the browser context, not Node.
+ $: "readonly", // jQuery, when loaded on the page
+ KeyboardEvent: "readonly",
+ MouseEvent: "readonly",
+ Response: "readonly",
+ CSSRule: "readonly",
+ // Page-defined functions referenced from page.evaluate() with a
+ // `typeof X === 'function'` guard
+ handleTestRun: "readonly",
+ },
+ },
},
];
diff --git a/src/local_deep_research/web/static/js/pages/news.js b/src/local_deep_research/web/static/js/pages/news.js
index 004083d391..08b28b1c0c 100644
--- a/src/local_deep_research/web/static/js/pages/news.js
+++ b/src/local_deep_research/web/static/js/pages/news.js
@@ -3581,8 +3581,13 @@ function showNewsSubscriptionModal(query = '', templateName = '') {
loadSubscriptionFolders();
// Initialize the custom dropdown for model selection
+ // TODO: This appears to be a typo — templates define `initializeDropdowns`
+ // (plural) but this calls `initializeDropdown` (singular). The typeof
+ // guard masks the bug; the dropdown likely never initialises here.
+ // Investigate separately; not changing behaviour as part of a lint PR.
+ // eslint-disable-next-line no-undef -- see TODO above
if (typeof initializeDropdown !== 'undefined') {
- // Initialize model dropdown with available models
+ // eslint-disable-next-line no-undef
initializeDropdown('news-subscription-model', 'news-model-dropdown', 'model');
}
diff --git a/src/local_deep_research/web/static/js/utils/sse-completion.js b/src/local_deep_research/web/static/js/utils/sse-completion.js
index 3b79388d20..38b2fef458 100644
--- a/src/local_deep_research/web/static/js/utils/sse-completion.js
+++ b/src/local_deep_research/web/static/js/utils/sse-completion.js
@@ -11,14 +11,24 @@
function handleSSECompletion(data, onSuccess) {
if (!data.complete) return false;
+ // closeProgressModal is page-specific — defined inline in
+ // download_manager.html and library.html (the only callers of this
+ // utility). Look it up via window so a caller from a different page
+ // doesn't crash, and so eslint doesn't flag it as undefined.
+ const closeModalIfDefined = () => {
+ if (typeof window.closeProgressModal === 'function') {
+ window.closeProgressModal();
+ }
+ };
+
if (data.error) {
setTimeout(() => {
- closeProgressModal();
+ closeModalIfDefined();
alert(data.error);
}, 1000);
} else {
setTimeout(() => {
- closeProgressModal();
+ closeModalIfDefined();
onSuccess(data);
}, 2000);
}
diff --git a/tests/ui_tests/test_metrics_chart.js b/tests/ui_tests/test_metrics_chart.js
index ebfc41f9ea..26485599bb 100644
--- a/tests/ui_tests/test_metrics_chart.js
+++ b/tests/ui_tests/test_metrics_chart.js
@@ -4,9 +4,10 @@ const { getPuppeteerLaunchOptions } = require('./puppeteer_config');
(async () => {
const browser = await puppeteer.launch(getPuppeteerLaunchOptions());
- const chartLoaded = await page.evaluate(() => typeof Chart !== 'undefined');
- console.log('Chart.js loaded on main metrics page:', chartLoaded);
+ const page = await browser.newPage();
+ const chartLoaded = await page.evaluate(() => typeof Chart !== 'undefined');
+ console.log('Chart.js loaded on main metrics page:', chartLoaded);
- await new Promise(resolve => setTimeout(resolve, 1000));
- await browser.close();
+ await new Promise(resolve => setTimeout(resolve, 1000));
+ await browser.close();
})();