Registry / testing / eslint-plugin-comment-length

eslint-plugin-comment-length

JSON →
library2.3.1jsnpmunverified

ESLint plugin limiting comment line length to improve readability. Version 2.3.1, maintained, actively updated. Provides rules like 'comment-length/max-len' and 'comment-length/reflow' to enforce max length in comments, including options for block vs line comments. Works with ESLint >=8.0.0, ships TypeScript types. Key differentiator: focuses solely on comment formatting, unlike general max-len rules which affect code.

npm install eslint-plugin-comment-length
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-COMM
E
eslint-plugin-comment-length
testingjavascriptv2.3.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import plugin from 'eslint-plugin-comment-length'
const plugin = require('eslint-plugin-comment-length')
ESLint plugins are typically imported as default and added to 'plugins' array. Requires ESLint >=8.0.0.
rules
import { rules } from 'eslint-plugin-comment-length'
Named export for rules is available for advanced usage like custom rule mapping.
configs
import { configs } from 'eslint-plugin-comment-length'
Exported config presets (e.g. 'recommended') for easy setup.

Configures ESLint to enforce max line length in comments (80 chars) and auto-fix comment reflow, using the comment-length plugin.

// .eslintrc.js module.exports = { plugins: ['comment-length'], rules: { 'comment-length/max-len': ['error', { maxLen: 80, commentsOnly: true }], 'comment-length/reflow': ['error', { maxLen: 80, autoFix: true }] } };
Debug
Known issues
breakingv2.0.0 changed rule names from 'max-len' to 'comment-length/max-len'
fix
Update rule names to include the plugin prefix 'comment-length/'
affects: <2.0.0
deprecatedv1.x.x is deprecated and no longer supported; upgrade to v2.x.x
fix
Update to v2.3.1: npm install eslint-plugin-comment-length@latest
affects: <2.0.0
gotchaThe 'reflow' rule auto-fixes comments which may alter visual alignment; use with caution
fix
Review auto-fix changes before applying; consider using 'suggest' mode first
affects: >=2.0.0
gotchaESLint >=8.0.0 required; does not work with ESLint <8
fix
Ensure ESLint version is 8 or higher
affects: >=2.0.0
Errors
Common errors & fixes
Error: Failed to load plugin 'comment-length': Cannot find module 'eslint-plugin-comment-length'
Plugin not installed in local node_modules; missing dependency
fix
Run: npm install eslint-plugin-comment-length --save-dev
Configuration for rule 'comment-length/max-len' is invalid: Value ["error", {"maxLen": 80, "commentsOnly": true}] is not an array
Misplaced rule options; rule config must be an array with severity and options object
fix
Use: 'comment-length/max-len': ['error', { maxLen: 80, commentsOnly: true }]
Parsing error: The keyword 'import' is reserved
Using import syntax without proper parser (e.g. babel-eslint) or in CommonJS file
fix
Use require syntax for CommonJS or install babel-eslint for ES modules
Upgrade
Version history
2.3.1latest on npm
Audit
Dependencies
eslintrequiredpeer dependency; plugin is an ESLint plugin and requires ESLint >=8.0.0
Agent activity
5 hits · last 30 days
node
4
Resources
eslint-plugin-comment-length — npm install eslint-plugin-comment-length · libregistry