Skip to content

mdx/code-blocks doesn't respect eslint-disable from outside of the block #534

Open
@rainecheck

Description

@rainecheck

Initial checklist

Affected packages and versions

eslint-plugin-mdx-3.1.5

Link to runnable example

No response

Steps to reproduce

The following contents report

**:2 warning Unused eslint-disable directive (no problems were reported)
**:7 error 'deployProjectCommand' is never reassigned. Use 'const' instead prefer-const


{/* eslint-disable prefer-const */}
```ts

import { CommandRegister } from "@foo";
export function registerCommands(commandRegister: CommandRegister) {
  let deployProjectCommand: DeployProjectCommand = new DeployProjectCommand();
  commandRegister.addCommand(deployProjectCommand);
}
```
{/* eslint-enable prefer-const */}

Whereas this is correctly ignoring the linting error.


```ts
{/* eslint-disable prefer-const */}
import { CommandRegister } from "@foo";
export function registerCommands(commandRegister: CommandRegister) {
  let deployProjectCommand: DeployProjectCommand = new DeployProjectCommand();
  commandRegister.addCommand(deployProjectCommand);
}
{/* eslint-enable prefer-const */}
```

Expected behavior

Both should correctly suppress the linting error.

Actual behavior

Only eslint-disables inside the block suppress the error. This means that the eslint-disable comment is visible inside the codeblock.

I've searched through issues and haven't found anything directly related to this, but given the response here this might be something from a dependency - if someone can confirm this, I'm happy to raise it there alternatively.

Runtime

Node v20

Package manager

yarn v1

OS

macOS

Build and bundle tools

Docusaurus

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions