eslint-rule-docs

raw JSON →
1.1.235 verified Sat Apr 25 auth: no javascript

A utility library (v1.1.235) that returns the documentation URL for a given ESLint rule, supporting both core rules and known plugins. Updated daily via cron job to keep plugin mappings current. Differentiates itself from manual lookup by providing exact-match URLs for core rules, per-plugin documentation for known plugins (e.g., React, Flowtype), and fallback to repository URL or empty object for unknown plugins. Works in Node.js with CommonJS/ESM.

error Cannot find module 'eslint-rule-docs'
cause Package not installed or not in node_modules.
fix
Run npm install eslint-rule-docs
error getRuleUrl is not a function
cause Wrong import style: imported as named export instead of default.
fix
Use import getRuleUrl from 'eslint-rule-docs' or const getRuleUrl = require('eslint-rule-docs')
error TypeError: getRuleUrl is not a function
cause Attempted to destructure import incorrectly, e.g., `const { getRuleUrl } = require('eslint-rule-docs')`.
fix
Import default: import getRuleUrl from 'eslint-rule-docs'
error {} returned for a rule I know exists
cause Plugin is not included in the library's mapping.
fix
Check the list of supported plugins; if missing, contribute to the database or use the fallback manual URL.
gotcha The rule name must be exactly as ESLint expects (e.g., 'no-undef', not 'no_undef').
fix Use the official rule name (kebab-case for core rules, slash-separated for plugins).
gotcha Plugin rules are only supported if the plugin is known to the library; unknown plugins return an empty object.
fix Check if result has an 'exactMatch' property or a 'url' property to determine if it was found.
gotcha URLs for core rules point to eslint.org/docs/rules/, which may change if ESLint updates its documentation structure.
fix Do not rely on the URL being permanent; always fetch the latest version of the library.
deprecated The package may rely on outdated mappings for deprecated ESLint rules.
fix Check ESLint core rules documentation for removed rules; the library may still return old URLs.
gotcha The library only returns one URL per rule; it does not support multiple documentation sources.
fix If you need multiple URLs, consider additional sources or fork the package.
npm install eslint-rule-docs
yarn add eslint-rule-docs
pnpm add eslint-rule-docs

Demonstrates usage to get rule documentation URLs for core ESLint rules, plugin rules, and unknown rules.

const getRuleUrl = require('eslint-rule-docs');

const coreResult = getRuleUrl('no-undef');
console.log(coreResult);
// { exactMatch: true, url: 'https://eslint.org/docs/rules/no-undef' }

const pluginResult = getRuleUrl('react/sort-prop-types');
console.log(pluginResult);
// { exactMatch: true, url: 'https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-prop-types.md' }

const unknownResult = getRuleUrl('unknown-foo/bar');
console.log(unknownResult);
// {}