{"record":{"id":"d49ab671aa224656","repo":"denoland/deno","slug":"deno-lint-runplugin-is-only-available-in-deno-t","errorCode":null,"errorMessage":"`Deno.lint.runPlugin` is only available in `deno test` subcommand.","messagePattern":"`Deno\\.lint\\.runPlugin` is only available in `deno test` subcommand\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"runtime/js/99_main.js","lineNumber":814,"sourceCode":"noopTest.only.each = noopTestEach;\nnoopTest.ignore.each = noopTestEach;\n// Build finalDenoNs without spreading denoNs: spread invokes every getter,\n// including the lazy ones (Deno.serve / Deno.run / etc.) that intentionally\n// avoid loading 06_streams / 22_body / 40_process at snapshot time. Use\n// ObjectDefineProperties + getOwnPropertyDescriptors to preserve the lazy\n// descriptors.\nconst finalDenoNs = ObjectDefineProperties(\n  {\n    internal: internalSymbol,\n    [internalSymbol]: internals,\n    // Deno.test, Deno.bench, Deno.lint are noops here, but kept for\n    // compatibility; so that they don't cause errors when used outside of\n    // `deno test`/`deno bench`/`deno lint` contexts.\n    test: noopTest,\n    bench: () => {},\n    lint: {\n      runPlugin: () => {\n        throw new Error(\n          \"`Deno.lint.runPlugin` is only available in `deno test` subcommand.\",\n        );\n      },\n    },\n  },\n  getSafeOwnPropertyDescriptors(denoNs),\n);\n\nObjectDefineProperties(finalDenoNs, {\n  pid: core.propGetterOnly(opPid),\n  // `ppid` should not be memoized.\n  // https://github.com/denoland/deno/issues/23004\n  ppid: core.propGetterOnly(() => op_ppid()),\n  noColor: core.propGetterOnly(() => op_bootstrap_no_color()),\n  args: core.propGetterOnly(opArgs),\n  mainModule: core.propGetterOnly(() => op_main_module()),\n  exitCode: {\n    __proto__: null,","sourceCodeStart":796,"sourceCodeEnd":832,"githubUrl":"https://github.com/denoland/deno/blob/a961cdec3b1948844414ebeecc697dcad76df2d1/runtime/js/99_main.js#L796-L832","documentation":"In the standard runtime bootstrap, Deno.lint is a compatibility stub: test and bench are no-ops, and lint.runPlugin is a function whose only job is to throw, stating it is available only under the lint-capable subcommands. The real implementation is installed later by cli/js/40_lint.js when the process runs `deno lint` (and lint plugin tests under `deno test`); anywhere else the call throws this Error.","triggerScenarios":"Calling Deno.lint.runPlugin(...) under `deno run`, `deno repl`, or in module code imported into a normal program; sharing lint-plugin source files between lint rules and regular scripts so the call executes in the wrong context.","commonSituations":"Lint plugin development where plugin modules are exercised by `deno test`; CI jobs importing plugin files for type-checking that accidentally execute them; unstable API churn across Deno versions.","solutions":["Run plugin code under `deno test` (or `deno lint`), where 40_lint.js installs the real implementation","Keep plugin entry points side-effect free so importing them elsewhere never calls runPlugin","Guard the call with try/catch or your own context flag and skip when unavailable","Check the current Deno version's lint plugin docs — the API is unstable and has shifted between releases"],"exampleFix":"// before\nDeno.lint.runPlugin(visitor, ast);\n\n// after\ntry {\n  Deno.lint.runPlugin(visitor, ast);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('only available')) return; // not a lint context\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  Deno.lint.runPlugin(visitor, ast);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('only available')) {\n    return; // not running under deno test / deno lint — skip\n  }\n  throw e;\n}","preventionTips":["Run plugin logic only under deno test or deno lint, where the real implementation is installed","Keep plugin modules free of top-level runPlugin calls — export registered rules instead","Gate execution behind your own context flag or environment variable","Watch unstable-API changelogs when upgrading Deno"],"tags":["lint","plugins","subcommand","deno-test","unstable"],"backgroundTag":"wrong-subcommand-context","analyzedSha":"a961cdec3b1948844414ebeecc697dcad76df2d1","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}