Skip to content

linter: context.sourceCode.markVariableAsUsed not implemented in JS plugin compatibility layer #19971

@rakleed

Description

@rakleed

What version of Oxlint are you using?

latest

What command did you run?

npx oxlint .

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

 {
    "$schema": "./node_modules/oxlint/configuration_schema.json",
    "plugins": [],
    "categories": { "correctness": "off" },
    "overrides": [{
      "files": ["**/*.{js,jsx}"],
      "jsPlugins": ["eslint-plugin-react-x"],
      "rules": {
        "react-x/jsx-uses-vars": "warn",
        "react-x/jsx-uses-react": "warn",
      }
    }]
  }

Full config: https://github.com/rakleed/eslint-react-oxc-migration/blob/main/.oxlintrc.json

What happened?

When running oxlint with eslint-plugin-react-x@2.13.0 as a JS plugin, the react-x/jsx-uses-vars and react-x/jsx-uses-react rules cause a crash:

Error running JS plugin.
File path: src/main.jsx
Error: `context.markVariableAsUsed` not implemented yet
    at Object.markVariableAsUsed (oxlint/dist/lint.js:11968:8)
    at JSXOpeningElement (eslint-plugin-react-x/dist/index.js:606:24)
    at file:///...oxlint/dist/lint.js:19760:17
    at walkJSXOpeningElement (file:///...oxlint/dist/lint.js:17920:70)
    ...

Root cause: The error message is misleading. Both rules correctly use the new ESLint v9+ API context.sourceCode.markVariableAsUsed() — not the deprecated context.markVariableAsUsed(). This can be verified in both TypeScript sources and the compiled dist/index.js:

// All four call sites in eslint-plugin-react-x/dist/index.js
context.sourceCode.markVariableAsUsed(jsxFactory, node);         // line 565
context.sourceCode.markVariableAsUsed(jsxFragmentFactory, node); // line 569
context.sourceCode.markVariableAsUsed(node.name.name, node);     // line 606
context.sourceCode.markVariableAsUsed(object.name, node);        // line 610

Despite calling context.sourceCode.markVariableAsUsed, the error says context.markVariableAsUsed is not implemented — suggesting oxlint's sourceCode object internally delegates to context.markVariableAsUsed which throws. In effect, context.sourceCode.markVariableAsUsed is not properly implemented in the JS plugin compatibility layer.

Expected behavior: context.sourceCode.markVariableAsUsed(name, node) should work as described in the ESLint v9 migration guide.

Steps to reproduce: see https://github.com/rakleed/eslint-react-oxc-migration

Metadata

Metadata

Assignees

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