Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

ESLint warns that the React version is not specified in eslint-plugin-react settings

ErrorWarning: React version not specified in eslint-plugin-react settings

Short answer

eslint-plugin-react needs to know your React version for some rules. If settings.react.version is missing, it warns. Add a react settings block with version set to detect, so the plugin reads the installed React. Use the legacy or flat config form, whichever your project has.

  • Applies to ESLint 9, eslint-plugin-react 7, React 19
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Find out which config format the project uses. A file named eslint.config.js (or .mjs) is flat config; .eslintrc.* is the legacy format.

    ls -a | grep -i eslint
  2. 2Match what you see, then jump to its fix

    1. 1The project has .eslintrc.json or .eslintrc.js and no react key under settings.Legacy config has no settings.react blockFix
    2. 2The project has eslint.config.js and no settings object with a react key.Flat config has no settings object for reactFix

What does the error look like?

  • Warning: React version not specified in eslint-plugin-react settings

Cause 1 of 2

Legacy config has no settings.react block

1Check

Open the file and look for a settings section.

grep -n "settings" -A3 .eslintrc.*

2Fix

Add settings.react.version. The value detect makes the plugin pick the version you have installed.

{
  "settings": {
    "react": {
      "version": "detect"
    }
  }
}

3Verify

Run ESLint. The warning line should no longer print.

npx eslint .

Confirmed by github.com

Did this fix it?

Cause 2 of 2

Flat config has no settings object for react

1Check

The plugin README says the settings.react schema is the same in flat config. Look for settings in your config array.

grep -n "settings" eslint.config.*

2Fix

Add a settings object to a config entry; ESLint passes it to every rule. The README also shows the jsx-runtime config for React 17 and later, which turns off the rules that expect React to be imported.

import react from 'eslint-plugin-react';

export default [
  react.configs.flat['jsx-runtime'],
  {
    settings: { react: { version: 'detect' } },
  },
];

3Verify

Run ESLint again.

npx eslint .

Confirmed by github.com

Did this fix it?

How do I stop it coming back?

  • Keep the react settings block in the shared ESLint config, not in each package.
  • Run ESLint in CI and treat new warnings as review comments, so a missing setting is noticed early.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.