lint-my-lines is an ESLint plugin that provides a set of rules to enforce a clear, effective, and maintainable style for code comments.
Good comments are a crucial part of high-quality code, but they are often neglected. This project aims to help developers improve their commenting habits by providing real-time feedback within their code editor.
minimal, recommended, strict, or language-specific presets.Download the pre-built binary for your platform from GitHub Releases:
| Platform | Download |
|---|---|
| Windows | lint-my-lines-win-x64.exe |
| macOS (Intel) | lint-my-lines-macos-x64 |
| macOS (Apple Silicon) | lint-my-lines-macos-arm64 |
| Linux | lint-my-lines-linux-x64 |
# Make executable (macOS/Linux)
chmod +x lint-my-lines-macos-arm64
# Lint current directory
./lint-my-lines lint
# Lint specific files
./lint-my-lines lint src/**/*.js
# Use strict preset
./lint-my-lines lint --preset strict
# Auto-fix issues
./lint-my-lines lint --fix
# Output as JSON
./lint-my-lines lint --format json
npm install eslint-plugin-lint-my-lines --save-dev
The fastest way to configure lint-my-lines:
# Generate ESLint config with recommended preset
npx lint-my-lines init
# Use a different preset
npx lint-my-lines init --preset strict
# For ESLint v8 (legacy config)
npx lint-my-lines init --no-flat
// eslint.config.js
import lintMyLines from "eslint-plugin-lint-my-lines";
export default [
lintMyLines.configs["flat/recommended"],
];
// .eslintrc.js
module.exports = {
extends: ["plugin:lint-my-lines/recommended"]
};
| Preset | Description | Rules |
|---|---|---|
plugin:lint-my-lines/minimal |
Essential comment hygiene | 4 rules |
plugin:lint-my-lines/recommended |
Balanced defaults for most projects | 8 rules |
plugin:lint-my-lines/strict |
Maximum enforcement for high-quality codebases | 14 rules |
plugin:lint-my-lines/analysis |
Advanced analysis (stale detection, aging, ratios) | 3 rules |
plugin:lint-my-lines/accessibility |
Accessibility-focused comment rules | 3 rules |
You can also configure individual rules:
{
"plugins": ["lint-my-lines"],
"rules": {
"lint-my-lines/enforce-todo-format": "warn",
"lint-my-lines/no-commented-code": "error",
"lint-my-lines/enforce-capitalization": "warn"
}
}
Start with a preset and customize as needed:
// .eslintrc.js
module.exports = {
extends: ["plugin:lint-my-lines/recommended"],
rules: {
// Override specific rules
"lint-my-lines/enforce-comment-length": ["error", { maxLength: 80 }],
// Disable a rule from the preset
"lint-my-lines/ban-specific-words": "off"
}
};
| Rule | Description | Fixable |
|---|---|---|
| enforce-todo-format | Enforce TODO (ref): description format |
✅ |
| enforce-fixme-format | Enforce FIXME (ref): description format |
✅ |
| enforce-note-format | Enforce NOTE (ref): description format |
✅ |
| enforce-comment-length | Enforce min/max comment length | |
| enforce-capitalization | Require capital letter at start | ✅ |
| comment-spacing | Require space after // and * |
✅ |
| Rule | Description | Fixable |
|---|---|---|
| no-commented-code | Detect commented-out code | |
| no-obvious-comments | Detect comments that restate code | |
| ban-specific-words | Ban vague/non-inclusive terms | ✅ |
| require-explanation-comments | Require comments for complex code |
| Rule | Description | Fixable |
|---|---|---|
| require-jsdoc | Require JSDoc for exported functions | ✅ |
| valid-jsdoc | Validate JSDoc matches function signature | ✅ |
| valid-tsdoc | Validate TSDoc-specific tags | |
| jsdoc-type-syntax | Enforce consistent type syntax | ✅ |
| require-file-header | Require file header comments | ✅ |
| Rule | Description | Fixable |
|---|---|---|
| vue-template-comments | Lint HTML comments in Vue templates | |
| svelte-template-comments | Lint HTML comments in Svelte markup |
| Rule | Description | Fixable |
|---|---|---|
| stale-comment-detection | Detect comments referencing non-existent code | |
| todo-aging-warnings | Warn on old TODO/FIXME comments | |
| comment-code-ratio | Report under/over-documented files | |
| issue-tracker-integration | Validate ticket IDs in issue trackers |
| Rule | Description | Fixable |
|---|---|---|
| accessibility-todo-format | Enforce A11Y-TODO (ref): desc format |
✅ |
| require-alt-text-comments | Require comments for UI elements | |
| screen-reader-context | Require screen reader behavior docs |
See the Accessibility Guide for best practices on documenting accessibility in your codebase.
{
"lint-my-lines/enforce-todo-format": "warn",
"lint-my-lines/enforce-fixme-format": "warn",
"lint-my-lines/enforce-note-format": "warn",
"lint-my-lines/no-commented-code": "warn"
}
Includes everything in minimal, plus:
{
"lint-my-lines/enforce-comment-length": ["warn", { maxLength: 120 }],
"lint-my-lines/enforce-capitalization": "warn",
"lint-my-lines/comment-spacing": "warn",
"lint-my-lines/ban-specific-words": ["warn", { includeDefaults: true }]
}
Includes everything in recommended (as errors), plus:
{
"lint-my-lines/no-obvious-comments": ["warn", { sensitivity: "medium" }],
"lint-my-lines/require-explanation-comments": ["warn", { requireFor: ["regex", "bitwise"] }],
"lint-my-lines/require-jsdoc": "warn",
"lint-my-lines/valid-jsdoc": "warn",
"lint-my-lines/jsdoc-type-syntax": ["warn", { prefer: "typescript" }],
"lint-my-lines/require-file-header": ["warn", { requiredTags: ["@file"] }]
}
Advanced analysis rules for code quality insights:
{
"lint-my-lines/stale-comment-detection": "warn",
"lint-my-lines/todo-aging-warnings": ["warn", { maxAgeDays: 30 }],
"lint-my-lines/comment-code-ratio": ["warn", { minRatio: 0.05, maxRatio: 0.40 }]
// issue-tracker-integration requires configuration
}
Note: issue-tracker-integration requires explicit configuration for your tracker. See issue-tracker-integration docs.
With Husky and lint-staged:
{
"lint-staged": {
"*.{js,ts}": "eslint --fix"
}
}
Copy the workflow from .github/workflows/lint-comments.yml or create your own:
- run: npm ci
- run: npx eslint .
See the full Integration Guide for CI/CD, editor setup, and monorepo configurations. Check the FAQ for common questions and troubleshooting tips.
lint-my-lines supports multiple languages and frameworks:
| Language/Framework | Preset | Features |
|---|---|---|
| JavaScript | recommended |
All rules |
| TypeScript | typescript |
All rules + TSDoc validation |
| JSX/TSX (React) | react |
JSX-aware autofix |
| Vue | vue |
Template HTML comment linting |
| Svelte | svelte |
Template HTML comment linting |
| Markdown | markdown |
Code block linting |
// eslint.config.js
import lintMyLines from "eslint-plugin-lint-my-lines";
export default [
lintMyLines.configs["flat/recommended"],
lintMyLines.configs["flat/typescript"],
lintMyLines.configs["flat/vue"],
];
See the Integration Guide for detailed setup instructions.
This project is licensed under the MIT License. See the LICENSE file for details.