eslint-plugin-comment-length

raw JSON →
2.3.1 verified Sat May 09 auth: no javascript

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.

error Error: Failed to load plugin 'comment-length': Cannot find module 'eslint-plugin-comment-length'
cause Plugin not installed in local node_modules; missing dependency
fix
Run: npm install eslint-plugin-comment-length --save-dev
error Configuration for rule 'comment-length/max-len' is invalid: Value ["error", {"maxLen": 80, "commentsOnly": true}] is not an array
cause 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 }]
error Parsing error: The keyword 'import' is reserved
cause 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
breaking v2.0.0 changed rule names from 'max-len' to 'comment-length/max-len'
fix Update rule names to include the plugin prefix 'comment-length/'
deprecated v1.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
gotcha The '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
gotcha ESLint >=8.0.0 required; does not work with ESLint <8
fix Ensure ESLint version is 8 or higher
npm install eslint-plugin-comment-length
yarn add eslint-plugin-comment-length
pnpm add eslint-plugin-comment-length

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 }]
  }
};