eslint-plugin-apidoc
raw JSON → 0.0.7 verified Fri May 01 auth: no javascript
An ESLint plugin for linting apidoc.json configuration files based on API style rules. Version 0.0.7 is the latest release. It provides rules to enforce base URL, contact information, and description presence for APIs and resources. Designed to integrate with ESLint, it allows developers to validate apidoc.json files as part of their linting process. The plugin is minimal, with only a few rules, and requires ESLint as a peer dependency. It is not actively maintained, with no recent updates.
Common errors
error Error: Failed to load plugin 'apidoc': Cannot find module 'eslint-plugin-apidoc' ↓
cause Plugin not installed or ESLint cannot resolve it.
fix
Run 'npm install eslint-plugin-apidoc --save-dev'
error Error: Cannot read property 'base-url' of undefined ↓
cause Missing 'apidoc/' prefix in rule name.
fix
Use 'apidoc/base-url' instead of 'base-url'
error Parsing error: Unexpected token ↓
cause apidoc.json file is not valid JSON or missing.
fix
Ensure the file is valid JSON and exists.
Warnings
gotcha Package is not widely maintained; no updates since 2017. May have compatibility issues with modern ESLint versions. ↓
fix Consider forking or using an alternative if issues arise.
gotcha The plugin only works with apidoc.json files; it does not parse inline JSDoc annotations for apiDoc. ↓
fix Ensure your apiDoc configuration is in a separate JSON file.
Install
npm install eslint-plugin-apidoc yarn add eslint-plugin-apidoc pnpm add eslint-plugin-apidoc Imports
- apidoc wrong
import { apidoc } from 'eslint-plugin-apidoc'correct"plugins": ["apidoc"] - rules wrong
"rules": { "base-url": 2 }correct"rules": { "apidoc/base-url": 2 } - require('eslint-plugin-apidoc') wrong
import plugin from 'eslint-plugin-apidoc'; // CJS module, default import failscorrectconst plugin = require('eslint-plugin-apidoc'); // in ESM context, use createRequire
Quickstart
// .eslintrc.json
{
"plugins": ["apidoc"],
"rules": {
"apidoc/base-url": ["error", { "domain": "example.com" }],
"apidoc/contact": "error",
"apidoc/description": "warn"
}
}
// Run: eslint apidoc.json