Skip to content

linter: eslint-plugin-react-hooks crashes when used as a jsPlugin #14488

@matthewdavi

Description

@matthewdavi

What version of Oxlint are you using?

1.22.0

What command did you run?

oxlint -c .oxlintrc.json

What does your .oxlintrc.json config file look like?

{
  "$schema": "./node_modules/oxlint/configuration_schema.json",
  "plugins": ["typescript", "import"],
  "ignorePatterns": [
    "node_modules",
    "dist",
    "build",
    ".next",
    "coverage",
    ".turbo",
    "*.config.js",
    "*.config.ts"
  ],
  "jsPlugins": ["eslint-plugin-react-hooks"],
  "rules": {
    "eslint-plugin-react-hooks/purity": "error"
  }
}

What happened?

Attempting to run the new eslint-react-hooks rules (which rely on information from the react compiler) via jsPlugins in oxlint. but I get this error:

bun oxlint -c .oxlintrc.json                                             ✔  root@ubuntu  05:10:30 PM ▓▒░
WARNING: JS plugins are experimental and not subject to semver.
Breaking changes are possible while JS plugins support is under development.

  × Error running JS plugin.
  │ File path: /root/code/react-compiler-test/__eslint.js
  │ Error: `sourceCode.getAllComments` not implemented yet
  │     at Object.getAllComments (file:///root/code/react-compiler-test/node_modules/oxlint/dist/plugins.js:516:9)
  │     at getFlowSuppressions (/root/code/react-compiler-test/node_modules/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js:54159:33)
  │     at runReactCompilerImpl (/root/code/react-compiler-test/node_modules/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js:54223:36)
  │     at runReactCompiler (/root/code/react-compiler-test/node_modules/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js:54278:22)
  │     at getReactCompilerResult (/root/code/react-compiler-test/node_modules/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js:54344:21)
  │     at Object.create (/root/code/react-compiler-test/node_modules/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js:54362:24)
  │     at lintFileImpl (file:///root/code/react-compiler-test/node_modules/oxlint/dist/plugins.js:4169:40)
  │     at lintFile (file:///root/code/react-compiler-test/node_modules/oxlint/dist/plugins.js:4147:10)
  │     at lintFileWrapper (file:///root/code/react-compiler-test/node_modules/oxlint/dist/cli.js:411:9)

  × Error running JS plugin.
  │ File path: /root/code/react-compiler-test/src/main.tsx
  │ Error: `sourceCode.getAllComments` not implemented yet
  │     at Object.getAllComments (file:///root/code/react-compiler-test/node_modules/oxlint/dist/plugins.js:516:9)
  │     at getFlowSuppressions (/root/code/react-compiler-test/node_modules/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js:54159:33)
  │     at runReactCompilerImpl (/root/code/react-compiler-test/node_modules/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js:54223:36)
  │     at runReactCompiler (/root/code/react-compiler-test/node_modules/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js:54278:22)
  │     at getReactCompilerResult (/root/code/react-compiler-test/node_modules/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js:54344:21)
  │     at Object.create (/root/code/react-compiler-test/node_modules/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js:54362:24)
  │     at lintFileImpl (file:///root/code/react-compiler-test/node_modules/oxlint/dist/plugins.js:4169:40)
  │     at lintFile (file:///root/code/react-compiler-test/node_modules/oxlint/dist/plugins.js:4147:10)
  │     at lintFileWrapper (file:///root/code/react-compiler-test/node_modules/oxlint/dist/cli.js:411:9)

  ⚠ eslint(no-unused-vars): Identifier 'useEffect' is imported but never used.
   ╭─[src/App.tsx:1:20]
 1 │ import { useState, useEffect, useRef } from 'react'
   ·                    ────┬────
   ·                        ╰── 'useEffect' is imported here
 2 │ import reactLogo from './assets/react.svg'
   ╰────
  help: Consider removing this import.

  × Error running JS plugin.
  │ File path: /root/code/react-compiler-test/src/App.tsx
  │ Error: `sourceCode.getAllComments` not implemented yet
  │     at Object.getAllComments (file:///root/code/react-compiler-test/node_modules/oxlint/dist/plugins.js:516:9)
  │     at getFlowSuppressions (/root/code/react-compiler-test/node_modules/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js:54159:33)
  │     at runReactCompilerImpl (/root/code/react-compiler-test/node_modules/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js:54223:36)
  │     at runReactCompiler (/root/code/react-compiler-test/node_modules/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js:54278:22)
  │     at getReactCompilerResult (/root/code/react-compiler-test/node_modules/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js:54344:21)
  │     at Object.create (/root/code/react-compiler-test/node_modules/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js:54362:24)
  │     at lintFileImpl (file:///root/code/react-compiler-test/node_modules/oxlint/dist/plugins.js:4169:40)
  │     at lintFile (file:///root/code/react-compiler-test/node_modules/oxlint/dist/plugins.js:4147:10)
  │     at lintFileWrapper (file:///root/code/react-compiler-test/node_modules/oxlint/dist/cli.js:411:9)

Found 1 warning and 3 errors.
Finished in 438ms on 3 files with 65 rules using 8 threads.
error: "oxlint" exited with code 1

I wonder if we could create a special handling for the react compiler (written in TS) like how the ts-go type aware rules are implemented currently

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions