{"record":{"id":"e532b2d8236595a9","repo":"denoland/deno","slug":"linter-plugin-plugin-name-has-already-been-regi","errorCode":null,"errorMessage":"Linter plugin ${plugin.name} has already been registered","messagePattern":"Linter plugin (.+?) has already been registered","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/js/40_lint.js","lineNumber":507,"sourceCode":"    throw new Error(\n      `${prefix}Linter plugin name must only contain lowercase letters (a-z) or hyphens (-).`,\n    );\n  }\n  if (plugin.name.startsWith(\"-\") || plugin.name.endsWith(\"-\")) {\n    throw new Error(\n      `${prefix}Linter plugin name must start and end with a lowercase letter.`,\n    );\n  }\n  if (plugin.name.includes(\"--\")) {\n    throw new Error(\n      `${prefix}Linter plugin name must not have consequtive hyphens.`,\n    );\n  }\n  if (typeof plugin.rules !== \"object\") {\n    throw new Error(`${prefix}Linter plugin rules must be an object`);\n  }\n  if (state.installedPlugins.has(plugin.name)) {\n    throw new Error(`Linter plugin ${plugin.name} has already been registered`);\n  }\n  state.plugins.push(plugin);\n  state.installedPlugins.add(plugin.name);\n\n  return {\n    name: plugin.name,\n    ruleNames: Object.keys(plugin.rules),\n  };\n}\n\n/**\n * @param {AstContext} ctx\n * @param {number} idx\n * @returns {FacadeNode | null}\n */\nfunction getNode(ctx, idx) {\n  if (idx === AST_IDX_INVALID) return null;\n  const cached = ctx.nodes.get(idx);","sourceCodeStart":489,"sourceCodeEnd":525,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/js/40_lint.js#L489-L525","documentation":"The linter keeps a per-instance set of installed plugin names (state.installedPlugins in cli/js/40_lint.js). Installing a second plugin with a name already in that set throws `Linter plugin <name> has already been registered`. Unlike the validation errors, this message has no specifier prefix — only the offending plugin name is included.","triggerScenarios":"The same plugin name installed twice in one linter run: the same module listed twice in `lint.plugins` under different specifiers (e.g. a URL and a local path that resolve to the same code), two different files exporting plugins with the same `name`, or a programmatic caller invoking installPlugins twice with the same list.","commonSituations":"Listing a plugin both by absolute path and relative path in config; a monorepo where two teams shipped plugins with a generic name like \"lint-rules\"; refactoring that left an old entry and a new entry pointing at the same plugin.","solutions":["Deduplicate the `lint.plugins` list so each plugin module is listed once under one canonical specifier.","If two genuinely different plugins collide, rename one of them to a unique lowercase-hyphen name.","Search the plugin sources for `name:` exports to find which two files claim the same name (the error message names it)."],"exampleFix":"// deno.json before\n{\n  \"lint\": {\n    \"plugins\": [\"./rules/mod.js\", \"https://example.com/rules/mod.js\"]\n  }\n}\n\n// after\n{\n  \"lint\": {\n    \"plugins\": [\"./rules/mod.js\"]\n  }\n}","handlingStrategy":"validation","validationCode":"// Before listing plugins, load them and deduplicate by name\nconst plugins = [await import(\"./a.js\"), await import(\"./b.js\")];\nconst seen = new Set();\nfor (const p of plugins) {\n  if (seen.has(p.default.name)) {\n    throw new Error(`Duplicate lint plugin name: ${p.default.name}`);\n  }\n  seen.add(p.default.name);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep one canonical specifier per plugin in lint.plugins; do not list both a path and a URL for the same module.","Give shared/monorepo plugins distinctive names to avoid collisions across teams.","If the error appears, grep plugin sources for `name:` to find the two files claiming the name in the message."],"tags":["deno","deno-lint","lint-plugin","duplicate","registration"],"backgroundTag":"duplicate-plugin-registration","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}