denoland/deno · error · Error

Linter plugin name must be a string

Error message

${prefix}Linter plugin name must be a string

What it means

While mirroring remote modules for the stock-tsc compatibility layer, `write_mirror` maps each URL to `<remote_root>/<host>/<path>` via `url_to_local_path`. That mapping returns None when the URL has no host or its path is empty/ends with `/` (a directory-like URL — no index filename can be inferred without server cooperation). Such a URL cannot be mirrored to a file, so the error names it.

Solutions

  1. Import a concrete file URL: `import "https://example.com/lib/mod.ts"` instead of `https://example.com/lib/`
  2. If the trailing-slash import is in a third-party module, use an import map to alias it to the concrete file
  3. Vendor the dependency locally so no remote mirror path is needed

Example fix

// before
import { helper } from "https://example.com/lib/";
// URL has no resolvable mirror path: https://example.com/lib/

// after
import { helper } from "https://example.com/lib/mod.ts";
Defensive patterns

Strategy: type-guard

Validate before calling

// Flag directory-like remote imports before running check/sync-types
export function isMirrorableUrl(specifier: string): boolean {
  try {
    const u = new URL(specifier);
    return !!u.host && u.pathname !== "" && !u.pathname.endsWith("/");
  } catch {
    return false;
  }
}

Type guard

function isMirrorableUrl(url: string): boolean {
  const u = new URL(url);
  return u.host.length > 0 && u.pathname.length > 0 && !u.pathname.endsWith("/");
}

Prevention

When it happens

Trigger: The module graph built during `deno check`/`deno sync-types` (npm-compat path) contains a remote import of a directory-style URL, e.g. `import "https://example.com/lib/"` or a bare-host URL, and the fetched module is about to be written into the local mirror.

Common situations: Code written for the web where the server redirects directory imports to an index file; hand-written imports with trailing slashes; dependencies that themselves import directories via redirects (works in deno's runtime resolution but has no filename to mirror).

Related errors


AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20). Data as JSON: /api/errors/62aed8c650f9945b. Report an issue: GitHub.

Appendix: source

Thrown at cli/js/40_lint.js:486

  return plugins.map((plugin, i) => installPlugin(plugin, specifiers?.[i]));
}

/**
 * @param {Deno.lint.Plugin} plugin
 * @param {string} [specifier] The specifier the plugin was loaded from, if any.
 */
function installPlugin(plugin, specifier) {
  // When the plugin was loaded from a specifier (i.e. `lint.plugins` in the
  // config), prefix validation errors with it so the user knows which plugin
  // is misbehaving instead of getting an anonymous error.
  const prefix = typeof specifier === "string"
    ? `Failed to load lint plugin '${specifier}': `
    : "";
  if (typeof plugin !== "object") {
    throw new Error(`${prefix}Linter plugin must be an object`);
  }
  if (typeof plugin.name !== "string") {
    throw new Error(`${prefix}Linter plugin name must be a string`);
  }
  if (!/^[a-z-]+$/.test(plugin.name)) {
    throw new Error(
      `${prefix}Linter plugin name must only contain lowercase letters (a-z) or hyphens (-).`,
    );
  }
  if (plugin.name.startsWith("-") || plugin.name.endsWith("-")) {
    throw new Error(
      `${prefix}Linter plugin name must start and end with a lowercase letter.`,
    );
  }
  if (plugin.name.includes("--")) {
    throw new Error(
      `${prefix}Linter plugin name must not have consequtive hyphens.`,
    );
  }
  if (typeof plugin.rules !== "object") {
    throw new Error(`${prefix}Linter plugin rules must be an object`);

View on GitHub (pinned to 9ad36f7a2c)