eslint-rule-documentation
raw JSON → 1.0.23 verified Sat Apr 25 auth: no javascript
A utility to retrieve the documentation URL for any ESLint rule, including core rules and many popular plugin rules. Current version 1.0.23 supports dozens of plugins like eslint-plugin-import, jest, react, typescript, and more. Updated periodically with contributions. Differentiates by being lightweight and community-driven for plugin URL mappings, unlike built-in ESLint lookups.
Common errors
error TypeError: getRuleURI is not a function ↓
cause Using mismatched import style (e.g., import { getRuleURI } from '...') in CommonJS.
fix
Use
const getRuleURI = require('eslint-rule-documentation'); error TypeError: ruleId must be a string ↓
cause Passing a non-string argument (e.g., number, object) to getRuleURI.
fix
Ensure ruleId is a string:
getRuleURI(String(ruleId)) error Cannot find module 'eslint-rule-documentation' ↓
cause Package not installed in node_modules.
fix
Run
npm install eslint-rule-documentation or yarn add eslint-rule-documentation. Warnings
gotcha The function returns an object with `found` and `url`; check `found` before using `url` to avoid linking to contribution page. ↓
fix Always check `result.found` before using `result.url`.
breaking Version 1.0.15: throws if ruleId is not a string (previously returned an object with found=false). ↓
fix Ensure ruleId is a string: `getRuleURI(String(ruleId))`.
deprecated No deprecations known, but many plugin URLs change; the package may not always be up-to-date. ↓
fix Check the plugin's actual docs or contribute updates to eslint-rule-documentation's plugins.json.
Install
npm install eslint-rule-documentation yarn add eslint-rule-documentation pnpm add eslint-rule-documentation Imports
- default wrong
import getRuleURI from 'eslint-rule-documentation';correctconst getRuleURI = require('eslint-rule-documentation'); - getRuleURI wrong
import { getRuleURI } from 'eslint-rule-documentation';correctconst getRuleURI = require('eslint-rule-documentation'); - getRuleURI wrong
const getRuleURI = require('eslint-rule-documentation').default;correctimport getRuleURI from 'eslint-rule-documentation'; // With esm shim
Quickstart
const getRuleURI = require('eslint-rule-documentation');
console.log(getRuleURI('no-var'));
// { found: true, url: 'https://eslint.org/docs/rules/no-var' }
console.log(getRuleURI('import/no-unresolved'));
// { found: true, url: 'https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unresolved.md' }