Files
react.dev/src/content/reference/eslint-plugin-react-hooks/lints/config.md
Lauren Tan 757666abf0 Add new eslint rule reference docs
Adds new docs for our new eslint rules.
2025-09-17 13:10:58 -04:00

2.0 KiB

title
title
config

Validates the compiler configuration options.

Rule Details {/rule-details/}

React Compiler accepts various configuration options to control its behavior. This rule validates that your configuration uses correct option names and value types, preventing silent failures from typos or incorrect settings.

Invalid {/invalid/}

Examples of incorrect code for this rule:

// ❌ Unknown option name
module.exports = {
  plugins: [
    ['babel-plugin-react-compiler', {
      compileMode: 'all' // Typo: should be compilationMode
    }]
  ]
};

// ❌ Invalid option value
module.exports = {
  plugins: [
    ['babel-plugin-react-compiler', {
      compilationMode: 'everything' // Invalid: use 'all' or 'infer'
    }]
  ]
};

Valid {/valid/}

Examples of correct code for this rule:

// ✅ Valid compiler configuration
module.exports = {
  plugins: [
    ['babel-plugin-react-compiler', {
      compilationMode: 'infer',
      panicThreshold: 'critical_errors'
    }]
  ]
};

Troubleshooting {/troubleshooting/}

Configuration not working as expected {/config-not-working/}

Your compiler configuration might have typos or incorrect values:

// ❌ Wrong: Common configuration mistakes
module.exports = {
  plugins: [
    ['babel-plugin-react-compiler', {
      // Typo in option name
      compilationMod: 'all',
      // Wrong value type
      panicThreshold: true,
      // Unknown option
      optimizationLevel: 'max'
    }]
  ]
};

Check the configuration documentation for valid options:

// ✅ Better: Valid configuration
module.exports = {
  plugins: [
    ['babel-plugin-react-compiler', {
      compilationMode: 'all', // or 'infer'
      panicThreshold: 'none', // or 'critical_errors', 'all_errors'
      // Only use documented options
    }]
  ]
};