# no-inline-comments

> Disallow comments on the same line as code

A comment next to code makes the line longer, and it's easy to miss when you scan down the left edge of a file. With this rule, every comment goes on its own line.

Comments that configure the linter, such as `// eslint-disable-line`, aren't reported.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. To turn it on:

```toml bunfig.toml
[lint.rules]
"no-inline-comments" = "error" # or "warn"
```

Every option, set to its default. The ones that are commented out are unset by default.

```toml bunfig.toml
[lint.rules]
"no-inline-comments" = ["error", {
  # ignorePattern = <string>,
}]
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad {"count": 3} */}
```js
const retries = 3; // the network is flaky
const timeout = /* seconds */ 30;
/* legacy */ connect(retries, timeout);
```

Not reported:

{/* good */}
```js
// The network is flaky.
const retries = 3;

/* In seconds. */
const timeout = 30;

connect(retries, timeout); // eslint-disable-line no-undef
```

In JSX, a comment in braces is fine if nothing else shares a line with the braces:

{/* good */}
```jsx
const page = (
  <main>
    {/* The header comes from the layout. */}
    <Article />
  </main>
);
```

{/* bad */}
```jsx
const page = (
  <main>
    <Article /> {/* The header comes from the layout. */}
  </main>
);
```

## Options

| Option | Default | What it does |
| --- | --- | --- |
| `ignorePattern` | none | A regular expression. A comment whose text matches it isn't reported. |

{/* good {"options": [{"ignorePattern": "webpackChunkName"}]} */}
```js
const locale = import(/* webpackChunkName: "locale-en" */ "./locale/en.js");
```

{/* bad {"options": [{"ignorePattern": "webpackChunkName"}]} */}
```js
const locale = import(/* the default */ "./locale/en.js");
```
