complete/format-line-comments
💼 This rule is enabled in the ✅ recommended config.
📝 Disallows // comments longer than N characters and multi-line comments that
can be merged together.
🔧 This rule is automatically fixable by the
--fix CLI option.
⚙️ This rule is configurable.
Like Prettier, this rule is designed to auto-format your
comments so that you don’t have to think about it. Try
configuring your IDE to run
eslint --fix on save.
Also see the
format-jsdoc-comments
rule.
For more information on why you should use this rule, see the comment formatting discussion.
Rule Details
Section titled “Rule Details”Lines that are too long will be split to the next line:
// Bad// Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
// Good// Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut// labore et dolore magna aliqua.Lines that are too short will be merged together:
// Bad// Lorem ipsum dolor sit amet,// consectetur adipiscing elit
// Good// Lorem ipsum dolor sit amet, consectetur adipiscing elitThe rule tries to be as smart as possible. For example, it won’t complain about TypeScript triple slash directives:
/// <reference path="foo.d.ts" />You can open a GitHub issue if you find a situation where this rule should be smarter.
Options
Section titled “Options”{ "rules": { "complete/format-line-comments": [ "error", { "maxLength": 100 } ] }}