# no-inline-comments

Rule `eslint/no-inline-comments`. Disallow inline comments after code

- Source: eslint
- Technologies: JavaScript
- Kind: suspicious
- Needs type information: no
- Autofix: no
- Reach: 2.1M weekly downloads of presets that enable it
- Trend: +151.7% last quarter
- Rank: #1514 by reach, #18 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `no-inline-comments` | no | no | package `eslint` | [docs](https://eslint.org/docs/latest/rules/no-inline-comments) |
| Oxlint | `no-inline-comments` | no | no | plugin `eslint`, category pedantic | [docs](https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-inline-comments.html) |

## Code examples

### Incorrect: the rule reports this

```js
const a = 1; // declaring a to 1

function getRandomNumber(){
    return 4; // chosen by fair dice roll.
              // guaranteed to be random.
}

/* A block comment before code */ const b = 2;

const c = 3; /* A block comment after code */
```

```jsx
const foo = <div>{ /* On the same line with other code */ }<h1>Some heading</h1></div>;

const bar = (
    <div>
    {   // These braces are not just for the comment, so it can't be on the same line
        baz
    }
    </div>
);
```

### Correct: the rule accepts this

```js
// This is a comment above a line of code
const foo = 5;

const bar = 5;
//This is a comment below a line of code
```

```jsx
const foo = (
    <div>
      {/* These braces are just for this comment and there is nothing else on this line */}
      <h1>Some heading</h1>
    </div>
)

const bar = (
    <div>
    {
        // There is nothing else on this line
        baz
    }
    </div>
);

const quux = (
    <div>
      {/*
        Multiline
        comment
      */}
      <h1>Some heading</h1>
    </div>
)
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
export default [
  {
    rules: {
      "no-inline-comments": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "no-inline-comments": "error"
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Ultracite for Oxlint](https://lintradar.dev/presets/ultracite-oxlint.md) | Oxlint | `ultracite` | 475 | 2.1M | +151.7% |

## Related rules

- [eslint/no-duplicate-imports](https://lintradar.dev/rules/eslint/no-duplicate-imports.md): Disallow duplicate module imports
- [eslint/sort-vars](https://lintradar.dev/rules/eslint/sort-vars.md): Require variables within the same declaration block to be sorted
- [eslint/id-match](https://lintradar.dev/rules/eslint/id-match.md): Require identifiers to match a specified regular expression
- [eslint/id-denylist](https://lintradar.dev/rules/eslint/id-denylist.md): Disallow specified identifiers
- [eslint/func-style](https://lintradar.dev/rules/eslint/func-style.md): Enforce the consistent use of either `function` declarations or expressions assigned to variables
- [eslint/require-await](https://lintradar.dev/rules/eslint/require-await.md): Disallow async functions which have no `await` expression

---

Web page: https://lintradar.dev/rules/eslint/no-inline-comments. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
