Skip to content

linter: react/no-find-dom-node not triggering on TS files, only TSX #22468

@JasonKaz

Description

@JasonKaz

What version of Oxlint are you using?

1.64.0

What command did you run?

No response

What does your .oxlintrc.json (or oxlint.config.ts) config file look like?

{
  "plugins": ["react"],
  "rules": {
    "react/no-find-dom-node": "error"
  }
}

What happened?

The react/no-find-dom-node rule does not find a violation when the code is in .ts files, only in .tsx files. This differs from eslint where the rules could be configured to run against .ts files.

Seems like a change is needed to should_run() to check against non-jsx files?

demo.tsx

import React from 'react';
import ReactDOM from 'react-dom';

// oxlint WILL flag this file — .tsx triggers react plugin rules
class Demo extends React.Component {
    foo() {
        ReactDOM.findDOMNode(this); // react/no-find-dom-node fires here
    }
}

demo.ts

import React from 'react';
import ReactDOM from 'react-dom';

// oxlint will NOT flag this file — react rules only apply to .tsx (JSX-capable) files
class Demo extends React.Component {
    foo() {
        ReactDOM.findDOMNode(this); // no oxlint violation here
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions