Skip to content

[bug] @eslint-react/react/no-dangerously-set-innerhtml-with-children doesn't fail with failing example #1163

@karlhorky

Description

@karlhorky

Describe the bug

Hi @Rel1cx, hope you're well! 👋

I noticed that the failing example code for @eslint-react/react/no-dangerously-set-innerhtml-with-children doesn't fail:

Image

The div with the text node as children errors (similar to the failing example code from eslint-plugin-react), but the div with the JSX element as children does not

$ pnpm eslint .

/Users/k/p/repro-eslint-react-dom-no-dangerously-set-innerhtml-with-children-with-typescript-eslint/index.tsx
  1:10  error  'Abc' is defined but never used                                           @typescript-eslint/no-unused-vars
  5:7   error  A DOM component cannot use both 'children' and 'dangerouslySetInnerHTML'  @eslint-react/dom/no-dangerously-set-innerhtml-with-children

✖ 2 problems (2 errors, 0 warnings)

Reproduction

Expected behavior

The failing example code for @eslint-react/react/no-dangerously-set-innerhtml-with-children (div with the JSX element as children) should error

import React from "react";

function MyComponent() {
  return (
    <div dangerouslySetInnerHTML={{ __html: "Hello World" }}>
      <p>Goodbye World</p>
    </div>
  );
}

Platform and versions

$ node -v
v22.18.0

$ cat package.json
...
  "dependencies": {
    "react": "19.1.1"
  },
  "devDependencies": {
    "@eslint-react/eslint-plugin": "1.52.3",
    "@eslint/js": "9.32.0",
    "@types/react": "19.1.9",
    "eslint": "9.32.0",
    "typescript": "5.8.3",
    "typescript-eslint": "8.38.0"
  },
...

$ cat eslint.config.mjs
import eslintReact from '@eslint-react/eslint-plugin';
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';

export default tseslint.config(
  eslint.configs.recommended,
  tseslint.configs.recommended,
  eslintReact.configs.recommended,
  eslintReact.configs['disable-dom'],
  {
    rules: {
      '@eslint-react/dom/no-dangerously-set-innerhtml-with-children': 'error',
    },
  },
);

Stack trace


Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions