Skip to main content
Skip to Content
interlace
Plugin: conventionsRules

no-json-schema-tags

Disallow JSON Schema keywords (e.g. @minimum, @maximum, @pattern, @format) used as JSDoc tags.

Next step

no-json-schema-tags ships in eslint-plugin-conventions, with 6 of its 20 rules in the recommended preset.

Install
npm install -D eslint-plugin-conventions
eslint.config.js
import { configs } from 'eslint-plugin-conventions';

export default [configs.recommended];

Plugin pagenpmSource on GitHub

Disallow JSON Schema keywords (e.g. @minimum, @maximum, @pattern, @format) used as JSDoc tags. These keywords are valid in OpenAPI / JSON Schema documents but not in JSDoc; they fail in projects with strict tag validation (e.g. DefinitelyTyped, TSDoc-strict CI).

This rule is part of eslint-plugin-conventions.

Quick Summary

AspectDetails
SeverityMedium (Quality)
Auto-Fix💡 Suggestions
CategoryConventions
ESLint MCP✅ Optimized for ESLint MCP integration
Best ForLibraries published to npm; codebases that publish TypeScript types externally

Why these tags don't belong in JSDoc

JSDoc and TSDoc define a finite tag vocabulary (@param, @returns, @throws, @deprecated, …). JSON Schema keywords like @minimum, @maximum, @pattern and @format look like JSDoc tags but are not recognized by:

  • The TypeScript compiler's strict TSDoc mode (tsdoc.json → noStandardTags).
  • DefinitelyTyped's lint suite (dtslint).
  • IDE tooling that ships type-aware JSDoc autocomplete.

They originate from people generating OpenAPI specs from TypeScript types and leaking constraint annotations into the source. The constraint belongs in the description prose, not in a synthetic tag.

Examples

❌ Incorrect

/**
 * @param age The user's age.
 * @minimum 0
 * @maximum 150
 */
function setAge(age: number) {}

/**
 * @param email Contact email.
 * @format email
 */
function setEmail(email: string) {}

✅ Correct

/**
 * @param age The user's age. Must be in the range [0, 150].
 */
function setAge(age: number) {}

/**
 * @param email Contact email. Must be a valid RFC 5322 address.
 */
function setEmail(email: string) {}

Error Message Format

⚠️ CONVENTIONS | @minimum is a JSON Schema keyword, not a valid JSDoc tag | MEDIUM
   Fix: Move the constraint into the @param description, or move the entire validation to a schema layer (zod, valibot, ajv).

What the rule reads

The rule reports a forbidden keyword written as a block tag in a JSDoc comment (/** … */): first on a line after the optional * gutter, or first in a one-line /** @format email */.

Forbidden by default: minimum, maximum, exclusiveMinimum, exclusiveMaximum, minLength, maxLength, minItems, maxItems, minProperties, maxProperties, multipleOf, pattern, uniqueItems, format, contentMediaType, contentEncoding.

It does not report:

  • @enum and @const — JSON Schema keywords, but also tags JSDoc itself defines (TypeScript reads @enum in JavaScript).
  • An @keyword inside prose (team@format.io, Range note: @minimum 1): it is description text, not a tag.
  • A plain block comment (/* … */) or a line comment: no JSDoc tool reads them as carrying tags.

Options

OptionTypeDefaultDescription
additionalForbiddenTagsstring[][]More tag names to report, on top of the default set
{
  rules: {
    'conventions/no-json-schema-tags': ['warn', { additionalForbiddenTags: ['openapi'] }],
  },
}

Known False Negatives

  • Project-specific tag allowlists in tsdoc.json are not consulted: a tag is reported only when it is in the default set or additionalForbiddenTags.

Use this rule

npm install -D eslint-plugin-conventions
eslint.config.js
import conventions from 'eslint-plugin-conventions';export default [  {    plugins: { 'conventions': conventions },    rules: {      'conventions/no-json-schema-tags': 'error'    },  },];
npm install -D oxlint-plugin-conventions
.oxlintrc.json
{  "jsPlugins": ["oxlint-plugin-conventions"],  "rules": {    "conventions/no-json-schema-tags": "error"  }}
vite.config.ts
import { defineConfig } from 'vite-plus';export default defineConfig({  lint: {    jsPlugins: ['oxlint-plugin-conventions'],    rules: {      'conventions/no-json-schema-tags': 'error',    },  },});

oxlint-plugin-conventions re-exports eslint-plugin-conventions/oxlint: the same rules under the same IDs, and no ESLint install. Why oxlint.

Did this rule catch something? Star the repo to get new CWE coverage as we ship it — or follow the AI-code-security benchmarks behind these rules.